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:
Vesa
2014-06-29 23:13:00 +03:00
parent a7bb31159e
commit 270af579b8
23 changed files with 137 additions and 124 deletions

View File

@@ -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;