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

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

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 239 by schoenebeck, Sun Sep 12 14:48:19 2004 UTC revision 2600 by schoenebeck, Sat Jun 7 00:16:03 2014 UTC
# Line 2  Line 2 
2   *                                                                         *   *                                                                         *
3   *   LinuxSampler - modular, streaming capable sampler                     *   *   LinuxSampler - modular, streaming capable sampler                     *
4   *                                                                         *   *                                                                         *
5   *   Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck   *   *   Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck    *
6     *   Copyright (C) 2005-2008 Christian Schoenebeck                         *
7     *   Copyright (C) 2009-2010 Christian Schoenebeck and Grigor Iliev        *
8   *                                                                         *   *                                                                         *
9   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
10   *   it under the terms of the GNU General Public License as published by  *   *   it under the terms of the GNU General Public License as published by  *
# Line 21  Line 23 
23   ***************************************************************************/   ***************************************************************************/
24    
25  #ifndef __LS_GIG_ENGINE_H__  #ifndef __LS_GIG_ENGINE_H__
26  #define __LS_GIG_ENGINE_H__  #define __LS_GIG_ENGINE_H__
27    
28  #include "../../common/global.h"  #include "DiskThread.h"
29    #include "../EngineBase.h"
30  #if DEBUG_HEADERS  #include "Voice.h"
31  # warning Engine.h included  #include <gig.h>
 #endif // DEBUG_HEADERS  
   
 #include <map>  
   
 #include "../../common/RingBuffer.h"  
 #include "../../common/RTELMemoryPool.h"  
 #include "../../common/ConditionServer.h"  
 #include "../common/Engine.h"  
 #include "../common/Event.h"  
 #include "../common/BiquadFilter.h"  
 #include "../../lib/fileloader/libgig/gig.h"  
 #include "InstrumentResourceManager.h"  
 #include "../../network/lscp.h"  
   
 #define PITCHBEND_SEMITONES             12  
 #define MAX_AUDIO_VOICES                128  
