/[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 1041 - (hide annotations) (download) (as text)
Wed Feb 7 17:45:19 2007 UTC (17 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 11418 byte(s)
* handle MIDI coarse tuning messages (MIDI RPN #0 MSB, #2 LSB),
  currently lazy implementation, transpose value is simply added on the
  note on/off values instead only at the mandatory places, thus when
  altering transpose while playing, voices can unintendedly survive

1 schoenebeck 889 /***************************************************************************
2     * *
3 schoenebeck 1041 * Copyright (C) 2005 - 2007 Christian Schoenebeck *
4 schoenebeck 889 * *
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 schoenebeck 1001 #include "FxSend.h"
30 schoenebeck 889
31     namespace LinuxSampler {
32    
33     // just symbol prototyping
34     class AudioOutputDevice;
35     class MidiInputPort;
36 schoenebeck 1001 class FxSend;
37 schoenebeck 889
38 schoenebeck 1001
39 schoenebeck 889 /** @brief Channel Interface for LinuxSampler Sampler Engines
40     *
41     * Every sampler engine can be used on several sampler channels and
42     * usually the same Engine instance is used on multiple sampler
43     * channels. For this every sampler engine must also implement a class
44     * which handles all channel dependant parameters and channel
45     * dependant execution code.
46     *
47     * This abstract base interface class defines all mandatory methods
48     * which have to be implemented by all engine channel implementations.
49     */
50     class EngineChannel {
51     public:
52    
53     /////////////////////////////////////////////////////////////////
54     // abstract methods
55     // (these have to be implemented by the descendant)
56    
57     virtual void PrepareLoadInstrument(const char* FileName, uint Instrument) = 0;
58     virtual void LoadInstrument() = 0;
59     virtual void Reset() = 0;
60     virtual void SendNoteOn(uint8_t Key, uint8_t Velocity) = 0;
61 schoenebeck 906 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) = 0;
62 schoenebeck 889 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity) = 0;
63 schoenebeck 906 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos) = 0;
64 schoenebeck 889 virtual void SendPitchbend(int Pitch) = 0;
65 schoenebeck 906 virtual void SendPitchbend(int Pitch, int32_t FragmentPos) = 0;
66 schoenebeck 889 virtual void SendControlChange(uint8_t Controller, uint8_t Value) = 0;
67 schoenebeck 906 virtual void SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos) = 0;
68 schoenebeck 889 virtual bool StatusChanged(bool bNewStatus = false) = 0;
69     virtual float Volume() = 0;
70     virtual void Volume(float f) = 0;
71     virtual uint Channels() = 0;
72     virtual void Connect(AudioOutputDevice* pAudioOut) = 0;
73     virtual void DisconnectAudioOutputDevice() = 0;
74 schoenebeck 1001 virtual AudioOutputDevice* GetAudioOutputDevice() = 0;
75 schoenebeck 889 virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) = 0;
76     virtual int OutputChannel(uint EngineAudioChannel) = 0;
77     virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) = 0;
78     virtual void DisconnectMidiInputPort() = 0;
79     virtual MidiInputPort* GetMidiInputPort() = 0;
80     virtual midi_chan_t MidiChannel() = 0;
81     virtual String InstrumentFileName() = 0;
82     virtual String InstrumentName() = 0;
83     virtual int InstrumentIndex() = 0;
84     virtual int InstrumentStatus() = 0;
85     virtual Engine* GetEngine() = 0;
86     virtual String EngineName() = 0;
87 schoenebeck 1001 virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception) = 0;
88     virtual FxSend* GetFxSend(uint FxSendIndex) = 0;
89     virtual uint GetFxSendCount() = 0;
90     virtual void RemoveFxSend(FxSend* pFxSend) = 0;
91 schoenebeck 889
92 schoenebeck 1001
93     /////////////////////////////////////////////////////////////////
94     // normal methods
95     // (usually not to be overridden by descendant)
96    
97 schoenebeck 889 /**
98     * Sets the mute state of this channel.
99     *
100     * @param state - specifies the mute state of this sampler channel.
101     * @throws Exception - if state does not contain valid
102     * value.
103     */
104     void SetMute(int state) throw (Exception);
105    
106     /**
107     * Determines whether this channel is muted.
108     *
109     * @returns 1 if the channel is muted, 0 if the channel is not muted
110     * and -1 if the channel is muted because of presence of at least
111     * one solo channel.
112     */
113     int GetMute();
114    
115     /**
116     * Sets the solo state of this channel.
117     *
118     * @param solo - specifies whether this is a solo channel.
119     */
120     void SetSolo(bool solo);
121    
122     /**
123     * Determines whether this is a solo channel.
124     *
125     * @returns true if this is a solo channel, false otherwise.
126     */
127     bool GetSolo();
128    
129 schoenebeck 947 /**
130     * Returns current MIDI program (change) number of this
131     * EngineChannel.
132     */
133     uint8_t GetMidiProgram();
134    
135     /**
136     * Change EngineChannel's MIDI program.
137     */
138     void SetMidiProgram(uint8_t Program);
139    
140     /**
141     * Returns current MIDI bank MSB (coarse) number of this
142     * EngineChannel.
143     */
144     uint8_t GetMidiBankMsb();
145    
146     /**
147     * Change current MIDI bank MSB (coarse) number of this
148     * EngineChannel.
149     */
150     void SetMidiBankMsb(uint8_t BankMSB);
151    
152     /**
153     * Returns current MIDI bank LSB (fine) number of this
154     * EngineChannel.
155     */
156     uint8_t GetMidiBankLsb();
157    
158     /**
159     * Change current MIDI bank LSB (fine) number of this
160     * EngineChannel.
161     */
162     void SetMidiBankLsb(uint8_t BankLSB);
163    
164 schoenebeck 973 /**
165     * Returns true if this EngineChannel is using no MIDI
166     * instrument map at all, that is if it will ignore all MIDI
167     * program change messages.
168     *
169     * @see UsesDefaultMidiInstrumentMap()
170     * @see GetMidiInstrumentMap()
171     */
172     bool UsesNoMidiInstrumentMap();
173    
174     /**
175     * Returns true if this EngineChannel is using the default MIDI
176     * instrument map for handling MIDI program changes.
177     *
178     * @see UsesNoMidiInstrumentMap()
179     * @see GetMidiInstrumentMap()
180     */
181     bool UsesDefaultMidiInstrumentMap();
182    
183     /**
184     * Returns ID of the MIDI instrument map currently used by this
185     * EngineChannel to handle MIDI program changes. You should
186     * always call @c UsesNoMidiInstrumentMap() and
187     * @c UsesDefaultMidiInstrumentMap() before calling this method
188     * to check if this EngineChannel is probably using the default
189     * map or no map at all, because in these two particular cases
190     * this method would throw an exception!
191     *
192     * @throws Exception - if EngineChannel is set to no map at all
193     * or is set to the default map
194     * @see UsesNoMidiInstrumentMap()
195     * @see UsesDefaultMidiInstrumentMap()
196     */
197     int GetMidiInstrumentMap() throw (Exception);
198    
199     /**
200     * Let this EngineChannel use no MIDI instrument map at all,
201     * that is to let it ignore all MIDI program change messages.
202     *
203     * @see SetMidiInstrumentMapToDefault()
204     * @see SetMidiInstrumentMap()
205     */
206     void SetMidiInstrumentMapToNone();
207    
208     /**
209     * Let this EngineChannel use the default MIDI instrument map to
210     * handle MIDI program changes.
211     *
212     * @see SetMidiInstrumentMapToNone()
213     * @see SetMidiInstrumentMap()
214     */
215     void SetMidiInstrumentMapToDefault();
216    
217     /**
218     * Set a specific MIDI instrument map this EngineChannel should
219     * use to handle MIDI program changes.
220     *
221     * @see SetMidiInstrumentMapToNone()
222     * @see SetMidiInstrumentMapToDefault()
223     *
224     * @throws Exception - in case given map does not exist
225     */
226     void SetMidiInstrumentMap(int MidiMap) throw (Exception);
227    
228 schoenebeck 1041 /**
229     * Set MIDI Registered Parameter Number (RPN) Controller
230     * (upper 8 bits / coarse).
231     */
232     void SetMidiRpnControllerMsb(uint8_t CtrlMSB);
233    
234     /**
235     * Set MIDI Registered Parameter Number (RPN) Controller
236     * (lower 8 bits / fine).
237     */
238     void SetMidiRpnControllerLsb(uint8_t CtrlLSB);
239    
240     /**
241     * Get currently selected MIDI Registered Parameter Number
242     * (RPN) Controller, this method will return the already merged
243     * value (MSB and LSB value).
244     */
245     int GetMidiRpnController();
246    
247 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)
248    
249     protected:
250 schoenebeck 906 EngineChannel();
251 schoenebeck 889 virtual ~EngineChannel() {}; // MUST only be destroyed by EngineChannelFactory
252     friend class EngineChannelFactory;
253    
254     private:
255 schoenebeck 947 int iMute;
256     bool bSolo;
257     uint8_t uiMidiProgram;
258     uint8_t uiMidiBankMsb;
259     uint8_t uiMidiBankLsb;
260 schoenebeck 1041 uint8_t uiMidiRpnMsb; ///< MIDI Registered Parameter Number (upper 8 bits / coarse)
261     uint8_t uiMidiRpnLsb; ///< MIDI Registered Parameter Number (lower 8 bits / fine)
262 schoenebeck 973 bool bMidiBankMsbReceived;
263     bool bMidiBankLsbReceived;
264     bool bProgramChangeReceived;
265     int iMidiInstrumentMap;
266 schoenebeck 889 };
267    
268     } // namespace LinuxSampler
269    
270     #endif // __LS_ENGINECHANNEL_H__

  ViewVC Help
Powered by ViewVC