2013-07-27 23:36:58 +02:00
|
|
|
|
|
|
|
#ifndef LUPPP_TRACK_OUTPUT_H
|
|
|
|
#define LUPPP_TRACK_OUTPUT_H
|
|
|
|
|
2013-07-30 01:56:13 +02:00
|
|
|
#include <stdio.h>
|
|
|
|
|
2013-07-28 14:14:25 +02:00
|
|
|
#include "audioprocessor.hxx"
|
|
|
|
|
2013-07-28 14:31:07 +02:00
|
|
|
#include "eventhandler.hxx"
|
|
|
|
#include "dsp/dsp_dbmeter.hxx"
|
|
|
|
|
2013-07-28 14:14:25 +02:00
|
|
|
class TrackOutput : public AudioProcessor
|
2013-07-27 23:36:58 +02:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
TrackOutput(int t, AudioProcessor* ap) :
|
2013-07-31 02:28:18 +02:00
|
|
|
AudioProcessor(),
|
2013-07-27 23:36:58 +02:00
|
|
|
track(t),
|
2013-07-28 14:31:07 +02:00
|
|
|
previousInChain(ap),
|
|
|
|
dbMeter(44100)
|
2013-07-27 23:36:58 +02:00
|
|
|
{
|
2013-07-30 01:56:13 +02:00
|
|
|
printf("trackOutput ID: %i\n", track);
|
|
|
|
|
2013-07-28 14:31:07 +02:00
|
|
|
// UI update
|
2013-07-30 04:07:46 +02:00
|
|
|
uiUpdateConstant = 44100 / 30;
|
2013-07-28 14:31:07 +02:00
|
|
|
uiUpdateCounter = 44100 / 30;
|
2013-07-28 15:20:54 +02:00
|
|
|
|
2013-07-30 01:56:13 +02:00
|
|
|
_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)
|
|
|
|
{
|
2013-07-30 01:56:13 +02:00
|
|
|
printf("TrackOutput: master vol : %f\n", value);
|
2013-07-28 15:56:34 +02:00
|
|
|
_toMaster = value;
|
2013-07-28 14:31:07 +02:00
|
|
|
}
|
|
|
|
/// set sidechain mix, 0-1
|
|
|
|
void setSidechain(float value)
|
|
|
|
{
|
2013-07-28 15:56:34 +02:00
|
|
|
_toSidechain = value;
|
2013-07-28 14:31:07 +02:00
|
|
|
}
|
|
|
|
/// set post sidechain mix, 0-1
|
|
|
|
void setPostSidechain(float value)
|
|
|
|
{
|
2013-07-28 15:56:34 +02:00
|
|
|
_toPostSidechain = value;
|
2013-07-28 14:31:07 +02:00
|
|
|
}
|
|
|
|
/// set reverb mix, 0-1
|
|
|
|
void setReverb(float value)
|
|
|
|
{
|
2013-07-28 15:56:34 +02:00
|
|
|
_toReverb = value;
|
2013-07-27 23:36:58 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/// copies the track output to master buffer, sidechain & post-side buffer
|
|
|
|
void process(int nframes, Buffers* buffers)
|
|
|
|
{
|
2013-07-28 14:14:25 +02:00
|
|
|
if ( previousInChain )
|
|
|
|
{
|
|
|
|
previousInChain->process( nframes, buffers );
|
|
|
|
}
|
2013-07-27 23:36:58 +02:00
|
|
|
|
2013-07-30 19:34:47 +02:00
|
|
|
|
2013-07-28 14:31:07 +02:00
|
|
|
float* buf = buffers->audio[Buffers::TRACK_0 + track];
|
|
|
|
dbMeter.process( nframes, buf, buf );
|
|
|
|
|
|
|
|
if (uiUpdateCounter > uiUpdateConstant )
|
|
|
|
{
|
2013-07-30 04:07:46 +02:00
|
|
|
EventTrackSignalLevel e( track, dbMeter.getLeftDB(), dbMeter.getRightDB() );
|
|
|
|
writeToGuiRingbuffer( &e );
|
2013-07-28 14:31:07 +02:00
|
|
|
uiUpdateCounter = 0;
|
|
|
|
}
|
|
|
|
uiUpdateCounter += nframes;
|
2013-07-28 14:42:05 +02:00
|
|
|
|
|
|
|
/// 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];
|
|
|
|
|
2013-07-30 01:56:13 +02:00
|
|
|
float* master = buffers->audio[Buffers::MASTER_OUTPUT];
|
|
|
|
|
2013-07-27 23:36:58 +02:00
|
|
|
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;
|
2013-07-30 01:56:13 +02:00
|
|
|
|
2013-07-28 14:42:05 +02:00
|
|
|
trackBuf++;
|
2013-07-27 23:36:58 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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;
|
2013-07-27 23:36:58 +02:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // LUPPP_TRACK_OUTPUT_H
|
|
|
|
|