Index: libopenmpt/bindings/freebasic/libopenmpt.bi =================================================================== --- libopenmpt/bindings/freebasic/libopenmpt.bi (revision 21858) +++ libopenmpt/bindings/freebasic/libopenmpt.bi (working copy) @@ -1281,6 +1281,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 format do not support time signature information. 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 format do not support time signature information. 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 21858) +++ libopenmpt/libopenmpt.h (working copy) @@ -1338,6 +1338,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 format do not support time signature information. 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 format do not support time signature information. 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 21858) +++ libopenmpt/libopenmpt.hpp (working copy) @@ -996,6 +996,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 format do not support time signature information. 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 format do not support time signature information. 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 21858) +++ libopenmpt/libopenmpt_c.cpp (working copy) @@ -1235,6 +1235,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 21858) +++ libopenmpt/libopenmpt_cxx.cpp (working copy) @@ -393,6 +393,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 21858) +++ libopenmpt/libopenmpt_impl.cpp (working copy) @@ -1464,6 +1464,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 21858) +++ libopenmpt/libopenmpt_impl.hpp (working copy) @@ -245,6 +245,8 @@ std::vector get_sample_names() const; std::int32_t get_order_pattern( std::int32_t o ) const; 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;