Set tempo with recorded loop in free mode
parent
f41d76b3d7
commit
994ead34ff
|
@ -108,6 +108,7 @@ void AudioEditor::show( AudioBuffer* buf, bool modal )
|
||||||
const auto size = tmp.size();
|
const auto size = tmp.size();
|
||||||
waveform->setData( tmp );
|
waveform->setData( tmp );
|
||||||
|
|
||||||
|
// TODO 4 beats/bar
|
||||||
const int beats[]= {1,2,4,8,16,32,64};
|
const int beats[]= {1,2,4,8,16,32,64};
|
||||||
|
|
||||||
int iBeatOne = -1;
|
int iBeatOne = -1;
|
||||||
|
|
|
@ -152,8 +152,14 @@ void GridLogic::pressed( int track, int scene )
|
||||||
to->recordArm(false);
|
to->recordArm(false);
|
||||||
jack->getControllerUpdater()->recordArm( track, false );
|
jack->getControllerUpdater()->recordArm( track, false );
|
||||||
} else {
|
} else {
|
||||||
if ( s == STATE_EMPTY )
|
if(s == STATE_EMPTY) {
|
||||||
lc->queueRecord();
|
if(!jack->getFreeRecMode()) {
|
||||||
|
lc->queueRecord();
|
||||||
|
} else {
|
||||||
|
cout << "Instant Rec!!\n";
|
||||||
|
lc->setRecording();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( s == STATE_STOPPED ) {
|
if ( s == STATE_STOPPED ) {
|
||||||
// hack, stop all scenes, then launch proper one
|
// hack, stop all scenes, then launch proper one
|
||||||
|
@ -170,8 +176,14 @@ void GridLogic::pressed( int track, int scene )
|
||||||
if ( s == STATE_PLAYING )
|
if ( s == STATE_PLAYING )
|
||||||
lc->queueStop();
|
lc->queueStop();
|
||||||
|
|
||||||
if ( s == STATE_RECORDING )
|
if(s == STATE_RECORDING) {
|
||||||
lc->queuePlay();
|
if(!jack->getFreeRecMode()) {
|
||||||
|
lc->queuePlay();
|
||||||
|
} else {
|
||||||
|
lc->processFreeRec();
|
||||||
|
// lc->setPlaying();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( s == STATE_PLAY_QUEUED )
|
if ( s == STATE_PLAY_QUEUED )
|
||||||
lc->queueStop();
|
lc->queueStop();
|
||||||
|
|
|
@ -217,7 +217,9 @@ void LooperClip::record(int count, float* L, float* R)
|
||||||
}
|
}
|
||||||
|
|
||||||
_loaded = true;
|
_loaded = true;
|
||||||
_recFpb = jack->getTimeManager()->getFpb();
|
if(!jack->getFreeRecMode()) {
|
||||||
|
_recFpb = jack->getTimeManager()->getFpb();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long LooperClip::recordSpaceAvailable()
|
unsigned long LooperClip::recordSpaceAvailable()
|
||||||
|
@ -269,7 +271,7 @@ LooperClip::bar()
|
||||||
if(_playing) {
|
if(_playing) {
|
||||||
_barsPlayed++;
|
_barsPlayed++;
|
||||||
}
|
}
|
||||||
if(_recording) {
|
if(_recording && !jack->getFreeRecMode()) {
|
||||||
_barsRecorded++;
|
_barsRecorded++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -285,7 +287,7 @@ LooperClip::bar()
|
||||||
_barsRecorded == jack->getClipLength() - 1) {
|
_barsRecorded == jack->getClipLength() - 1) {
|
||||||
queuePlay();
|
queuePlay();
|
||||||
}
|
}
|
||||||
if(_recording) {
|
if(_recording && !jack->getFreeRecMode()) {
|
||||||
// FIXME: assumes 4 beats in a bar
|
// FIXME: assumes 4 beats in a bar
|
||||||
_buffer->setBeats(_buffer->getBeats() + 4);
|
_buffer->setBeats(_buffer->getBeats() + 4);
|
||||||
_buffer->setAudioFrames(
|
_buffer->setAudioFrames(
|
||||||
|
@ -298,8 +300,11 @@ LooperClip::beat()
|
||||||
{
|
{
|
||||||
if(_playing) {
|
if(_playing) {
|
||||||
_beatsPlayed++;
|
_beatsPlayed++;
|
||||||
|
cout << "Beat Num: "
|
||||||
|
<< jack->getTimeManager()->getBeatCounter() % 4 << "\n";
|
||||||
}
|
}
|
||||||
if(_playing && _beatsPlayed >= (getBeats() / _playbackSpeed)) {
|
if(_playing && _beatsPlayed >= (getBeats() / _playbackSpeed)) {
|
||||||
|
cout << "Beats Played: " << _beatsPlayed << "\n";
|
||||||
resetPlayHead();
|
resetPlayHead();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -505,6 +510,23 @@ float LooperClip::getPlayhead()
|
||||||
return _playhead;
|
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
|
#ifdef BUILD_TESTS
|
||||||
void LooperClip::setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec )
|
void LooperClip::setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec )
|
||||||
{
|
{
|
||||||
|
|
|
@ -123,6 +123,13 @@ public:
|
||||||
/// reset the play head to zero. Does nothing when recording
|
/// reset the play head to zero. Does nothing when recording
|
||||||
void resetPlayHead();
|
void resetPlayHead();
|
||||||
|
|
||||||
|
/// Change State to Recording
|
||||||
|
void setRecording();
|
||||||
|
/// Change State to Playing
|
||||||
|
void setPlaying();
|
||||||
|
|
||||||
|
void processFreeRec();
|
||||||
|
|
||||||
#ifdef BUILD_TESTS
|
#ifdef BUILD_TESTS
|
||||||
// used only in test cases
|
// used only in test cases
|
||||||
void setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec );
|
void setState( bool load, bool play, bool rec, bool qPlay, bool qStop, bool qRec );
|
||||||
|
@ -165,10 +172,6 @@ private:
|
||||||
/// Get available Space to record
|
/// Get available Space to record
|
||||||
unsigned long recordSpaceAvailable();
|
unsigned long recordSpaceAvailable();
|
||||||
|
|
||||||
/// Change State to Playing
|
|
||||||
void setPlaying();
|
|
||||||
/// Change State to Recording
|
|
||||||
void setRecording();
|
|
||||||
/// Change State to Stopped
|
/// Change State to Stopped
|
||||||
void setStopped();
|
void setStopped();
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,10 @@ public:
|
||||||
/// TRANSPORT_STATE is defined in transport.hxx
|
/// TRANSPORT_STATE is defined in transport.hxx
|
||||||
void setTransportState( TRANSPORT_STATE s );
|
void setTransportState( TRANSPORT_STATE s );
|
||||||
|
|
||||||
|
int getBeatCounter() {
|
||||||
|
return beatCounter;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int samplerate;
|
int samplerate;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue