From abe157edbae109b9436e388fbdb0a1d2e65ebb3c Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 26 Apr 2013 14:43:04 +0200 Subject: Move setValue to past connect in order to make initial value propagate to the engine. --- dgedit/mainwindow.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc index ada7f95..7d060cb 100644 --- a/dgedit/mainwindow.cc +++ b/dgedit/mainwindow.cc @@ -152,32 +152,32 @@ MainWindow::MainWindow() configs->addWidget(new QLabel("Attack length:")); QSlider *slider = new QSlider(Qt::Horizontal); slider->setRange(10, 1000); - slider->setValue(666); connect(slider, SIGNAL(sliderMoved(int)), sorter, SLOT(setAttackLength(int))); + slider->setValue(666); configs->addWidget(slider); configs->addWidget(new QLabel("Falloff:")); QSlider *slider2 = new QSlider(Qt::Horizontal); slider2->setRange(1, 10000); - slider2->setValue(666); connect(slider2, SIGNAL(sliderMoved(int)), selections, SLOT(noiseFloorChanged(int))); + slider2->setValue(666); configs->addWidget(slider2); configs->addWidget(new QLabel("Fadelength:")); QSlider *slider3 = new QSlider(Qt::Horizontal); slider3->setRange(1, 2000); - slider3->setValue(666); connect(slider3, SIGNAL(sliderMoved(int)), selections, SLOT(fadeoutChanged(int))); + slider3->setValue(666); configs->addWidget(slider3); configs->addWidget(new QLabel("Player volume:")); QSlider *slider4 = new QSlider(Qt::Horizontal); slider4->setRange(0, 1000000); - slider4->setValue(100000); connect(slider4, SIGNAL(sliderMoved(int)), listen, SLOT(setVolume(int))); + slider4->setValue(100000); configs->addWidget(slider4); configs->addWidget(new QLabel("Prefix:")); -- cgit v1.2.3 From 605dee007b10fbca1a03b0a2b604b4e999ad7c0f Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 26 Apr 2013 14:49:30 +0200 Subject: Don't set value if the value is the same (and save a repaintEvent) --- plugingui/scrollbar.cc | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/plugingui/scrollbar.cc b/plugingui/scrollbar.cc index 3fc3ac8..d48da1a 100644 --- a/plugingui/scrollbar.cc +++ b/plugingui/scrollbar.cc @@ -141,7 +141,9 @@ void GUI::ScrollBar::mouseMoveEvent(MouseMoveEvent *e) int h = height() - 2 * width() - 3; delta /= (float)h / (float)max; - setValue(value_offset - delta); + + int newval = value_offset - delta; + if(newval != value()) setValue(newval); } void GUI::ScrollBar::buttonEvent(ButtonEvent *e) -- cgit v1.2.3 From 813d802443679a6f937a13680bc0ec3fb11a96b6 Mon Sep 17 00:00:00 2001 From: Bent Bisballe Nyeng Date: Fri, 26 Apr 2013 15:18:22 +0200 Subject: Add MidimapLoadStatus Message. --- plugingui/plugingui.cc | 20 ++++++++++++++++++++ src/audioinputenginemidi.cc | 26 +++++++++++++++++++++++--- src/audioinputenginemidi.h | 6 +++++- src/drumgizmo.cc | 12 +++++++++--- src/message.h | 7 +++++++ 5 files changed, 64 insertions(+), 7 deletions(-) diff --git a/plugingui/plugingui.cc b/plugingui/plugingui.cc index 864f4d8..8e886ee 100644 --- a/plugingui/plugingui.cc +++ b/plugingui/plugingui.cc @@ -250,11 +250,31 @@ void PluginGUI::thread_main() } } break; + case Message::LoadStatusMidimap: + { + LoadStatusMessageMidimap *ls = (LoadStatusMessageMidimap*)msg; + DEBUG(gui, "Midimap status (%d)\n", + ls->success); + progress2->setProgress(1); + if(ls->success) { + progress2->setState(GUI::ProgressBar::green); + } else { + progress2->setState(GUI::ProgressBar::red); + } + } + break; case Message::EngineSettingsMessage: { EngineSettingsMessage *settings = (EngineSettingsMessage *)msg; lineedit->setText(settings->drumkitfile); lineedit2->setText(settings->midimapfile); + if(settings->midimap_loaded) { + progress2->setProgress(1); + progress2->setState(GUI::ProgressBar::green); + } else { + progress2->setProgress(0); + progress2->setState(GUI::ProgressBar::blue); + } check->setChecked(settings->enable_velocity_modifier); knob->setValue(settings->velocity_modifier_weight); knob2->setValue(settings->velocity_modifier_falloff); diff --git a/src/audioinputenginemidi.cc b/src/audioinputenginemidi.cc index 00aa518..44e8606 100644 --- a/src/audioinputenginemidi.cc +++ b/src/audioinputenginemidi.cc @@ -30,13 +30,25 @@ #include -void AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments) +AudioInputEngineMidi::AudioInputEngineMidi() { + is_valid = false; +} + +bool AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments) +{ + file = ""; + is_valid = false; + DEBUG(mmap, "loadMidiMap(%s, i.size() == %d)\n", f.c_str(), instruments.size()); - if(f == "") return; + + if(f == "") return false; + MidiMapParser p(f); - if(p.parse()) {/*return false;*/} + if(p.parse()) { + return false; + } mmap.clear(); mmap.midimap = p.midimap; @@ -46,6 +58,9 @@ void AudioInputEngineMidi::loadMidiMap(std::string f, Instruments &instruments) } file = f; + is_valid = true; + + return true; } std::string AudioInputEngineMidi::midimapFile() @@ -53,6 +68,11 @@ std::string AudioInputEngineMidi::midimapFile() return file; } +bool AudioInputEngineMidi::isValid() +{ + return is_valid; +} + #ifdef TEST_AUDIOINPUTENGINEMIDI //Additional dependency files //deps: diff --git a/src/audioinputenginemidi.h b/src/audioinputenginemidi.h index 0f63f8a..b01fef0 100644 --- a/src/audioinputenginemidi.h +++ b/src/audioinputenginemidi.h @@ -36,6 +36,7 @@ class AudioInputEngineMidi : public AudioInputEngine { public: + AudioInputEngineMidi(); virtual ~AudioInputEngineMidi() {} bool isMidiEngine() { return true; } @@ -51,13 +52,16 @@ public: virtual event_t *run(size_t pos, size_t len, size_t *nevents) = 0; virtual void post() = 0; - void loadMidiMap(std::string file, Instruments &i); + bool loadMidiMap(std::string file, Instruments &i); std::string midimapFile(); + bool isValid(); + protected: MidiMapper mmap; std::string file; + bool is_valid; }; #endif/*__DRUMGIZMO_AUDIOINPUTENGINEMIDI_H__*/ diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 8ba45f5..943e852 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -201,22 +201,28 @@ void DrumGizmo::handleEngineEvents() { AudioInputEngineMidi *aim = (AudioInputEngineMidi*)ie; LoadMidimapMessage *m = (LoadMidimapMessage*)msg; - aim->loadMidiMap(m->midimapfile, kit.instruments); + bool ret = aim->loadMidiMap(m->midimapfile, kit.instruments); + + LoadStatusMessageMidimap *ls = new LoadStatusMessageMidimap(); + ls->success = ret; + sendGUIMessage(ls); } break; case Message::EngineSettingsMessage: { DEBUG(msg, "got EngineSettingsMessage message."); - + bool mmap_loaded = false; std::string mmapfile; if(ie->isMidiEngine()) { AudioInputEngineMidi *aim = (AudioInputEngineMidi*)ie; mmapfile = aim->midimapFile(); + mmap_loaded = aim->isValid(); + } EngineSettingsMessage *msg = new EngineSettingsMessage(); msg->midimapfile = mmapfile; - msg->midimap_loaded = true; + msg->midimap_loaded = mmap_loaded; msg->drumkitfile = drumkitfile(); msg->drumkit_loaded = true; msg->enable_velocity_modifier = Conf::enable_velocity_modifier; diff --git a/src/message.h b/src/message.h index 9bf2f12..4ce65ef 100644 --- a/src/message.h +++ b/src/message.h @@ -32,6 +32,7 @@ public: typedef enum { // Engine -> GUI Messages: LoadStatus, // Signal GUI the current load status. + LoadStatusMidimap, // Signal GUI the current load status of the midimap. // GUI -> Engine, Engine -> Engine Messages: LoadDrumKit, // Signal engine to load drumkit. @@ -52,6 +53,12 @@ public: std::string current_file; }; +class LoadStatusMessageMidimap : public Message { +public: + type_t type() { return Message::LoadStatusMidimap; } + bool success; +}; + class LoadDrumKitMessage : public Message { public: type_t type() { return Message::LoadDrumKit; } -- cgit v1.2.3