/[svn]/linuxsampler/trunk/src/drivers/midi/MidiInputDeviceMme.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/drivers/midi/MidiInputDeviceMme.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1715 by schoenebeck, Tue Mar 11 15:20:46 2008 UTC revision 1887 by persson, Sat Apr 18 08:17:16 2009 UTC
# Line 3  Line 3 
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *
6   *   Copyright (C) 2005 - 2008 Christian Schoenebeck                       *   *   Copyright (C) 2005 - 2009 Christian Schoenebeck                       *
7   *                                                                         *   *                                                                         *
8   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
9   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 89  void CALLBACK MidiInputDeviceMme::MidiIn Line 89  void CALLBACK MidiInputDeviceMme::MidiIn
89      String MidiInputDeviceMme::ParameterPorts::Name() {      String MidiInputDeviceMme::ParameterPorts::Name() {
90          return "PORTS";          return "PORTS";
91      }      }
92        
93      // the MME driver supports only one port so to manage multiple MME MIDI ports the user just creates several MME drivers and connects each one to the desired MME port      // the MME driver supports only one port so to manage multiple MME MIDI ports the user just creates several MME drivers and connects each one to the desired MME port
94        
95    
96    
97  // *************** ParameterPort ***************  // *************** ParameterPort ***************
# Line 203  void MidiInputDeviceMme::MidiInputPortMm Line 203  void MidiInputDeviceMme::MidiInputPortMm
203      if(res != MMSYSERR_NOERROR) {      if(res != MMSYSERR_NOERROR) {
204          throw MidiInputException("MIDI port connect failed. midiInOpen error");          throw MidiInputException("MIDI port connect failed. midiInOpen error");
205      }      }
206        
207      MidiInOpened = true;      MidiInOpened = true;
208    
209      /* Store pointer to our input buffer for System Exclusive messages in MIDIHDR */      /* Store pointer to our input buffer for System Exclusive messages in MIDIHDR */
# Line 221  void MidiInputDeviceMme::MidiInputPortMm Line 221  void MidiInputDeviceMme::MidiInputPortMm
221          CloseMmeMidiPort();          CloseMmeMidiPort();
222          throw MidiInputException("MIDI port connect failed. midiInPrepareHeader error");          throw MidiInputException("MIDI port connect failed. midiInPrepareHeader error");
223      }      }
224                    
225      /* Queue MIDI input buffer */      /* Queue MIDI input buffer */
226      res = midiInAddBuffer(MidiInHandle, &midiHdr, sizeof(MIDIHDR));      res = midiInAddBuffer(MidiInHandle, &midiHdr, sizeof(MIDIHDR));
227      if(res != MMSYSERR_NOERROR) {      if(res != MMSYSERR_NOERROR) {
# Line 229  void MidiInputDeviceMme::MidiInputPortMm Line 229  void MidiInputDeviceMme::MidiInputPortMm
229          throw MidiInputException("MIDI port connect failed. midiInAddBuffer error");          throw MidiInputException("MIDI port connect failed. midiInAddBuffer error");
230      }      }
231    
232    
233      res = midiInStart(MidiInHandle);      res = midiInStart(MidiInHandle);
234      if(res != MMSYSERR_NOERROR) {      if(res != MMSYSERR_NOERROR) {
235          CloseMmeMidiPort();          CloseMmeMidiPort();
# Line 237  void MidiInputDeviceMme::MidiInputPortMm Line 237  void MidiInputDeviceMme::MidiInputPortMm
237      }      }
238    
239  }  }
240            
241  void MidiInputDeviceMme::MidiInputPortMme::MmeCallbackDispatcher(HMIDIIN handle, UINT uMsg, DWORD dwParam1, DWORD dwParam2) {  void MidiInputDeviceMme::MidiInputPortMme::MmeCallbackDispatcher(HMIDIIN handle, UINT uMsg, DWORD dwParam1, DWORD dwParam2) {
242    
243      unsigned char *DataPtr; // pointer to SysEx data      unsigned char *DataPtr; // pointer to SysEx data
# Line 247  void MidiInputDeviceMme::MidiInputPortMm Line 247  void MidiInputDeviceMme::MidiInputPortMm
247    
248      switch(uMsg) {      switch(uMsg) {
249          case MIM_DATA:          case MIM_DATA:
250              switch(data[0] & 0xF0) { // status byte              DispatchRaw(data);
   
                 case 0xB0:  
                     if (data[1] == 0)  
                         DispatchBankSelectMsb(data[2], data[0] & 0x0F);  
                     else if (data[1] == 32)  
                         DispatchBankSelectLsb(data[2], data[0] & 0x0F);  
                     DispatchControlChange(data[1], data[2], data[0] & 0x0F);  
                     break;  
   
                 case 0xD0:  
                         DispatchControlChange(128, data[1], data[0] & 0x0F);  
                     break;  
   
                 case 0xE0:  
                         DispatchPitchbend(data[1], data[0] & 0x0F);  
                     break;  
   
                 case 0x90:  
                     if (data[1] < 0x80) {  
                         if (data[2] > 0){  
                             DispatchNoteOn(data[1], data[2], data[0] & 0x0F);  
                         }else{  
                             DispatchNoteOff(data[1], data[2], data[0] & 0x0F);  
                         }  
                     }  
                     break;  
   
                 case 0x80:  
                     if (data[1] < 0x80) {  
                         DispatchNoteOff(data[1], data[2], data[0] & 0x0F);  
                     }  
                     break;  
   
                 case 0xC0:  
                     if (data[1] < 0x80) {  
                         DispatchProgramChange(data[1], data[0] & 0x0F);  
                     }  
                     break;  
             }  
                   
251              break;              break;
252                            
253          case MIM_LONGDATA:          case MIM_LONGDATA:
254              if(!ExitFlag) {              if(!ExitFlag) {
255                  LPMIDIHDR lpMIDIHeader = (LPMIDIHDR)dwParam1;                  LPMIDIHDR lpMIDIHeader = (LPMIDIHDR)dwParam1;
# Line 316  void MidiInputDeviceMme::MidiInputPortMm Line 276  void MidiInputDeviceMme::MidiInputPortMm
276    
277                  if(SysExMsgComplete) DispatchSysex(SysExBuf, SysExOffset);                  if(SysExMsgComplete) DispatchSysex(SysExBuf, SysExOffset);
278    
279                  /* Queue the MIDIHDR for more input, only if ExitFlag was not set otherwise we risk an infinite loop                    /* Queue the MIDIHDR for more input, only if ExitFlag was not set otherwise we risk an infinite loop
280                  because when we call midiInReset() below, Windows will send a final  MIM_LONGDATA message to that callback.                  because when we call midiInReset() below, Windows will send a final  MIM_LONGDATA message to that callback.
281      */      */
282                  midiInAddBuffer(MidiInHandle, lpMIDIHeader, sizeof(MIDIHDR));                                    midiInAddBuffer(MidiInHandle, lpMIDIHeader, sizeof(MIDIHDR));
283              }                        }
284              break;              break;
285      }      }
286    
# Line 374  void MidiInputDeviceMme::MidiInputPortMm Line 334  void MidiInputDeviceMme::MidiInputPortMm
334      }      }
335    
336      String MidiInputDeviceMme::Version() {      String MidiInputDeviceMme::Version() {
337          String s = "$Revision: 1.3 $";          String s = "$Revision: 1.4 $";
338          return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword          return s.substr(11, s.size() - 13); // cut dollar signs, spaces and CVS macro keyword
339      }      }
340    
341            
342            
343  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.1715  
changed lines
  Added in v.1887

  ViewVC Help
Powered by ViewVC