32    
33  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
34    
35      using std::map;      class Engine: public LinuxSampler::EngineBase<Voice, ::gig::Region, ::gig::DimensionRegion, DiskThread, InstrumentResourceManager, ::gig::Instrument> {
   
     // just symbol prototyping  
     class Voice;  
     class DiskThread;  
     class InstrumentResourceManager;  
   
     /**  
      * Sampler engine for the Gigasampler format.  
      */  
     class gig::Engine : public LinuxSampler::Engine, public InstrumentConsumer {  
36          public:          public:
37              // methods              Engine() { }
38              Engine();              virtual ~Engine() { }
39             ~Engine();              // implementation of abstract methods derived from class 'LinuxSampler::Engine'
40                virtual bool    DiskStreamSupported();
41              // abstract methods derived from class 'LinuxSampler::Engine'              virtual String  Description();
42              virtual void   LoadInstrument(const char* FileName, uint Instrument);              virtual String  Version();
43              virtual void   Reset();  
44              virtual void   Enable();              virtual Format  GetEngineFormat();
45              virtual void   Disable();  
46              virtual void   SendNoteOn(uint8_t Key, uint8_t Velocity);              virtual void ProcessControlChange (
47              virtual void   SendNoteOff(uint8_t Key, uint8_t Velocity);                  LinuxSampler::EngineChannel*  pEngineChannel,
48              virtual void   SendPitchbend(int Pitch);                  Pool<Event>::Iterator&        itControlChangeEvent
49              virtual void   SendControlChange(uint8_t Controller, uint8_t Value);              ) OVERRIDE;
50              virtual float  Volume();              virtual void ProcessChannelPressure(LinuxSampler::EngineChannel* pEngineChannel, Pool<Event>::Iterator& itChannelPressureEvent) OVERRIDE;
51              virtual void   Volume(float f);              virtual void ProcessPolyphonicKeyPressure(LinuxSampler::EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNotePressureEvent) OVERRIDE;
52              virtual uint   Channels();              virtual LinuxSampler::InstrumentScriptVM* CreateInstrumentScriptVM() OVERRIDE;
53              virtual void   Connect(AudioOutputDevice* pAudioOut);              friend class Voice;
54              virtual void   DisconnectAudioOutputDevice();  
             virtual void   SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel);  
             virtual int    OutputChannel(uint EngineAudioChannel);  
             virtual int    RenderAudio(uint Samples);  
             virtual uint   VoiceCount();  
             virtual uint   VoiceCountMax();  
             virtual bool   DiskStreamSupported();  
             virtual uint   DiskStreamCount();  
             virtual uint   DiskStreamCountMax();  
             virtual String DiskStreamBufferFillBytes();  
             virtual String DiskStreamBufferFillPercentage();  
             virtual String Description();  
             virtual String Version();  
             virtual String EngineName();  
             virtual String InstrumentFileName();  
             virtual int    InstrumentIndex();  
             virtual int    InstrumentStatus();  
   
             // abstract methods derived from interface class 'InstrumentConsumer'  
             virtual void ResourceToBeUpdated(::gig::Instrument* pResource, void*& pUpdateArg);  
             virtual void ResourceUpdated(::gig::Instrument* pOldResource, ::gig::Instrument* pNewResource, void* pUpdateArg);  
55          protected:          protected:
56              struct midi_key_info_t {              virtual DiskThread* CreateDiskThread();
                 RTEList<Voice>* pActiveVoices; ///< Contains the active voices associated with the MIDI key.  
                 bool            KeyPressed;    ///< Is true if the respective MIDI key is currently pressed.  
                 bool            Active;        ///< If the key contains active voices.  
                 uint*           pSelf;         ///< hack to allow fast deallocation of the key from the list of active keys  
                 RTEList<Event>* pEvents;       ///< Key specific events (only Note-on, Note-off and sustain pedal currently)  
             };  
   
             static InstrumentResourceManager Instruments;  
   
             AudioOutputDevice*      pAudioOutputDevice;  
             float*                  pOutputLeft;           ///< Audio output channel buffer (left)  
             float*                  pOutputRight;          ///< Audio output channel buffer (right)  
             int                     AudioDeviceChannelLeft;  ///< audio device channel number to which the left channel is connected to  
             int                     AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to  
             uint                    SampleRate;            ///< Sample rate of the engines output audio signal (in Hz)  
             uint                    MaxSamplesPerCycle;    ///< Size of each audio output buffer  
             DiskThread*             pDiskThread;  
             uint8_t                 ControllerTable[128];  ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel.  
             RingBuffer<Event>*      pEventQueue;           ///< Input event queue.  
             midi_key_info_t         pMIDIKeyInfo[128];     ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key  
             RTELMemoryPool<Voice>*  pVoicePool;            ///< Contains all voices that can be activated.  
             RTELMemoryPool<uint>*   pActiveKeys;           ///< Holds all keys in it's allocation list with active voices.  
             RTELMemoryPool<Event>*  pEventPool;            ///< Contains all Event objects that can be used.  
             EventGenerator*         pEventGenerator;  
             RTEList<Event>*         pEvents;               ///< All events for the current audio fragment.  
             RTEList<Event>*         pCCEvents;             ///< All control change events for the current audio fragment.  
             RTEList<Event>*         pSynthesisEvents[Event::destination_count];     ///< Events directly affecting synthesis parameter (like pitch, volume and filter).  
             float*                  pSynthesisParameters[Event::destination_count]; ///< Matrix with final synthesis parameters for the current audio fragment which will be used in the main synthesis loop.  
             biquad_param_t*         pBasicFilterParameters; ///< Biquad parameters of the basic bandpass filter.  
             biquad_param_t*         pMainFilterParameters;  ///< Main biquad parameters of the individual filter (lowpass / bandpass / highpass).  
             map<uint,uint*>         ActiveKeyGroups;        ///< Contains active keys (in case they belong to a key group) ordered by key group ID.  
             RIFF::File*             pRIFF;  
             ::gig::File*            pGig;  
             ::gig::Instrument*      pInstrument;  
             bool                    SustainPedal;          ///< true if sustain pedal is down  
             double                  GlobalVolume;          ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification)  
             int                     Pitch;                 ///< Current (absolute) MIDI pitch value.  
             int                     ActiveVoiceCount;      ///< number of currently active voices  
             int                     ActiveVoiceCountMax;   ///< the maximum voice usage since application start  
             bool                    SuspensionRequested;  
             ConditionServer         EngineDisabled;  
             String                  InstrumentFile;  
             int                     InstrumentIdx;  
             int                     InstrumentStat;  
   
             void ProcessNoteOn(Event* pNoteOnEvent);  
             void ProcessNoteOff(Event* pNoteOffEvent);  
             void ProcessPitchbend(Event* pPitchbendEvent);  
             void ProcessControlChange(Event* pControlChangeEvent);  
             void LaunchVoice(Event* pNoteOnEvent, int iLayer = 0);  
             void KillVoiceImmediately(Voice* pVoice);  
             void ResetSynthesisParameters(Event::destination_t dst, float val);  
             void ResetInternal();  
57    
58              friend class Voice;              virtual Pool<Voice>::Iterator LaunchVoice (
59              friend class EGADSR;                  LinuxSampler::EngineChannel* pEngineChannel,
60              friend class EGDecay;                  Pool<Event>::Iterator&       itNoteOnEvent,
61              friend class VCAManipulator;                  int                          iLayer,
62              friend class VCFCManipulator;                  bool                         ReleaseTriggerVoice,
63              friend class VCOManipulator;                  bool                         VoiceStealing,
64              friend class InstrumentResourceManager;                  bool                         HandleKeyGroupConflicts
65          private:              );
66              void DisableAndLock();  
67                virtual void TriggerNewVoices (
68                    LinuxSampler::EngineChannel*  pEngineChannel,
69                    RTList<Event>::Iterator&      itNoteOnEvent,
70                    bool                          HandleKeyGroupConflicts
71                );
72    
73                void TriggerReleaseVoices (
74                    LinuxSampler::EngineChannel*  pEngineChannel,
75                    RTList<Event>::Iterator&      itNoteOffEvent
76                );
77      };      };
78    
79  }} // namespace LinuxSampler::gig  }} // namespace LinuxSampler::gig
80    
81  #endif // __LS_GIG_ENGINE_H__  #endif  /* __LS_GIG_ENGINE_H__ */
82    

Legend:
Removed from v.239  
changed lines
  Added in v.2600

  ViewVC Help
Powered by ViewVC