diff --git a/ChangeLog b/ChangeLog index 3b1d21c44..714252a3a 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,24 @@ +2008-12-16 Tobias Doerffel + + * plugins/sf2_player/sf2_player.cpp: + * plugins/sf2_player/sf2_player.h: + fixed broken panning support + + * include/instrument.h: + * include/note_play_handle.h: + * src/core/note_play_handle.cpp: + * src/tracks/instrument_track.cpp: + reverted previous API changes as they can be implemented in a + generic manner + + * src/tracks/instrument_track.cpp: + * include/instrument_track.h: + - do not create a instrument track window just for calling + dragEnterEvent() - use a static method instead + - limit panning in processAudioBuffer() + 2008-12-16 Andrew Kelley - + * src/gui/piano_roll.cpp: * src/gui/automatable_model_view.cpp: * src/gui/song_editor.cpp: @@ -18,7 +37,7 @@ changed modifier detection from mainWindow::isCtrlPressed etc to Qt framework detection. Fixes a bunch of little glitches and enables horizontal scroll wheels. - + * plugins/sf2_player/sf2_player.cpp: * plugins/sf2_player/sf2_player.h: * include/note_play_handle.h: @@ -30,7 +49,7 @@ what worked for my setup.) 2008-12-15 Paul Giblock - + * src/core/track.cpp: * include/track.h: Cache background per-object instead of per-class. @@ -58,8 +77,8 @@ * include/piano_roll.h: * src/gui/piano_roll.cpp: - - double click in the note edit area to clear selected notes (allowing you - to edit note velocities/panning for all notes) + - double click in the note edit area to clear selected notes(allowing + you to edit note velocities/panning for all notes) - when setting a new note, set panning and volume to that of last clicked on note diff --git a/plugins/sf2_player/sf2_player.cpp b/plugins/sf2_player/sf2_player.cpp index a2f195d7c..2d295649b 100644 --- a/plugins/sf2_player/sf2_player.cpp +++ b/plugins/sf2_player/sf2_player.cpp @@ -46,6 +46,7 @@ #undef SINGLE_SOURCE_COMPILE #include "embed.cpp" +#define SF2_PANNING_SUPPORT extern "C" { @@ -67,6 +68,14 @@ plugin::descriptor sf2player_plugin_descriptor = } +struct SF2PluginData +{ + int midiNote; + int midiChannel; + int lastPanning; +} ; + + // Static map of current sfonts QMap sf2Instrument::s_fonts; QMutex sf2Instrument::s_fontsMutex; @@ -409,7 +418,8 @@ QString sf2Instrument::getCurrentPatchName( void ) for( int i = 0; i < cSoundFonts; i++ ) { fluid_sfont_t *pSoundFont = fluid_synth_get_sfont( m_synth, i ); - if (pSoundFont) { + if ( pSoundFont ) + { #ifdef CONFIG_FLUID_BANK_OFFSET int iBankOffset = fluid_synth_get_bank_offset( @@ -573,44 +583,52 @@ void sf2Instrument::playNote( notePlayHandle * _n, sampleFrame * ) if( tfp == 0 ) { - _n->m_pluginData = new int( midiNote ); + SF2PluginData * pluginData = new SF2PluginData; + pluginData->midiNote = midiNote; + pluginData->midiChannel = m_channel; + pluginData->lastPanning = -1; + + _n->m_pluginData = pluginData; m_synthMutex.lock(); - - short ctrl = 0x0A; // PAN_MSB - int pan = 0 + - ( (float)( _n->getPanning() - PanningLeft ) ) / - ( (float)( PanningRight - PanningLeft ) ) * - ( (float)( 127 - 0 ) ); - fluid_synth_cc( m_synth, m_channel, ctrl, pan ); - fluid_synth_noteon( m_synth, m_channel, midiNote, + + fluid_synth_noteon( m_synth, pluginData->midiChannel, midiNote, _n->getMidiVelocity() ); - _n->setChannel( m_channel ); + +#ifdef SF2_PANNING_SUPPORT + updatePatch(); + if( ++m_channel > m_maxChannels ) { m_channel = 1; } - +#endif + m_synthMutex.unlock(); m_notesRunningMutex.lock(); ++m_notesRunning[midiNote]; m_notesRunningMutex.unlock(); } -} - -void sf2Instrument::updatePanning( notePlayHandle * _n ) -{ - short ctrl = 0x0A; // PAN_MSB - int pan = 0 + +#ifdef SF2_PANNING_SUPPORT + SF2PluginData * pluginData = static_cast( + _n->m_pluginData ); + if( pluginData->lastPanning != _n->getPanning() ) + { + int pan = 0 + ( (float)( _n->getPanning() - PanningLeft ) ) / ( (float)( PanningRight - PanningLeft ) ) * ( (float)( 127 - 0 ) ); - fluid_synth_cc( m_synth, _n->channel(), ctrl, pan ); + fluid_synth_cc( m_synth, pluginData->midiChannel, 0x0A, pan ); + pluginData->lastPanning = _n->getPanning(); + } +#endif } + + // Could we get iph-based instruments support sample-exact models by using a // frame-length of 1 while rendering? void sf2Instrument::play( sampleFrame * _working_buffer ) @@ -668,18 +686,21 @@ void sf2Instrument::play( sampleFrame * _working_buffer ) void sf2Instrument::deleteNotePluginData( notePlayHandle * _n ) { - int * midiNote = static_cast( _n->m_pluginData ); + SF2PluginData * pluginData = static_cast( + _n->m_pluginData ); m_notesRunningMutex.lock(); - const int n = --m_notesRunning[*midiNote]; + const int n = --m_notesRunning[pluginData->midiNote]; m_notesRunningMutex.unlock(); + if( n <= 0 ) { m_synthMutex.lock(); - fluid_synth_noteoff( m_synth, _n->channel(), *midiNote ); + fluid_synth_noteoff( m_synth, pluginData->midiChannel, + pluginData->midiNote ); m_synthMutex.unlock(); } - delete midiNote; + delete pluginData; } @@ -687,7 +708,7 @@ void sf2Instrument::deleteNotePluginData( notePlayHandle * _n ) pluginView * sf2Instrument::instantiateView( QWidget * _parent ) { - return( new sf2InstrumentView( this, _parent ) ); + return new sf2InstrumentView( this, _parent ); } diff --git a/plugins/sf2_player/sf2_player.h b/plugins/sf2_player/sf2_player.h index 1d0670d3c..7dc09c07a 100644 --- a/plugins/sf2_player/sf2_player.h +++ b/plugins/sf2_player/sf2_player.h @@ -60,8 +60,6 @@ public: sampleFrame * _working_buffer ); virtual void deleteNotePluginData( notePlayHandle * _n ); - virtual void updatePanning( notePlayHandle * ); - virtual void saveSettings( QDomDocument & _doc, QDomElement & _parent ); virtual void loadSettings( const QDomElement & _this );