zynaddsubfx

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

commit 4ba256a4ce733e9613d48ec25c95cc68f23d39e5
parent 2ae144403154e23648d49e4cffaf277837217cd5
Author: fundamental <mark.d.mccurry@gmail.com>
Date:   Sun, 27 Dec 2009 18:26:45 -0500

Nio: First stage Input test (getting alsa midi input)

- Adding a thin wrapper around Master (InMgr)
- Testing with Input/ALSAMidiIn
(so far it works, but it is ugly)

Diffstat:
Msrc/Input/ALSAMidiIn.cpp | 64++++++++++++++++++++++++++++++++++++++++++++++++++++++----------
Msrc/Input/ALSAMidiIn.h | 8++++++++
Msrc/Misc/Master.cpp | 44++++----------------------------------------
Msrc/Misc/Master.h | 20++++++--------------
Msrc/Nio/CMakeLists.txt | 2++
Asrc/Nio/InMgr.cpp | 41+++++++++++++++++++++++++++++++++++++++++
Asrc/Nio/InMgr.h | 28++++++++++++++++++++++++++++
Asrc/Nio/MidiEvent.cpp | 10++++++++++
Asrc/Nio/MidiEvent.h | 29+++++++++++++++++++++++++++++
Msrc/Nio/MidiIn.cpp | 194+++++++++++++++++++++++++++++++++----------------------------------------------
Msrc/Nio/MidiIn.h | 55++++++++++++++++++++++++++++++++++---------------------
Msrc/UI/VirKeyboard.fl | 17++++++++++-------
Msrc/main.cpp | 54+++++++++++++-----------------------------------------
13 files changed, 321 insertions(+), 245 deletions(-)

