From aa8364db20a698d86d7bd1f00689a9155cb3d663 Mon Sep 17 00:00:00 2001 From: Harry van Haaren Date: Sun, 19 May 2013 02:23:18 +0100 Subject: [PATCH] -Fixed timestretching, adjusted APC feedback --- src/controller/apc.cxx | 2 +- src/looper.cxx | 23 +++++++++++++++-------- src/looper.hxx | 4 +++- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/controller/apc.cxx b/src/controller/apc.cxx index 2ce0e61..acdee3a 100644 --- a/src/controller/apc.cxx +++ b/src/controller/apc.cxx @@ -31,7 +31,7 @@ void AkaiAPC::clipSelect(int t, int clip, ClipMode cm) case CLIP_MODE_PLAYING: data[2] = 1; break; case CLIP_MODE_PLAY_QUEUED: data[2] = 2; break; case CLIP_MODE_RECORDING: data[2] = 3; break; - //case CLIP_MODE_RECORDING: data[2] = 4; break; + // case flashing red light?: data[2] = 4; break; case CLIP_MODE_LOADED: data[2] = 5; break; } diff --git a/src/looper.cxx b/src/looper.cxx index 6fe0e5c..06c442c 100644 --- a/src/looper.cxx +++ b/src/looper.cxx @@ -87,6 +87,12 @@ void Looper::updateControllers() { numBeats = 0; jack->getControllerUpdator()->recordArm(track, true); + jack->getControllerUpdator()->clipSelect(track, currentClip, Controller::CLIP_MODE_RECORD_QUEUED); + } + else if (state == STATE_RECORDING ) + { + jack->getControllerUpdator()->recordArm(track, true); + jack->getControllerUpdator()->clipSelect(track, currentClip, Controller::CLIP_MODE_RECORDING); } else { @@ -95,20 +101,21 @@ void Looper::updateControllers() if (state == STATE_PLAY_QUEUED ) { - jack->getControllerUpdator()->clipSelect(track, 0, Controller::CLIP_MODE_PLAY_QUEUED); + jack->getControllerUpdator()->clipSelect(track, currentClip, Controller::CLIP_MODE_PLAY_QUEUED); } - else if ( state == STATE_PLAYING ) + + if ( state == STATE_PLAYING ) { - jack->getControllerUpdator()->clipSelect(track, 0, Controller::CLIP_MODE_PLAYING); + jack->getControllerUpdator()->clipSelect(track, currentClip, Controller::CLIP_MODE_PLAYING); } if (state == STATE_STOP_QUEUED ) { - jack->getControllerUpdator()->clipSelect(track, 0, Controller::CLIP_MODE_LOADED); + jack->getControllerUpdator()->clipSelect(track, currentClip, Controller::CLIP_MODE_LOADED); } else if ( state == STATE_STOPPED ) { - jack->getControllerUpdator()->clipSelect(track, 0, Controller::CLIP_MODE_LOADED); + jack->getControllerUpdator()->clipSelect(track, currentClip, Controller::CLIP_MODE_LOADED); } } @@ -139,11 +146,11 @@ void Looper::process(int nframes, Buffers* buffers) { if ( playPoint < endPoint ) { - tmpBuffer[i] = sample[playPoint] * gain; + tmpBuffer[i] = sample[int(playPoint)];// * gain; } // always update playPoint, even when not playing sound. // it updates the UI of progress - playPoint++; + playPoint += playbackSpeed; } // now pitch-shift the audio in the buffer @@ -218,7 +225,7 @@ void Looper::bar() if ( barTmpState != state ) { - jack->getControllerUpdator()->recordArm( track, state == STATE_RECORDING ? 1 : 0 ); + updateControllers(); } } diff --git a/src/looper.hxx b/src/looper.hxx index e6d93ae..8096108 100644 --- a/src/looper.hxx +++ b/src/looper.hxx @@ -40,6 +40,7 @@ class Looper : public Observer // for notifications private: const int track; State state; + int currentClip; int fpb; float gain; @@ -47,7 +48,8 @@ class Looper : public Observer // for notifications int playedBeats; bool stopRecordOnBar; - int endPoint, playPoint, lastWrittenSampleIndex; + int endPoint, lastWrittenSampleIndex; + float playPoint; float sample[44100*60]; // Pitch Shifting