Unify of single clips and the hole session

This introduces a new Event, called EventSaveClip which starts saving of a single clip. On the other side, the confusing and not anymore needed no_dealloc option in the
EventStateSaveBuffer was removed. I think this is now easier to understand.

Possible problem: The differentiation of the saving location is done by checking if gui->saveBufferPath is set, feedback here is welcome.
main
Georg Krause 2019-03-19 13:43:20 +01:00
parent 7961658933
commit 0b5b7bf199
4 changed files with 31 additions and 23 deletions

View File

@ -65,7 +65,8 @@ enum EVENT_TYPE {
MASTER_RETURN,
RECORD,
SESSION_SAVE, // save action
SESSION_SAVE, // save hole session
CLIP_SAVE, // save single clip
STATE_RESET, // reset all state
STATE_SAVE_FINISH,// save action finished, flush metadata to disk
STATE_SAVE_BUFFER,// save an individual AudioBuffer* to disk
@ -550,6 +551,25 @@ public:
EventSessionSave() {}
};
class EventClipSave : public EventBase
{
public:
int type()
{
return int(CLIP_SAVE);
}
uint32_t size()
{
return sizeof(EventClipSave);
}
int track;
int scene;
EventClipSave(): track(0), scene(0) {};
EventClipSave(int t, int s): track(t), scene(s) {}
};
class EventStateReset : public EventBase
{
public:
@ -1034,9 +1054,8 @@ public:
int scene;
// pointer to the AudioBuffer to be saved
AudioBuffer* ab;
bool no_dealloc;
EventStateSaveBuffer(): track(0), scene(0), ab(0), no_dealloc(0) {}
EventStateSaveBuffer(): track(0), scene(0), ab(0) {}
EventStateSaveBuffer(int t, int s, AudioBuffer* a): track(t), scene(s), ab(a) {}
};

View File

@ -107,19 +107,14 @@ void handleDspEvents()
}
break;
}
case Event::STATE_SAVE_BUFFER: {
if ( availableRead >= sizeof(EventStateReset) ) {
EventStateSaveBuffer ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventStateSaveBuffer) );
case Event::CLIP_SAVE: {
if ( availableRead >= sizeof(EventClipSave) ) {
EventClipSave ev;
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventClipSave) );
printf("jack got save buffer in %d, %d\n", ev.track, ev.scene);
LooperClip* lc = jack->getLooper(ev.track)->getClip(ev.scene);
if(!lc) break;
EventStateSaveBuffer e;
e.track = ev.track;
e.scene = ev.scene;
e.ab = lc->getAudioBuffer();
e.no_dealloc = 1;
writeToGuiRingbuffer( &e );
lc->save();
}
break;
}

View File

@ -214,14 +214,10 @@ void handleGuiEvents()
#ifdef DEBUG_SAVE
cout << "EventSaveBuffer: " << ev.track << " " << ev.scene << " " << ev.ab->getID() << endl;
#endif
gui->getDiskWriter()->writeAudioBuffer( ev.track, ev.scene, ev.ab );
// de allocate the AudioBuffer only if reqested
if(!ev.no_dealloc) {
if(gui->saveBufferPath.empty()) {
gui->getDiskWriter()->writeAudioBuffer( ev.track, ev.scene, ev.ab );
delete ev.ab;
} else {
gui->getDiskWriter()->writeAudioBuffer(ev.track, ev.scene, ev.ab,
gui->saveBufferPath.c_str());
gui->getDiskWriter()->writeAudioBuffer(ev.track, ev.scene, ev.ab, gui->saveBufferPath.c_str());
gui->saveBufferPath = "";
}

View File

@ -247,10 +247,8 @@ string Gui::getProjectsDir()
void Gui::selectSaveSample( int track, int scene )
{
EventStateSaveBuffer e;
e.track = track,
e.scene = scene,
writeToDspRingbuffer( &e );
EventClipSave e = EventClipSave(track, scene);
writeToDspRingbuffer( &e );
}
char *