Commit b389c0b8 authored by Georg Krause's avatar Georg Krause

Inject jack into looperclip instead of using a global var

parent 2d7a34fb
Pipeline #858 failed with stages
in 20 seconds
......@@ -29,14 +29,12 @@
#include "../timemanager.hxx"
#include <math.h>
extern Jack* jack;
LooperClip::LooperClip(int t, int s, AudioBuffer *b) :
LooperClip::LooperClip(int t, int s, AudioBuffer *b, Jack *j) :
Stately(),
track(t),
scene(s),
TimeObserver()
TimeObserver(),
_jack(j)
{
_buffer = b;
init();
......@@ -69,8 +67,8 @@ void LooperClip::init()
resetPlayHead();
jack->getControllerUpdater()->setSceneState(track, scene, getState());
jack->getControllerUpdater()->setTrackSceneProgress(
_jack->getControllerUpdater()->setSceneState(track, scene, getState());
_jack->getControllerUpdater()->setTrackSceneProgress(
track, scene, getProgress());
}
......@@ -182,7 +180,7 @@ void LooperClip::resetPlayHead()
_playbackSpeedChange = false;
}
jack->getControllerUpdater()->setTrackSceneProgress(
_jack->getControllerUpdater()->setTrackSceneProgress(
track, scene, getProgress());
}
}
......@@ -219,8 +217,8 @@ void LooperClip::record(int count, float* L, float* R)
}
_loaded = true;
if(!jack->getFreeRecMode()) {
_recFpb = jack->getTimeManager()->getFpb();
if(!_jack->getFreeRecMode()) {
_recFpb = _jack->getTimeManager()->getFpb();
}
}
......@@ -273,7 +271,7 @@ LooperClip::bar()
if(_playing) {
_barsPlayed++;
}
if(_recording && !jack->getFreeRecMode()) {
if(_recording && !_jack->getFreeRecMode()) {
_barsRecorded++;
}
......@@ -285,15 +283,15 @@ LooperClip::bar()
setRecording();
}
if(_recording && jack->getClipLength() > 0 &&
_barsRecorded == jack->getClipLength() - 1) {
if(_recording && _jack->getClipLength() > 0 &&
_barsRecorded == _jack->getClipLength() - 1) {
queuePlay();
}
if(_recording && !jack->getFreeRecMode()) {
if(_recording && !_jack->getFreeRecMode()) {
// FIXME: assumes 4 beats in a bar
_buffer->setBeats(_buffer->getBeats() + 4);
_buffer->setAudioFrames(
jack->getTimeManager()->getFpb() * _buffer->getBeats());
_jack->getTimeManager()->getFpb() * _buffer->getBeats());
}
}
......@@ -331,7 +329,7 @@ void LooperClip::queuePlay()
_queueStop = false;
_queueRecord = false;
}
jack->getControllerUpdater()->setSceneState(track, scene, getState());
_jack->getControllerUpdater()->setSceneState(track, scene, getState());
}
void LooperClip::queueStop()
......@@ -342,7 +340,7 @@ void LooperClip::queueStop()
_queueStop = true;
_queueRecord = false;
}
jack->getControllerUpdater()->setSceneState(track, scene, getState());
_jack->getControllerUpdater()->setSceneState(track, scene, getState());
}
void LooperClip::queueRecord()
......@@ -353,7 +351,7 @@ void LooperClip::queueRecord()
_queueStop = false;
_queueRecord = true;
}
jack->getControllerUpdater()->setSceneState(track, scene, getState());
_jack->getControllerUpdater()->setSceneState(track, scene, getState());
}
void LooperClip::setRecording()
......@@ -370,7 +368,7 @@ void LooperClip::setRecording()
_buffer->setBeats( 0 );
}
jack->getControllerUpdater()->setSceneState(track, scene, getState());
_jack->getControllerUpdater()->setSceneState(track, scene, getState());
}
void LooperClip::setPlaying()
......@@ -385,7 +383,7 @@ void LooperClip::setPlaying()
} else {
resetQueues();
}
jack->getControllerUpdater()->setSceneState(track, scene, getState());
_jack->getControllerUpdater()->setSceneState(track, scene, getState());
}
void LooperClip::setStopped()
......@@ -399,7 +397,7 @@ void LooperClip::setStopped()
resetPlayHead();
// set "progress" to zero, as we're stopped!
jack->getControllerUpdater()->setSceneState(
_jack->getControllerUpdater()->setSceneState(
track, scene, getState());
}
......@@ -505,7 +503,7 @@ float LooperClip::getPlayhead()
void LooperClip::processFreeRec() {
setStopped();
int max_beats =
(MAX_TEMPO * _recordhead) / (jack->getSamplerate() * 60);
(MAX_TEMPO * _recordhead) / (_jack->getSamplerate() * 60);
// calculate lower multiple of 4
int beats = (int)(max_beats/4)*4; // TODO 4 beats/bar
if (beats < 1)
......@@ -515,11 +513,11 @@ void LooperClip::processFreeRec() {
_recordhead);
_barsRecorded = beats / 4; // TODO 4 beats/bar
_recFpb = _recordhead / beats;
jack->getTimeManager()->setFpb(_recFpb);
jack->getTimeManager()->setTransportState(TRANSPORT_ROLLING);
_jack->getTimeManager()->setFpb(_recFpb);
_jack->getTimeManager()->setTransportState(TRANSPORT_ROLLING);
queuePlay();
jack->setFreeRecMode(false);
_jack->setFreeRecMode(false);
}
#ifdef BUILD_TESTS
......
......@@ -47,7 +47,7 @@ class AudioBuffer;
class LooperClip : public Stately, public TimeObserver
{
public:
LooperClip(int track, int scene, AudioBuffer *b);
LooperClip(int track, int scene, AudioBuffer *b, Jack *j);
/// Set everything up
void init();
......@@ -138,6 +138,8 @@ public:
private:
int track, scene;
Jack *_jack;
/** Loopp needs more than the current state of the clip to accuratly handle
* it. The current state of the grid is kept up-to-date by GridLogic
* abstracting detail away, sending GridLogic::State to Controllers.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment