Skip to content

Commit

Permalink
Make SampleBuffer adjust its members when resampling. Fixes LMMS#5218.
Browse files Browse the repository at this point in the history
  • Loading branch information
softrabbit committed Oct 6, 2019
1 parent 419321d commit cd642b1
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/core/SampleBuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -387,6 +387,8 @@ void SampleBuffer::normalizeSampleRate( const sample_rate_t _src_sr,
{
SampleBuffer * resampled = resample( _src_sr,
mixerSampleRate() );

m_sampleRate = mixerSampleRate();
MM_FREE( m_data );
m_frames = resampled->frames();
m_data = MM_ALLOC( sampleFrame, m_frames );
Expand All @@ -401,6 +403,13 @@ void SampleBuffer::normalizeSampleRate( const sample_rate_t _src_sr,
m_loopStartFrame = m_startFrame = 0;
m_loopEndFrame = m_endFrame = m_frames;
}
else if( _src_sr != mixerSampleRate() )
{
m_startFrame *= ((float)mixerSampleRate() / _src_sr);
m_endFrame *= ((float)mixerSampleRate() / _src_sr);
m_loopStartFrame *= ((float)mixerSampleRate() / _src_sr);
m_loopEndFrame *= ((float)mixerSampleRate() / _src_sr);
}
}


Expand Down

0 comments on commit cd642b1

Please sign in to comment.