From: <sag...@us...> - 2014-11-10 00:02:03
|
Revision: 4578 http://sourceforge.net/p/modplug/code/4578 Author: saga-games Date: 2014-11-10 00:01:55 +0000 (Mon, 10 Nov 2014) Log Message: ----------- [New] libopenmpt: Added openmpt::ext::interactive, which adds a whole bunch of new functionality to change playback in some way or another. The interface may still change within the next few days. Modified Paths: -------------- trunk/OpenMPT/libopenmpt/libopenmpt.hpp trunk/OpenMPT/libopenmpt/libopenmpt_ext.cpp trunk/OpenMPT/libopenmpt/libopenmpt_ext.hpp trunk/OpenMPT/soundlib/Sndfile.cpp trunk/OpenMPT/soundlib/Sndfile.h trunk/OpenMPT/soundlib/Sndmix.cpp Modified: trunk/OpenMPT/libopenmpt/libopenmpt.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/libopenmpt/libopenmpt.hpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -222,7 +222,7 @@ \param stream Input stream from which the module is loaded. After the constructor has finished successfully, the input position of stream is set to the byte after the last byte that has been read. If the constructor fails, the state of the input position of stream is undefined. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( std::istream & stream, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -230,7 +230,7 @@ \param data Data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const std::vector<std::uint8_t> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -239,7 +239,7 @@ \param end End of data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const std::uint8_t * beg, const std::uint8_t * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -248,7 +248,7 @@ \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const std::uint8_t * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -256,7 +256,7 @@ \param data Data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const std::vector<char> & data, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -265,7 +265,7 @@ \param end End of data to load the module from. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const char * beg, const char * end, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -274,7 +274,7 @@ \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const char * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -283,7 +283,7 @@ \param size Amount of data available. \param log Log where any warnings or errors are printed to. The lifetime of the reference has to be as long as the lifetime of the module instance. \param ctls A map of initial ctl values, see openmpt::module::get_ctls. - \return Throw an exception derived from openmpt::exception in case the provided file cannot be opened. + \throws openmpt::exception Throws an exception derived from openmpt::exception in case the provided file cannot be opened. \remarks The input data can be discarded after an openmpt::module has been constructed succesfully. */ module( const void * data, std::size_t size, std::ostream & log = std::clog, const std::map< std::string, std::string > & ctls = detail::initial_ctls_map() ); @@ -293,7 +293,7 @@ //! Select a subsong from a multi-song module /*! \param subsong Index of the subsong. -1 plays all subsongs consecutively. - \return Throws an exception derived from openmpt::exception if subsong is not in range [-1,openmpt::module::get_num_subsongs()[ + \throws openmpt::exception Throws an exception derived from openmpt::exception if subsong is not in range [-1,openmpt::module::get_num_subsongs()[ */ void select_subsong( std::int32_t subsong ); //! Set Repeat Count @@ -349,7 +349,8 @@ //! Get render parameter /*! \param param Parameter to query. See openmpt::module::render_param. - \return The current value of the parameter. Throws an exception derived from openmpt::exception if param is invalid. + \return The current value of the parameter. + \throws openmpt::exception Throws an exception derived from openmpt::exception if param is invalid. \sa openmpt::module::render_param \sa openmpt::module::set_render_param */ @@ -358,7 +359,7 @@ /*! \param param Parameter to set. See openmpt::module::render_param. \param value The value to set param to. - \return Throws an exception derived from openmpt::exception if param is invalid or value is out of range. + \throws openmpt::exception Throws an exception derived from openmpt::exception if param is invalid or value is out of range. \sa openmpt::module::render_param \sa openmpt::module::get_render_param */ Modified: trunk/OpenMPT/libopenmpt/libopenmpt_ext.cpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_ext.cpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/libopenmpt/libopenmpt_ext.cpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -20,6 +20,7 @@ class module_ext_impl : public module_impl , public ext::pattern_vis + , public ext::interactive @@ -97,6 +98,8 @@ return 0; } else if ( interface_id == ext::pattern_vis_id ) { return dynamic_cast< ext::pattern_vis * >( this ); + } else if ( interface_id == ext::interactive_id ) { + return dynamic_cast< ext::interactive * >( this ); @@ -135,8 +138,179 @@ } } + // interactive + virtual void set_current_speed( std::int32_t speed ) { + if ( speed < 1 || speed > 65535 ) { + throw openmpt::exception("invalid tick count"); + } + m_sndFile->m_PlayState.m_nMusicSpeed = speed; + } + virtual void set_current_tempo( std::int32_t tempo ) { + if ( tempo < 32 || tempo > 512 ) { + throw openmpt::exception("invalid tempo"); + } + m_sndFile->m_PlayState.m_nMusicTempo = tempo; + } + + virtual void set_tempo_factor( double factor ) { + if ( factor <= 0.0 || factor > 4.0 ) { + throw openmpt::exception("invalid tempo factor"); + } + m_sndFile->m_nTempoFactor = Util::Round<uint32_t>( 65536.0 / factor ); + m_sndFile->RecalculateSamplesPerTick(); + } + + virtual double get_tempo_factor( ) const { + return 65536.0 / m_sndFile->m_nTempoFactor; + } + + virtual void set_pitch_factor( double factor ) { + if ( factor <= 0.0 || factor > 4.0 ) { + throw openmpt::exception("invalid pitch factor"); + } + m_sndFile->m_nFreqFactor = Util::Round<uint32_t>( 65536.0 * factor ); + m_sndFile->RecalculateSamplesPerTick(); + } + + virtual double get_pitch_factor( ) const { + return m_sndFile->m_nFreqFactor / 65536.0; + } + + virtual void set_global_volume( double volume ) { + if ( volume < 0.0 || volume > 1.0 ) { + throw openmpt::exception("invalid global volume"); + } + m_sndFile->m_PlayState.m_nGlobalVolume = Util::Round<uint32_t>( volume * MAX_GLOBAL_VOLUME ); + } + + virtual double get_global_volume( ) const { + return m_sndFile->m_PlayState.m_nGlobalVolume / static_cast<double>( MAX_GLOBAL_VOLUME ); + } + + virtual void set_channel_volume( std::int32_t channel, double volume ) { + if ( channel < 0 || channel >= get_num_channels() ) { + throw openmpt::exception("invalid channel"); + } + if ( volume < 0.0 || volume > 1.0 ) { + throw openmpt::exception("invalid global volume"); + } + m_sndFile->m_PlayState.Chn[channel].nGlobalVol = Util::Round<std::int32_t>(volume * 64.0); + } + + virtual double get_channel_volume( std::int32_t channel ) const { + if ( channel < 0 || channel >= get_num_channels() ) { + throw openmpt::exception("invalid channel"); + } + return m_sndFile->m_PlayState.Chn[channel].nGlobalVol / 64.0; + } + + virtual void set_channel_mute_status( std::int32_t channel, bool mute ) { + if ( channel < 0 || channel >= get_num_channels() ) { + throw openmpt::exception("invalid channel"); + } + m_sndFile->ChnSettings[channel].dwFlags.set( CHN_MUTE | CHN_SYNCMUTE , mute ); + m_sndFile->m_PlayState.Chn[channel].dwFlags.set( CHN_MUTE | CHN_SYNCMUTE , mute ); + + // Also update NNA channels + for ( CHANNELINDEX i = m_sndFile->GetNumChannels(); i < MAX_CHANNELS; i++) + { + if ( m_sndFile->m_PlayState.Chn[i].nMasterChn == channel + 1) + { + m_sndFile->m_PlayState.Chn[i].dwFlags.set( CHN_MUTE | CHN_SYNCMUTE, mute ); + } + } + } + + virtual bool get_channel_mute_status( std::int32_t channel ) const { + if ( channel < 0 || channel >= get_num_channels() ) { + throw openmpt::exception("invalid channel"); + } + return m_sndFile->m_PlayState.Chn[channel].dwFlags[CHN_MUTE]; + } + + virtual void set_instrument_mute_status( std::int32_t instrument, bool mute ) { + const bool instrument_mode = get_num_instruments() != 0; + const int32_t max_instrument = instrument_mode ? get_num_instruments() : get_num_samples(); + if ( instrument < 0 || instrument >= max_instrument ) { + throw openmpt::exception("invalid instrument"); + } + if ( instrument_mode ) { + if ( m_sndFile->Instruments[instrument + 1] != nullptr ) { + m_sndFile->Instruments[instrument + 1]->dwFlags.set( INS_MUTE, mute ); + } + } else { + m_sndFile->GetSample( static_cast<OpenMPT::SAMPLEINDEX>( instrument + 1 ) ).uFlags.set( CHN_MUTE, mute ) ; + } + } + + virtual bool get_instrument_mute_status( std::int32_t instrument ) const { + const bool instrument_mode = get_num_instruments() != 0; + const int32_t max_instrument = instrument_mode ? get_num_instruments() : get_num_samples(); + if ( instrument < 0 || instrument >= max_instrument ) { + throw openmpt::exception("invalid instrument"); + } + if ( instrument_mode ) { + if ( m_sndFile->Instruments[instrument + 1] != nullptr ) { + return m_sndFile->Instruments[instrument + 1]->dwFlags[INS_MUTE]; + } + return true; + } else { + return m_sndFile->GetSample( static_cast<OpenMPT::SAMPLEINDEX>( instrument + 1 ) ).uFlags[CHN_MUTE]; + } + } + + virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ) { + const bool instrument_mode = get_num_instruments() != 0; + const int32_t max_instrument = instrument_mode ? get_num_instruments() : get_num_samples(); + if ( instrument < 0 || instrument >= max_instrument ) { + throw openmpt::exception("invalid instrument"); + } + note += NOTE_MIN; + if ( note < NOTE_MIN || note > NOTE_MAX ) { + throw openmpt::exception("invalid note"); + } + + // Find a free channel + CHANNELINDEX free_channel = MAX_CHANNELS - 1; + // Search for available channel + for(CHANNELINDEX i = MAX_CHANNELS - 1; i >= get_num_channels(); i--) + { + const ModChannel &chn = m_sndFile->m_PlayState.Chn[i]; + if ( chn.nLength == 0 ) { + free_channel = i; + break; + } else if ( chn.dwFlags[CHN_NOTEFADE] ) { + // We can probably still do better than this. + free_channel = i; + } + } + + ModChannel &chn = m_sndFile->m_PlayState.Chn[free_channel]; + chn.Reset(ModChannel::resetTotal, *m_sndFile, CHANNELINDEX_INVALID); + chn.nMasterChn = 0; // remove NNA association + chn.nNewNote = chn.nLastNote = static_cast<uint8>(note); + chn.ResetEnvelopes(); + m_sndFile->InstrumentChange(&chn, instrument + 1); + chn.nFadeOutVol = 0x10000; + m_sndFile->NoteChange(&chn, note, false, true, true); + chn.nPan = Util::Round<int32_t>( Clamp( panning * 128.0, -128.0, 128.0 ) + 128.0 ); + chn.nVolume = Util::Round<int32_t>( Clamp( volume * 256.0, 0.0, 256.0 ) ); + + return free_channel; + } + + virtual void stop_note( std::int32_t channel ) { + if ( channel < 0 || channel >= MAX_CHANNELS ) { + throw openmpt::exception("invalid channel"); + } + ModChannel &chn = m_sndFile->m_PlayState.Chn[channel]; + chn.nLength = 0; + chn.pCurrentSample = nullptr; + } + + /* add stuff here */ Modified: trunk/OpenMPT/libopenmpt/libopenmpt_ext.hpp =================================================================== --- trunk/OpenMPT/libopenmpt/libopenmpt_ext.hpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/libopenmpt/libopenmpt_ext.hpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -65,6 +65,7 @@ LIBOPENMPT_EXT_INTERFACE(pattern_vis) + //! Pattern command type enum effect_type { effect_unknown = 0, @@ -76,14 +77,179 @@ }; // enum effect_type + //! Get pattern command type for pattern highlighting + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \return The command type in the effect column at the given pattern position (see openmpt::ext::pattern_vis::effect_type) + \sa openmpt::ext::pattern_vis::get_pattern_row_channel_effect_type + */ virtual effect_type get_pattern_row_channel_volume_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0; + //! Get pattern command type for pattern highlighting + /*! + \param pattern The pattern whose data should be retrieved. + \param row The row from which the data should be retrieved. + \param channel The channel from which the data should be retrieved. + \return The command type in the volume column at the given pattern position (see openmpt::ext::pattern_vis::effect_type) + \sa openmpt::ext::pattern_vis::get_pattern_row_channel_volume_effect_type + */ virtual effect_type get_pattern_row_channel_effect_type( std::int32_t pattern, std::int32_t row, std::int32_t channel ) const = 0; }; // class pattern_vis +LIBOPENMPT_DECLARE_EXT_INTERFACE(interactive) +class interactive { + + LIBOPENMPT_EXT_INTERFACE(interactive) + + //! Set the current ticks per row (speed) + /*! + \param speed The new tick count in range [1, 65535]. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the speed is outside the specified range. + \remarks The tick count may be reset by pattern commands at any time. + \sa openmpt::module::get_current_speed + */ + virtual void set_current_speed( std::int32_t speed ) = 0; + + //! Set the current module tempo + /*! + \param tempo The new tempo in range [32, 512]. The exact meaning of the value depends on the tempo mode used by the module. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the tempo is outside the specified range. + \remarks The tempo may be reset by pattern commands at any time. Use openmpt::ext:interactive::set_tempo_factor to apply a tempo factor that is independent of pattern commands. + \sa openmpt::module::get_current_tempo + */ + virtual void set_current_tempo( std::int32_t tempo ) = 0; + + //! Set the current module tempo factor without affecting playback pitch + /*! + \param factor The new tempo factor in range ]0.0, 4.0] - 1.0 means unmodified tempo. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range. + \remarks Modifying the tempo without applying the same pitch factor using openmpt::ext::interactive::set_pitch_factor may cause rhythmic samples (e.g. drum loops) to go out of sync. + \sa openmpt::ext::interactive::get_tempo_factor + */ + virtual void set_tempo_factor( double factor ) = 0; + + //! Gets the current module tempo factor + /*! + \return The current tempo factor. + \sa openmpt::ext::interactive::set_tempo_factor + */ + virtual double get_tempo_factor( ) const = 0; + + //! Set the current module pitch factor without affecting playback speed + /*! + \param factor The new pitch factor in range ]0.0, 4.0] - 1.0 means unmodified pitch. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the factor is outside the specified range. + \remarks Modifying the pitch without applying the the same tempo factor openmpt::ext::interactive::set_tempo_factor may cause rhythmic samples (e.g. drum loops) to go out of sync. + \sa openmpt::ext::interactive::get_pitch_factor + */ + virtual void set_pitch_factor( double factor ) = 0; + + //! Gets the current module pitch factor + /*! + \return The current pitch factor. + \sa openmpt::ext::interactive::set_pitch_factor + */ + virtual double get_pitch_factor( ) const = 0; + + //! Set the current global volume + /*! + \param volume The new global volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the volume is outside the specified range. + \remarks The global volume may be reset by pattern commands at any time. Use openmpt::module:set_render_param to apply a global overall volume factor that is independent of pattern commands. + \sa openmpt::ext::interactive::get_global_volume + */ + virtual void set_global_volume( double volume ) = 0; + + //! Get the current global volume + /*! + \return The current global volume in range [0.0, 1.0] + \sa openmpt::ext::interactive::set_global_volume + */ + virtual double get_global_volume( ) const = 0; + + //! Set the current channel volume for a channel + /*! + \param channel The channel whose volume should be set, in range [0, openmpt::module::get_num_channels()[ + \param volume The new channel volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel or volume is outside the specified range. + \remarks The channel volume may be reset by pattern commands at any time. + \sa openmpt::ext::interactive::get_channel_volume + */ + virtual void set_channel_volume( std::int32_t channel, double volume ) = 0; + + //! Get the current channel volume for a channel + /*! + \param channel The channel whose volume should be retrieved, in range [0, openmpt::module::get_num_channels()[ + \return The current channel volume in range [0.0, 1.0] + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::set_channel_volume + */ + virtual double get_channel_volume( std::int32_t channel ) const = 0; + + //! Set the current mute status for a channel + /*! + \param channel The channel whose mute status should be set, in range [0, openmpt::module::get_num_channels()[ + \param mute The new mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::get_channel_mute_status + */ + virtual void set_channel_mute_status( std::int32_t channel, bool mute ) = 0; + + //! Get the current mute status for a channel + /*! + \param channel The channel whose mute status should be retrieved, in range [0, openmpt::module::get_num_channels()[ + \return The current channel mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel is outside the specified range. + \sa openmpt::ext::interactive::set_channel_mute_status + */ + virtual bool get_channel_mute_status( std::int32_t channel ) const = 0; + + //! Set the current mute status for an instrument + /*! + \param instrument The instrument whose mute status should be set, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \param mute The new mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range. + \sa openmpt::ext::interactive::get_instrument_mute_status + */ + virtual void set_instrument_mute_status( std::int32_t instrument, bool mute ) = 0; + + //! Get the current mute status for an instrument + /*! + \param instrument The instrument whose mute status should be retrieved, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \return The current channel mute status. true is muted, false is unmuted. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument is outside the specified range. + \sa openmpt::ext::interactive::set_instrument_mute_status + */ + virtual bool get_instrument_mute_status( std::int32_t instrument ) const = 0; + + //! Play a note using the specified instrument + /*! + \param instrument The instrument that should be played, in range [0, openmpt::module::get_num_instruments()[ if openmpt::module::get_num_instruments is not 0, otherwise in [0, openmpt::module::get_num_samples()[ + \param note The note to play, in rage [0, 119]. 60 is the middle C. + \param volume The volume at which the note should be triggered, in range [0.0, 1.0] + \param panning The panning position at which the note should be triggered, in range [-1.0, 1.0], 0.0 is center. + \return The channel on which the note is played. This can pe be passed to openmpt::ext::interactive::stop_note to stop the note. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the instrument or note is outside the specified range. + \sa openmpt::ext::interactive::stop_note + */ + virtual std::int32_t play_note( std::int32_t instrument, std::int32_t note, double volume, double panning ) = 0; + + //! Stop the note playing on the specified channel + /*! + \param channel The channel on which the note should be stopped. + \throws openmpt::exception Throws an exception derived from openmpt::exception if the channel index is invalid. + \sa openmpt::ext::interactive::play_note + */ + virtual void stop_note( std::int32_t channel ) = 0; + +}; // class interactive + + /* add stuff here */ Modified: trunk/OpenMPT/soundlib/Sndfile.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/soundlib/Sndfile.cpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -598,7 +598,7 @@ m_nSamples = 0; m_nInstruments = 0; #ifndef MODPLUG_TRACKER - m_nFreqFactor = m_nTempoFactor = 128; + m_nFreqFactor = m_nTempoFactor = 65536; #endif m_nMinPeriod = MIN_PERIOD; m_nMaxPeriod = 0x7FFF; @@ -725,7 +725,7 @@ m_nMixChannels = 0; #ifndef MODPLUG_TRACKER - m_nFreqFactor = m_nTempoFactor = 128; + m_nFreqFactor = m_nTempoFactor = 65536; #endif m_PlayState.m_nGlobalVolume = MAX_GLOBAL_VOLUME; @@ -1877,7 +1877,7 @@ break; } #ifndef MODPLUG_TRACKER - m_PlayState.m_nSamplesPerTick = Util::muldivr(m_PlayState.m_nSamplesPerTick, m_nTempoFactor, 128); + m_PlayState.m_nSamplesPerTick = Util::muldivr(m_PlayState.m_nSamplesPerTick, m_nTempoFactor, 65536); #endif // !MODPLUG_TRACKER } @@ -1923,7 +1923,7 @@ } #ifndef MODPLUG_TRACKER // when the user modifies the tempo, we do not really care about accurate tempo error accumulation - retval = Util::muldivr(retval, m_nTempoFactor, 128); + retval = Util::muldivr(retval, m_nTempoFactor, 65536); #endif // !MODPLUG_TRACKER return retval; } Modified: trunk/OpenMPT/soundlib/Sndfile.h =================================================================== --- trunk/OpenMPT/soundlib/Sndfile.h 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/soundlib/Sndfile.h 2014-11-10 00:01:55 UTC (rev 4578) @@ -421,8 +421,8 @@ UINT m_nSamplePreAmp, m_nVSTiVolume; bool IsGlobalVolumeUnset() const { return IsFirstTick(); } #ifndef MODPLUG_TRACKER - UINT m_nFreqFactor; // Pitch shift factor (128 = no pitch shifting). Interesting ModPlug Player relict, but unused in OpenMPT. - UINT m_nTempoFactor; // Tempo factor (128 = no tempo adjustment). Interesting ModPlug Player relict, but unused in OpenMPT. + UINT m_nFreqFactor; // Pitch shift factor (65536 = no pitch shifting). Only used in libopenmpt (openmpt::ext::interactive::set_pitch_factor) + UINT m_nTempoFactor; // Tempo factor (65536 = no tempo adjustment). Only used in libopenmpt (openmpt::ext::interactive::set_tempo_factor) #endif int32 m_nMinPeriod, m_nMaxPeriod; // min period = highest possible frequency, max period = lowest possible frequency int32 m_nRepeatCount; // -1 means repeat infinitely. Modified: trunk/OpenMPT/soundlib/Sndmix.cpp =================================================================== --- trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-09 20:15:29 UTC (rev 4577) +++ trunk/OpenMPT/soundlib/Sndmix.cpp 2014-11-10 00:01:55 UTC (rev 4578) @@ -1986,7 +1986,7 @@ uint32 ninc = GetChannelIncrement(pChn, period, nPeriodFrac); #ifndef MODPLUG_TRACKER - ninc = Util::muldivr(ninc, m_nFreqFactor, 128); + ninc = Util::muldivr(ninc, m_nFreqFactor, 65536); #endif // !MODPLUG_TRACKER if(ninc == 0) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |