-Cleaned up Event code, updated GClipSelector and AVTK Clip Selector

main
Harry van Haaren 2013-07-25 02:00:35 +01:00
parent 1121c068ca
commit 953ea89d64
5 changed files with 24 additions and 35 deletions

View File

@ -29,6 +29,12 @@
#include "../gclipselectoraction.hxx"
#include "../worker.hxx"
#include "../looper.hxx"
#include "../audiobuffer.hxx"
#include "../eventhandler.hxx"
namespace Avtk
{
@ -256,6 +262,7 @@ class ClipSelector : public Fl_Button
}
else if ( strcmp(m->label(), "Duration") == 0 )
{
//clips[clipNum].name = "title";
clips[clipNum].state = ClipState::CLIP_QUEUED;
}
@ -268,13 +275,21 @@ class ClipSelector : public Fl_Button
clips[clipNum].state = ClipState::CLIP_RECORDING;
break;
case ClipState::CLIP_LOADED:
clips[clipNum].state = ClipState::CLIP_QUEUED;
{
EventLooperState e = EventLooperState( 0, Looper::STATE_PLAY_QUEUED);
writeToDspRingbuffer( &e );
clips[clipNum].state = ClipState::CLIP_PLAYING;
}
break;
case ClipState::CLIP_QUEUED:
clips[clipNum].state = ClipState::CLIP_PLAYING;
break;
case ClipState::CLIP_PLAYING:
clips[clipNum].state = ClipState::CLIP_STOPPING;
{
EventLooperState e = EventLooperState( 0, Looper::STATE_STOP_QUEUED);
writeToDspRingbuffer( &e );
clips[clipNum].state = ClipState::CLIP_LOADED;
}
break;
case ClipState::CLIP_RECORDING:
clips[clipNum].state = ClipState::CLIP_STOPPING;

View File

@ -113,21 +113,6 @@ class EventLooperLoad : public EventBase
}
};
class EventLooperPlay : public EventBase
{
public:
int type() { return int(LOOPER_PLAY); }
uint32_t size() { return sizeof(EventLooperPlay); }
int track, scene;
EventLooperPlay(int t, int s)
{
track = t;
scene = s;
}
};
class EventMetronomeActive : public EventBase
{
public:

View File

@ -45,12 +45,7 @@ void handleDspEvents()
Looper* l = jack->getLooper( ev.track );
//assert(l);
l->setSample( ev.clip, (AudioBuffer*)ev.audioBuffer );
} break; }
case Event::LOOPER_PLAY: {
if ( availableRead >= sizeof(EventLooperPlay) ) {
EventLooperPlay ev(0,0);
jack_ringbuffer_read( rbToDsp, (char*)&ev, sizeof(EventLooperPlay) );
//jack->setPlayBuffer( ev.track, ev.bufferID );
//jack->setLooperState( ev.track, ev.state );
} break; }
case Event::METRONOME_ACTIVE: {
if ( availableRead >= sizeof(EventMetronomeActive) ) {

View File

@ -40,12 +40,6 @@ void handleGuiEvents()
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventMasterVol) );
//jack->masterVolume = ev.vol;
} break; }
case Event::LOOPER_PLAY: {
if ( availableRead >= sizeof(EventLooperPlay) ) {
EventLooperPlay ev(0,0);
jack_ringbuffer_read( rbToGui, (char*)&ev, sizeof(EventLooperPlay) );
//jack->setPlayBuffer( ev.track, ev.bufferID );
} break; }
case Event::METRONOME_ACTIVE: {
if ( availableRead >= sizeof(EventMetronomeActive) ) {
EventMetronomeActive ev(false);

View File

@ -4,10 +4,10 @@
#include "config.hxx"
#include "worker.hxx"
#include "looper.hxx"
#include "audiobuffer.hxx"
#include "eventhandler.hxx"
static string choose_file()
{
string path;
@ -32,15 +32,15 @@ static string choose_file()
static void clipSelectorLoad(int track)
{
AudioBuffer* ab = Worker::loadSample( choose_file() );
EventLooperLoad e = EventLooperLoad( track, 0, ab );
writeToDspRingbuffer( &e );
AudioBuffer* ab = Worker::loadSample( choose_file() );
EventLooperLoad e = EventLooperLoad( track, 0, ab );
writeToDspRingbuffer( &e );
}
static void clipSelectorPlay(int track, int scene)
{
EventLooperPlay e = EventLooperPlay( track, scene );
writeToDspRingbuffer( &e );
EventLooperState e = EventLooperState(track, Looper::STATE_PLAY_QUEUED);
writeToDspRingbuffer( &e );
}
#endif // LUPPP_G_CLIP_SELECTOR_ACTION_H