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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 56 - (show annotations) (download) (as text)
Tue Apr 27 09:21:58 2004 UTC (19 years, 11 months ago) by schoenebeck
File MIME type: text/x-c++hdr
File size: 7899 byte(s)
updated copyright header for 2004

1 /***************************************************************************
2 * *
3 * LinuxSampler - modular, streaming capable sampler *
4 * *
5 * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck *
6 * *
7 * This program is free software; you can redistribute it and/or modify *
8 * it under the terms of the GNU General Public License as published by *
9 * the Free Software Foundation; either version 2 of the License, or *
10 * (at your option) any later version. *
11 * *
12 * This program is distributed in the hope that it will be useful, *
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
15 * GNU General Public License for more details. *
16 * *
17 * You should have received a copy of the GNU General Public License *
18 * along with this program; if not, write to the Free Software *
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, *
20 * MA 02111-1307 USA *
21 ***************************************************************************/
22
23 #ifndef __LS_GIG_ENGINE_H__
24 #define __LS_GIG_ENGINE_H__
25
26 #include "../../common/global.h"
27
28 #if DEBUG_HEADERS
29 # warning Engine.h included
30 #endif // DEBUG_HEADERS
31
32 #include "../../common/RingBuffer.h"
33 #include "../../common/RTELMemoryPool.h"
34 #include "../../common/ConditionServer.h"
35 #include "../common/Engine.h"
36 #include "../common/Event.h"
37 #include "../../lib/fileloader/libgig/gig.h"
38 #include "InstrumentResourceManager.h"
39 #include "../../network/lscp.h"
40
41 #define PITCHBEND_SEMITONES 12
42 #define MAX_AUDIO_VOICES 64
43
44 namespace LinuxSampler { namespace gig {
45
46 // just symbol prototyping
47 class Voice;
48 class DiskThread;
49 class InstrumentResourceManager;
50
51 /**
52 * Sampler engine for the Gigasampler format.
53 */
54 class gig::Engine : public LinuxSampler::Engine, public InstrumentConsumer {
55 public:
56 // methods
57 Engine();
58 ~Engine();
59
60 // abstract methods derived from class 'LinuxSampler::Engine'
61 virtual void LoadInstrument(const char* FileName, uint Instrument);
62 virtual void Reset();
63 virtual void Enable();
64 virtual void Disable();
65 virtual void SendNoteOn(uint8_t Key, uint8_t Velocity);
66 virtual void SendNoteOff(uint8_t Key, uint8_t Velocity);
67 virtual void SendPitchbend(int Pitch);
68 virtual void SendControlChange(uint8_t Controller, uint8_t Value);
69 virtual float Volume();
70 virtual void Volume(float f);
71 virtual void Connect(AudioOutputDevice* pAudioOut);
72 virtual void DisconnectAudioOutputDevice();
73 virtual int RenderAudio(uint Samples);
74 virtual uint VoiceCount();
75 virtual uint VoiceCountMax();
76 virtual bool DiskStreamSupported();
77 virtual uint DiskStreamCount();
78 virtual uint DiskStreamCountMax();
79 virtual String DiskStreamBufferFillBytes();
80 virtual String DiskStreamBufferFillPercentage();
81 virtual String Description();
82 virtual String Version();
83
84 // abstract methods derived from interface class 'InstrumentConsumer'
85 virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg);
86 virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg);
87 protected:
88 struct midi_key_info_t {
89 RTEList<Voice>* pActiveVoices; ///< Contains the active voices associated with the MIDI key.
90 bool KeyPressed; ///< Is true if the respective MIDI key is currently pressed.
91 bool Active; ///< If the key contains active voices.
92 uint* pSelf; ///< hack to allow fast deallocation of the key from the list of active keys
93 RTEList<Event>* pEvents; ///< Key specific events (only Note-on, Note-off and sustain pedal currently)
94 };
95
96 static InstrumentResourceManager Instruments;
97
98 AudioOutputDevice* pAudioOutputDevice;
99 DiskThread* pDiskThread;
100 uint8_t ControllerTable[128]; ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel.
101 RingBuffer<Event>* pEventQueue; ///< Input event queue.
102 midi_key_info_t pMIDIKeyInfo[128]; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key
103 RTELMemoryPool<Voice>* pVoicePool; ///< Contains all voices that can be activated.
104 RTELMemoryPool<uint>* pActiveKeys; ///< Holds all keys in it's allocation list with active voices.
105 RTELMemoryPool<Event>* pEventPool; ///< Contains all Event objects that can be used.
106 EventGenerator* pEventGenerator;
107 RTEList<Event>* pEvents; ///< All events for the current audio fragment.
108 RTEList<Event>* pCCEvents; ///< All control change events for the current audio fragment.
109 RTEList<Event>* pSynthesisEvents[Event::destination_count]; ///< Events directly affecting synthesis parameter (like pitch, volume and filter).
110 float* pSynthesisParameters[Event::destination_count]; ///< Matrix with final synthesis parameters for the current audio fragment which will be used in the main synthesis loop.
111 RIFF::File* pRIFF;
112 ::gig::File* pGig;
113 ::gig::Instrument* pInstrument;
114 bool SustainPedal; ///< true if sustain pedal is down
115 double GlobalVolume; ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification)
116 int Pitch; ///< Current (absolute) MIDI pitch value.
117 int ActiveVoiceCount; ///< number of currently active voices
118 int ActiveVoiceCountMax; ///< the maximum voice usage since application start
119 bool SuspensionRequested;
120 ConditionServer EngineDisabled;
121
122 void ProcessNoteOn(Event* pNoteOnEvent);
123 void ProcessNoteOff(Event* pNoteOffEvent);
124 void ProcessPitchbend(Event* pPitchbendEvent);
125 void ProcessControlChange(Event* pControlChangeEvent);
126 void KillVoice(Voice* pVoice);
127 void ResetSynthesisParameters(Event::destination_t dst, float val);
128 void ResetInternal();
129
130 friend class Voice;
131 friend class EGADSR;
132 friend class EGDecay;
133 friend class VCAManipulator;
134 friend class VCFCManipulator;
135 friend class VCOManipulator;
136 friend class InstrumentResourceManager;
137 private:
138 //static void AllocateSynthesisParametersMatrix();
139
140 void DisableAndLock();
141 };
142
143 }} // namespace LinuxSampler::gig
144
145 #endif // __LS_GIG_ENGINE_H__

  ViewVC Help
Powered by ViewVC