00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "common.h"
00020 #include "Esitar.h"
00021
00022 #ifdef MARSYAS_MIDIIO
00023 #include "RtMidi.h"
00024 #endif
00025
00026
00027 using std::ostringstream;
00028 using namespace Marsyas;
00029
00030 Esitar::Esitar(mrs_string name):MarSystem("Esitar",name)
00031 {
00032
00033
00034
00035 #ifdef MARSYAS_MIDIIO
00036 midiin = NULL;
00037 #endif
00038 }
00039
00040
00041 Esitar::~Esitar()
00042 {
00043 #ifdef MARSYAS_MIDIIO
00044 delete midiin;
00045 #endif
00046 }
00047
00048
00049 MarSystem*
00050 Esitar::clone() const
00051 {
00052 return new Esitar(*this);
00053 }
00054
00055 void
00056 Esitar::myUpdate(MarControlPtr sender)
00057 {
00058 MRSDIAG("Esitar.cpp - Esitar:myUpdate");
00059
00060
00061
00062
00063
00064 MarSystem::myUpdate(sender);
00065
00066 #ifdef MARSYAS_MIDIIO
00067 try {
00068 midiin = new RtMidiIn();
00069 }
00070 catch (RtError3 &error) {
00071 error.printMessage();
00072 return;
00073 }
00074
00075 try {
00076 midiin->openPort(0);
00077 }
00078 catch (RtError3 &error)
00079 {
00080 error.printMessage();
00081 return;
00082 }
00083 midiin->setCallback(&Esitar::mycallback, this);
00084 midiin->ignoreTypes(false, false, false);
00085 #endif
00086 }
00087
00088
00089 void
00090 Esitar::mycallback(double deltatime, std::vector< unsigned char > * message, void *userData)
00091 {
00092
00093 (void) deltatime;
00094 int nBytes = 0;
00095 nBytes = message->size();
00096
00097 Esitar* mythis = (Esitar*) userData;
00098
00099
00100 if (nBytes > 0)
00101 {
00102 if (nBytes > 2)
00103 {
00104 mythis->byte3 = message->at(2);
00105 mythis->byte2 = message->at(1);
00106 mythis->type = message->at(0);
00107 }
00108
00109
00110 if ((mythis->type == 176)&&(mythis->byte2 == 1))
00111 {
00112 mythis->thumb = mythis->byte3;
00113 }
00114
00115
00116 if ((mythis->type == 176)&&(mythis->byte2 == 2))
00117 {
00118 mythis->fret = mythis->byte3;
00119 }
00120
00121
00122 if ((mythis->type == 176)&&(mythis->byte2 == 6))
00123 {
00124 mythis->headx = mythis->byte3;
00125 }
00126
00127
00128 if ((mythis->type == 176)&&(mythis->byte2 == 8))
00129 {
00130 mythis->heady = mythis->byte3;
00131 }
00132
00133
00134 if ((mythis->type == 176)&&(mythis->byte2 == 10))
00135 {
00136 mythis->headz = mythis->byte3;
00137 }
00138
00139
00140 if ((mythis->type == 176)&&(mythis->byte2 == 7))
00141 {
00142 mythis->pot1 = mythis->byte3;
00143 }
00144
00145
00146 if ((mythis->type == 176)&&(mythis->byte2 == 9))
00147 {
00148 mythis->pot2 = mythis->byte3;
00149 }
00150
00151
00152 if ((mythis->type == 144)&&(mythis->byte2 == 1))
00153 {
00154 mythis->switch1 = mythis->byte3;
00155 }
00156
00157
00158 if ((mythis->type == 144)&&(mythis->byte2 == 2))
00159 {
00160 mythis->switch2 = mythis->byte3;
00161 }
00162
00163
00164 if ((mythis->type == 144)&&(mythis->byte2 == 3))
00165 {
00166 mythis->switch3 = mythis->byte3;
00167 }
00168
00169
00170 if ((mythis->type == 144)&&(mythis->byte2 == 4))
00171 {
00172 mythis->switch4 = mythis->byte3;
00173 }
00174
00175
00176 if ((mythis->type == 144)&&(mythis->byte2 == 5))
00177 {
00178 mythis->switch5 = mythis->byte3;
00179 }
00180
00181
00182 if ((mythis->type == 144)&&(mythis->byte2 == 6))
00183 {
00184 mythis->switch6 = mythis->byte3;
00185 }
00186
00187
00188 if ((mythis->type == 144)&&(mythis->byte2 == 7))
00189 {
00190 mythis->switch7 = mythis->byte3;
00191 }
00192
00193
00194 if ((mythis->type == 144)&&(mythis->byte2 == 8))
00195 {
00196 mythis->switch8 = mythis->byte3;
00197 }
00198
00199
00200 if ((mythis->type == 144)&&(mythis->byte2 == 9))
00201 {
00202 mythis->switch9 = mythis->byte3;
00203 }
00204
00205
00206 if ((mythis->type == 144)&&(mythis->byte2 == 10))
00207 {
00208 mythis->switch10 = mythis->byte3;
00209 }
00210
00211 }
00212 }
00213
00214 void
00215 Esitar::myProcess(realvec& in, realvec& out)
00216 {
00217 mrs_natural o,t;
00218
00219
00220 for (o=0; o < inObservations_; o++)
00221 for (t = 0; t < inSamples_; t++)
00222 {
00223 out(o,t) = in(o,t);
00224 }
00225 }
00226
00227
00228
00229
00230
00231
00232
00233