-Debuggging master output glitch

This commit is contained in:
Harry van Haaren 2013-08-15 17:18:03 +01:00
parent ad74c72fea
commit 74fb5bcee1
5 changed files with 65 additions and 49 deletions

View file

@ -24,26 +24,14 @@ class Reverb // : Effect
int getNumInputs() { return 2; }
int getNumOutputs(){ return 2; }
void setActive(bool a)
{
active = a;
}
bool getActive()
{
return active;
}
/// set HF damping, 0-1
void damping(float d)
{
if( d > 1.0 ) d = 1.0f;
if( d < 0.0 ) d = 0.0f;
fslider1 = d * 18500 + 1500.f;
fslider1 = (1-d) * 18500 + 1500.f;
}
/// set size, 0-1
void rt60(float rt)
{
if( rt > 1.0 ) rt = 1.0f;
@ -52,11 +40,15 @@ class Reverb // : Effect
fslider0 = 1 + rt * 5;
}
void process(int count, float** input, float** output)
void dryWet(float dw)
{
if( dw > 1.0 ) dw = 1.0f;
if( dw < 0.0 ) dw = 0.0f;
_dryWet = dw;
}
void process (int count, float** input, float** output)
{
if ( !active )
return;
float fSlow0 = fslider0;
float fSlow1 = expf((fConst2 / fSlow0));
float fSlow2 = faustpower<2>(fSlow1);
@ -210,8 +202,14 @@ class Reverb // : Effect
float fTemp16 = (fRec9 + fRec17);
fRec6[0] = (0 - ((fRec8[1] + (fRec16[1] + (fRec28[1] + (fRec32[1] + (fRec33 + (fRec29 + fTemp16)))))) - (fRec12[1] + (fRec20[1] + (fRec24[1] + (fRec36[1] + (fRec37 + (fRec25 + fTemp15))))))));
fRec7[0] = (0 - ((fRec8[1] + (fRec16[1] + (fRec24[1] + (fRec36[1] + (fRec37 + (fRec25 + fTemp16)))))) - (fRec12[1] + (fRec20[1] + (fRec28[1] + (fRec32[1] + (fRec33 + (fRec29 + fTemp15))))))));
output0[i] = (float)(0.37f * (fRec1[0] + fRec2[0]));
output1[i] = (float)(0.37f * (fRec1[0] - fRec2[0]));
float reverb0 = (float)(0.37f * (fRec1[0] + fRec2[0]));
float reverb1 = (float)(0.37f * (fRec1[0] - fRec2[0]));
output0[i] = (input0[i] * (1-_dryWet)) + (reverb0 * _dryWet );
output1[i] = (input1[i] * (1-_dryWet)) + (reverb1 * _dryWet );
// post processing
fRec7[2] = fRec7[1]; fRec7[1] = fRec7[0];
fRec6[2] = fRec6[1]; fRec6[1] = fRec6[0];
@ -250,7 +248,7 @@ class Reverb // : Effect
}
private:
bool active;
float _dryWet;
float fslider0;
int iConst0;
float fConst1;
@ -352,7 +350,9 @@ class Reverb // : Effect
/// Long nasty function setting initial values
void init(int samplingFreq)
{
active = 0;
// dry by default!
_dryWet = 0.0;
fslider0 = 3.0f;
iConst0 = min(192000, max(1, samplingFreq));
fConst1 = floorf((0.5f + (0.174713f * iConst0)));

View file

@ -18,7 +18,10 @@ const char* StateString[8] = {
GridLogic::GridLogic()
{
for( int i = 0; i < NTRACKS*NSCENES; i++ )
{
state[i] = STATE_EMPTY;
}
}

View file

@ -20,12 +20,8 @@ Jack::Jack() :
logic( new Logic() ),
gridLogic( new GridLogic() ),
controllerUpdater( new ControllerUpdater() ),
clientActive(false)
{
/// open the client
//client = ;
buffers.nframes = jack_get_buffer_size( client );
buffers.samplerate = jack_get_sample_rate( client );
@ -81,9 +77,9 @@ Jack::Jack() :
buffers.audio[Buffers::MASTER_OUT_R] = &masterR[0]; //new float( buffers.nframes );
cout << "master L buffer = " << *buffers.audio[Buffers::MASTER_OUT_L] << endl
<< "master R buffer = " << *buffers.audio[Buffers::MASTER_OUT_R] << endl
<< "difference = " << *buffers.audio[Buffers::MASTER_OUT_R] - *buffers.audio[Buffers::MASTER_OUT_L] << endl;
cout << "master L buffer = " << buffers.audio[Buffers::MASTER_OUT_L] << endl
<< "master R buffer = " << buffers.audio[Buffers::MASTER_OUT_R] << endl
<< "difference = " << buffers.audio[Buffers::MASTER_OUT_R] - buffers.audio[Buffers::MASTER_OUT_L] << endl;
for(int i = 0; i < NTRACKS; i++)
@ -96,6 +92,8 @@ Jack::Jack() :
/// setup FX
reverb = new Reverb( buffers.samplerate );
reverb->dryWet( 0.5 );
reverbMeter = new DBMeter( buffers.samplerate );
masterMeter = new DBMeter( buffers.samplerate );
@ -136,6 +134,7 @@ void Jack::activate()
int Jack::process (jack_nframes_t nframes)
{
/*
/// get buffers
buffers.audio[Buffers::MASTER_INPUT] = (float*)jack_port_get_buffer( masterInput , nframes );
buffers.audio[Buffers::JACK_MASTER_OUT_L] = (float*)jack_port_get_buffer( masterOutputL , nframes );
@ -153,11 +152,12 @@ int Jack::process (jack_nframes_t nframes)
memset( buffers.audio[Buffers::POST_SIDECHAIN] , 0, sizeof(float) * nframes );
jack_midi_clear_buffer( buffers.midi[Buffers::APC_OUTPUT] );
*/
/// do events from the ringbuffer
handleDspEvents();
/*
/// process incoming MIDI
jack_midi_event_t in_event;
@ -181,6 +181,7 @@ int Jack::process (jack_nframes_t nframes)
masterMidiInputIndex++;
}
*/
/// process each track, starting at output and working up signal path
for(unsigned int i = 0; i < NTRACKS; i++)
@ -191,20 +192,13 @@ int Jack::process (jack_nframes_t nframes)
metronome->process( nframes, &buffers );
// process fx
float* buf[] = {
buffers.audio[Buffers::REVERB],
buffers.audio[Buffers::REVERB],
buffers.audio[Buffers::REVERB],
buffers.audio[Buffers::REVERB],
};
/*
if ( reverb->getActive() )
{
reverbMeter->process(nframes, buffers.audio[Buffers::REVERB], buffers.audio[Buffers::REVERB] );
reverb->process( nframes, &buf[0], &buf[2] );
}
*/
@ -221,17 +215,33 @@ int Jack::process (jack_nframes_t nframes)
uiUpdateCounter += nframes;
for(unsigned int i = 0; i < buffers.nframes; i++)
{
float tmp = 0.f;
float master = 0.f;
float rev = 0.f;
for(int t = 0; t < NTRACKS; t++)
{
tmp += buffers.audio[Buffers::TRACK_0 + t][i];
master += buffers.audio[Buffers::TRACK_0 + t][i] * trackOutputs[t]->getMaster();
}
/*
// process fx
float* buf[] = {
buffers.audio[Buffers::REVERB],
buffers.audio[Buffers::REVERB],
&master,
&master,
};
buffers.audio[Buffers::JACK_MASTER_OUT_L][i] = tmp; // + buffers.audio[Buffers::MASTER_OUT_L][i];
buffers.audio[Buffers::JACK_MASTER_OUT_R][i] = tmp; // + buffers.audio[Buffers::MASTER_OUT_R][i];
//if ( reverb->getActive() )
{
reverbMeter->process(nframes, buffers.audio[Buffers::REVERB], buffers.audio[Buffers::REVERB] );
reverb->process( 1, &buf[0], &buf[2] );
}
*/
//buffers.audio[Buffers::JACK_MASTER_OUT_L][i] = master;
//buffers.audio[Buffers::JACK_MASTER_OUT_R][i] = master;
}
/*
@ -253,7 +263,7 @@ int Jack::process (jack_nframes_t nframes)
void Jack::setReverb( bool a, float d, float s )
{
reverb->setActive( a );
//reverb->setActive( a );
reverb->damping( d );
reverb->rt60( d );
}

View file

@ -19,8 +19,8 @@ Looper::Looper(int t) :
uiUpdateCounter(44100/30.f)
{
// pre-zero the internal sample
tmpRecordBuffer = (float*)malloc( sizeof(float) * MAX_BUFFER_SIZE );
memset( tmpRecordBuffer, 0, sizeof(float) * MAX_BUFFER_SIZE );
//tmpRecordBuffer = (float*)malloc( sizeof(float) * MAX_BUFFER_SIZE );
//memset( tmpRecordBuffer, 0, sizeof(float) * MAX_BUFFER_SIZE );
for(int i = 0; i < 10; i++ )
{
@ -33,7 +33,7 @@ Looper::Looper(int t) :
fSamplingFreq = 44100;
IOTA = 0;
tmpBuffer.resize(MAX_BUFFER_SIZE);
//tmpRecordBuffer.resize(MAX_BUFFER_SIZE);
for (int i=0; i<65536; i++)
fVec0[i] = 0;
@ -48,6 +48,7 @@ void Looper::setRecord(int scene, bool r)
{
clips[scene].recording(r);
/*
if ( !r )
{
// set beats based on recording duration
@ -55,6 +56,7 @@ void Looper::setRecord(int scene, bool r)
clips[scene].setBeats( beats );
printf("stop record, has %i beats\n", beats );
}
*/
}
void Looper::play(int scene, bool r)

View file

@ -54,12 +54,13 @@ class Looper : public AudioProcessor, public TimeObserver
int fpb;
float* tmpRecordBuffer;
//vector<float> tmpRecordBuffer;
LooperClip clips[10];
// Pitch Shifting
void pitchShift(int count, float* input, float* output);
vector<float> tmpBuffer;
int IOTA;
float fVec0[65536];
float semitoneShift;