From 61bbc63ea511bedabd4eb7b0b775fb936856b9ba Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Thu, 25 Jul 2013 19:21:57 +0100 Subject: [PATCH] -Track buffers implemented, and copied into master output --- src/jack.cxx | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/jack.cxx b/src/jack.cxx index 3969071..ea159a6 100644 --- a/src/jack.cxx +++ b/src/jack.cxx @@ -96,6 +96,10 @@ int Jack::process (jack_nframes_t nframes) // pre-zero output buffers memset( buffers.audio[Buffers::MASTER_OUTPUT], 0, sizeof(float) * nframes ); + + for(int i = 0; i < NTRACKS; i++) + memset( buffers.audio[Buffers::TRACK_0 + i], 0, sizeof(float) * nframes ); + jack_midi_clear_buffer( buffers.midi[Buffers::APC_OUTPUT] ); @@ -125,9 +129,23 @@ int Jack::process (jack_nframes_t nframes) masterMidiInputIndex++; } + // process each track for(uint i = 0; i < loopers.size(); i++) loopers.at(i)->process( nframes, &buffers ); + // mixdown tracks into master output buffer + float* output = buffers.audio[Buffers::MASTER_OUTPUT]; + for(int i = 0; i < nframes; i++) + { + float tmp = 0.f; + + for(int n = 0; n < NTRACKS; n++) + { + tmp += buffers.audio[Buffers::TRACK_0 + n][i]; + } + *output++ = tmp; + } + metronome.process( nframes, &buffers ); return false;