/[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 829 - (show annotations) (download) (as text)
Sat Jan 14 14:07:47 2006 UTC (18 years, 2 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 8461 byte(s)
* implemented portamento mode and solo mode (a.k.a 'mono mode'):
  all modes can be altered via standard GM messages, that is CC5 for
  altering portamento time, CC65 for enabling / disabling portamento
  mode, CC126 for enabling solo mode and CC127 for disabling solo mode
* fixed EG3 (pitch envelope) synthesis which was neutral all the time
* configure.in: do not automatically pick optimized gcc flags if the user
  already provided some on his own (as CXXFLAGS)

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

  ViewVC Help
Powered by ViewVC