diff options
author | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-04-20 22:06:08 +0200 |
---|---|---|
committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2013-04-20 22:06:08 +0200 |
commit | 3f33469b7237240a2be708ca29087773a4b7e228 (patch) | |
tree | 9ee0a87039d8c45e746c5162ef70de90bafb8f49 /src/drumgizmo.cc | |
parent | c9200c25e02b2ab5c1fc4461a4621d109e798350 (diff) |
Added messages for 'get engine seetings' and 'set engine setting', thereby removing the last 'direct call' in the engine code from the gui code.
Diffstat (limited to 'src/drumgizmo.cc')
-rw-r--r-- | src/drumgizmo.cc | 60 |
1 files changed, 34 insertions, 26 deletions
diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 77d9b89..49ea787 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -38,6 +38,7 @@ #include "drumkitparser.h" #include "audioinputenginemidi.h" +#include "configuration.h" DrumGizmo::DrumGizmo(AudioOutputEngine *o, AudioInputEngine *i) : loader(this), oe(o), ie(i) @@ -179,8 +180,6 @@ bool DrumGizmo::init(bool preload) void DrumGizmo::handleEngineEvents() { - // DEBUG(msg, "handle?"); - Message *msg = receiveEngineMessage(); if(msg) { DEBUG(msg, "got message."); @@ -202,36 +201,47 @@ void DrumGizmo::handleEngineEvents() aim->loadMidiMap(m->midimapfile, kit.instruments); } break; + case Message::EngineSettingsMessage: + { + DEBUG(msg, "got EngineSettingsMessage message."); + EngineSettingsMessage *msg = new EngineSettingsMessage(); + msg->midimapfile = midimapfile; + msg->midimap_loaded = true; + msg->drumkitfile = drumkitfile(); + msg->drumkit_loaded = true; + msg->enable_velocity_modifier = Conf::enable_velocity_modifier; + msg->velocity_modifier_falloff = Conf::velocity_modifier_falloff; + msg->velocity_modifier_weight = Conf::velocity_modifier_weight; + msg->enable_velocity_randomiser = Conf::enable_velocity_randomiser; + msg->velocity_randomiser_weight = Conf::velocity_randomiser_weight; + sendGUIMessage(msg); + } + break; + case Message::ChangeSettingMessage: + { + ChangeSettingMessage *ch = (ChangeSettingMessage*)msg; + switch(ch->name) { + case ChangeSettingMessage::enable_velocity_modifier: + Conf::enable_velocity_modifier = ch->value; + break; + case ChangeSettingMessage::velocity_modifier_weight: + Conf::velocity_modifier_weight = ch->value; + break; + case ChangeSettingMessage::velocity_modifier_falloff: + Conf::velocity_modifier_falloff = ch->value; + break; + } + } + break; default: break; } - // delete msg; + delete msg; } } bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples) { -#if 0 - DEBUG(drumgizmo, "loader.isDone() = %d", (int)loader.isDone()); - if(!loader.isDone()) { - /* - // return false; - ie->pre(); - oe->pre(nsamples); - size_t nev; - event_t *evs = ie->run(pos, nsamples, &nev); - free(evs); - // memset(samples, 0, nsamples); - for(size_t i = 0; i < nsamples / 2; i++) samples[i] = sin(pos + i); - for(size_t c = 0; c < 16; c++) oe->run(c, samples, nsamples); - ie->post(); - oe->post(nsamples); - pos += nsamples; - */ - return true; - } -#endif - // Handle engine messages, at most one in each iteration: handleEngineEvents(); @@ -435,8 +445,6 @@ void DrumGizmo::stop() // engine.stop(); } -#include "configuration.h" - std::string float2str(float a) { char buf[256]; |