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:
@@ -312,7 +312,6 @@ public:
|
||||
// audio-buffer-mgm
|
||||
void bufferToPort( const sampleFrame * _buf,
|
||||
const fpp_t _frames,
|
||||
const f_cnt_t _offset,
|
||||
stereoVolumeVector _volume_vector,
|
||||
AudioPort * _port );
|
||||
|
||||
|
||||
@@ -74,6 +74,16 @@ public:
|
||||
{
|
||||
return m_midiChannel;
|
||||
}
|
||||
|
||||
/*! convenience function that returns offset for the first period and zero otherwise,
|
||||
used by instruments to handle the offset: instruments have to check this property and
|
||||
add the correct number of empty frames in the beginning of the period */
|
||||
f_cnt_t noteOffset() const
|
||||
{
|
||||
return m_totalFramesPlayed == 0
|
||||
? offset()
|
||||
: 0;
|
||||
}
|
||||
|
||||
const float& frequency() const
|
||||
{
|
||||
@@ -94,7 +104,7 @@ public:
|
||||
/*! Returns whether playback of note is finished and thus handle can be deleted */
|
||||
virtual bool isFinished() const
|
||||
{
|
||||
return m_released && framesLeft() <= 0 && m_scheduledNoteOff < 0;
|
||||
return m_released && framesLeft() <= 0;
|
||||
}
|
||||
|
||||
/*! Returns number of frames left for playback */
|
||||
@@ -264,7 +274,6 @@ private:
|
||||
// played after release
|
||||
f_cnt_t m_releaseFramesDone; // number of frames done after
|
||||
// release of note
|
||||
f_cnt_t m_scheduledNoteOff; // variable for scheduling noteoff at next period
|
||||
NotePlayHandleList m_subNotes; // used for chords and arpeggios
|
||||
volatile bool m_released; // indicates whether note is released
|
||||
bool m_hasParent;
|
||||
|
||||
@@ -88,8 +88,8 @@ public:
|
||||
virtual void play( sampleFrame* buffer ) = 0;
|
||||
virtual bool isFinished( void ) const = 0;
|
||||
|
||||
// returns how many frames this play-handle is aligned ahead, i.e.
|
||||
// at which position it is inserted in the according buffer
|
||||
// returns the frameoffset at the start of the playhandle,
|
||||
// ie. how many empty frames should be inserted at the start of the first period
|
||||
f_cnt_t offset() const
|
||||
{
|
||||
return m_offset;
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _SAMPLE_PLAY_HANDLE_H
|
||||
#define _SAMPLE_PLAY_HANDLE_H
|
||||
#ifndef SAMPLE_PLAY_HANDLE_H
|
||||
#define SAMPLE_PLAY_HANDLE_H
|
||||
|
||||
#include "Mixer.h"
|
||||
#include "SampleBuffer.h"
|
||||
@@ -49,7 +49,7 @@ public:
|
||||
}
|
||||
|
||||
|
||||
virtual void play( sampleFrame * _working_buffer );
|
||||
virtual void play( sampleFrame * buffer );
|
||||
virtual bool isFinished() const;
|
||||
|
||||
virtual bool isFromTrack( const track * _track ) const;
|
||||
|
||||
Reference in New Issue
Block a user