Merge pull request #159 from wongcc966422/sfxr

sfxr plugin: Added pitch support
This commit is contained in:
Andrew Kelley
2014-01-25 19:53:39 -08:00

View File

@@ -300,7 +300,7 @@ void SfxrSynth::update( sampleFrame * buffer, const fpp_t frameNum )
{
if(ssample>1.0f) ssample=1.0f;
if(ssample<-1.0f) ssample=-1.0f;
for( ch_cnt_t j=0; j < DEFAULT_CHANNELS; j++ )
for( ch_cnt_t j=0; j<DEFAULT_CHANNELS; j++ )
{
buffer[i][j]=ssample;
}
@@ -459,7 +459,18 @@ void sfxrInstrument::playNote(notePlayHandle * _n, sampleFrame * _working_buffer
_n->noteOff();
}
static_cast<SfxrSynth*>(_n->m_pluginData)->update( _working_buffer, frameNum );
fpp_t pitchedFrameNum = (_n->frequency()/BaseFreq)*frameNum;
sampleFrame * pitchedBuffer = new sampleFrame[pitchedFrameNum];
static_cast<SfxrSynth*>(_n->m_pluginData)->update( pitchedBuffer, pitchedFrameNum );
for( fpp_t i=0; i<frameNum; i++ )
{
for( ch_cnt_t j=0; j<DEFAULT_CHANNELS; j++ )
{
_working_buffer[i][j] = pitchedBuffer[(int)(((double)pitchedFrameNum/frameNum)*i)][j];
}
}
delete[] pitchedBuffer;
m_synthMutex.unlock();
instrumentTrack()->processAudioBuffer( _working_buffer, frameNum, NULL );