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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 840 - (show annotations) (download) (as text)
Sun Feb 26 13:00:08 2006 UTC (12 years, 1 month ago) by persson
File MIME type: text/x-c++hdr
File size: 8498 byte(s)
* fixed some concurrency problems between the lscp thread and the
  audio/midi threads for these commands: load engine, set channel
  audio output device, set channel midi input device/port/channel and
  remove channel. Thanks to Vincent Bongiorno for bug reports and
  testing.
* removed an autotools warning
* fixed an iterator bug
* minor code clean-ups

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * Copyright (C) 2005, 2006 Christian Schoenebeck *
7 * *
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 #if DEBUG_HEADERS
28 # warning EngineChannel.h included
29 #endif // DEBUG_HEADERS
30
31 #include "../common/Event.h"
32 #include "../common/EngineChannel.h"
33 #include "../../common/RingBuffer.h"
34 #include "EngineGlobals.h"
35 #include "Engine.h"
36 #include "Voice.h"
37 #include "InstrumentResourceManager.h"
38
39 namespace LinuxSampler { namespace gig {
40
41 // just symbol prototyping
42 class midi_key_info_t;
43 class Voice;
44
45 /** @brief Engine Channel of a gig::Engine
46 *
47 * Encapsulates a engine channel for the Gigasampler format capable
48 * sampler engine.
49 */
50 class EngineChannel : public LinuxSampler::EngineChannel, public InstrumentConsumer {
51 public:
52 EngineChannel();
53 virtual ~EngineChannel();
54
55 // implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel'
56 virtual void PrepareLoadInstrument(const char* FileName, uint Instrument);
57 virtual void LoadInstrument();
58 virtual void Reset();
59 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity);
60 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity);
61 virtual void SendPitchbend(int Pitch);
62 virtual void SendControlChange(uint8_t Controller, uint8_t Value);
63 virtual bool StatusChanged(bool bNewStatus = false);
64 virtual float Volume();
65 virtual void Volume(float f);
66 virtual uint Channels();
67 virtual void Connect(AudioOutputDevice* pAudioOut);
68 virtual void DisconnectAudioOutputDevice();
69 virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel);
70 virtual int OutputChannel(uint EngineAudioChannel);
71 virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel);
72 virtual void DisconnectMidiInputPort();
73 virtual MidiInputPort* GetMidiInputPort();
74 virtual midi_chan_t MidiChannel();
75 virtual String InstrumentFileName();
76 virtual String InstrumentName();
77 virtual int InstrumentIndex();
78 virtual int InstrumentStatus();
79 virtual LinuxSampler::Engine* GetEngine();
80 virtual String EngineName();
81
82 // implementation of abstract methods derived from interface class 'InstrumentConsumer'
83 virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg);
84 virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg);
85 virtual void OnResourceProgress(float fProgress);
86
87 //protected:
88 Engine* pEngine;
89 float* pOutputLeft; ///< Audio output channel buffer (left)
90 float* pOutputRight; ///< Audio output channel buffer (right)
91 int AudioDeviceChannelLeft; ///< audio device channel number to which the left channel is connected to
92 int AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to
93 MidiInputPort* pMidiInputPort; ///< Points to the connected MIDI input port or NULL if none assigned.
94 midi_chan_t midiChannel; ///< MIDI channel(s) on which this engine channel listens to.
95 RingBuffer<Event>* pEventQueue; ///< Input event queue.
96 RTList<Event>* pEvents; ///< All engine channel specific events for the current audio fragment.
97 uint8_t ControllerTable[128]; ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel.
98 midi_key_info_t* pMIDIKeyInfo; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key
99 Pool<uint>* pActiveKeys; ///< Holds all keys in it's allocation list with active voices.
100 std::map<uint,uint*> ActiveKeyGroups; ///< Contains active keys (in case they belong to a key group) ordered by key group ID.
101 ::gig::Instrument* pInstrument;
102 bool SustainPedal; ///< true if sustain pedal is down
103 bool SostenutoPedal; ///< true if sostenuto pedal is down
104 bool SoloMode; ///< in Solo Mode we only play one voice (group) at a time
105 int SoloKey; ///< Currently 'active' solo key, that is the key to which the currently sounding voice belongs to (only if SoloMode is enabled)
106 bool PortamentoMode; ///< in Portamento Mode we slide the pitch from the last note to the current note.
107 float PortamentoTime; ///< How long it will take to glide from the previous note to the current (in seconds)
108 float PortamentoPos; ///< Current position on the keyboard, that is integer and fractional part (only used if PortamentoMode is on)
109 double GlobalVolume; ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification)
110 float GlobalPanLeft;
111 float GlobalPanRight;
112 int Pitch; ///< Current (absolute) MIDI pitch value.
113 int CurrentKeyDimension; ///< Current value (0-127) for the keyboard dimension, altered by pressing a keyswitching key.
114 String InstrumentFile;
115 int InstrumentIdx;
116 String InstrumentIdxName;
117 int InstrumentStat;
118 int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList.
119 bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet)
120
121 void ResetControllers();
122 void ClearEventLists();
123 void ImportEvents(uint Samples);
124
125 friend class Engine;
126 friend class Voice;
127 friend class InstrumentResourceManager;
128
129 private:
130 void ResetInternal();
131 };
132
133 }} // namespace LinuxSampler::gig
134
135 #endif // __LS_GIG_ENGINECHANNEL_H__

  ViewVC Help
Powered by ViewVC