Loopp/src/trackoutput.hxx

116 lines
2.8 KiB
C++
Raw Normal View History

#ifndef LUPPP_TRACK_OUTPUT_H
#define LUPPP_TRACK_OUTPUT_H
#include <stdio.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) :
2013-07-31 02:28:18 +02:00
AudioProcessor(),
track(t),
2013-07-28 14:31:07 +02:00
previousInChain(ap),
dbMeter(44100)
{
printf("trackOutput ID: %i\n", track);
2013-07-28 14:31:07 +02:00
// UI update
uiUpdateConstant = 44100 / 30;
2013-07-28 14:31:07 +02:00
uiUpdateCounter = 44100 / 30;
_toReverb = 0.0;
_toMaster = 0.8;
_toSidechain = 0.0;
_toPostSidechain = 0.0;
2013-07-28 14:31:07 +02:00
}
/// set main mix, 0-1
void setMaster(float value)
{
printf("TrackOutput: master vol : %f\n", 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 );
2013-07-28 14:31:07 +02:00
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];
float* master = buffers->audio[Buffers::MASTER_OUTPUT];
for(int i = 0; i < nframes; i++)
{
2013-07-31 02:05:14 +02:00
//*reverb++ += *trackBuf * _toReverb;
//*sidechain++ += *trackBuf * _toSidechain;
//*postSidechain++ += *trackBuf * _toPostSidechain;
2013-07-28 14:31:07 +02:00
2013-07-31 02:05:14 +02:00
//*master++ += *trackBuf * _toMaster;
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