From: <man...@us...> - 2013-12-06 06:50:17
|
Revision: 3393 http://sourceforge.net/p/modplug/code/3393 Author: manxorist Date: 2013-12-06 06:50:02 +0000 (Fri, 06 Dec 2013) Log Message: ----------- [New] libopenmpt: Add set_position_order_row(). [New] openmpt123: Add prev/next order seeking via H/L and prev/next row seeking via J/K. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.h trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c trunk/OpenMPT/openmpt123/openmpt123.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.h =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-12-06 06:48:16 UTC (rev 3392) +++ trunk/OpenMPT/libopenmpt/libopenmpt.h 2013-12-06 06:50:02 UTC (rev 3393) @@ -88,6 +88,8 @@ LIBOPENMPT_API double openmpt_module_set_position_seconds( openmpt_module * mod, double seconds ); LIBOPENMPT_API double openmpt_module_get_position_seconds( openmpt_module * mod ); +LIBOPENMPT_API double openmpt_module_set_position_order_row( openmpt_module * mod, int32_t order, int32_t row ); + LIBOPENMPT_API int openmpt_module_get_render_param( openmpt_module * mod, int param, int32_t * value ); LIBOPENMPT_API int openmpt_module_set_render_param( openmpt_module * mod, int param, int32_t value ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-12-06 06:48:16 UTC (rev 3392) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2013-12-06 06:50:02 UTC (rev 3393) @@ -118,6 +118,8 @@ double set_position_seconds( double seconds ); double get_position_seconds() const; + double set_position_order_row( std::int32_t order, std::int32_t row ); + std::int32_t get_render_param( int param ) const; void set_render_param( int param, std::int32_t value ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-12-06 06:48:16 UTC (rev 3392) +++ trunk/OpenMPT/libopenmpt/libopenmpt_c.cpp 2013-12-06 06:50:02 UTC (rev 3393) @@ -383,7 +383,7 @@ OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); return mod->impl->set_position_seconds( seconds ); } OPENMPT_INTERFACE_CATCH_TO_LOG; - return 0; + return 0.0; } double openmpt_module_get_position_seconds( openmpt_module * mod ) { try { @@ -393,6 +393,14 @@ return 0.0; } +double openmpt_module_set_position_order_row( openmpt_module * mod, int32_t order, int32_t row ) { + try { + OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); + return mod->impl->set_position_order_row( order, row ); + } OPENMPT_INTERFACE_CATCH_TO_LOG; + return 0.0; +} + int openmpt_module_get_render_param( openmpt_module * mod, int param, int32_t * value ) { try { OPENMPT_INTERFACE_CHECK_SOUNDFILE( mod ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-12-06 06:48:16 UTC (rev 3392) +++ trunk/OpenMPT/libopenmpt/libopenmpt_cxx.cpp 2013-12-06 06:50:02 UTC (rev 3393) @@ -151,6 +151,10 @@ return impl->get_position_seconds(); } +double module::set_position_order_row( std::int32_t order, std::int32_t row ) { + return impl->set_position_order_row( order, row ); +} + std::int32_t module::get_render_param( int param ) const { return impl->get_render_param( param ); } Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-12-06 06:48:16 UTC (rev 3392) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.cpp 2013-12-06 06:50:02 UTC (rev 3393) @@ -608,6 +608,21 @@ m_currentPositionSeconds = m_sndFile->GetLength( eAdjust, GetLengthTarget( t.lastOrder, t.lastRow ) ).duration; return m_currentPositionSeconds; } +double module_impl::set_position_order_row( std::int32_t order, std::int32_t row ) { + if ( order < 0 || order >= m_sndFile->Order.GetLengthTailTrimmed() ) { + return m_currentPositionSeconds; + } + std::int32_t pattern = m_sndFile->Order[order]; + if ( row < 0 || row >= (std::int32_t)m_sndFile->Patterns[pattern].GetNumRows() ) { + return m_currentPositionSeconds; + } + m_sndFile->InitializeVisitedRows(); + m_sndFile->m_nCurrentOrder = order; + m_sndFile->SetCurrentOrder( order ); + m_sndFile->m_nNextRow = row; + m_currentPositionSeconds = m_sndFile->GetLength( eAdjust, GetLengthTarget( order, row ) ).duration; + return m_currentPositionSeconds; +} std::vector<std::string> module_impl::get_metadata_keys() const { std::vector<std::string> retval; retval.push_back("type"); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-12-06 06:48:16 UTC (rev 3392) +++ trunk/OpenMPT/libopenmpt/libopenmpt_impl.hpp 2013-12-06 06:50:02 UTC (rev 3393) @@ -92,6 +92,7 @@ double get_duration_seconds() const; double set_position_seconds( double seconds ); double get_position_seconds() const; + double set_position_order_row( std::int32_t order, std::int32_t row ); std::int32_t get_render_param( int param ) const; void set_render_param( int param, std::int32_t value ); std::size_t read( std::int32_t samplerate, std::size_t count, std::int16_t * mono ); Modified: trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c 2013-12-06 06:48:16 UTC (rev 3392) +++ trunk/OpenMPT/libopenmpt/libopenmpt_modplug.c 2013-12-06 06:50:02 UTC (rev 3393) @@ -336,8 +336,7 @@ LIBOPENMPT_MODPLUG_API void ModPlug_SeekOrder(ModPlugFile* file,int order) { if(!file) return; - // todo: seek exactly to order - openmpt_module_set_position_seconds(file->mod,openmpt_module_get_duration_seconds(file->mod)*order/openmpt_module_get_num_orders(file->mod)); + openmpt_module_set_position_order_row(file->mod,order,0); } LIBOPENMPT_MODPLUG_API int ModPlug_GetModuleType(ModPlugFile* file) Modified: trunk/OpenMPT/openmpt123/openmpt123.cpp =================================================================== --- trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-12-06 06:48:16 UTC (rev 3392) +++ trunk/OpenMPT/openmpt123/openmpt123.cpp 2013-12-06 06:50:02 UTC (rev 3393) @@ -460,6 +460,10 @@ case 'j': mod.set_position_seconds( mod.get_position_seconds() - 1.0 ); break; case 'k': mod.set_position_seconds( mod.get_position_seconds() + 1.0 ); break; case 'l': mod.set_position_seconds( mod.get_position_seconds() + 10.0 ); break; + case 'H': mod.set_position_order_row( mod.get_current_order() - 1, 0 ); break; + case 'J': mod.set_position_order_row( mod.get_current_order(), mod.get_current_row() - 1 ); break; + case 'K': mod.set_position_order_row( mod.get_current_order(), mod.get_current_row() + 1 ); break; + case 'L': mod.set_position_order_row( mod.get_current_order() + 1, 0 ); break; case 'm': throw next_file(1); break; case 'M': throw next_file(10); break; case '3': flags.gain -=100; apply_mod_settings( flags, mod ); break; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |