/[svn]/linuxsampler/trunk/src/engines/EngineChannel.h
ViewVC logotype

Annotation of /linuxsampler/trunk/src/engines/EngineChannel.h

Parent Directory Parent Directory | Revision Log Revision Log


Revision 973 - (hide annotations) (download) (as text)
Fri Dec 15 21:40:27 2006 UTC (17 years, 4 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 10015 byte(s)
* revised and extended MIDI instrument mapping feature to allow managing
  arbitrary amount of maps and assigning each sampler channel individually
  to one map (this commit batch includes LSCP spec document update and
  respective implementation on LS side)

1 schoenebeck 889 /***************************************************************************
2     * *
3     * Copyright (C) 2005, 2006 Christian Schoenebeck *
4     * *
5     * This program is free software; you can redistribute it and/or modify *
6     * it under the terms of the GNU General Public License as published by *
7     * the Free Software Foundation; either version 2 of the License, or *
8     * (at your option) any later version. *
9     * *
10     * This program is distributed in the hope that it will be useful, *
11     * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13     * GNU General Public License for more details. *
14     * *
15     * You should have received a copy of the GNU General Public License *
16     * along with this program; if not, write to the Free Software *
17     * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
18     * MA 02111-1307 USA *
19     ***************************************************************************/
20    
21     #ifndef __LS_ENGINECHANNEL_H__
22     #define __LS_ENGINECHANNEL_H__
23    
24     #include "../drivers/audio/AudioOutputDevice.h"
25     #include "../drivers/midi/midi.h"
26     #include "../drivers/midi/MidiInputDevice.h"
27     #include "../drivers/midi/MidiInputPort.h"
28     #include "Engine.h"
29    
30     namespace LinuxSampler {
31    
32     // just symbol prototyping
33     class AudioOutputDevice;
34     class MidiInputPort;
35    
36     /** @brief Channel Interface for LinuxSampler Sampler Engines
37     *
38     * Every sampler engine can be used on several sampler channels and
39     * usually the same Engine instance is used on multiple sampler
40     * channels. For this every sampler engine must also implement a class
41     * which handles all channel dependant parameters and channel
42     * dependant execution code.
43     *
44     * This abstract base interface class defines all mandatory methods
45     * which have to be implemented by all engine channel implementations.
46     */
47     class EngineChannel {
48     public:
49    
50     /////////////////////////////////////////////////////////////////
51     // abstract methods
52     // (these have to be implemented by the descendant)
53    
54     virtual void PrepareLoadInstrument(const char* FileName, uint Instrument) = 0;
55     virtual void LoadInstrument() = 0;
56     virtual void Reset() = 0;
57     virtual void SendNoteOn(uint8_t Key, uint8_t Velocity) = 0;
58 schoenebeck 906 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) = 0;
59 schoenebeck 889 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity) = 0;
60 schoenebeck 906 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) = 0;
61 schoenebeck 889 virtual void SendPitchbend(int Pitch) = 0;
62 schoenebeck 906 virtual void SendPitchbend(int Pitch, int32_t FragmentPos) = 0;
63 schoenebeck 889 virtual void SendControlChange(uint8_t Controller, uint8_t Value) = 0;
64 schoenebeck 906 virtual void SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos) = 0;
65 schoenebeck 889 virtual bool StatusChanged(bool bNewStatus = false) = 0;
66     virtual float Volume() = 0;
67     virtual void Volume(float f) = 0;
68     virtual uint Channels() = 0;
69     virtual void Connect(AudioOutputDevice* pAudioOut) = 0;
70     virtual void DisconnectAudioOutputDevice() = 0;
71     virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) = 0;
72     virtual int OutputChannel(uint EngineAudioChannel) = 0;
73     virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) = 0;
74     virtual void DisconnectMidiInputPort() = 0;
75     virtual MidiInputPort* GetMidiInputPort() = 0;
76     virtual midi_chan_t MidiChannel() = 0;
77     virtual String InstrumentFileName() = 0;
78     virtual String InstrumentName() = 0;
79     virtual int InstrumentIndex() = 0;
80     virtual int InstrumentStatus() = 0;
81     virtual Engine* GetEngine() = 0;
82     virtual String EngineName() = 0;
83    
84     /**
85     * Sets the mute state of this channel.
86     *
87     * @param state - specifies the mute state of this sampler channel.
88     * @throws Exception - if state does not contain valid
89     * value.
90     */
91     void SetMute(int state) throw (Exception);
92    
93     /**
94     * Determines whether this channel is muted.
95     *
96     * @returns 1 if the channel is muted, 0 if the channel is not muted
97     * and -1 if the channel is muted because of presence of at least
98     * one solo channel.
99     */
100     int GetMute();
101    
102     /**
103     * Sets the solo state of this channel.
104     *
105     * @param solo - specifies whether this is a solo channel.
106     */
107     void SetSolo(bool solo);
108    
109     /**
110     * Determines whether this is a solo channel.
111     *
112     * @returns true if this is a solo channel, false otherwise.
113     */
114     bool GetSolo();
115    
116 schoenebeck 947 /**
117     * Returns current MIDI program (change) number of this
118     * EngineChannel.
119     */
120     uint8_t GetMidiProgram();
121    
122     /**
123     * Change EngineChannel's MIDI program.
124     */
125     void SetMidiProgram(uint8_t Program);
126    
127     /**
128     * Returns current MIDI bank MSB (coarse) number of this
129     * EngineChannel.
130     */
131     uint8_t GetMidiBankMsb();
132    
133     /**
134     * Change current MIDI bank MSB (coarse) number of this
135     * EngineChannel.
136     */
137     void SetMidiBankMsb(uint8_t BankMSB);
138    
139     /**
140     * Returns current MIDI bank LSB (fine) number of this
141     * EngineChannel.
142     */
143     uint8_t GetMidiBankLsb();
144    
145     /**
146     * Change current MIDI bank LSB (fine) number of this
147     * EngineChannel.
148     */
149     void SetMidiBankLsb(uint8_t BankLSB);
150    
151 schoenebeck 973 /**
152     * Returns true if this EngineChannel is using no MIDI
153     * instrument map at all, that is if it will ignore all MIDI
154     * program change messages.
155     *
156     * @see UsesDefaultMidiInstrumentMap()
157     * @see GetMidiInstrumentMap()
158     */
159     bool UsesNoMidiInstrumentMap();
160    
161     /**
162     * Returns true if this EngineChannel is using the default MIDI
163     * instrument map for handling MIDI program changes.
164     *
165     * @see UsesNoMidiInstrumentMap()
166     * @see GetMidiInstrumentMap()
167     */
168     bool UsesDefaultMidiInstrumentMap();
169    
170     /**
171     * Returns ID of the MIDI instrument map currently used by this
172     * EngineChannel to handle MIDI program changes. You should
173     * always call @c UsesNoMidiInstrumentMap() and
174     * @c UsesDefaultMidiInstrumentMap() before calling this method
175     * to check if this EngineChannel is probably using the default
176     * map or no map at all, because in these two particular cases
177     * this method would throw an exception!
178     *
179     * @throws Exception - if EngineChannel is set to no map at all
180     * or is set to the default map
181     * @see UsesNoMidiInstrumentMap()
182     * @see UsesDefaultMidiInstrumentMap()
183     */
184     int GetMidiInstrumentMap() throw (Exception);
185    
186     /**
187     * Let this EngineChannel use no MIDI instrument map at all,
188     * that is to let it ignore all MIDI program change messages.
189     *
190     * @see SetMidiInstrumentMapToDefault()
191     * @see SetMidiInstrumentMap()
192     */
193     void SetMidiInstrumentMapToNone();
194    
195     /**
196     * Let this EngineChannel use the default MIDI instrument map to
197     * handle MIDI program changes.
198     *
199     * @see SetMidiInstrumentMapToNone()
200     * @see SetMidiInstrumentMap()
201     */
202     void SetMidiInstrumentMapToDefault();
203    
204     /**
205     * Set a specific MIDI instrument map this EngineChannel should
206     * use to handle MIDI program changes.
207     *
208     * @see SetMidiInstrumentMapToNone()
209     * @see SetMidiInstrumentMapToDefault()
210     *
211     * @throws Exception - in case given map does not exist
212     */
213     void SetMidiInstrumentMap(int MidiMap) throw (Exception);
214    
215 schoenebeck 889 int iSamplerChannelIndex; ///< FIXME: nasty hack, might be removed (should be 'virtual EngineChannel* EngineChannel() = 0;', but due to cyclic dependencies only a void* solution would be possible ATM)
216    
217     protected:
218 schoenebeck 906 EngineChannel();
219 schoenebeck 889 virtual ~EngineChannel() {}; // MUST only be destroyed by EngineChannelFactory
220     friend class EngineChannelFactory;
221    
222     private:
223 schoenebeck 947 int iMute;
224     bool bSolo;
225     uint8_t uiMidiProgram;
226     uint8_t uiMidiBankMsb;
227     uint8_t uiMidiBankLsb;
228 schoenebeck 973 bool bMidiBankMsbReceived;
229     bool bMidiBankLsbReceived;
230     bool bProgramChangeReceived;
231     int iMidiInstrumentMap;
232 schoenebeck 889 };
233    
234     } // namespace LinuxSampler
235    
236     #endif // __LS_ENGINECHANNEL_H__

  ViewVC Help
Powered by ViewVC