Defer updates to SampleBuffer
Removed global lock from the Mixer
This commit is contained in:
@@ -184,9 +184,9 @@ public:
|
||||
// audio-port-stuff
|
||||
inline void addAudioPort( AudioPort * _port )
|
||||
{
|
||||
lock();
|
||||
requestChangeInModel();
|
||||
m_audioPorts.push_back( _port );
|
||||
unlock();
|
||||
doneChangeInModel();
|
||||
}
|
||||
|
||||
void removeAudioPort( AudioPort * _port );
|
||||
@@ -274,16 +274,6 @@ public:
|
||||
|
||||
|
||||
// methods needed by other threads to alter knob values, waveforms, etc
|
||||
void lock()
|
||||
{
|
||||
m_globalMutex.lock();
|
||||
}
|
||||
|
||||
void unlock()
|
||||
{
|
||||
m_globalMutex.unlock();
|
||||
}
|
||||
|
||||
void lockInputFrames()
|
||||
{
|
||||
m_inputFramesMutex.lock();
|
||||
@@ -429,7 +419,6 @@ private:
|
||||
QString m_midiClientName;
|
||||
|
||||
// mutexes
|
||||
QMutex m_globalMutex;
|
||||
QMutex m_inputFramesMutex;
|
||||
QMutex m_playHandleMutex; // mutex used only for adding playhandles
|
||||
QMutex m_playHandleRemovalMutex;
|
||||
|
||||
@@ -151,19 +151,16 @@ public:
|
||||
|
||||
void setLoopStartFrame( f_cnt_t _start )
|
||||
{
|
||||
QWriteLocker writeLocker(&m_varLock);
|
||||
m_loopStartFrame = _start;
|
||||
}
|
||||
|
||||
void setLoopEndFrame( f_cnt_t _end )
|
||||
{
|
||||
QWriteLocker writeLocker(&m_varLock);
|
||||
m_loopEndFrame = _end;
|
||||
}
|
||||
|
||||
void setAllPointFrames( f_cnt_t _start, f_cnt_t _end, f_cnt_t _loopstart, f_cnt_t _loopend )
|
||||
{
|
||||
QWriteLocker writeLocker(&m_varLock);
|
||||
m_startFrame = _start;
|
||||
m_endFrame = _end;
|
||||
m_loopStartFrame = _loopstart;
|
||||
@@ -202,13 +199,11 @@ public:
|
||||
|
||||
inline void setFrequency( float _freq )
|
||||
{
|
||||
QWriteLocker writeLocker(&m_varLock);
|
||||
m_frequency = _freq;
|
||||
}
|
||||
|
||||
inline void setSampleRate( sample_rate_t _rate )
|
||||
{
|
||||
QWriteLocker writeLocker(&m_varLock);
|
||||
m_sampleRate = _rate;
|
||||
}
|
||||
|
||||
@@ -224,31 +219,37 @@ public:
|
||||
QString & toBase64( QString & _dst ) const;
|
||||
|
||||
|
||||
static SampleBuffer * resample( sampleFrame * _data,
|
||||
const f_cnt_t _frames,
|
||||
const sample_rate_t _src_sr,
|
||||
// protect calls from the GUI to this function with dataReadLock() and
|
||||
// dataUnlock()
|
||||
SampleBuffer * resample( const sample_rate_t _src_sr,
|
||||
const sample_rate_t _dst_sr );
|
||||
|
||||
static inline SampleBuffer * resample( SampleBuffer * _buf,
|
||||
const sample_rate_t _src_sr,
|
||||
const sample_rate_t _dst_sr )
|
||||
{
|
||||
return resample( _buf->m_data, _buf->m_frames, _src_sr,
|
||||
_dst_sr );
|
||||
}
|
||||
|
||||
void normalizeSampleRate( const sample_rate_t _src_sr,
|
||||
bool _keep_settings = false );
|
||||
|
||||
// protect calls from the GUI to this function with dataReadLock() and
|
||||
// dataUnlock(), out of loops for efficiency
|
||||
inline sample_t userWaveSample( const float _sample ) const
|
||||
{
|
||||
const float frame = _sample * m_frames;
|
||||
f_cnt_t f1 = static_cast<f_cnt_t>( frame ) % m_frames;
|
||||
f_cnt_t frames = m_frames;
|
||||
sampleFrame * data = m_data;
|
||||
const float frame = _sample * frames;
|
||||
f_cnt_t f1 = static_cast<f_cnt_t>( frame ) % frames;
|
||||
if( f1 < 0 )
|
||||
{
|
||||
f1 += m_frames;
|
||||
f1 += frames;
|
||||
}
|
||||
return linearInterpolate( m_data[f1][0], m_data[ (f1 + 1) % m_frames ][0], fraction( frame ) );
|
||||
return linearInterpolate( data[f1][0], data[ (f1 + 1) % frames ][0], fraction( frame ) );
|
||||
}
|
||||
|
||||
void dataReadLock()
|
||||
{
|
||||
m_varLock.lockForRead();
|
||||
}
|
||||
|
||||
void dataUnlock()
|
||||
{
|
||||
m_varLock.unlock();
|
||||
}
|
||||
|
||||
static QString tryToMakeRelative( const QString & _file );
|
||||
|
||||
@@ -31,9 +31,9 @@
|
||||
|
||||
#include "MidiTime.h"
|
||||
#include "PlayHandle.h"
|
||||
#include "SampleBuffer.h"
|
||||
|
||||
class BBTrack;
|
||||
class SampleBuffer;
|
||||
class SampleTCO;
|
||||
class Track;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user