diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index 9091cafef..368a9779b 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -87,7 +87,8 @@ sf2Instrument::sf2Instrument( InstrumentTrack * _instrument_track ) : m_font( NULL ), m_fontId( 0 ), m_filename( "" ), - m_lastMidiPitch( 8192 ), + m_lastMidiPitch( -1 ), + m_lastMidiPitchRange( -1 ), m_channel( 1 ), m_bankNum( 0, 0, 999, this, tr("Bank") ), m_patchNum( 0, 0, 127, this, tr("Patch") ), @@ -679,12 +680,21 @@ void sf2Instrument::play( sampleFrame * _working_buffer ) const fpp_t frames = engine::mixer()->framesPerPeriod(); m_synthMutex.lock(); - if( m_lastMidiPitch != instrumentTrack()->midiPitch() ) + + const int currentMidiPitch = instrumentTrack()->midiPitch(); + if( m_lastMidiPitch != currentMidiPitch ) { - m_lastMidiPitch = instrumentTrack()->midiPitch(); + m_lastMidiPitch = currentMidiPitch; fluid_synth_pitch_bend( m_synth, m_channel, m_lastMidiPitch ); } + const int currentMidiPitchRange = instrumentTrack()->midiPitchRange(); + if( m_lastMidiPitchRange != currentMidiPitchRange ) + { + m_lastMidiPitchRange = currentMidiPitchRange; + fluid_synth_pitch_wheel_sens( m_synth, m_channel, m_lastMidiPitchRange ); + } + if( m_internalSampleRate < engine::mixer()->processingSampleRate() && m_srcState != NULL ) { diff --git a/plugins/sf2_player/sf2_player.h b/plugins/sf2_player/sf2_player.h index 903480605..691a2be83 100644 --- a/plugins/sf2_player/sf2_player.h +++ b/plugins/sf2_player/sf2_player.h @@ -129,6 +129,7 @@ private: int m_notesRunning[128]; sample_rate_t m_internalSampleRate; int m_lastMidiPitch; + int m_lastMidiPitchRange; int m_channel; lcdSpinBoxModel m_bankNum;