mirror of
https://github.com/vale981/openAV-Luppp
synced 2025-03-06 01:21:38 -05:00
-Working on track metering
This commit is contained in:
parent
6fca9a3095
commit
9337fae460
5 changed files with 84 additions and 0 deletions
|
@ -44,6 +44,8 @@ class Background : public Fl_Widget
|
||||||
|
|
||||||
label = _label;
|
label = _label;
|
||||||
|
|
||||||
|
printf("AVTK background label: %s\n", label );
|
||||||
|
|
||||||
highlight = false;
|
highlight = false;
|
||||||
}
|
}
|
||||||
bool highlight;
|
bool highlight;
|
||||||
|
|
73
src/dsp/dsp_dbmeter.hxx
Normal file
73
src/dsp/dsp_dbmeter.hxx
Normal file
|
@ -0,0 +1,73 @@
|
||||||
|
|
||||||
|
#ifndef OPENAV_DSP_DBMETER_H
|
||||||
|
#define OPENAV_DSP_DBMETER_H
|
||||||
|
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
#include <cmath>
|
||||||
|
#include <cstdlib>
|
||||||
|
|
||||||
|
float fabsf(float dummy0);
|
||||||
|
float log10f(float dummy0);
|
||||||
|
|
||||||
|
class DBMeter
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
DBMeter(int rate)
|
||||||
|
{
|
||||||
|
fSamplingFreq = rate;
|
||||||
|
fConst0 = (96.f / float(min(192000, max(1, fSamplingFreq))));
|
||||||
|
|
||||||
|
fRec0[0] = -96.f;
|
||||||
|
fRec0[1] = -96.f;
|
||||||
|
fRec1[0] = -96.f;
|
||||||
|
fRec1[1] = -96.f;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getNumInputs() { return 2;}
|
||||||
|
int getNumOutputs(){ return 2;}
|
||||||
|
|
||||||
|
// call this to get the current dB value, range = -96 -> +10
|
||||||
|
float getLeftDB()
|
||||||
|
{
|
||||||
|
return fvbargraph0;
|
||||||
|
}
|
||||||
|
float getRightDB()
|
||||||
|
{
|
||||||
|
return fvbargraph1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void process(int count, float** inputs, float** outputs)
|
||||||
|
{
|
||||||
|
float* input0 = inputs[0];
|
||||||
|
float* input1 = inputs[1];
|
||||||
|
float* output0 = outputs[0];
|
||||||
|
float* output1 = outputs[1];
|
||||||
|
for (int i = 0; (i < count); i = (i + 1))
|
||||||
|
{
|
||||||
|
float fTemp0 = float(input0[i]);
|
||||||
|
fRec0[0] = max((fRec0[1] - fConst0), min(10.f, (20.f * log10f(max(1.58489e-05f, fabsf(fTemp0))))));
|
||||||
|
fvbargraph0 = fRec0[0];
|
||||||
|
output0[i] = float(fTemp0);
|
||||||
|
|
||||||
|
float fTemp1 = float(input1[i]);
|
||||||
|
fRec1[0] = max((fRec1[1] - fConst0), min(10.f, (20.f * log10f(max(1.58489e-05f, fabsf(fTemp1))))));
|
||||||
|
fvbargraph1 = fRec1[0];
|
||||||
|
output1[i] = float(fTemp1);
|
||||||
|
|
||||||
|
fRec0[1] = fRec0[0];
|
||||||
|
fRec1[1] = fRec1[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
float fRec0[2];
|
||||||
|
float fRec1[2];
|
||||||
|
int fSamplingFreq;
|
||||||
|
float fConst0;
|
||||||
|
float fvbargraph0;
|
||||||
|
float fvbargraph1;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // OPENAV_DSP_DBMETER_H
|
||||||
|
|
|
@ -61,12 +61,14 @@ Gui::Gui() :
|
||||||
tooltipLabel->hide();
|
tooltipLabel->hide();
|
||||||
//tooltipLabel->align( FL_ALIGN_TOP_LEFT );
|
//tooltipLabel->align( FL_ALIGN_TOP_LEFT );
|
||||||
|
|
||||||
|
window.resizable( headerImage );
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < NTRACKS; i++ )
|
for (; i < NTRACKS; i++ )
|
||||||
{
|
{
|
||||||
stringstream s;
|
stringstream s;
|
||||||
s << "Track " << i+1;
|
s << "Track " << i+1;
|
||||||
|
printf("track name %s\n", s.str().c_str() );
|
||||||
tracks.push_back( new GTrack(8 + i * 118, 40, 110, 600, s.str().c_str() ) );
|
tracks.push_back( new GTrack(8 + i * 118, 40, 110, 600, s.str().c_str() ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -71,6 +71,8 @@ Jack::Jack()
|
||||||
|
|
||||||
loopers.push_back( new Looper(i) );
|
loopers.push_back( new Looper(i) );
|
||||||
timeManager.registerObserver( loopers.back() );
|
timeManager.registerObserver( loopers.back() );
|
||||||
|
|
||||||
|
dbMeters.push_back( new DBMeter( buffers.samplerate ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
timeManager.registerObserver( &metronome );
|
timeManager.registerObserver( &metronome );
|
||||||
|
@ -135,6 +137,8 @@ int Jack::process (jack_nframes_t nframes)
|
||||||
|
|
||||||
// mixdown tracks into master output buffer
|
// mixdown tracks into master output buffer
|
||||||
float* output = buffers.audio[Buffers::MASTER_OUTPUT];
|
float* output = buffers.audio[Buffers::MASTER_OUTPUT];
|
||||||
|
|
||||||
|
|
||||||
for(int i = 0; i < nframes; i++)
|
for(int i = 0; i < nframes; i++)
|
||||||
{
|
{
|
||||||
float tmp = 0.f;
|
float tmp = 0.f;
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
#include "metronome.hxx"
|
#include "metronome.hxx"
|
||||||
#include "timemanager.hxx"
|
#include "timemanager.hxx"
|
||||||
|
|
||||||
|
#include "dsp/dsp_dbmeter.hxx"
|
||||||
|
|
||||||
#include "controllerupdater.hxx"
|
#include "controllerupdater.hxx"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
@ -62,6 +64,7 @@ class Jack
|
||||||
ControllerUpdater controllerUpdater;
|
ControllerUpdater controllerUpdater;
|
||||||
|
|
||||||
vector<Looper*> loopers;
|
vector<Looper*> loopers;
|
||||||
|
vector<DBMeter*> dbMeters;
|
||||||
|
|
||||||
int nframes;
|
int nframes;
|
||||||
int samplerate;
|
int samplerate;
|
||||||
|
|
Loading…
Add table
Reference in a new issue