Loopp/src/trackoutput.hxx

103 lines
2.4 KiB
C++
Raw Normal View History

#ifndef LUPPP_TRACK_OUTPUT_H
#define LUPPP_TRACK_OUTPUT_H
#include "audioprocessor.hxx"
2013-07-28 14:31:07 +02:00
#include "eventhandler.hxx"
#include "dsp/dsp_dbmeter.hxx"
class TrackOutput : public AudioProcessor
{
public:
TrackOutput(int t, AudioProcessor* ap) :
track(t),
2013-07-28 14:31:07 +02:00
previousInChain(ap),
dbMeter(44100)
{
2013-07-28 14:31:07 +02:00
// UI update
uiUpdateConstant = 44100 / 20;
uiUpdateCounter = 44100 / 30;
_toReverb = 1.0;
2013-07-28 14:31:07 +02:00
}
/// set main mix, 0-1
void setMaster(float value)
{
_toMaster = value;
2013-07-28 14:31:07 +02:00
}
/// set sidechain mix, 0-1
void setSidechain(float value)
{
_toSidechain = value;
2013-07-28 14:31:07 +02:00
}
/// set post sidechain mix, 0-1
void setPostSidechain(float value)
{
_toPostSidechain = value;
2013-07-28 14:31:07 +02:00
}
/// set reverb mix, 0-1
void setReverb(float value)
{
_toReverb = value;
}
/// copies the track output to master buffer, sidechain & post-side buffer
void process(int nframes, Buffers* buffers)
{
if ( previousInChain )
{
previousInChain->process( nframes, buffers );
}
2013-07-28 14:31:07 +02:00
float* buf = buffers->audio[Buffers::TRACK_0 + track];
dbMeter.process( nframes, buf, buf );
if (uiUpdateCounter > uiUpdateConstant )
{
EventTrackSignalLevel e( track, dbMeter.getLeftDB(), dbMeter.getRightDB() );
writeToGuiRingbuffer( &e );
uiUpdateCounter = 0;
}
uiUpdateCounter += nframes;
/// copy audio data into reverb / sidechain / master buffers
float* trackBuf = buffers->audio[Buffers::TRACK_0 + track];
float* reverb = buffers->audio[Buffers::REVERB];
float* sidechain = buffers->audio[Buffers::SIDECHAIN];
float* postSidechain = buffers->audio[Buffers::POST_SIDECHAIN];
for(int i = 0; i < nframes; i++)
{
*reverb++ += *trackBuf * _toReverb;
*sidechain++ += *trackBuf * _toSidechain;
*postSidechain++ += *trackBuf * _toPostSidechain;
2013-07-28 14:31:07 +02:00
trackBuf++;
}
}
private:
int track;
float _toMaster;
float _toReverb;
float _toSidechain;
float _toPostSidechain;
/// Pointer to "previous" processor: the graph is backwards
AudioProcessor* previousInChain;
2013-07-28 14:31:07 +02:00
// Metering variables
long uiUpdateCounter;
long uiUpdateConstant;
DBMeter dbMeter;
};
#endif // LUPPP_TRACK_OUTPUT_H