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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1686 - (hide annotations) (download) (as text)
Thu Feb 14 14:58:50 2008 UTC (16 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 11201 byte(s)
* added new LSCP event "CHANNEL_MIDI" which can be used by frontends to
  react on MIDI data arriving on certain sampler channels (so far only
  Note-On and Note-Off events are sent via this LSCP event)
* bumped LSCP compliance version to 1.4
* bumped LS version to 0.5.1.3cvs

1 schoenebeck 411 /***************************************************************************
2     * *
3     * LinuxSampler - modular, streaming capable sampler *
4     * *
5     * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 persson 1646 * Copyright (C) 2005 - 2008 Christian Schoenebeck *
7 schoenebeck 411 * *
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_GIG_ENGINECHANNEL_H__
25     #define __LS_GIG_ENGINECHANNEL_H__
26    
27     #include "../common/Event.h"
28 schoenebeck 890 #include "../EngineChannel.h"
29 persson 840 #include "../../common/RingBuffer.h"
30 schoenebeck 1659 #include "../../common/ArrayList.h"
31 schoenebeck 1001 #include "../../drivers/audio/AudioChannel.h"
32 schoenebeck 411 #include "EngineGlobals.h"
33     #include "Engine.h"
34 schoenebeck 412 #include "Voice.h"
35 schoenebeck 411 #include "InstrumentResourceManager.h"
36    
37     namespace LinuxSampler { namespace gig {
38    
39 schoenebeck 412 // just symbol prototyping
40 schoenebeck 411 class midi_key_info_t;
41 schoenebeck 412 class Voice;
42 schoenebeck 411
43 schoenebeck 563 /** @brief Engine Channel of a gig::Engine
44     *
45     * Encapsulates a engine channel for the Gigasampler format capable
46     * sampler engine.
47     */
48 schoenebeck 411 class EngineChannel : public LinuxSampler::EngineChannel, public InstrumentConsumer {
49     public:
50     EngineChannel();
51 schoenebeck 460 virtual ~EngineChannel();
52    
53 schoenebeck 411 // implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel'
54     virtual void PrepareLoadInstrument(const char* FileName, uint Instrument);
55     virtual void LoadInstrument();
56 schoenebeck 670 virtual void Reset();
57 schoenebeck 411 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity);
58 schoenebeck 906 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos);
59 schoenebeck 411 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity);
60 schoenebeck 906 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos);
61 schoenebeck 411 virtual void SendPitchbend(int Pitch);
62 schoenebeck 906 virtual void SendPitchbend(int Pitch, int32_t FragmentPos);
63 schoenebeck 460 virtual void SendControlChange(uint8_t Controller, uint8_t Value);
64 schoenebeck 906 virtual void SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos);
65 schoenebeck 670 virtual bool StatusChanged(bool bNewStatus = false);
66 schoenebeck 411 virtual float Volume();
67     virtual void Volume(float f);
68     virtual uint Channels();
69     virtual void Connect(AudioOutputDevice* pAudioOut);
70     virtual void DisconnectAudioOutputDevice();
71 schoenebeck 1001 virtual AudioOutputDevice* GetAudioOutputDevice();
72 schoenebeck 411 virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel);
73     virtual int OutputChannel(uint EngineAudioChannel);
74 schoenebeck 675 virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel);
75     virtual void DisconnectMidiInputPort();
76     virtual MidiInputPort* GetMidiInputPort();
77     virtual midi_chan_t MidiChannel();
78 schoenebeck 411 virtual String InstrumentFileName();
79     virtual String InstrumentName();
80     virtual int InstrumentIndex();
81     virtual int InstrumentStatus();
82 schoenebeck 460 virtual LinuxSampler::Engine* GetEngine();
83 schoenebeck 475 virtual String EngineName();
84 schoenebeck 1001 virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception);
85     virtual FxSend* GetFxSend(uint FxSendIndex);
86     virtual uint GetFxSendCount();
87     virtual void RemoveFxSend(FxSend* pFxSend);
88 schoenebeck 1686 virtual void Connect(VirtualMidiDevice* pDevice);
89     virtual void Disconnect(VirtualMidiDevice* pDevice);
90 schoenebeck 411
91     // implementation of abstract methods derived from interface class 'InstrumentConsumer'
92     virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg);
93     virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg);
94 schoenebeck 517 virtual void OnResourceProgress(float fProgress);
95 schoenebeck 460
96     //protected:
97 schoenebeck 411 Engine* pEngine;
98 schoenebeck 1001 AudioChannel* pChannelLeft; ///< encapsulates the audio rendering buffer (left)
99     AudioChannel* pChannelRight; ///< encapsulates the audio rendering buffer (right)
100 schoenebeck 411 int AudioDeviceChannelLeft; ///< audio device channel number to which the left channel is connected to
101     int AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to
102 schoenebeck 675 MidiInputPort* pMidiInputPort; ///< Points to the connected MIDI input port or NULL if none assigned.
103     midi_chan_t midiChannel; ///< MIDI channel(s) on which this engine channel listens to.
104 schoenebeck 970 RingBuffer<Event,false>* pEventQueue; ///< Input event queue.
105 schoenebeck 460 RTList<Event>* pEvents; ///< All engine channel specific events for the current audio fragment.
106 persson 903 uint8_t ControllerTable[129]; ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel. Number 128 is for channel pressure (mono aftertouch).
107 schoenebeck 411 midi_key_info_t* pMIDIKeyInfo; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key
108 schoenebeck 460 Pool<uint>* pActiveKeys; ///< Holds all keys in it's allocation list with active voices.
109 schoenebeck 411 std::map<uint,uint*> ActiveKeyGroups; ///< Contains active keys (in case they belong to a key group) ordered by key group ID.
110     ::gig::Instrument* pInstrument;
111     bool SustainPedal; ///< true if sustain pedal is down
112 iliev 776 bool SostenutoPedal; ///< true if sostenuto pedal is down
113 schoenebeck 829 bool SoloMode; ///< in Solo Mode we only play one voice (group) at a time
114     int SoloKey; ///< Currently 'active' solo key, that is the key to which the currently sounding voice belongs to (only if SoloMode is enabled)
115     bool PortamentoMode; ///< in Portamento Mode we slide the pitch from the last note to the current note.
116     float PortamentoTime; ///< How long it will take to glide from the previous note to the current (in seconds)
117     float PortamentoPos; ///< Current position on the keyboard, that is integer and fractional part (only used if PortamentoMode is on)
118 schoenebeck 947 double GlobalVolume; ///< Master volume factor set through the C++ API / LSCP (a value < 1.0 means attenuation, a value > 1.0 means amplification)
119     double MidiVolume; ///< Volume factor altered by MIDI CC#7 (a value < 1.0 means attenuation, a value > 1.0 means amplification)
120 schoenebeck 424 float GlobalPanLeft;
121     float GlobalPanRight;
122 schoenebeck 411 int Pitch; ///< Current (absolute) MIDI pitch value.
123 persson 865 float CurrentKeyDimension; ///< Current value (0-1.0) for the keyboard dimension, altered by pressing a keyswitching key.
124 schoenebeck 411 String InstrumentFile;
125     int InstrumentIdx;
126     String InstrumentIdxName;
127 schoenebeck 412 int InstrumentStat;
128 schoenebeck 460 int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList.
129 schoenebeck 660 bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet)
130 schoenebeck 1001 std::vector<FxSend*> fxSends;
131 schoenebeck 1041 int GlobalTranspose; ///< amount of semi tones all notes should be transposed
132 schoenebeck 411
133 persson 1646 /// Command used by the instrument loader thread to
134     /// request an instrument change on a channel.
135     struct instrument_change_command_t {
136     bool bChangeInstrument; ///< Set to true by the loader when the channel should change instrument.
137     ::gig::Instrument* pInstrument; ///< The new instrument. Also used by the loader to read the previously loaded instrument.
138     RTList< ::gig::DimensionRegion*>* pDimRegionsInUse; ///< List of dimension regions in use by the currently loaded instrument. Continuously updated by the audio thread.
139     };
140     SynchronizedConfig<instrument_change_command_t> InstrumentChangeCommand;
141     SynchronizedConfig<instrument_change_command_t>::Reader InstrumentChangeCommandReader;
142    
143     RTList< ::gig::DimensionRegion*>* pDimRegionsInUse; ///< temporary pointer into the instrument change command, used by the audio thread
144    
145 schoenebeck 1659 SynchronizedConfig< ArrayList<VirtualMidiDevice*> > virtualMidiDevices;
146 schoenebeck 1662 SynchronizedConfig< ArrayList<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader_AudioThread;
147     SynchronizedConfig< ArrayList<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader_MidiThread;
148 schoenebeck 1659
149 schoenebeck 473 void ResetControllers();
150 schoenebeck 460 void ClearEventLists();
151     void ImportEvents(uint Samples);
152    
153 schoenebeck 411 friend class Engine;
154     friend class Voice;
155     friend class InstrumentResourceManager;
156 schoenebeck 460
157 schoenebeck 411 private:
158     void ResetInternal();
159 schoenebeck 1001 void RemoveAllFxSends();
160 persson 1646 instrument_change_command_t& ChangeInstrument(::gig::Instrument* pInstrument);
161 schoenebeck 411 };
162    
163     }} // namespace LinuxSampler::gig
164    
165     #endif // __LS_GIG_ENGINECHANNEL_H__

  ViewVC Help
Powered by ViewVC