From 0745a1f60d8945933c48e87aed366cfaa0858357 Mon Sep 17 00:00:00 2001 From: Mark Oates Date: Tue, 14 Apr 2015 11:35:01 -0400 Subject: [PATCH] improved mixer and patches implementation --- src/main.cpp | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 28a42995..2b5fe1da 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,10 +23,29 @@ class GUIMixer : public FGUIFramedWindow public: int channel_num; int patch; + Channel(int channel_num, int patch) + : channel_num(channel_num) + , patch(patch) + {} }; private: + class GUIPatchTextInput : public FGUITextInput + { + public: + int channel_num; + GUIPatchTextInput(FGUIParent *parent, int channel_num, float x, float y) + : FGUITextInput(parent, af::fonts["DroidSans.ttf 16"], "0", x, y, 50, 30) + , channel_num(channel_num) + {} + void on_change() override + { + GUIMixer *mixer = static_cast(parent); + mixer->channels[channel_num].patch = atoi(get_text().c_str()); + } + }; + std::vector channels; public: GUIMixer(FGUIParent *parent, float x_, float y_, int num_channels=8) @@ -35,8 +54,8 @@ class GUIMixer : public FGUIFramedWindow { this->set_title("Mixer & Channel Settings"); - // create 16 channels - channels.resize(num_channels); + // create the channels + for (unsigned i=0; iplace.align = vec2d(1, 1); - FGUITextInput *text_input = new FGUITextInput(this, af::fonts["DroidSans.ttf 16"], "0", x, y, 50, 30); + FGUITextInput *text_input = new GUIPatchTextInput(this, c, x, y); text_input->place.align = vec2d(0, 1); text_input->attr.set("select_all_on_focus", "true"); @@ -59,6 +78,11 @@ class GUIMixer : public FGUIFramedWindow if (channels.empty() || channel_num < 0 || channel_num >= channels.size()) return NULL; return &channels[channel_num]; } + int get_patch_num(int channel_num) + { + if (channels.empty() || channel_num < 0 || channel_num >= channels.size()) return 0; + return channels[channel_num].patch; + } }; @@ -151,7 +175,7 @@ class Project : public FGUIScreen simple_notification_screen->spawn_notification("Press F1 for help"); - create_help_window(); + // create_help_window(); } void create_help_window() { @@ -205,6 +229,12 @@ class Project : public FGUIScreen break; case ALLEGRO_KEY_SPACE: { + // send the patches before play + PlaybackDeviceInterface *device = score_editor->playback_control.playback_device; + for (unsigned i=0; imeasure_grid.get_num_staves(); i++) + { + device->patch_change(i, gui_mixer->get_patch_num(i)); + } // toggle playback score_editor->playback_control.toggle_playback(); }