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

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

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

revision 244 by schoenebeck, Fri Sep 17 01:01:11 2004 UTC revision 903 by persson, Sat Jul 22 14:22:53 2006 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, 2006 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 27  Line 28 
28    
29  namespace LinuxSampler {  namespace LinuxSampler {
30    
     REGISTER_MIDI_INPUT_DRIVER(MidiInputDeviceAlsa);  
   
     /* Common parameters */  
     REGISTER_MIDI_INPUT_DRIVER_PARAMETER(MidiInputDeviceAlsa, ParameterActive);  
     REGISTER_MIDI_INPUT_DRIVER_PARAMETER(MidiInputDeviceAlsa, ParameterPorts);  
   
   
   
31  // *************** ParameterName ***************  // *************** ParameterName ***************
32  // *  // *
33    
34      MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterName::ParameterName(MidiInputPort* pPort) throw (LinuxSamplerException) : MidiInputPort::ParameterName(pPort, "Port " + ToString(pPort->GetPortNumber())) {      MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterName::ParameterName(MidiInputPort* pPort) throw (Exception) : MidiInputPort::ParameterName(pPort, "Port " + ToString(pPort->GetPortNumber())) {
35          OnSetValue(ValueAsString()); // initialize port name          OnSetValue(ValueAsString()); // initialize port name
36      }      }
37    
38      void MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterName::OnSetValue(String s) throw (LinuxSamplerException) {      void MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterName::OnSetValue(String s) throw (Exception) {
39          if (s.size() > 16) throw LinuxSamplerException("Name too long for ALSA MIDI input port (max. 16 characters)");          if (s.size() > 16) throw Exception("Name too long for ALSA MIDI input port (max. 16 characters)");
40          snd_seq_port_info_t* hInfo;          snd_seq_port_info_t* hInfo;
41          snd_seq_port_info_malloc(&hInfo);          snd_seq_port_info_malloc(&hInfo);
42          snd_seq_get_port_info(((MidiInputDeviceAlsa*)pPort->GetDevice())->hAlsaSeq, pPort->GetPortNumber(), hInfo);          snd_seq_get_port_info(((MidiInputDeviceAlsa*)pPort->GetDevice())->hAlsaSeq, pPort->GetPortNumber(), hInfo);
# Line 92  namespace LinuxSampler { Line 85  namespace LinuxSampler {
85          return res;          return res;
86      }      }
87    
88      void MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqBindings::OnSetValue(std::vector<String> vS) throw (LinuxSamplerException) {      void MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqBindings::OnSetValue(std::vector<String> vS) throw (Exception) {
89          std::vector<String>::iterator iter = vS.begin();          std::vector<String>::iterator iter = vS.begin();
90          for (; iter != vS.end(); iter++) pPort->ConnectToAlsaMidiSource((*iter).c_str());          for (; iter != vS.end(); iter++) pPort->ConnectToAlsaMidiSource((*iter).c_str());
91      }      }
92    
93    
94    
95    // *************** ParameterAlsaSeqId ***************
96    // *
97    
98        MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqId::ParameterAlsaSeqId(MidiInputPortAlsa* pPort)
99            : DeviceRuntimeParameterString(ToString(pPort->pDevice->hAlsaSeqClient) + ":" + ToString(pPort->portNumber)) {
100        }
101    
102        String MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqId::Description() {
103            return "ALSA Sequencer ID";
104        }
105    
106        bool MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqId::Fix() {
107            return true;
108        }
109    
110        std::vector<String> MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqId::PossibilitiesAsString() {
111            return std::vector<String>(); // nothing
112        }
113    
114        void MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqId::OnSetValue(String s) {
115            // not possible as parameter is 'fix'
116        }
117    
118    
119    
120  // *************** MidiInputPortAlsa ***************  // *************** MidiInputPortAlsa ***************
121  // *  // *
122    
# Line 114  namespace LinuxSampler { Line 132  namespace LinuxSampler {
132    
133          Parameters["NAME"]              = new ParameterName(this);          Parameters["NAME"]              = new ParameterName(this);
134          Parameters["ALSA_SEQ_BINDINGS"] = new ParameterAlsaSeqBindings(this);          Parameters["ALSA_SEQ_BINDINGS"] = new ParameterAlsaSeqBindings(this);
135            Parameters["ALSA_SEQ_ID"]       = new ParameterAlsaSeqId(this);
136      }      }
137    
138      MidiInputDeviceAlsa::MidiInputPortAlsa::~MidiInputPortAlsa() {      MidiInputDeviceAlsa::MidiInputPortAlsa::~MidiInputPortAlsa() {
# Line 152  namespace LinuxSampler { Line 171  namespace LinuxSampler {
171  // *************** MidiInputDeviceAlsa ***************  // *************** MidiInputDeviceAlsa ***************
172  // *  // *
173    
174      MidiInputDeviceAlsa::MidiInputDeviceAlsa(std::map<String,DeviceCreationParameter*> Parameters) : MidiInputDevice(Parameters), Thread(true, 1, -1) {      MidiInputDeviceAlsa::MidiInputDeviceAlsa(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler) : MidiInputDevice(Parameters, pSampler), Thread(true, true, 1, -1) {
175          if (snd_seq_open(&hAlsaSeq, "default", SND_SEQ_OPEN_INPUT, 0) < 0) {          if (snd_seq_open(&hAlsaSeq, "default", SND_SEQ_OPEN_INPUT, 0) < 0) {
176              throw MidiInputException("Error opening ALSA sequencer");              throw MidiInputException("Error opening ALSA sequencer");
177          }          }
# Line 193  namespace LinuxSampler { Line 212  namespace LinuxSampler {
212      }      }
213    
214      String MidiInputDeviceAlsa::Version() {      String MidiInputDeviceAlsa::Version() {
215              String s = "$Revision: 1.11 $";              String s = "$Revision: 1.17 $";
216              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
217      }      }
218    
# Line 217  namespace LinuxSampler { Line 236  namespace LinuxSampler {
236                              pMidiInputPort->DispatchControlChange(ev->data.control.param, ev->data.control.value, ev->data.control.channel);                              pMidiInputPort->DispatchControlChange(ev->data.control.param, ev->data.control.value, ev->data.control.channel);
237                              break;                              break;
238    
239                            case SND_SEQ_EVENT_CHANPRESS:
240                                pMidiInputPort->DispatchControlChange(128, ev->data.control.value, ev->data.control.channel);
241                                break;
242    
243                          case SND_SEQ_EVENT_PITCHBEND:                          case SND_SEQ_EVENT_PITCHBEND:
                           //  fprintf(stderr, "Pitchbender event on Channel %2d: %5d   \n",  
                           //          ev->data.control.channel, ev->data.control.value);  
244                              pMidiInputPort->DispatchPitchbend(ev->data.control.value, ev->data.control.channel);                              pMidiInputPort->DispatchPitchbend(ev->data.control.value, ev->data.control.channel);
245                              break;                              break;
246    
# Line 239  namespace LinuxSampler { Line 260  namespace LinuxSampler {
260                          case SND_SEQ_EVENT_SYSEX:                          case SND_SEQ_EVENT_SYSEX:
261                              pMidiInputPort->DispatchSysex(ev->data.ext.ptr, ev->data.ext.len);                              pMidiInputPort->DispatchSysex(ev->data.ext.ptr, ev->data.ext.len);
262                              break;                              break;
263    
264                            case SND_SEQ_EVENT_PGMCHANGE:
265                                pMidiInputPort->DispatchProgramChange(ev->data.control.value, ev->data.control.channel);
266                                break;
267                      }                      }
268                      snd_seq_free_event(ev);                      snd_seq_free_event(ev);
269                  } while (snd_seq_event_input_pending(hAlsaSeq, 0) > 0);                  } while (snd_seq_event_input_pending(hAlsaSeq, 0) > 0);

Legend:
Removed from v.244  
changed lines
  Added in v.903

  ViewVC Help
Powered by ViewVC