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

Annotation of /linuxsampler/trunk/src/drivers/midi/MidiInputDeviceAlsa.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1296 - (hide annotations) (download) (as text)
Wed Aug 15 17:43:34 2007 UTC (16 years, 8 months ago) by iliev
File MIME type: text/x-c++hdr
File size: 5789 byte(s)
* bugfix: The previous bindings were not been disconnected when
  altering the ALSA_SEQ_BINDINGS parameter.
* Introduced a NONE keyword for unsubscribing from all bindings
  (e.g. SET MIDI_INPUT_PORT_PARAMETER 0 0 ALSA_SEQ_BINDINGS=NONE).

1 schoenebeck 201 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 schoenebeck 880 * Copyright (C) 2005, 2006 Christian Schoenebeck *
7 schoenebeck 201 * *
8     * 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 *
10     * the Free Software Foundation; either version 2 of the License, or *
11     * (at your option) any later version. *
12     * *
13     * This program is distributed in the hope that it will be useful, *
14     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
15     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
16     * GNU General Public License for more details. *
17     * *
18     * You should have received a copy of the GNU General Public License *
19     * along with this program; if not, write to the Free Software *
20     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
21     * MA 02111-1307 USA *
22     ***************************************************************************/
23    
24     #ifndef __LS_MIDIINPUTDEVICEALSA_H__
25     #define __LS_MIDIINPUTDEVICEALSA_H__
26    
27     #include <alsa/asoundlib.h>
28    
29     #include "../../common/global.h"
30     #include "../../common/Thread.h"
31     #include "MidiInputDevice.h"
32    
33     namespace LinuxSampler {
34    
35     /** ALSA MIDI input driver
36     *
37     * Implements MIDI input for the Advanced Linux Sound Architecture
38     * (ALSA).
39     */
40     class MidiInputDeviceAlsa : public MidiInputDevice, public Thread {
41     public:
42 schoenebeck 221
43     /**
44     * MIDI Port implementation for the ALSA MIDI input driver.
45     */
46     class MidiInputPortAlsa : public MidiInputPort {
47     public:
48     /** MIDI Port Parameter 'NAME'
49     *
50     * Used to assign an arbitrary name to the MIDI port.
51     */
52     class ParameterName : public MidiInputPort::ParameterName {
53     public:
54 schoenebeck 880 ParameterName(MidiInputPort* pPort) throw (Exception);
55     virtual void OnSetValue(String s) throw (Exception);
56 schoenebeck 221 };
57    
58     /** MIDI Port Parameter 'ALSA_SEQ_BINDINGS'
59     *
60     * Used to connect to other Alsa sequencer clients.
61     */
62     class ParameterAlsaSeqBindings : public DeviceRuntimeParameterStrings {
63     public:
64     ParameterAlsaSeqBindings(MidiInputPortAlsa* pPort);
65     virtual String Description();
66     virtual bool Fix();
67     virtual std::vector<String> PossibilitiesAsString();
68 schoenebeck 880 virtual void OnSetValue(std::vector<String> vS) throw (Exception);
69 schoenebeck 221 protected:
70     MidiInputPortAlsa* pPort;
71     };
72    
73 schoenebeck 476 /** MIDI Port Parameter 'ALSA_SEQ_ID'
74     *
75     * Reflects the ALSA sequencer ID of this MIDI port,
76     * e.g. "128:0".
77     */
78     class ParameterAlsaSeqId : public DeviceRuntimeParameterString {
79     public:
80     ParameterAlsaSeqId(MidiInputPortAlsa* pPort);
81     virtual String Description();
82     virtual bool Fix();
83     virtual std::vector<String> PossibilitiesAsString();
84     virtual void OnSetValue(String s);
85     };
86    
87 schoenebeck 221 void ConnectToAlsaMidiSource(const char* MidiSource);
88     protected:
89 iliev 1296 std::vector<snd_seq_port_subscribe_t*> subscriptions;
90    
91 schoenebeck 221 MidiInputPortAlsa(MidiInputDeviceAlsa* pDevice) throw (MidiInputException);
92     ~MidiInputPortAlsa();
93     friend class MidiInputDeviceAlsa;
94     private:
95     MidiInputDeviceAlsa* pDevice;
96 schoenebeck 277
97     friend class ParameterName;
98     friend class ParameterAlsaSeqBindings;
99 schoenebeck 221 };
100    
101 schoenebeck 551 MidiInputDeviceAlsa(std::map<String,DeviceCreationParameter*> Parameters, void* pSampler);
102 schoenebeck 201 ~MidiInputDeviceAlsa();
103    
104     // derived abstract methods from class 'MidiInputDevice'
105     void Listen();
106     void StopListen();
107 schoenebeck 221 virtual String Driver();
108     static String Name();
109     static String Description();
110     static String Version();
111 schoenebeck 201
112 schoenebeck 221 MidiInputPortAlsa* CreateMidiPort();
113 schoenebeck 201 protected:
114     int Main(); ///< Implementation of virtual method from class Thread
115     private:
116     snd_seq_t* hAlsaSeq;
117     int hAlsaSeqClient; ///< Alsa Sequencer client ID
118 schoenebeck 277
119     friend class MidiInputPortAlsa;
120     friend class MidiInputPortAlsa::ParameterName;
121     friend class MidiInputPortAlsa::ParameterAlsaSeqBindings;
122 schoenebeck 201 };
123     }
124    
125     #endif // __LS_MIDIINPUTDEVICEALSA_H__

  ViewVC Help
Powered by ViewVC