diff --git a/src/gaudioeditor.cxx b/src/gaudioeditor.cxx index 2b1ad33..d5a475f 100644 --- a/src/gaudioeditor.cxx +++ b/src/gaudioeditor.cxx @@ -108,6 +108,7 @@ void AudioEditor::show( AudioBuffer* buf, bool modal ) const auto size = tmp.size(); waveform->setData( tmp ); + // TODO 4 beats/bar const int beats[]= {1,2,4,8,16,32,64}; int iBeatOne = -1; diff --git a/src/gridlogic.cxx b/src/gridlogic.cxx index a49956b..9e2fec7 100644 --- a/src/gridlogic.cxx +++ b/src/gridlogic.cxx @@ -152,8 +152,14 @@ void GridLogic::pressed( int track, int scene ) to->recordArm(false); jack->getControllerUpdater()->recordArm( track, false ); } else { - if ( s == STATE_EMPTY ) - lc->queueRecord(); + if(s == STATE_EMPTY) { + if(!jack->getFreeRecMode()) { + lc->queueRecord(); + } else { + cout << "Instant Rec!!\n"; + lc->setRecording(); + } + } if ( s == STATE_STOPPED ) { // hack, stop all scenes, then launch proper one @@ -170,8 +176,14 @@ void GridLogic::pressed( int track, int scene ) if ( s == STATE_PLAYING ) lc->queueStop(); - if ( s == STATE_RECORDING ) - lc->queuePlay(); + if(s == STATE_RECORDING) { + if(!jack->getFreeRecMode()) { + lc->queuePlay(); + } else { + lc->processFreeRec(); + // lc->setPlaying(); + } + } if ( s == STATE_PLAY_QUEUED ) lc->queueStop(); diff --git a/src/looperclip.cxx b/src/looperclip.cxx index 2646ba6..2a6e773 100644 --- a/src/looperclip.cxx +++ b/src/looperclip.cxx @@ -217,7 +217,9 @@ void LooperClip::record(int count, float* L, float* R) } _loaded = true; - _recFpb = jack->getTimeManager()->getFpb(); + if(!jack->getFreeRecMode()) { + _recFpb = jack->getTimeManager()->getFpb(); + } } unsigned long LooperClip::recordSpaceAvailable() @@ -269,7 +271,7 @@ LooperClip::bar() if(_playing) { _barsPlayed++; } - if(_recording) { + if(_recording && !jack->getFreeRecMode()) { _barsRecorded++; } @@ -285,7 +287,7 @@ LooperClip::bar() _barsRecorded == jack->getClipLength() - 1) { queuePlay(); } - if(_recording) { + if(_recording && !jack->getFreeRecMode()) { // FIXME: assumes 4 beats in a bar _buffer->setBeats(_buffer->getBeats() + 4); _buffer->setAudioFrames( @@ -298,8 +300,11 @@ LooperClip::beat() { if(_playing) { _beatsPlayed++; + cout << "Beat Num: " + << jack->getTimeManager()->getBeatCounter() % 4 << "\n"; } if(_playing && _beatsPlayed >= (getBeats() / _playbackSpeed)) { + cout << "Beats Played: " << _beatsPlayed << "\n"; resetPlayHead(); } } @@ -505,6 +510,23 @@ float LooperClip::getPlayhead() return _playhead; } +void LooperClip::processFreeRec() { + setStopped(); + int max_beats = + (MAX_TEMPO * _recordhead) / (jack->getSamplerate() * 60); + // calculate lower multiple of 4 + int beats = (int)(max_beats/4)*4; // TODO 4 beats/bar + cout << _recordhead << " " << beats << "\n"; + _buffer->setBeats(beats); + _buffer->setAudioFrames( + _recordhead); + _barsRecorded = beats / 4; // TODO 4 beats/bar + _recFpb = _recordhead / beats; + jack->getTimeManager()->setFpb(_recFpb); + jack->getTimeManager()->setTransportState(TRANSPORT_ROLLING); + queuePlay(); +} + #ifdef BUILD_TESTS void LooperClip::setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec ) { diff --git a/src/looperclip.hxx b/src/looperclip.hxx index 9493f28..e8d51f1 100644 --- a/src/looperclip.hxx +++ b/src/looperclip.hxx @@ -123,6 +123,13 @@ public: /// reset the play head to zero. Does nothing when recording void resetPlayHead(); + /// Change State to Recording + void setRecording(); + /// Change State to Playing + void setPlaying(); + + void processFreeRec(); + #ifdef BUILD_TESTS // used only in test cases void setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec ); @@ -165,10 +172,6 @@ private: /// Get available Space to record unsigned long recordSpaceAvailable(); - /// Change State to Playing - void setPlaying(); - /// Change State to Recording - void setRecording(); /// Change State to Stopped void setStopped(); diff --git a/src/timemanager.hxx b/src/timemanager.hxx index 0187a59..b87db39 100644 --- a/src/timemanager.hxx +++ b/src/timemanager.hxx @@ -59,6 +59,10 @@ public: /// TRANSPORT_STATE is defined in transport.hxx void setTransportState( TRANSPORT_STATE s ); + int getBeatCounter() { + return beatCounter; + } + private: int samplerate;