/[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 3699 - (hide annotations) (download) (as text)
Sat Jan 4 14:07:02 2020 UTC (4 years, 3 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 21929 byte(s)
* Added support for MIDI CC #96 (data increment).

* Added support for MIDI CC #97 (data decrement).

* Bumped version (2.1.1.svn34).

1 schoenebeck 889 /***************************************************************************
2     * *
3 schoenebeck 3687 * Copyright (C) 2005 - 2020 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 iliev 1130 #include "../EventListeners.h"
25 schoenebeck 889 #include "../drivers/audio/AudioOutputDevice.h"
26     #include "../drivers/midi/midi.h"
27     #include "../drivers/midi/MidiInputDevice.h"
28     #include "../drivers/midi/MidiInputPort.h"
29 schoenebeck 1686 #include "../drivers/midi/VirtualMidiDevice.h"
30 schoenebeck 889 #include "Engine.h"
31 schoenebeck 1001 #include "FxSend.h"
32 schoenebeck 889
33     namespace LinuxSampler {
34    
35     // just symbol prototyping
36 iliev 1761 class Sampler;
37     class SamplerChannel;
38 schoenebeck 889 class AudioOutputDevice;
39     class MidiInputPort;
40 schoenebeck 1001 class FxSend;
41 schoenebeck 889
42 schoenebeck 1001
43 schoenebeck 889 /** @brief Channel Interface for LinuxSampler Sampler Engines
44     *
45     * Every sampler engine can be used on several sampler channels and
46     * usually the same Engine instance is used on multiple sampler
47     * channels. For this every sampler engine must also implement a class
48     * which handles all channel dependant parameters and channel
49     * dependant execution code.
50     *
51     * This abstract base interface class defines all mandatory methods
52     * which have to be implemented by all engine channel implementations.
53     */
54     class EngineChannel {
55     public:
56    
57     /////////////////////////////////////////////////////////////////
58     // abstract methods
59     // (these have to be implemented by the descendant)
60    
61 schoenebeck 2500 // general sampler part management
62 schoenebeck 889 virtual void Reset() = 0;
63 persson 2317 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel) = 0;
64     virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel, int32_t FragmentPos) = 0;
65     virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel) = 0;
66     virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel, int32_t FragmentPos) = 0;
67     virtual void SendPitchbend(int Pitch, uint8_t MidiChannel) = 0;
68     virtual void SendPitchbend(int Pitch, uint8_t MidiChannel, int32_t FragmentPos) = 0;
69     virtual void SendControlChange(uint8_t Controller, uint8_t Value, uint8_t MidiChannel) = 0;
70     virtual void SendControlChange(uint8_t Controller, uint8_t Value, uint8_t MidiChannel, int32_t FragmentPos) = 0;
71 persson 1924 virtual void SendProgramChange(uint8_t Program) = 0;
72 schoenebeck 2559 virtual void SendChannelPressure(uint8_t Value, uint8_t MidiChannel) = 0;
73     virtual void SendChannelPressure(uint8_t Value, uint8_t MidiChannel, int32_t FragmentPos) = 0;
74     virtual void SendPolyphonicKeyPressure(uint8_t Key, uint8_t Value, uint8_t MidiChannel) = 0;
75     virtual void SendPolyphonicKeyPressure(uint8_t Key, uint8_t Value, uint8_t MidiChannel, int32_t FragmentPos) = 0;
76 schoenebeck 889 virtual bool StatusChanged(bool bNewStatus = false) = 0;
77     virtual float Volume() = 0;
78     virtual void Volume(float f) = 0;
79 schoenebeck 1723 virtual float Pan() = 0;
80     virtual void Pan(float f) = 0;
81 schoenebeck 889 virtual uint Channels() = 0;
82 schoenebeck 2500
83     // audio driver management
84 schoenebeck 889 virtual void Connect(AudioOutputDevice* pAudioOut) = 0;
85     virtual void DisconnectAudioOutputDevice() = 0;
86 schoenebeck 1001 virtual AudioOutputDevice* GetAudioOutputDevice() = 0;
87 schoenebeck 889 virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel) = 0;
88     virtual int OutputChannel(uint EngineAudioChannel) = 0;
89 schoenebeck 2500
90     // MIDI driver management
91     virtual void Connect(MidiInputPort* pMidiPort) = 0;
92     virtual void Disconnect(MidiInputPort* pMidiPort) = 0;
93     virtual void DisconnectAllMidiInputPorts() = 0;
94     virtual uint GetMidiInputPortCount() = 0;
95     virtual MidiInputPort* GetMidiInputPort(uint index) = 0;
96 schoenebeck 889 virtual midi_chan_t MidiChannel() = 0;
97 schoenebeck 2500 virtual void SetMidiChannel(midi_chan_t MidiChannel) = 0;
98     // (deprecated MIDI driver management methods)
99     virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel) DEPRECATED_API = 0;
100     virtual void DisconnectMidiInputPort() DEPRECATED_API = 0;
101     virtual MidiInputPort* GetMidiInputPort() DEPRECATED_API = 0;
102    
103     // virtual MIDI driver management (i.e. virtual on-screen MIDI keyboards)
104     virtual void Connect(VirtualMidiDevice* pDevice) = 0;
105     virtual void Disconnect(VirtualMidiDevice* pDevice) = 0;
106    
107     // instrument (sound file) management
108     virtual void PrepareLoadInstrument(const char* FileName, uint Instrument) = 0;
109     virtual void LoadInstrument() = 0;
110 schoenebeck 2330 virtual String InstrumentFileName() = 0; ///< Returns the file name of the currently loaded instrument. Equivalent as calling InstrumentFileName(0).
111     virtual String InstrumentFileName(int index);
112 schoenebeck 889 virtual String InstrumentName() = 0;
113     virtual int InstrumentIndex() = 0;
114     virtual int InstrumentStatus() = 0;
115 schoenebeck 2500
116     // sampler format / sampler engine implementation details
117 schoenebeck 889 virtual Engine* GetEngine() = 0;
118     virtual String EngineName() = 0;
119 schoenebeck 2500
120     // effect routing
121 schoenebeck 1001 virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception) = 0;
122     virtual FxSend* GetFxSend(uint FxSendIndex) = 0;
123     virtual uint GetFxSendCount() = 0;
124     virtual void RemoveFxSend(FxSend* pFxSend) = 0;
125 schoenebeck 889
126 schoenebeck 1001
127     /////////////////////////////////////////////////////////////////
128     // normal methods
129     // (usually not to be overridden by descendant)
130    
131 schoenebeck 889 /**
132     * Sets the mute state of this channel.
133     *
134     * @param state - specifies the mute state of this sampler channel.
135     * @throws Exception - if state does not contain valid
136     * value.
137     */
138     void SetMute(int state) throw (Exception);
139    
140     /**
141     * Determines whether this channel is muted.
142     *
143     * @returns 1 if the channel is muted, 0 if the channel is not muted
144     * and -1 if the channel is muted because of presence of at least
145     * one solo channel.
146     */
147     int GetMute();
148    
149     /**
150     * Sets the solo state of this channel.
151     *
152     * @param solo - specifies whether this is a solo channel.
153     */
154     void SetSolo(bool solo);
155    
156     /**
157     * Determines whether this is a solo channel.
158     *
159     * @returns true if this is a solo channel, false otherwise.
160     */
161     bool GetSolo();
162    
163 schoenebeck 947 /**
164     * Returns current MIDI program (change) number of this
165     * EngineChannel.
166     */
167     uint8_t GetMidiProgram();
168    
169     /**
170     * Change EngineChannel's MIDI program.
171     */
172     void SetMidiProgram(uint8_t Program);
173    
174     /**
175     * Returns current MIDI bank MSB (coarse) number of this
176     * EngineChannel.
177     */
178     uint8_t GetMidiBankMsb();
179    
180     /**
181     * Change current MIDI bank MSB (coarse) number of this
182     * EngineChannel.
183     */
184     void SetMidiBankMsb(uint8_t BankMSB);
185    
186     /**
187     * Returns current MIDI bank LSB (fine) number of this
188     * EngineChannel.
189     */
190     uint8_t GetMidiBankLsb();
191    
192     /**
193     * Change current MIDI bank LSB (fine) number of this
194     * EngineChannel.
195     */
196     void SetMidiBankLsb(uint8_t BankLSB);
197    
198 schoenebeck 973 /**
199     * Returns true if this EngineChannel is using no MIDI
200     * instrument map at all, that is if it will ignore all MIDI
201     * program change messages.
202     *
203     * @see UsesDefaultMidiInstrumentMap()
204     * @see GetMidiInstrumentMap()
205     */
206     bool UsesNoMidiInstrumentMap();
207    
208     /**
209     * Returns true if this EngineChannel is using the default MIDI
210     * instrument map for handling MIDI program changes.
211     *
212     * @see UsesNoMidiInstrumentMap()
213     * @see GetMidiInstrumentMap()
214     */
215     bool UsesDefaultMidiInstrumentMap();
216    
217     /**
218     * Returns ID of the MIDI instrument map currently used by this
219     * EngineChannel to handle MIDI program changes. You should
220     * always call @c UsesNoMidiInstrumentMap() and
221     * @c UsesDefaultMidiInstrumentMap() before calling this method
222     * to check if this EngineChannel is probably using the default
223     * map or no map at all, because in these two particular cases
224     * this method would throw an exception!
225     *
226     * @throws Exception - if EngineChannel is set to no map at all
227     * or is set to the default map
228     * @see UsesNoMidiInstrumentMap()
229     * @see UsesDefaultMidiInstrumentMap()
230     */
231     int GetMidiInstrumentMap() throw (Exception);
232    
233     /**
234     * Let this EngineChannel use no MIDI instrument map at all,
235     * that is to let it ignore all MIDI program change messages.
236     *
237     * @see SetMidiInstrumentMapToDefault()
238     * @see SetMidiInstrumentMap()
239     */
240     void SetMidiInstrumentMapToNone();
241    
242     /**
243     * Let this EngineChannel use the default MIDI instrument map to
244     * handle MIDI program changes.
245     *
246     * @see SetMidiInstrumentMapToNone()
247     * @see SetMidiInstrumentMap()
248     */
249     void SetMidiInstrumentMapToDefault();
250    
251     /**
252     * Set a specific MIDI instrument map this EngineChannel should
253     * use to handle MIDI program changes.
254     *
255     * @see SetMidiInstrumentMapToNone()
256     * @see SetMidiInstrumentMapToDefault()
257     *
258     * @throws Exception - in case given map does not exist
259     */
260     void SetMidiInstrumentMap(int MidiMap) throw (Exception);
261    
262 schoenebeck 1041 /**
263 schoenebeck 3687 * Set MIDI Registered Parameter Number (RPN)
264     * (upper 7 bits / coarse).
265 schoenebeck 1041 */
266 schoenebeck 3687 void SetMidiRpnParameterMsb(uint8_t ParamMSB);
267 schoenebeck 1041
268     /**
269 schoenebeck 3687 * Set MIDI Registered Parameter Number (RPN)
270     * (lower 7 bits / fine).
271 schoenebeck 1041 */
272 schoenebeck 3687 void SetMidiRpnParameterLsb(uint8_t ParamLSB);
273 schoenebeck 1041
274     /**
275 schoenebeck 3697 * Set new MSB data value (upper 7 bits / coarse) for currently
276     * selected MIDI Registered Parameter Number (RPN).
277     */
278     void SetMidiRpnDataMsb(uint8_t DataMSB);
279    
280     /**
281     * Set new LSB data value (lower 7 bits / fine) for currently
282     * selected MIDI Registered Parameter Number (RPN).
283     */
284     void SetMidiRpnDataLsb(uint8_t DataLSB);
285    
286     /**
287 schoenebeck 3699 * Set new data value (14 bits, MSB and LSB data combined) for
288     * currently selected MIDI Registered Parameter Number (RPN).
289     */
290     void SetMidiRpnData(int Data);
291    
292     /**
293 schoenebeck 3687 * Reset to no RPN parameter currently selected.
294 schoenebeck 1044 */
295 schoenebeck 3687 void ResetMidiRpnParameter();
296 schoenebeck 1879
297 schoenebeck 2121 /**
298 schoenebeck 3687 * Set MIDI Non-Registered Parameter Number (NRPN)
299     * (upper 7 bits / coarse).
300 schoenebeck 2121 */
301 schoenebeck 3687 void SetMidiNrpnParameterMsb(uint8_t ParamMSB);
302 schoenebeck 2121
303     /**
304 schoenebeck 3687 * Set MIDI Non-Registered Parameter Number (NRPN)
305     * (lower 7 bits / fine).
306 schoenebeck 2121 */
307 schoenebeck 3687 void SetMidiNrpnParameterLsb(uint8_t ParamLSB);
308 schoenebeck 2121
309     /**
310 schoenebeck 3697 * Set new MSB data value (upper 7 bits / coarse) for currently
311     * selected MIDI Non-Registered Parameter Number (NRPN).
312     */
313     void SetMidiNrpnDataMsb(uint8_t DataMSB);
314    
315     /**
316     * Set new LSB data value (lower 7 bits / fine) for currently
317     * selected MIDI Non-Registered Parameter Number (NRPN).
318     */
319     void SetMidiNrpnDataLsb(uint8_t DataLSB);
320    
321     /**
322 schoenebeck 3699 * Set new data value (14 bits, MSB and LSB data combined) for
323     * currently selected MIDI Non-Registered Parameter Number (NRPN).
324     */
325     void SetMidiNrpnData(int Data);
326    
327     /**
328 schoenebeck 3687 * Reset to no NRPN parameter currently selected.
329 schoenebeck 2121 */
330 schoenebeck 3687 void ResetMidiNrpnParameter();
331 schoenebeck 2121
332 schoenebeck 3687 /**
333     * Get currently selected MIDI Registered Parameter Number
334     * (RPN), this method will return the already merged 14 bit
335     * parameter number (MSB and LSB value combined).
336     *
337     * @e WARNING: you have to call @c ResetMidiRpnParameter()
338     * after using this value, otherwise all subsequent MIDI CC #6
339     * (Data) messages are interpreted as RPN value messages.
340     *
341     * @returns currently selected (14 bit) RPN number, a negative
342     * value if no RPN parameter currently selected
343     */
344     int GetMidiRpnParameter();
345    
346     /**
347 schoenebeck 3697 * Get current data value of currently selected MIDI Registered
348     * Parameter Number (RPN), this method will return the already
349     * merged 14 bit data value (MSB and LSB data values combined).
350     *
351     * @returns latest data value (14 bits) of currently selected RPN
352     * parameter, zero otherwise
353     */
354     int GetMidiRpnData();
355    
356     /**
357 schoenebeck 3687 * Get currently selected MIDI Non-Registered Parameter Number
358     * (NRPN), this method will return the already merged 14 bit
359     * value (MSB and LSB value combined).
360     *
361     * @e WARNING: you have to call @c ResetMidiNrpnParameter()
362     * after using this value, otherwise all subsequent MIDI CC #6
363     * (Data) messages are interpreted as NRPN value messages.
364     *
365     * @returns currently selected (14 bit) NRPN number, a negative
366     * value if no NRPN parameter currently selected
367     */
368     int GetMidiNrpnParameter();
369    
370 schoenebeck 3697 /**
371     * Get current data value of currently selected MIDI Non-Registered
372     * Parameter Number (NRPN), this method will return the already
373     * merged 14 bit data value (MSB and LSB data values combined).
374     *
375     * @returns latest data value (14 bits) of currently selected NRPN
376     * parameter, zero otherwise
377     */
378     int GetMidiNrpnData();
379    
380 iliev 1130 /**
381     * Registers the specified listener to be notified when the number
382     * of effect sends on this channel is changed.
383     */
384     void AddFxSendCountListener(FxSendCountListener* l);
385 schoenebeck 1044
386     /**
387 iliev 1130 * Removes the specified listener.
388     */
389     void RemoveFxSendCountListener(FxSendCountListener* l);
390    
391     /**
392     * Removes all listeners.
393     */
394     void RemoveAllFxSendCountListeners();
395    
396     /**
397 iliev 1297 * Gets the current number of active voices.
398     */
399     uint GetVoiceCount();
400    
401     /**
402     * Sets the current number of active voices.
403     */
404     void SetVoiceCount(uint Voices);
405    
406     /**
407     * Gets the current number of active disk streams.
408     */
409     uint GetDiskStreamCount();
410    
411     /**
412     * Sets the current number of active disk streams.
413     */
414     void SetDiskStreamCount(uint Streams);
415    
416 iliev 1761 SamplerChannel* GetSamplerChannel();
417 schoenebeck 1879
418 iliev 1761 void SetSamplerChannel(SamplerChannel* pChannel);
419 schoenebeck 889
420 iliev 1761 /** Returns the sampler to which this channel belongs */
421     Sampler* GetSampler();
422    
423 persson 1924 /**
424     * Performs a program change on the channel.
425     *
426     * This method is not real-time safe.
427     */
428 persson 2277 void ExecuteProgramChange(uint32_t Program);
429 persson 1924
430 schoenebeck 3687
431     // Deprecated APIs
432     // (these public methods might be removed in future) ...
433    
434     /**
435     * Set MIDI Registered Parameter Number (RPN) Controller
436     * (upper 8 bits / coarse).
437     *
438     * @deprecated Use SetMidiRpnParameterMsb() instead.
439     */
440     void SetMidiRpnControllerMsb(uint8_t CtrlMSB) DEPRECATED_API;
441    
442     /**
443     * Set MIDI Registered Parameter Number (RPN) Controller
444     * (lower 8 bits / fine).
445     *
446     * @deprecated Use SetMidiRpnParameterLsb() instead.
447     */
448     void SetMidiRpnControllerLsb(uint8_t CtrlLSB) DEPRECATED_API;
449    
450     /**
451     * Reset to no RPN controller currently selected.
452     *
453     * @deprecated Use ResetMidiRpnParameter() instead.
454     */
455     void ResetMidiRpnController() DEPRECATED_API;
456    
457     /**
458     * Set MIDI Non-Registered Parameter Number (NRPN) Controller
459     * (upper 8 bits / coarse).
460     *
461     * @deprecated Use SetMidiNrpnParameterMsb() instead.
462     */
463     void SetMidiNrpnControllerMsb(uint8_t CtrlMSB) DEPRECATED_API;
464    
465     /**
466     * Set MIDI Non-Registered Parameter Number (NRPN) Controller
467     * (lower 8 bits / fine).
468     *
469     * @deprecated Use SetMidiNrpnParameterLsb() instead.
470     */
471     void SetMidiNrpnControllerLsb(uint8_t CtrlLSB) DEPRECATED_API;
472    
473     /**
474     * Reset to no NRPN controller currently selected.
475     *
476     * @deprecated Use ResetMidiNrpnParameter() instead.
477     */
478     void ResetMidiNrpnController() DEPRECATED_API;
479    
480     /**
481     * Get currently selected MIDI Registered Parameter Number
482     * (RPN) Controller, this method will return the already merged
483     * value (MSB and LSB value).
484     *
485     * @e WARNING: you have to call @c ResetMidiRpnController()
486     * after using this value, otherwise all subsequent MIDI CC #6
487     * (Data) messages are interpreted as RPN controller value
488     * messages.
489     *
490     * @returns currently selected RPN controller number, a negative
491     * value if no RPN controller currently selected
492     *
493     * @deprecated Use GetMidiRpnParameter() instead.
494     */
495     int GetMidiRpnController() DEPRECATED_API;
496    
497     /**
498     * Get currently selected MIDI Non-Registered Parameter Number
499     * (NRPN) Controller, this method will return the already merged
500     * value (MSB and LSB value).
501     *
502     * @e WARNING: you have to call @c ResetMidiNrpnController()
503     * after using this value, otherwise all subsequent MIDI CC #6
504     * (Data) messages are interpreted as NRPN controller value
505     * messages.
506     *
507     * @returns currently selected NRPN controller number, a negative
508     * value if no NRPN controller currently selected
509     *
510     * @deprecated Use GetMidiNrpnParameter() instead.
511     */
512     int GetMidiNrpnController() DEPRECATED_API;
513    
514 schoenebeck 889 protected:
515 schoenebeck 906 EngineChannel();
516 schoenebeck 1879 virtual ~EngineChannel(); // MUST only be destroyed by EngineChannelFactory
517 iliev 1130
518     /**
519     * Notifies listeners that the number of effect sends
520     * on a this channel is changed.
521     * @param ChannelId The numerical ID of the sampler channel.
522     * @param NewCount The new number of sampler channels.
523     */
524     void fireFxSendCountChanged(int ChannelId, int NewCount);
525    
526 schoenebeck 889 friend class EngineChannelFactory;
527    
528     private:
529 persson 1896 struct private_data_t;
530     private_data_t* const p;
531 schoenebeck 889 };
532    
533     } // namespace LinuxSampler
534    
535     #endif // __LS_ENGINECHANNEL_H__

  ViewVC Help
Powered by ViewVC