diff --git a/src/Input/ALSAMidiIn.cpp b/src/Input/ALSAMidiIn.cpp @@ -21,6 +21,11 @@ */ #include "ALSAMidiIn.h" +#include "../Nio/MidiEvent.h" + +#include <iostream> +using namespace std; + ALSAMidiIn::ALSAMidiIn() { @@ -32,7 +37,7 @@ ALSAMidiIn::ALSAMidiIn() if(snd_seq_open(&midi_handle, "default", SND_SEQ_OPEN_INPUT, 0) != 0) return; - snd_seq_set_client_name(midi_handle, "ZynAddSubFX"); //thanks to Frank Neumann + snd_seq_set_client_name(midi_handle, "ZynAddSubFX"); alsaport = snd_seq_create_simple_port( midi_handle, @@ -42,8 +47,6 @@ ALSAMidiIn::ALSAMidiIn() SND_SEQ_PORT_TYPE_SYNTH); if(alsaport < 0) return; - - inputok = true; } ALSAMidiIn::~ALSAMidiIn() @@ -52,6 +55,54 @@ ALSAMidiIn::~ALSAMidiIn() snd_seq_close(midi_handle); } +void ALSAMidiIn::run() +{ + cout << "starting midi#run" << endl; + pthread_attr_t attr; + + pthread_attr_init(&attr); + pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); + pthread_create(&thread, &attr, _inputThread, this); +} + +void *ALSAMidiIn::_inputThread(void *arg) +{ + return (static_cast<ALSAMidiIn *>(arg))->inputThread(); +} +void *ALSAMidiIn::inputThread() +{ + cout << "starting Midi" << endl; + while(1) { + snd_seq_event_t *midievent = NULL; + + snd_seq_event_input(midi_handle, &midievent); + + if(midievent == NULL) + continue; + switch(midievent->type) { + case SND_SEQ_EVENT_NOTEON: + sysIn->putEvent(MidiNote(midievent->data.note.note, + midievent->data.note.channel, + midievent->data.note.velocity)); + break; + case SND_SEQ_EVENT_NOTEOFF: + sysIn->putEvent(MidiNote(midievent->data.note.note, + midievent->data.note.channel)); + break; + case SND_SEQ_EVENT_PITCHBEND: + sysIn->putEvent(MidiCtl(C_pitchwheel, + midievent->data.control.channel, + midievent->data.control.value)); + break; + case SND_SEQ_EVENT_CONTROLLER: + sysIn->putEvent(MidiCtl(midievent->data.control.param, + midievent->data.control.channel, + midievent->data.control.value)); + break; + } + } + return NULL; +} /* * Get the midi command,channel and parameters @@ -63,13 +114,6 @@ void ALSAMidiIn::getmidicmd(MidiCmdType &cmdtype, snd_seq_event_t *midievent = NULL; cmdtype = MidiNull; - if(inputok == false) { - /* The input is broken. We need to block for a while anyway so other - non-RT threads get a chance to run. */ - sleep(1); - return; - } - snd_seq_event_input(midi_handle, &midievent); if(midievent == NULL) diff --git a/src/Input/ALSAMidiIn.h b/src/Input/ALSAMidiIn.h @@ -25,6 +25,7 @@ #include <alsa/asoundlib.h> #include "MidiIn.h" +#include "../Nio/InMgr.h" /**Midi input for ALSA (this creates an ALSA virtual port)*/ @@ -36,6 +37,12 @@ class ALSAMidiIn:public MidiIn /**Destructor*/ ~ALSAMidiIn(); + void run(); + + static void *_inputThread(void *arg); + void *inputThread(); + + void getmidicmd(MidiCmdType &cmdtype, unsigned char &cmdchan, int *cmdparams); @@ -45,6 +52,7 @@ class ALSAMidiIn:public MidiIn private: snd_seq_t *midi_handle; + pthread_t thread; }; #endif diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp @@ -134,23 +134,7 @@ bool Master::mutexLock(lockset request) /* * Note On Messages (velocity=0 for NoteOff) */ -void Master::NoteOn(unsigned char chan, - unsigned char note, - unsigned char velocity) -{ - pthread_mutex_lock(&mutex); - dump.dumpnote(chan, note, velocity); - - noteon(chan, note, velocity); - pthread_mutex_unlock(&mutex); -} - -/* - * Internal Note On (velocity=0 for NoteOff) - */ -void Master::noteon(unsigned char chan, - unsigned char note, - unsigned char velocity) +void Master::noteOn(char chan, char note, char velocity) { int npart; if(velocity != 0) { @@ -163,24 +147,14 @@ void Master::noteon(unsigned char chan, } } else - this->NoteOff(chan, note); + this->noteOff(chan, note); HDDRecorder.triggernow(); } /* * Note Off Messages */ -void Master::NoteOff(unsigned char chan, unsigned char note) -{ - dump.dumpnote(chan, note, 0); - - noteoff(chan, note); -} - -/* - * Internal Note Off - */ -void Master::noteoff(unsigned char chan, unsigned char note) +void Master::noteOff(char chan, char note) { int npart; for(npart = 0; npart < NUM_MIDI_PARTS; npart++) @@ -192,17 +166,7 @@ void Master::noteoff(unsigned char chan, unsigned char note) /* * Controllers */ -void Master::SetController(unsigned char chan, unsigned int type, int par) -{ - dump.dumpcontroller(chan, type, par); - - setcontroller(chan, type, par); -} - -/* - * Internal Controllers - */ -void Master::setcontroller(unsigned char chan, unsigned int type, int par) +void Master::setController(char chan, int type, int par) { if((type == C_dataentryhi) || (type == C_dataentrylo) || (type == C_nrpnhi) || (type == C_nrpnlo)) { //Process RPN and NRPN by the Master (ignore the chan) diff --git a/src/Misc/Master.h b/src/Misc/Master.h @@ -85,11 +85,9 @@ class Master bool mutexLock(lockset request); //Midi IN - void NoteOn(unsigned char chan, - unsigned char note, - unsigned char velocity); - void NoteOff(unsigned char chan, unsigned char note); - void SetController(unsigned char chan, unsigned int type, int par); + void noteOn(char chan, char note, char velocity); + void noteOff(char chan, char note); + void setController(char chan, int type, int par); //void NRPN... @@ -125,7 +123,7 @@ class Master //effects EffectMgr *sysefx[NUM_SYS_EFX]; //system EffectMgr *insefx[NUM_INS_EFX]; //insertion -// void swapcopyeffects(int what,int type,int neff1,int neff2); +// void swapcopyeffects(int what,int type,int neff1,int neff2); //HDD recorder Recorder HDDRecorder; @@ -148,6 +146,7 @@ class Master int swaplr; //1 if L and R are swapped //Sequencer +#warning TODO move Sequencer out of master Sequencer seq; //other objects @@ -158,6 +157,7 @@ class Master pthread_mutex_t mutex; pthread_mutex_t vumutex; + private: bool nullRun; vuData vu; @@ -179,14 +179,6 @@ class Master int ksoundbuffersample; //this is used to know if there is need to call AudioOut by GetAudioOutSamples method REALTYPE ksoundbuffersamplelow; //this is used for resampling (eg. if Jack samplerate!= SAMPLE_RATE) REALTYPE oldsamplel, oldsampler; //this is used for resampling - - //These are called by the NoteOn, NoteOff,SetController (which are from external sources like MIDI, Virtual Keyboard) - //and are called by internal parts of the program (like sequencer) - void noteon(unsigned char chan, - unsigned char note, - unsigned char velocity); - void noteoff(unsigned char chan, unsigned char note); - void setcontroller(unsigned char chan, unsigned int type, int par); }; diff --git a/src/Nio/CMakeLists.txt b/src/Nio/CMakeLists.txt @@ -8,6 +8,8 @@ set(zynaddsubfx_nio_SRCS NulEngine.cpp AudioOut.cpp OutMgr.cpp + InMgr.cpp + MidiEvent.cpp ) set(zynaddsubfx_nio_lib ) diff --git a/src/Nio/InMgr.cpp b/src/Nio/InMgr.cpp @@ -0,0 +1,41 @@ +#include <pthread.h> +#include "InMgr.h" +#include <iostream> + +using namespace std; + +InMgr *sysIn; + +InMgr::InMgr(Master *_master) + :master(_master) +{} + +void InMgr::putEvent(MidiNote note) +{ + pthread_mutex_lock(&master->mutex); + { + cout << "got a note event" << endl; + dump.dumpnote(note.channel, note.note, note.velocity); + + if(note.velocity) + master->noteOn(note.channel, note.note, note.velocity); + else + master->noteOff(note.channel, note.note); + } + pthread_mutex_unlock(&master->mutex); +} + +void InMgr::putEvent(MidiCtl control) +{ + pthread_mutex_lock(&master->mutex); + { + cout << "got a control event" << endl; + dump.dumpcontroller(control.channel, control.controller, + control.value); + + master->setController(control.channel, control.controller, control.value); + } + pthread_mutex_unlock(&master->mutex); +} + + diff --git a/src/Nio/InMgr.h b/src/Nio/InMgr.h @@ -0,0 +1,28 @@ +#ifndef INMGR_H +#define INMGR_H + +#include <string> +#include "MidiEvent.h" +#include "../Misc/Master.h" + + +class Master; +//super simple class to manage the inputs +class InMgr +{ + public: + InMgr(Master *nmaster); + ~InMgr(){}; + + //only interested in Notes and Controllers for now + void putEvent(MidiNote note); + void putEvent(MidiCtl control); + + private: + /**the link to the rest of zyn*/ + Master *master; +}; + +extern InMgr *sysIn; +#endif + diff --git a/src/Nio/MidiEvent.cpp b/src/Nio/MidiEvent.cpp @@ -0,0 +1,10 @@ +#include "MidiEvent.h" + +MidiNote::MidiNote(char _note, char _channel, char _velocity) + :note(_note), channel(_channel), velocity(_velocity) +{}; + +MidiCtl::MidiCtl(char _controller, char _channel, char _value) + :controller(_controller), channel(_channel), value(_value) +{}; + diff --git a/src/Nio/MidiEvent.h b/src/Nio/MidiEvent.h @@ -0,0 +1,29 @@ + +#ifndef MIDI_EVENT +#define MIDI_EVENT + +/**A class to generalize midi events*/ +struct MidiEvent +{ + MidiEvent(){}; +}; + +struct MidiNote : public MidiEvent +{ + MidiNote(char _note, char _channel, char _velocity = 0); + + char note; + char channel; + char velocity; +}; + +struct MidiCtl : public MidiEvent +{ + MidiCtl(char _controller, char _channel, char _value); + + char controller; + char channel; + char value; +}; + +#endif diff --git a/src/Nio/MidiIn.cpp b/src/Nio/MidiIn.cpp @@ -1,126 +1,96 @@ /* - MusicIO.cpp + ZynAddSubFX - a software synthesizer - Copyright 2009, Alan Calvert + MidiIn.C - This class is inherited by all the Midi input classes + Copyright (C) 2002-2005 Nasca Octavian Paul + Author: Nasca Octavian Paul - This file is part of yoshimi, which is free software: you can - redistribute it and/or modify it under the terms of the GNU General - Public License as published by the Free Software Foundation, either - version 3 of the License, or (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. - yoshimi is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License (version 2 or later) for more details. - You should have received a copy of the GNU General Public License - along with yoshimi. If not, see <http://www.gnu.org/licenses/>. -*/ - -#include <iostream> -#include <cstring> + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -using namespace std; +*/ -#include "../Misc/Master.h" +#include "../globals.h" #include "MidiIn.h" -MidiIn::MidiIn() -{} - -int MidiIn::getMidiController(unsigned char b) +int MidiIn::getcontroller(unsigned char b) { + /**\todo there might be a better way to do this*/ int ctl = C_NULL; - switch (b) - { - case 1: - ctl = C_modwheel; // Modulation Wheel - break; - case 7: - ctl=C_volume; // Volume - break; - case 10: - ctl = C_panning; // Panning - break; - case 11: - ctl = C_expression; // Expression - break; - case 64: - ctl = C_sustain; // Sustain pedal - break; - case 65: - ctl = C_portamento; // Portamento - break; - case 71: - ctl = C_filterq; // Filter Q (Sound Timbre) - break; - case 74: - ctl = C_filtercutoff; // Filter Cutoff (Brightness) - break; - case 75: - ctl = C_bandwidth; // BandWidth - break; - case 76: - ctl = C_fmamp; // FM amplitude - break; - case 77: - ctl = C_resonance_center; // Resonance Center Frequency - break; - case 78: - ctl = C_resonance_bandwidth; // Resonance Bandwith - break; - case 120: - ctl = C_allsoundsoff; // All Sounds OFF - break; - case 121: - ctl = C_resetallcontrollers; // Reset All Controllers - break; - case 123: - ctl = C_allnotesoff; // All Notes OFF - break; - // RPN and NRPN - case 0x06: - ctl = C_dataentryhi; // Data Entry (Coarse) - break; - case 0x26: - ctl = C_dataentrylo; // Data Entry (Fine) - break; - case 99: - ctl = C_nrpnhi; // NRPN (Coarse) - break; - case 98: - ctl = C_nrpnlo; // NRPN (Fine) - break; - default: - ctl = C_NULL; // an unrecognised controller! - break; - } + switch(b) { + case 1: + ctl = C_modwheel; //Modulation Wheel + break; + case 7: + ctl = C_volume; //Volume + break; + case 10: + ctl = C_panning; //Panning + break; + case 11: + ctl = C_expression; //Expression + break; + case 64: + ctl = C_sustain; //Sustain pedal + break; + case 65: + ctl = C_portamento; //Portamento + break; + case 71: + ctl = C_filterq; //Filter Q (Sound Timbre) + break; + case 74: + ctl = C_filtercutoff; //Filter Cutoff (Brightness) + break; + case 75: + ctl = C_bandwidth; //BandWidth + break; + case 76: + ctl = C_fmamp; //FM amplitude + break; + case 77: + ctl = C_resonance_center; //Resonance Center Frequency + break; + case 78: + ctl = C_resonance_bandwidth; //Resonance Bandwith + break; + case 120: + ctl = C_allsoundsoff; //All Sounds OFF + break; + case 121: + ctl = C_resetallcontrollers; //Reset All Controllers + break; + case 123: + ctl = C_allnotesoff; //All Notes OFF + break; + //RPN and NRPN + case 0x06: + ctl = C_dataentryhi; //Data Entry (Coarse) + break; + case 0x26: + ctl = C_dataentrylo; //Data Entry (Fine) + break; + case 99: + ctl = C_nrpnhi; //NRPN (Coarse) + break; + case 98: + ctl = C_nrpnlo; //NRPN (Fine) + break; + default: + ctl = C_NULL; //unknown controller + //fprintf(stderr,"Controller=%d , par=%d\n",midievent->data.control.param,cmdparams[1]); + break; + } return ctl; } - -void MidiIn::setMidiController(unsigned char ch, unsigned int ctrl, - int param) -{ - master->mutexLock(MUTEX_LOCK); - master->SetController(ch, ctrl, param); - master->mutexLock(MUTEX_UNLOCK); -} - - -void MidiIn::setMidiNote(unsigned char channel, unsigned char note, - unsigned char velocity) -{ - master->mutexLock(MUTEX_LOCK); - master->NoteOn(channel, note, velocity); - master->mutexLock(MUTEX_UNLOCK); -} - - -void MidiIn::setMidiNote(unsigned char channel, unsigned char note) -{ - master->mutexLock(MUTEX_LOCK); - master->NoteOff(channel, note); - master->mutexLock(MUTEX_UNLOCK); -} - diff --git a/src/Nio/MidiIn.h b/src/Nio/MidiIn.h @@ -1,37 +1,50 @@ /* - MusicIO.h + ZynAddSubFX - a software synthesizer - Copyright 2009, Alan Calvert - Copyright 2009, James Morris + MidiIn.h - This class is inherited by all the Midi input classes + Copyright (C) 2002-2005 Nasca Octavian Paul + Author: Nasca Octavian Paul - This file is part of yoshimi, which is free software: you can - redistribute it and/or modify it under the terms of the GNU General - Public License as published by the Free Software Foundation, either - version 3 of the License, or (at your option) any later version. + This program is free software; you can redistribute it and/or modify + it under the terms of version 2 of the GNU General Public License + as published by the Free Software Foundation. - yoshimi is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License (version 2 or later) for more details. + + You should have received a copy of the GNU General Public License (version 2) + along with this program; if not, write to the Free Software Foundation, + Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - You should have received a copy of the GNU General Public License - along with yoshimi. If not, see <http://www.gnu.org/licenses/>. */ #ifndef MIDI_IN_H #define MIDI_IN_H +#include "../globals.h" + +enum MidiCmdType { + MidiNull, MidiNoteOFF, MidiNoteON, MidiController +}; +#define MP_MAX_BYTES 4000 //in case of loooong SYS_EXes + +/**This class is inherited by all the Midi input classes*/ class MidiIn { public: - MidiIn(); - virtual ~MusicIO() {}; - - int getMidiController(unsigned char b); - void setMidiController(unsigned char ch, unsigned int ctrl, int param); - void setMidiNote(unsigned char chan, unsigned char note); - void setMidiNote(unsigned char chan, unsigned char note, - unsigned char velocity); + /**Get the command,channel and parameters of the MIDI + * + * \todo make pure virtual + * @param cmdtype the referece to the variable that will store the type + * @param cmdchan the channel for the event + * @param parameters for the event*/ + virtual void getmidicmd(MidiCmdType &cmdtype, + unsigned char &cmdchan, + int *cmdparams) = 0; + static int getcontroller(unsigned char b); }; #endif + diff --git a/src/UI/VirKeyboard.fl b/src/UI/VirKeyboard.fl @@ -1,5 +1,5 @@ # data file for the Fltk User Interface Designer (fluid) -version 1.0107 +version 1.0300 header_name {.h} code_name {.cc} decl {//Copyright (c) 2002-2005 Nasca Octavian Paul} {} @@ -204,7 +204,9 @@ if (rndvelocity!=0){ vel=midivel*(127.0-rndvelocity)/127.0+RND*rndvelocity; }; -master->NoteOn(midich,nk+midioct*12,(int)vel);} {} +pthread_mutex_lock(&master->mutex); +master->noteOn(midich,nk+midioct*12,(int)vel); +pthread_mutex_unlock(&master->mutex);} {} } Function {relasekey(int nk,int type)} {} { code {if ((nk<0)||(nk>=N_OCT*12)) return; @@ -216,8 +218,9 @@ pressed[nk]=0; damage(1); -master->NoteOff(midich,nk+12*midioct);} {selected - } +pthread_mutex_lock(&master->mutex); +master->noteOff(midich,nk+12*midioct); +pthread_mutex_unlock(&master->mutex);} {} } Function {relaseallkeys(int type)} {} { code {for (int i=0;i<N_OCT*12;i++) relasekey(i,type);} {} @@ -290,7 +293,7 @@ virkeyboardwindow->hide();} callback {int ctl=midictl; pthread_mutex_lock(&master->mutex); - master->SetController(virkeys->midich,ctl,(int) o->value()); +master->setController(virkeys->midich,ctl,(int) o->value()); pthread_mutex_unlock(&master->mutex); virkeys->take_focus();} tooltip {Controller value} xywh {605 10 15 115} type {Vert Fill} box ENGRAVED_BOX selection_color 229 labelsize 8 align 5 minimum 127 maximum 0 step 1 value 64 textsize 7 @@ -372,7 +375,7 @@ virkeys->take_focus();} Fl_Roller pitchwheelroller { label Pwh callback {pthread_mutex_lock(&master->mutex); - master->SetController(virkeys->midich,C_pitchwheel,-(int) o->value()); +master->setController(virkeys->midich,C_pitchwheel,-(int) o->value()); pthread_mutex_unlock(&master->mutex); virkeys->take_focus();} tooltip {Pitch Wheel} xywh {625 10 20 95} box PLASTIC_UP_BOX labelsize 8 align 1 when 3 minimum -8192 maximum 8192 step 64 @@ -385,7 +388,7 @@ pitchwheelroller->do_callback();} } Fl_Dial {} { label Vrnd - callback {virkeys->rndvelocity=(int) o->value();} + callback {virkeys->rndvelocity=(int) o->value();} selected tooltip {Velocity Randomness} xywh {205 105 20 20} box ROUND_UP_BOX labelsize 10 align 129 maximum 127 step 1 code0 {o->value(virkeys->rndvelocity);} class WidgetPDial diff --git a/src/main.cpp b/src/main.cpp @@ -41,6 +41,8 @@ extern Dump dump; #include "Nio/OutMgr.h" +#warning TODO remove conditional include block + #include "Input/MidiIn.h" #ifdef ALSAMIDIIN @@ -77,7 +79,7 @@ MasterUI *ui; using namespace std; -pthread_t thr1, thr2, thr3, thr4; +pthread_t thr3, thr4; Master *master; int swaplr = 0; //1 for left-right swapping bool usejackit = false; @@ -94,37 +96,6 @@ MidiIn *Midi; int Pexitprogram = 0; //if the UI set this to 1, the program will exit /* - * Midi input thread - */ -#if !(defined(WINMIDIIN) || defined(VSTMIDIIN)) -void *thread1(void *arg) -{ - MidiCmdType cmdtype = MidiNoteOFF; - unsigned char cmdchan = 0, note = 0, vel = 0; - int cmdparams[MP_MAX_BYTES]; - for(int i = 0; i < MP_MAX_BYTES; ++i) - cmdparams[i] = 0; - - set_realtime(); - while(Pexitprogram == 0) { - Midi->getmidicmd(cmdtype, cmdchan, cmdparams); - note = cmdparams[0]; - vel = cmdparams[1]; - - if((cmdtype == MidiNoteON) && (note != 0)) - master->NoteOn(cmdchan, note, vel); - if((cmdtype == MidiNoteOFF) && (note != 0)) - master->NoteOff(cmdchan, note); - if(cmdtype == MidiController) - master->SetController(cmdchan, cmdparams[0], cmdparams[1]); - } - - return 0; -} -#endif - - -/* * User Interface thread */ void *thread3(void *arg) @@ -166,6 +137,9 @@ void *thread3(void *arg) return 0; } +//this code is disabled for Nio testing +//it should get moved out of here into the nio system soon +#if 0 /* * Sequencer thread (test) */ @@ -208,12 +182,11 @@ void *thread4(void *arg) return 0; } +#endif /* * Program initialisation */ - - void initprogram() { cerr.precision(1); @@ -249,6 +222,11 @@ void initprogram() sysOut = new OutMgr(master); sysOut->run(); + sysIn = new InMgr(master); + ALSAMidiIn *alsamidi = dynamic_cast<ALSAMidiIn *>(Midi); + cout << "run" << endl; + alsamidi->run(); + #ifndef DISABLE_GUI ui = new MasterUI(master, &Pexitprogram); #endif @@ -567,16 +545,10 @@ int main(int argc, char *argv[]) } -#if !(defined(NONEMIDIIN) || defined(WINMIDIIN) || defined(VSTMIDIIN)) - pthread_create(&thr1, NULL, thread1, NULL); -#endif - - - if(noui == 0) pthread_create(&thr3, NULL, thread3, NULL); - pthread_create(&thr4, NULL, thread4, NULL); +// pthread_create(&thr4, NULL, thread4, NULL); #ifdef WINMIDIIN InitWinMidi(master); #endif