added m_runningNotes-array to track overlapping or edge-to-edge notes and act accordingly
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@768 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -1,3 +1,10 @@
|
||||
2008-03-06 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/sf2_player/sf2_player.h:
|
||||
* plugins/sf2_player/sf2_player.cpp:
|
||||
added m_runningNotes-array to track overlapping or edge-to-edge notes
|
||||
and act accordingly
|
||||
|
||||
2008-03-04 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* src/widgets/graph.cpp:
|
||||
|
||||
@@ -72,18 +72,21 @@ sf2Instrument::sf2Instrument( instrumentTrack * _instrument_track ) :
|
||||
m_bankNum( -1, -1, 999, 1, this ),
|
||||
m_patchNum( -1, -1, 127, 1, this )
|
||||
{
|
||||
|
||||
m_settings = new_fluid_settings();
|
||||
for( int i = 0; i < 128; ++i )
|
||||
{
|
||||
m_notesRunning[i] = 0;
|
||||
}
|
||||
m_settings = new_fluid_settings();
|
||||
|
||||
/* Set the synthesizer settings, if necessary */
|
||||
/* Set the synthesizer settings, if necessary */
|
||||
|
||||
|
||||
m_synth = new_fluid_synth( m_settings );
|
||||
m_synth = new_fluid_synth( m_settings );
|
||||
|
||||
|
||||
//fluid_settings_setstr(settings, "audio.driver", "jack");
|
||||
//fluid_settings_setstr(settings, "audio.driver", "jack");
|
||||
|
||||
//adriver = new_fluid_audio_driver(settings, synth);
|
||||
//adriver = new_fluid_audio_driver(settings, synth);
|
||||
|
||||
instrumentPlayHandle * iph = new instrumentPlayHandle( this );
|
||||
engine::getMixer()->addPlayHandle( iph );
|
||||
@@ -167,18 +170,24 @@ void sf2Instrument::updatePatch( void )
|
||||
|
||||
void sf2Instrument::playNote( notePlayHandle * _n, bool )
|
||||
{
|
||||
const float LOG440 = 2.64345267649f;
|
||||
const float LOG440 = 2.64345267649f;
|
||||
|
||||
const int defaultVelocity = 80;
|
||||
const f_cnt_t tfp = _n->totalFramesPlayed();
|
||||
|
||||
const f_cnt_t tfp = _n->totalFramesPlayed();
|
||||
|
||||
int midiNote = (int)floor( ( log2( _n->frequency() ) - LOG440 ) * 12 +69-58)+0.5;
|
||||
int midiNote = (int)floor( ( log2( _n->frequency() ) - LOG440 ) * 12+69-58)+0.5;
|
||||
// out of range?
|
||||
if( midiNote <= 0 || midiNote >= 128 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if ( tfp == 0 )
|
||||
{
|
||||
_n->m_pluginData = new int( midiNote );
|
||||
fluid_synth_noteon( m_synth, 1, midiNote, defaultVelocity );
|
||||
fluid_synth_noteon( m_synth, 1, midiNote, _n->getVolume() );
|
||||
m_notesRunningMutex.lock();
|
||||
++m_notesRunning[midiNote];
|
||||
m_notesRunningMutex.unlock();
|
||||
}
|
||||
else if( _n->released() )
|
||||
{
|
||||
@@ -188,11 +197,6 @@ void sf2Instrument::playNote( notePlayHandle * _n, bool )
|
||||
}
|
||||
|
||||
|
||||
void sf2Instrument::waitForWorkerThread( void )
|
||||
{
|
||||
// No waiting required, at least not that I know of
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
void sf2Instrument::play( bool _try_parallelizing )
|
||||
@@ -201,31 +205,29 @@ void sf2Instrument::play( bool _try_parallelizing )
|
||||
|
||||
sampleFrame * buf = new sampleFrame[frames];
|
||||
|
||||
// Assumes stereo and float sample_t
|
||||
// Assumes stereo and float sample_t
|
||||
|
||||
fluid_synth_write_float( m_synth, frames, buf, 0, 2, buf, 1, 2 );
|
||||
fluid_synth_write_float( m_synth, frames, buf, 0, 2, buf, 1, 2 );
|
||||
|
||||
getInstrumentTrack()->processAudioBuffer( buf, frames, NULL );
|
||||
|
||||
delete[] buf;
|
||||
|
||||
if( !_try_parallelizing )
|
||||
{
|
||||
waitForWorkerThread();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void sf2Instrument::deleteNotePluginData( notePlayHandle * _n )
|
||||
{
|
||||
int * midiNote = static_cast<int *>( _n->m_pluginData );
|
||||
|
||||
fluid_synth_noteoff( m_synth, 1, *midiNote );
|
||||
int * midiNote = static_cast<int *>( _n->m_pluginData );
|
||||
m_notesRunningMutex.lock();
|
||||
const int n = --m_notesRunning[*midiNote];
|
||||
m_notesRunningMutex.unlock();
|
||||
if( n <= 0 )
|
||||
{
|
||||
fluid_synth_noteoff( m_synth, 1, *midiNote );
|
||||
}
|
||||
|
||||
delete midiNote;
|
||||
|
||||
_n->noteOff();
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
#ifndef _SF2_PLAYER_H
|
||||
#define _SF2_PLAYER_H
|
||||
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
#include "instrument.h"
|
||||
#include "pixmap_button.h"
|
||||
#include "instrument_view.h"
|
||||
@@ -75,11 +77,10 @@ public:
|
||||
return( FALSE );
|
||||
}
|
||||
|
||||
virtual void waitForWorkerThread( void );
|
||||
|
||||
|
||||
virtual pluginView * instantiateView( QWidget * _parent );
|
||||
|
||||
|
||||
public slots:
|
||||
void openFile( const QString & _sf2File );
|
||||
void updatePatch( void );
|
||||
@@ -93,7 +94,8 @@ private:
|
||||
fluid_audio_driver_t* m_adriver;
|
||||
|
||||
int m_fontId;
|
||||
|
||||
QMutex m_notesRunningMutex;
|
||||
int m_notesRunning[128];
|
||||
|
||||
|
||||
QString m_filename;
|
||||
|
||||
Reference in New Issue
Block a user