DevMidi.h
gehe zur Dokumentation dieser Datei
00001 // -*- C++ -*- 
00024 // ------------------------------------------------------------------
00025 // Mutabor 3, 1998, R.Kraufle
00026 // MidiPort Klassen
00027 // ------------------------------------------------------------------
00028 
00029 #ifndef DEVMIDI_H
00030 #define DEVMIDI_H
00031 
00032 #include <cassert>
00033 
00034 #include "mhDefs.h"
00035 #include "Device.h"
00036 #ifdef RTMIDI
00037 #include "RtMidi.h"
00038 #else
00039 #ifndef H_MMSYSTEM
00040 //  #define WINVER 0x030a
00041 #include <mmsystem.h>
00042 #define H_MMSYSTEM
00043 #endif
00044 #endif
00045 
00046 extern RtMidiOut * rtmidiout;
00047 extern RtMidiIn * rtmidiin;
00048 
00049 // OutMidiPort ------------------------------------------------------
00050 
00051 typedef struct TAK
00052 {
00053         int taste;
00054         int key;
00055         DWORD id;         // (channel << 24) + (Route->Id << 16) + (Box << 8) + Taste
00056         // zum Identifizieren fürs korrekte Ausschalten
00057 } TonAufKanal;
00058 
00059 class OutMidiPort : public OutDevice
00060 {
00061         int bending_range;
00062 public:
00063         OutMidiPort():OutDevice(), bending_range (2), hMidiOut(NULL), nKeyOn(0) { }
00064 
00065         OutMidiPort(wxString name, int devId, int bendingRange = 2)
00066         : OutDevice(devId, name), bending_range (bendingRange), hMidiOut(NULL), nKeyOn(0)
00067         {
00068                 DEBUGLOG(other,_T(""));
00069         }
00070 
00071         ~OutMidiPort()
00072                 {};
00073         
00075 
00077         virtual void Save (tree_storage & config);
00078         
00080 
00085         virtual void Save (tree_storage & config, const Route * route);
00086         
00087         
00089 
00091         virtual void Load (tree_storage & config);
00092         
00094 
00099         virtual void Load (tree_storage & config, Route * route);
00100 
00101         
00102         virtual bool Open();
00103         virtual void Close();
00104         virtual void NoteOn(int Box, int taste, int velo, Route *r,
00105                             int channel, ChannelData *cd);
00106         virtual void NoteOff(int Box, int taste, int velo, Route *r, int channel);
00107         virtual void NotesCorrect(int box);
00108         virtual void Sustain(char on, int channel);
00109         virtual int  GetChannel(int taste);
00110         virtual void Gis(GisToken *token, char turn)
00111         {};
00112 
00113         virtual void AddTime(frac time)
00114         {};
00115 
00116         virtual void MidiOut(DWORD data, char n);
00117         virtual void MidiOut(BYTE *p, char n)
00118         {};
00119 
00120         virtual void Quite(Route *r);
00121         virtual void Panic();
00122         virtual bool NeedsRealTime()
00123         {
00124                 return true;
00125         }
00126 
00127         virtual void SetDevId (int id) {
00128                 DevId = id;            
00129                 Name = muT (rtmidiout->getPortName (DevId).c_str());
00130         }
00131                 
00132         void SetBendingRange (int r) {
00133                 bending_range = r;
00134         }
00135 
00136         int GetBendingRange() {
00137                 return bending_range;
00138         }
00139         
00140 
00141         virtual DevType GetType() const
00142         {
00143                 return DTMidiPort;
00144         }
00145 
00146         virtual mutString GetTypeName () const {
00147                 return _("Midi output device");
00148         }
00149 
00150         virtual void ReadData(wxConfigBase * config);
00151         virtual void WriteData(wxConfigBase * config);
00152         
00153 #ifdef WX
00154         virtual wxString TowxString() const {
00155                 wxString s = OutDevice::TowxString() +
00156                 wxString::Format(_T("\n  Name = %s\n  DevId = %d\n  Bending Range = %d\n  nKeyOn"),
00157                                  Name.c_str(), DevId, bending_range, nKeyOn);
00158                 s.Printf(_T("\n  KeyDir = [ %d"), KeyDir[0]);
00159                 for (int i = 1; i<16; i++)
00160                         s.Printf(_T(", %d"),KeyDir[i]);
00161                 s.Printf(_T("]\n  ton_auf_kanal = [ t=%d,k=%d"), 
00162                          ton_auf_kanal[0].taste,
00163                          ton_auf_kanal[0].key);
00164                 for (int i = 1; i<16; i++)
00165                         s.Printf(_T("; t=%d,k=%d"), 
00166                                  ton_auf_kanal[i].taste,
00167                                  ton_auf_kanal[i].key);
00168                 s+=_T("]");
00169                 return s;
00170         }
00171 #endif
00172 
00173         virtual int GetMaxChannel() const { return 15; }
00174         virtual int GetMinChannel() const { return 0; }
00175         
00176 private:
00177 
00178 #ifdef RTMIDI
00179         RtMidiOut *hMidiOut;
00180 #else
00181         HMIDIOUT hMidiOut;
00182 #endif
00183         ChannelData Cd[16];
00184         char KeyDir[16];
00185         TonAufKanal ton_auf_kanal[16];
00186         int nKeyOn;
00187 };
00188 
00189 // InMidiPort -------------------------------------------------------
00190 
00191 class InMidiPort : public InDevice
00192 {
00193 
00194 public:
00195         InMidiPort *NextMidiPort;
00196 
00197         InMidiPort() : InDevice(), NextMidiPort (NULL) { }
00198                        
00199         InMidiPort(const mutString &name, int devId)
00200         : InDevice(devId, name), NextMidiPort (NULL) {}
00201 
00202         virtual ~InMidiPort() {}
00203         
00205 
00207         virtual void Save (tree_storage & config);
00208         
00210 
00215         virtual void Save (tree_storage & config, const Route * route);
00216         
00217         
00219 
00221         virtual void Load (tree_storage & config);
00222         
00224 
00229         virtual void Load (tree_storage & config, Route * route);
00230 
00231         
00232         
00233         virtual bool Open();
00234         virtual void Close();
00235         virtual void Stop()
00236         {};
00237 
00238         virtual void Play()
00239         {};
00240 
00241         virtual void Pause()
00242         {};
00243 
00244 //         void Proceed(GisReadArtHead *h, char turn, Route *route) {};
00245 //         void ProceedRoute(GisReadArtHead *h, char turn) {};
00246         virtual frac ReadOn(frac time)
00247         {
00248                 return frac(0,1);
00249         };
00250 
00251         virtual bool NeedsRealTime()
00252         {
00253                 return true;
00254         }
00255 
00256         virtual void SetDevId (int id) {
00257                 DevId = id;            
00258                 Name = muT (rtmidiin->getPortName (DevId).c_str());
00259         }
00260 
00261         virtual int GetDevId() 
00262                 {
00263                         return DevId; 
00264                 }
00265 
00266         virtual wxString &GetName()
00267         {
00268                 return Name;
00269         }
00270 
00271         virtual void SetName(const wxString & s) 
00272         {
00273                 assert (false);
00274                 //Name = s;
00275         }
00276 
00277         void Proceed(DWORD midiCode);
00278         
00279         virtual int GetMaxChannel() const { return 15; }
00280         virtual int GetMinChannel() const { return 0; }
00281         virtual int GetMaxKey() const { return 127; }
00282         virtual int GetMinKey() const { return 0; }     
00283         
00284 
00285         virtual DevType GetType() const
00286         {
00287                 return DTMidiPort;
00288         }
00289 
00290         virtual mutString GetTypeName () const {
00291                 return _("Midi input device");
00292         }
00293 
00294 #ifdef WX
00295         virtual wxString TowxString() const {
00296                 return InDevice::TowxString();
00297         }
00298 #endif
00299         
00300         
00301 #ifdef RTMIDI
00302         RtMidiIn *hMidiIn;
00303 
00304 #else
00305         HMIDIIN hMidiIn;
00306 
00307 #endif
00308 private:
00309         ChannelData Cd[16];
00310 
00311         void ProceedRoute(DWORD midiCode, Route *route);
00312 };
00313 
00314 void MidiInit();
00315 void MidiUninit();
00316 
00317 
00318 #endif
00319 
00320 

Erzeugt am Sun Aug 21 2011 10:51:53 für Mutabor von doxygen 1.7.4