Skip to content

Commit

Permalink
Mixer refactor (#4894)
Browse files Browse the repository at this point in the history
Co-authored-by: Kevin Zander <[email protected]>
  • Loading branch information
M374LX and Veratil authored Dec 11, 2020
1 parent 2cb7973 commit 28ee260
Show file tree
Hide file tree
Showing 2 changed files with 131 additions and 129 deletions.
51 changes: 25 additions & 26 deletions include/Mixer.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ class LMMS_EXPORT Mixer : public QObject
Interpolation interpolation;
Oversampling oversampling;

qualitySettings( Mode _m )
qualitySettings(Mode m)
{
switch( _m )
switch (m)
{
case Mode_Draft:
interpolation = Interpolation_Linear;
Expand All @@ -118,9 +118,9 @@ class LMMS_EXPORT Mixer : public QObject
}
}

qualitySettings( Interpolation _i, Oversampling _o ) :
interpolation( _i ),
oversampling( _o )
qualitySettings(Interpolation i, Oversampling o) :
interpolation(i),
oversampling(o)
{
}

Expand Down Expand Up @@ -186,14 +186,14 @@ class LMMS_EXPORT Mixer : public QObject


// audio-port-stuff
inline void addAudioPort( AudioPort * _port )
inline void addAudioPort(AudioPort * port)
{
requestChangeInModel();
m_audioPorts.push_back( _port );
m_audioPorts.push_back(port);
doneChangeInModel();
}

void removeAudioPort( AudioPort * _port );
void removeAudioPort(AudioPort * port);


// MIDI-client-stuff
Expand All @@ -218,7 +218,7 @@ class LMMS_EXPORT Mixer : public QObject
return m_playHandles;
}

void removePlayHandlesOfTypes( Track * _track, const quint8 types );
void removePlayHandlesOfTypes(Track * track, const quint8 types);


// methods providing information for other classes
Expand Down Expand Up @@ -255,23 +255,23 @@ class LMMS_EXPORT Mixer : public QObject
return m_masterGain;
}

inline void setMasterGain( const float _mo )
inline void setMasterGain(const float mo)
{
m_masterGain = _mo;
m_masterGain = mo;
}


static inline sample_t clip( const sample_t _s )
static inline sample_t clip(const sample_t s)
{
if( _s > 1.0f )
if (s > 1.0f)
{
return 1.0f;
}
else if( _s < -1.0f )
else if (s < -1.0f)
{
return -1.0f;
}
return _s;
return s;
}


Expand All @@ -281,7 +281,7 @@ class LMMS_EXPORT Mixer : public QObject
sample_t left;
sample_t right;
};
StereoSample getPeakValues(sampleFrame * _ab, const f_cnt_t _frames) const;
StereoSample getPeakValues(sampleFrame * ab, const f_cnt_t _frames) const;


bool criticalXRuns() const;
Expand All @@ -308,7 +308,7 @@ class LMMS_EXPORT Mixer : public QObject
return hasFifoWriter() ? m_fifo->read() : renderNextBuffer();
}

void changeQuality( const struct qualitySettings & _qs );
void changeQuality(const struct qualitySettings & qs);

inline bool isMetronomeActive() const { return m_metronomeActive; }
inline void setMetronomeActive(bool value = true) { m_metronomeActive = value; }
Expand All @@ -333,7 +333,7 @@ class LMMS_EXPORT Mixer : public QObject
class fifoWriter : public QThread
{
public:
fifoWriter( Mixer * _mixer, fifo * _fifo );
fifoWriter(Mixer * mixer, fifo * _fifo);

void finish();

Expand All @@ -353,7 +353,7 @@ class LMMS_EXPORT Mixer : public QObject
Mixer( bool renderOnly );
virtual ~Mixer();

void startProcessing( bool _needs_fifo = true );
void startProcessing(bool needsFifo = true);
void stopProcessing();


Expand All @@ -363,6 +363,10 @@ class LMMS_EXPORT Mixer : public QObject

const surroundSampleFrame * renderNextBuffer();

void swapBuffers();

void handleMetronome();

void clearInternal();

//! Called by the audio thread to give control to other threads,
Expand All @@ -381,13 +385,8 @@ class LMMS_EXPORT Mixer : public QObject
int m_inputBufferRead;
int m_inputBufferWrite;

surroundSampleFrame * m_readBuf;
surroundSampleFrame * m_writeBuf;

QVector<surroundSampleFrame *> m_bufferPool;
int m_readBuffer;
int m_writeBuffer;
int m_poolDepth;
surroundSampleFrame * m_outputBufferRead;
surroundSampleFrame * m_outputBufferWrite;

// worker thread stuff
QVector<MixerWorkerThread *> m_workers;
Expand Down
Loading

0 comments on commit 28ee260

Please sign in to comment.