/[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 221 by schoenebeck, Fri Aug 20 17:25:19 2004 UTC revision 476 by schoenebeck, Fri Mar 18 18:16:27 2005 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 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 23  Line 24 
24  #include "MidiInputDeviceAlsa.h"  #include "MidiInputDeviceAlsa.h"
25  #include "MidiInputDeviceFactory.h"  #include "MidiInputDeviceFactory.h"
26    
27  namespace LinuxSampler {  #define perm_ok(pinfo,bits) ((snd_seq_port_info_get_capability(pinfo) & (bits)) == (bits))
   
     REGISTER_MIDI_INPUT_DRIVER(MidiInputDeviceAlsa);  
   
     /* Common parameters */  
     REGISTER_MIDI_INPUT_DRIVER_PARAMETER(MidiInputDeviceAlsa, ParameterActive);  
     REGISTER_MIDI_INPUT_DRIVER_PARAMETER(MidiInputDeviceAlsa, ParameterPorts);  
   
28    
29    namespace LinuxSampler {
30    
31  // *************** ParameterName ***************  // *************** ParameterName ***************
32  // *  // *
# Line 68  namespace LinuxSampler { Line 63  namespace LinuxSampler {
63      }      }
64    
65      std::vector<String> MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqBindings::PossibilitiesAsString() {      std::vector<String> MidiInputDeviceAlsa::MidiInputPortAlsa::ParameterAlsaSeqBindings::PossibilitiesAsString() {
66          return std::vector<String>(); //TODO          std::vector<String> res;
67            snd_seq_client_info_t* cinfo;
68            snd_seq_port_info_t* pinfo;
69    
70            snd_seq_client_info_alloca(&cinfo);
71            snd_seq_port_info_alloca(&pinfo);
72            snd_seq_client_info_set_client(cinfo, -1);
73            while (snd_seq_query_next_client(pPort->pDevice->hAlsaSeq, cinfo) >= 0) {
74                snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
75                snd_seq_port_info_set_port(pinfo, -1);
76                while (snd_seq_query_next_port(pPort->pDevice->hAlsaSeq, pinfo) >= 0) {
77                    if (perm_ok(pinfo, SND_SEQ_PORT_CAP_READ|SND_SEQ_PORT_CAP_SUBS_READ)) {
78                            String seq_id = ToString(snd_seq_client_info_get_client(cinfo)) + ":" +
79                                            ToString(snd_seq_port_info_get_port(pinfo));
80                            res.push_back(seq_id);
81                    }
82                }
83            }
84    
85            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 (LinuxSamplerException) {
# Line 78  namespace LinuxSampler { Line 92  namespace LinuxSampler {
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 93  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 131  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) : MidiInputDevice(Parameters), 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 172  namespace LinuxSampler { Line 212  namespace LinuxSampler {
212      }      }
213    
214      String MidiInputDeviceAlsa::Version() {      String MidiInputDeviceAlsa::Version() {
215              String s = "$Revision: 1.9 $";              String s = "$Revision: 1.14 $";
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 214  namespace LinuxSampler { Line 254  namespace LinuxSampler {
254                          case SND_SEQ_EVENT_NOTEOFF:                          case SND_SEQ_EVENT_NOTEOFF:
255                              pMidiInputPort->DispatchNoteOff(ev->data.note.note, ev->data.note.velocity, ev->data.control.channel);                              pMidiInputPort->DispatchNoteOff(ev->data.note.note, ev->data.note.velocity, ev->data.control.channel);
256                              break;                              break;
257    
258                            case SND_SEQ_EVENT_SYSEX:
259                                pMidiInputPort->DispatchSysex(ev->data.ext.ptr, ev->data.ext.len);
260                                break;
261                      }                      }
262                      snd_seq_free_event(ev);                      snd_seq_free_event(ev);
263                  } while (snd_seq_event_input_pending(hAlsaSeq, 0) > 0);                  } while (snd_seq_event_input_pending(hAlsaSeq, 0) > 0);

Legend:
Removed from v.221  
changed lines
  Added in v.476

  ViewVC Help
Powered by ViewVC