Merge pull request #911 from diizy/master-nph
Revision of handling of frameoffset for NPH, SPH
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#define AUTOMATABLE_MODEL_H
|
||||
|
||||
#include <math.h>
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
#include "JournallingObject.h"
|
||||
#include "Model.h"
|
||||
@@ -103,9 +104,6 @@ public:
|
||||
{
|
||||
return isAutomated() || m_controllerConnection != NULL;
|
||||
}
|
||||
|
||||
bool hasSampleExactData() const;
|
||||
|
||||
|
||||
ControllerConnection* controllerConnection() const
|
||||
{
|
||||
@@ -142,10 +140,8 @@ public:
|
||||
|
||||
float controllerValue( int frameOffset ) const;
|
||||
|
||||
// returns sample-exact data as a ValueBuffer
|
||||
// should only be called when sample-exact data exists
|
||||
// in other cases (eg. for automation), the receiving end should interpolate
|
||||
// the values themselves
|
||||
//! @brief Function that returns sample-exact data as a ValueBuffer
|
||||
//! @return pointer to model's valueBuffer when s.ex.data exists, NULL otherwise
|
||||
ValueBuffer * valueBuffer();
|
||||
|
||||
template<class T>
|
||||
@@ -264,6 +260,16 @@ public:
|
||||
{
|
||||
m_hasStrictStepSize = b;
|
||||
}
|
||||
|
||||
static void incrementPeriodCounter()
|
||||
{
|
||||
++s_periodCounter;
|
||||
}
|
||||
|
||||
static void resetPeriodCounter()
|
||||
{
|
||||
s_periodCounter = 0;
|
||||
}
|
||||
|
||||
public slots:
|
||||
virtual void reset();
|
||||
@@ -332,6 +338,13 @@ private:
|
||||
static float s_copiedValue;
|
||||
|
||||
ValueBuffer m_valueBuffer;
|
||||
long m_lastUpdatedPeriod;
|
||||
static long s_periodCounter;
|
||||
|
||||
bool m_hasSampleExactData;
|
||||
|
||||
// prevent several threads from attempting to write the same vb at the same time
|
||||
QMutex m_valueBufferMutex;
|
||||
|
||||
signals:
|
||||
void initValueChanged( float val );
|
||||
|
||||
@@ -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