zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 7a2441c42c3f34b81fdeb9d4b4869cd62e377f92
parent a734ee27ea7b1236cfabbf9e112fee784fce8365
Author: fundamental <[email protected]>
Date:   Sat,  8 May 2010 11:20:51 -0400

NioUI: cleanup and inprovements

- Removing dead code
- Now after starting the window, it shows the right drivers

Diffstat:
Msrc/UI/NioUI.cpp | 131++++++++-----------------------------------------------------------------------
Msrc/UI/NioUI.h | 21---------------------
2 files changed, 12 insertions(+), 140 deletions(-)

diff --git a/src/UI/NioUI.cpp b/src/UI/NioUI.cpp @@ -26,8 +26,6 @@ NioUI::NioUI() intro->buffer(buff); buff->text("Thanks For Testing Out the New" " Input/Output system. " - "To get started, you may want to play with " - "the open output, which is highted in green." "Beware of bugs that may exist and" " enjoy the new system."); intro->wrap_mode(4, 40); @@ -43,6 +41,8 @@ NioUI::NioUI() } settings->end(); + int audioval = 0; + int midival = 0; for(list<Engine *>::iterator itr = sysEngine->engines.begin(); itr != sysEngine->engines.end(); ++itr) { Engine *eng = *itr; @@ -50,20 +50,17 @@ NioUI::NioUI() midi->add(eng->name.c_str()); if(dynamic_cast<AudioOut *>(eng)) audio->add(eng->name.c_str()); + if(eng->name == sysOut->getSink()) { + audioval = audio->size() - 2; + cout << "Setting audio value to " << audio->size() << endl; + } + if(eng->name == sysIn->getSource()) { + midival = midi->size() - 2; + cout << "Setting midi value to " << midi->size() << endl; + } } - - - //for(list<Engine *>::iterator itr = sysEngine->engines.begin(); - // itr != sysEngine->engines.end(); ++itr) { - // bool midi = dynamic_cast<MidiIn *>(*itr); - // bool audio = dynamic_cast<AudioOut *>(*itr); - // tabs.push_back(new NioTab((*itr)->name, midi, audio)); - //} - - //add tabs - //for(list<NioTab *>::iterator itr = tabs.begin(); - // itr != tabs.end(); ++itr) - // wintabs->add(*itr); + audio->value(audioval); + midi->value(midival); } wintabs->end(); @@ -73,10 +70,6 @@ NioUI::NioUI() void NioUI::refresh() { - //for(list<NioTab *>::iterator itr = tabs.begin(); - // itr != tabs.end(); ++itr) - // (*itr)->refresh(); - } void NioUI::midiCallback(Fl_Widget *c) @@ -90,104 +83,4 @@ void NioUI::audioCallback(Fl_Widget *c) bool good = sysOut->setSink(static_cast<Fl_Choice *>(c)->text()); static_cast<Fl_Choice *>(c)->textcolor(fl_rgb_color(255*!good,0,0)); } -#if 0 -//this is a repetitve block of code -//perhaps something on the Engine's side should be refactored -void NioTab::nioToggle(Fl_Widget *wid, void *arg) -{ - Fl_Button *w = static_cast<Fl_Button *>(wid); - NioTab *p = static_cast<NioTab *>(arg); - bool val = w->value(); - - Engine *eng = sysEngine->getEng(p->name); - if(eng) { - if(val) - eng->Start(); - else - eng->Stop(); - } - p->refresh(); -} - -void NioTab::audioToggle(Fl_Widget *wid, void *arg) -{ - Fl_Button *w = static_cast<Fl_Button *>(wid); - NioTab *p = static_cast<NioTab *>(arg); - bool val = w->value(); - - AudioOut *out = sysOut->getOut(p->name); - out->setAudioEn(val); - p->refresh(); -} - -void NioTab::midiToggle(Fl_Widget *wid, void *arg) -{ - Fl_Button *w = static_cast<Fl_Button *>(wid); - NioTab *p = static_cast<NioTab *>(arg); - bool val = w->value(); - - MidiIn *in = dynamic_cast<MidiIn *>(sysEngine->getEng(p->name)); - in->setMidiEn(val); - p->refresh(); -} - -void NioTab::nioBuffer(Fl_Widget *wid, void *arg) -{ - Fl_Spinner *w = static_cast<Fl_Spinner *>(wid); - char *str = static_cast<char *>(arg); - int val = (int) w->value(); - - cout << "Chaning Buffer Size For " << str << endl; - AudioOut *out = sysOut->getOut(str); - if(out) { - cout << "Chaning Buffer Size To " << val << endl; - out->bufferingSize(val); - } -} - -NioTab::NioTab(string name, bool _midi, bool _audio) - :Fl_Group(10, 40, 400, 400-35, strdup(name.c_str())), - enable(20, 30, 100, 25, "Enable"), - audio(NULL), midi(NULL), buffer(NULL), - name(name) -{ - enable.callback(nioToggle, (void *)this); - if(_audio) { - buffer = new Fl_Spinner(70, 60, 50, 25, "Buffer:");//in SOUND_BUFFER_SIZE units - buffer->callback(nioBuffer, (void *)name.c_str()); - //this is a COMPLETELY arbitrary max - //I just assume that users do not want an overly long buffer - buffer->range(1, 100); - buffer->type(FL_INT_INPUT); - audio = new Fl_Light_Button(20, 80, 100, 25, "Audio"); - audio->callback(audioToggle, (void *)this); - } - if(_midi) { - midi = new Fl_Light_Button(20, 100, 100, 25, "Midi"); - midi->callback(midiToggle, (void *)this); - } - - end(); -} - -void NioTab::refresh() -{ - //get engine - Engine *eng = sysEngine->getEng(name); - MidiIn *midiIn = dynamic_cast<MidiIn *>(eng); - AudioOut *audioOut = dynamic_cast<AudioOut *>(eng); - if(midi) - midi->value(midiIn->getMidiEn()); - if(audio) - audio->value(audioOut->getAudioEn()); - - bool state = eng->isRunning(); - enable.value(state); - buffer->value(sysOut->getOut(name)->bufferingSize()); - - - this->labelcolor(fl_rgb_color(0,255*state,0)); - this->redraw(); -} -#endif diff --git a/src/UI/NioUI.h b/src/UI/NioUI.h @@ -11,27 +11,6 @@ #include <list> #include <string> -//removed from code for now -#if 0 -struct NioTab : public Fl_Group -{ - NioTab(std::string name, bool _midi, bool _audio); - - void refresh(); - static void nioToggle(Fl_Widget *w, void *arg); - static void audioToggle(Fl_Widget *w, void *arg); - static void midiToggle(Fl_Widget *w, void *arg); - static void nioBuffer(Fl_Widget *w, void *arg); - - Fl_Light_Button enable; - Fl_Light_Button *midi; - Fl_Light_Button *audio; - Fl_Spinner *buffer; - const std::string name; -}; -#endif - - class NioUI : public Fl_Window { public: