-Updated buffer management, implementing _trackBuffer in TrackOutput

This commit is contained in:
Harry van Haaren 2013-07-31 02:27:27 +01:00
parent cf359f044d
commit 5a4d0f84a1
6 changed files with 35 additions and 79 deletions

View file

@ -24,29 +24,29 @@ class Buffers
enum BUFFER {
// AUDIO
MASTER_INPUT = 0,
MASTER_OUTPUT,
JACK_MASTER_OUTPUT,
MASTER_OUTPUT = 1,
JACK_MASTER_OUTPUT = 2,
REVERB,
SIDECHAIN,
POST_SIDECHAIN,
REVERB = 3,
SIDECHAIN = 4,
POST_SIDECHAIN = 5,
// MIDI
MASTER_MIDI_INPUT,
APC_INPUT,
APC_OUTPUT,
MASTER_MIDI_INPUT = 6,
APC_INPUT = 7,
APC_OUTPUT = 8,
// track buffers: they are the "working" buffers per track:
// the end result is mixed into the master output, while each
// stage along the way the amplitude etc can be analysed
TRACK_0,
TRACK_1,
TRACK_2,
TRACK_3,
TRACK_4,
TRACK_5,
TRACK_6,
TRACK_7,
TRACK_0 = 9,
TRACK_1 = 10,
TRACK_2 = 11,
TRACK_3 = 12,
TRACK_4 = 13,
TRACK_5 = 14,
TRACK_6 = 15,
TRACK_7 = 16,
};
// Jack details

View file

@ -63,7 +63,7 @@ void handleGuiEvents()
if ( availableRead >= sizeof(EventLooperProgress) ) {
EventLooperProgress ev;
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventLooperProgress) );
printf("progress on %i, %f\n", ev.track, ev.progress);
//printf("progress on %i, %f\n", ev.track, ev.progress);
gui->getTrack(ev.track)->radial.value(ev.progress);
//jack->setLooperLoopLength( ev.track, ev.scale );
} break; }

View file

@ -2,63 +2,3 @@
#include "gtrack.hxx"
#include "gui.hxx"
extern Gui* gui;
extern void luppp_tooltip(std::string s);
void gtrack_button_callback(Fl_Widget *w, void *data)
{
/*
int track = 0;
if ( data )
track = *(int*)data;
//cout << "Button " << *(int*)data << " " << w->label() << " clicked" << endl;
if ( strcmp( w->label() , "Rec" ) == 0 )
{
EventLooperState e = EventLooperState(track,0,Looper::STATE_RECORD_QUEUED);
writeToDspRingbuffer( &e );
//w->tooltip( "Rec Clicked" );
gui->setTooltip("Rec clicked");
}
else if ( strcmp( w->label() , "Play" ) == 0 )
{
EventLooperState e = EventLooperState(track,0,Looper::STATE_PLAY_QUEUED);
writeToDspRingbuffer( &e );
//w->tooltip( "Play clicked" );
gui->setTooltip("Play clicked");
}
else if ( strcmp( w->label() , "Stop" ) == 0 )
{
EventLooperState e = EventLooperState(track,0,Looper::STATE_STOP_QUEUED);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label() , "+" ) == 0 )
{
EventLooperLoopLength e = EventLooperLoopLength(track, 2);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label() , "-" ) == 0 )
{
EventLooperLoopLength e = EventLooperLoopLength(track, 0.5);
writeToDspRingbuffer( &e );
}
else if ( strcmp( w->label() , "Load" ) == 0 )
{
AudioBuffer* ab = Worker::loadSample( choose_file() );
EventLooperLoad e = EventLooperLoad( track, 0 , ab );
cout << "writing event ab ptr = " << ab << endl;
writeToDspRingbuffer( &e );
cout << "writing event done" << endl;
}
else if ( strcmp( w->label() , "Vol" ) == 0 )
{
}
else
{
cout << __FILE__ << __LINE__ << " Error: unknown command string" << endl;
}
*/
}

View file

@ -51,7 +51,6 @@ class GTrack : public Fl_Group
volume(x+63, y +427, 36, 162, ""),
side(x+22, y +440 + 0, 30, 30, "S-C"),
post(x+22, y +440 + 50, 30, 30, "P-S"),
rev (x+22, y +440 +100, 30, 30, "Rev")

View file

@ -120,11 +120,20 @@ int Jack::process (jack_nframes_t nframes)
buffers.midi [Buffers::APC_OUTPUT] = (void*) jack_port_get_buffer( apcMidiOutput , nframes );
// pre-zero output buffers
for(uint i = 0; i < nframes; i++)
{
buffers.audio[Buffers::MASTER_OUTPUT] [i] = 0.f;
buffers.audio[Buffers::REVERB] [i] = 0.f;
buffers.audio[Buffers::SIDECHAIN] [i] = 0.f;
buffers.audio[Buffers::POST_SIDECHAIN] [i] = 0.f;
}
/*
memset( buffers.audio[Buffers::MASTER_OUTPUT] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::MASTER_OUTPUT] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::REVERB] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::SIDECHAIN] , 0, sizeof(float) * nframes );
memset( buffers.audio[Buffers::POST_SIDECHAIN] , 0, sizeof(float) * nframes );
*/
jack_midi_clear_buffer( buffers.midi[Buffers::APC_OUTPUT] );

View file

@ -20,6 +20,8 @@ class TrackOutput : public AudioProcessor
{
printf("trackOutput ID: %i\n", track);
_trackBuffer = new float( 1024 );
// UI update
uiUpdateConstant = 44100 / 30;
uiUpdateCounter = 44100 / 30;
@ -33,7 +35,6 @@ class TrackOutput : public AudioProcessor
/// set main mix, 0-1
void setMaster(float value)
{
printf("TrackOutput: master vol : %f\n", value);
_toMaster = value;
}
/// set sidechain mix, 0-1
@ -91,10 +92,17 @@ class TrackOutput : public AudioProcessor
trackBuf++;
}
}
~TrackOutput()
{
delete _trackBuffer;
}
private:
int track;
float* _trackBuffer;
float _toMaster;
float _toReverb;