mirror of
https://github.com/LMMS/lmms.git
synced 2026-06-28 07:45:39 -04:00
Revision of handling of frameoffset for NPH, SPH
Change in handling of frameoffset for multistreamed instruments and sampletracks. - Instead of holding the offset for the lifetime of the playhandle, negate the offset in the first period - Multistream-instruments require some small changes: they have to now check for the offset and accordingly leave empty space in the start of the period (already done in this commit) - There are possibly optimizations that can be done later - This change is necessary so that we can have sample-exact models, and sample-exact vol/pan knobs for all instruments. Earlier multistream instruments were always rendering some frames ahead-of-time, so applying sample-exact data for them would have been impossible, since we don't have the future-values yet...
This commit is contained in:
@@ -96,7 +96,7 @@ SamplePlayHandle::~SamplePlayHandle()
|
||||
|
||||
|
||||
|
||||
void SamplePlayHandle::play( sampleFrame * _working_buffer )
|
||||
void SamplePlayHandle::play( sampleFrame * buffer )
|
||||
{
|
||||
//play( 0, _try_parallelizing );
|
||||
if( framesDone() >= totalFrames() )
|
||||
@@ -104,17 +104,27 @@ void SamplePlayHandle::play( sampleFrame * _working_buffer )
|
||||
return;
|
||||
}
|
||||
|
||||
const fpp_t frames = engine::mixer()->framesPerPeriod();
|
||||
sampleFrame * workingBuffer = buffer;
|
||||
const fpp_t fpp = engine::mixer()->framesPerPeriod();
|
||||
f_cnt_t frames = fpp;
|
||||
|
||||
// apply offset for the first period
|
||||
if( framesDone() == 0 )
|
||||
{
|
||||
buffer += offset();
|
||||
frames -= offset();
|
||||
}
|
||||
|
||||
if( !( m_track && m_track->isMuted() )
|
||||
&& !( m_bbTrack && m_bbTrack->isMuted() ) )
|
||||
{
|
||||
stereoVolumeVector v =
|
||||
{ { m_volumeModel->value() / DefaultVolume,
|
||||
m_volumeModel->value() / DefaultVolume } };
|
||||
m_sampleBuffer->play( _working_buffer, &m_state, frames,
|
||||
m_sampleBuffer->play( workingBuffer, &m_state, frames,
|
||||
BaseFreq );
|
||||
engine::mixer()->bufferToPort( _working_buffer, frames,
|
||||
offset(), v, m_audioPort );
|
||||
engine::mixer()->bufferToPort( buffer, fpp,
|
||||
v, m_audioPort );
|
||||
}
|
||||
|
||||
m_frame += frames;
|
||||
|
||||
Reference in New Issue
Block a user