Index: libopenmpt/bindings/freebasic/libopenmpt.bi =================================================================== --- libopenmpt/bindings/freebasic/libopenmpt.bi (revision 21863) +++ libopenmpt/bindings/freebasic/libopenmpt.bi (working copy) @@ -1314,6 +1314,26 @@ '/ Declare Function openmpt_module_get_pattern_num_rows(ByVal module As openmpt_module Ptr, ByVal pattern As Long) As Long +/'* \brief Get the rows per beat of a pattern + + \param mod The module handle to work on. + \param pattern The pattern whose time signature should be retrieved. + \return The rows per beat of the given pattern. If the pattern does not exist or the time signature is not defined, 0 is returned. + \remarks Many module formats lack time signature metadata. In this case, the returned value may be an incorrect estimation. + \since 0.8.0 +'/ +Declare Function openmpt_module_get_pattern_rows_per_beat(ByVal module As openmpt_module Ptr, ByVal pattern As Long) As Long + +/'* \brief Get the rows per beat of a measure + + \param mod The module handle to work on. + \param pattern The pattern whose time signature should be retrieved. + \return The rows per measure of the given pattern. If the pattern does not exist or the time signature is not defined, 0 is returned. + \remarks Many module formats lack time signature metadata. In this case, the returned value may be an incorrect estimation. + \since 0.8.0 +'/ +Declare Function openmpt_module_get_pattern_rows_per_measure(ByVal module As openmpt_module Ptr, ByVal pattern As Long) As Long + /'* \brief Get raw pattern content \param module The module handle to work on. Index: libopenmpt/libopenmpt.h =================================================================== --- libopenmpt/libopenmpt.h (revision 21863) +++ libopenmpt/libopenmpt.h (working copy) @@ -1372,6 +1372,25 @@ */ LIBOPENMPT_API int32_t openmpt_module_get_pattern_num_rows( openmpt_module * mod, int32_t pattern ); +/*! \brief Get the rows per beat of a pattern + * + * \param mod The module handle to work on. + * \param pattern The pattern whose time signature should be retrieved. + * \return The rows per beat of the given pattern. If the pattern does not exist or the time signature is not defined, 0 is returned. + * \remarks Many module formats lack time signature metadata. In this case, the returned value may be an incorrect estimation. + * \since 0.8.0 + */ +LIBOPENMPT_API int32_t openmpt_module_get_pattern_rows_per_beat( openmpt_module * mod, int32_t pattern ); + +/*! \brief Get the rows per beat of a measure + * + * \param mod The module handle to work on. + * \param pattern The pattern whose time signature should be retrieved. + * \return The rows per measure of the given pattern. If the pattern does not exist or the time signature is not defined, 0 is returned. + * \remarks Many module formats lack time signature metadata. In this case, the returned value may be an incorrect estimation. + */ +LIBOPENMPT_API int32_t openmpt_module_get_pattern_rows_per_measure(openmpt_module* mod, int32_t pattern); + /*! \brief Get raw pattern content * * \param mod The module handle to work on. Index: libopenmpt/libopenmpt.hpp =================================================================== --- libopenmpt/libopenmpt.hpp (revision 21863) +++ libopenmpt/libopenmpt.hpp (working copy) @@ -1029,6 +1029,24 @@ */ LIBOPENMPT_CXX_API_MEMBER std::int32_t get_pattern_num_rows( std::int32_t pattern ) const; + //! Get the rows per beat of a pattern + /*! + \param pattern The pattern whose time signature should be retrieved. + \return The rows per beat of the given pattern. If the pattern does not exist or the time signature is not defined, 0 is returned. + \remarks Many module formats lack time signature metadata. In this case, the returned value may be an incorrect estimation. + \since 0.8.0 + */ + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_pattern_rows_per_beat( std::int32_t pattern ) const; + + //! Get the rows per beat of a measure + /*! + \param pattern The pattern whose time signature should be retrieved. + \return The rows per measure of the given pattern. If the pattern does not exist or the time signature is not defined, 0 is returned. + \remarks Many module formats lack time signature metadata. In this case, the returned value may be an incorrect estimation. + \since 0.8.0 + */ + LIBOPENMPT_CXX_API_MEMBER std::int32_t get_pattern_rows_per_measure( std::int32_t pattern ) const; + //! Get raw pattern content /*! \param pattern The pattern whose data should be retrieved. Index: libopenmpt/libopenmpt_c.cpp =================================================================== --- libopenmpt/libopenmpt_c.cpp (revision 21863) +++ libopenmpt/libopenmpt_c.cpp (working copy) @@ -1273,6 +1273,25 @@ return 0; } +int32_t openmpt_module_get_pattern_rows_per_beat( openmpt_module * mod, int32_t pattern ) { + try { + openmpt::interface::check_soundfile( mod ); + return mod->impl->get_pattern_rows_per_beat( pattern ); + } catch ( ... ) { + openmpt::report_exception( __func__, mod ); + } + return 0; +} +int32_t openmpt_module_get_pattern_rows_per_measure( openmpt_module * mod, int32_t pattern ) { + try { + openmpt::interface::check_soundfile( mod ); + return mod->impl->get_pattern_rows_per_measure( pattern ); + } catch ( ... ) { + openmpt::report_exception( __func__, mod ); + } + return 0; +} + uint8_t openmpt_module_get_pattern_row_channel_command( openmpt_module * mod, int32_t pattern, int32_t row, int32_t channel, int command ) { try { openmpt::interface::check_soundfile( mod ); Index: libopenmpt/libopenmpt_cxx.cpp =================================================================== --- libopenmpt/libopenmpt_cxx.cpp (revision 21863) +++ libopenmpt/libopenmpt_cxx.cpp (working copy) @@ -407,6 +407,14 @@ return impl->get_pattern_num_rows( pattern ); } +std::int32_t module::get_pattern_rows_per_beat( std::int32_t pattern ) const { + return impl->get_pattern_rows_per_beat( pattern ); +} + +std::int32_t module::get_pattern_rows_per_measure( std::int32_t pattern ) const { + return impl->get_pattern_rows_per_measure( pattern ); +} + std::uint8_t module::get_pattern_row_channel_command( std::int32_t pattern, std::int32_t row, std::int32_t channel, int command ) const { return impl->get_pattern_row_channel_command( pattern, row, channel, command ); } Index: libopenmpt/libopenmpt_impl.cpp =================================================================== --- libopenmpt/libopenmpt_impl.cpp (revision 21863) +++ libopenmpt/libopenmpt_impl.cpp (working copy) @@ -1484,6 +1484,26 @@ return m_sndFile->Patterns[p].GetNumRows(); } +std::int32_t module_impl::get_pattern_rows_per_beat( std::int32_t p ) const { + if ( !mpt::is_in_range( p, std::numeric_limits::min(), std::numeric_limits::max() ) || !m_sndFile->Patterns.IsValidPat( static_cast( p ) ) ) { + return 0; + } + if ( m_sndFile->Patterns[p].GetOverrideSignature() ) { + return m_sndFile->Patterns[p].GetRowsPerBeat(); + } + return m_sndFile->m_nDefaultRowsPerBeat; +} + +std::int32_t module_impl::get_pattern_rows_per_measure( std::int32_t p ) const { + if ( !mpt::is_in_range( p, std::numeric_limits::min(), std::numeric_limits::max() ) || !m_sndFile->Patterns.IsValidPat( static_cast( p ) ) ) { + return 0; + } + if ( m_sndFile->Patterns[p].GetOverrideSignature() ) { + return m_sndFile->Patterns[p].GetRowsPerMeasure(); + } + return m_sndFile->m_nDefaultRowsPerMeasure; +} + std::uint8_t module_impl::get_pattern_row_channel_command( std::int32_t p, std::int32_t r, std::int32_t c, int cmd ) const { if ( !mpt::is_in_range( p, std::numeric_limits::min(), std::numeric_limits::max() ) || !m_sndFile->Patterns.IsValidPat( static_cast( p ) ) ) { return 0; Index: libopenmpt/libopenmpt_impl.hpp =================================================================== --- libopenmpt/libopenmpt_impl.hpp (revision 21863) +++ libopenmpt/libopenmpt_impl.hpp (working copy) @@ -249,6 +249,8 @@ bool is_order_stop_entry( std::int32_t order ) const; static bool is_pattern_stop_item( std::int32_t pattern ); std::int32_t get_pattern_num_rows( std::int32_t p ) const; + std::int32_t get_pattern_rows_per_beat( std::int32_t pattern ) const; + std::int32_t get_pattern_rows_per_measure( std::int32_t pattern ) const; std::uint8_t get_pattern_row_channel_command( std::int32_t p, std::int32_t r, std::int32_t c, int cmd ) const; std::string format_pattern_row_channel_command( std::int32_t p, std::int32_t r, std::int32_t c, int cmd ) const; std::string highlight_pattern_row_channel_command( std::int32_t p, std::int32_t r, std::int32_t c, int cmd ) const;