/[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 460 by schoenebeck, Mon Mar 14 22:35:44 2005 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 Christian Schoenebeck                              *   *   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 22  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 "EngineGlobals.h"  
 #include "../../common/RingBuffer.h"  
 #include "../../common/Pool.h"  
 #include "../../common/ArrayList.h"  
 #include "../../common/ConditionServer.h"  
 #include "../common/Engine.h"  
 #include "../common/Event.h"  
 #include "../common/BiquadFilter.h"  
 #include "../../lib/fileloader/libgig/gig.h"  
 #include "../../network/lscp.h"  
 #include "EngineChannel.h"  
32    
33  namespace LinuxSampler { namespace gig {  namespace LinuxSampler { namespace gig {
34    
35      // just symbol prototyping      class Engine: public LinuxSampler::EngineBase<Voice, ::gig::Region, ::gig::DimensionRegion, DiskThread, InstrumentResourceManager, ::gig::Instrument> {
     class Voice;  
     class DiskThread;  
     class InstrumentResourceManager;  
     class midi_key_info_t;  
     class EngineChannel;  
   
     /**  
      * Sampler engine for the Gigasampler format.  
      */  
     class Engine : public LinuxSampler::Engine {  
36          public:          public:
37              // methods              Engine() { }
38              Engine();              virtual ~Engine() { }
            ~Engine();  
             void Connect(AudioOutputDevice* pAudioOut);  
   
39              // implementation of abstract methods derived from class 'LinuxSampler::Engine'              // implementation of abstract methods derived from class 'LinuxSampler::Engine'
40              virtual int    RenderAudio(uint Samples);              virtual bool    DiskStreamSupported();
41              virtual void   SendSysex(void* pData, uint Size);              virtual String  Description();
42              virtual void   Reset();              virtual String  Version();
43              virtual void   Enable();  
44              virtual void   Disable();              virtual Format  GetEngineFormat();
45              virtual uint   VoiceCount();  
46              virtual uint   VoiceCountMax();              virtual void ProcessControlChange (
47              virtual bool   DiskStreamSupported();                  LinuxSampler::EngineChannel*  pEngineChannel,
48              virtual uint   DiskStreamCount();                  Pool<Event>::Iterator&        itControlChangeEvent
49              virtual uint   DiskStreamCountMax();              ) OVERRIDE;
50              virtual String DiskStreamBufferFillBytes();              virtual void ProcessChannelPressure(LinuxSampler::EngineChannel* pEngineChannel, Pool<Event>::Iterator& itChannelPressureEvent) OVERRIDE;
51              virtual String DiskStreamBufferFillPercentage();              virtual void ProcessPolyphonicKeyPressure(LinuxSampler::EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNotePressureEvent) OVERRIDE;
52              virtual String Description();              virtual LinuxSampler::InstrumentScriptVM* CreateInstrumentScriptVM() OVERRIDE;
             virtual String Version();  
             virtual String EngineName();  
   
         //protected:  
             static InstrumentResourceManager instruments;  
   
             AudioOutputDevice*      pAudioOutputDevice;  
             uint                    SampleRate;            ///< Sample rate of the engines output audio signal (in Hz)  
             uint                    MaxSamplesPerCycle;    ///< Size of each audio output buffer  
             DiskThread*             pDiskThread;  
             RingBuffer<Event>*      pEventQueue;           ///< Input event queue for engine global events (e.g. SysEx messages).  
             Pool<Voice>*            pVoicePool;            ///< Contains all voices that can be activated.  
             EventGenerator*         pEventGenerator;  
             RTList<Event>*          pVoiceStealingQueue;   ///< All voice-launching events which had to be postponed due to free voice shortage.  
             RTList<Event>*          pGlobalEvents;         ///< All engine global events for the current audio fragment (usually only SysEx messages).  
             Pool<Event>*            pEventPool;            ///< Contains all Event objects that can be used.  
             RingBuffer<uint8_t>*    pSysexBuffer;          ///< Input buffer for MIDI system exclusive messages.  
             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).  
             int                     ActiveVoiceCount;      ///< number of currently active voices (this value will be returned for public calls)  
             int                     ActiveVoiceCountTemp;  ///< number of currently active voices (for internal usage, will be used for incrementation)  
             int                     ActiveVoiceCountMax;   ///< the maximum voice usage since application start  
             int                     VoiceTheftsLeft;       ///< We only allow MAX_AUDIO_VOICES voices to be stolen per audio fragment, we use this variable to ensure this limit.  
             RTList<Voice>::Iterator itLastStolenVoice;     ///< Only for voice stealing: points to the last voice which was theft in current audio fragment, NULL otherwise.  
             RTList<uint>::Iterator  iuiLastStolenKey;      ///< Only for voice stealing: key number of last key on which the last voice was theft in current audio fragment, NULL otherwise.  
             EngineChannel*          pLastStolenChannel;    ///< Only for voice stealing: points to the engine channel on which the previous voice was stolen in this audio fragment.  
             bool                    SuspensionRequested;  
             ConditionServer         EngineDisabled;  
             int8_t                  ScaleTuning[12];       ///< contains optional detune factors (-64..+63 cents) for all 12 semitones of an octave  
             int                     MaxFadeOutPos;         ///< The last position in an audio fragment to allow an instant fade out (e.g. for voice stealing) without leading to clicks.  
             uint32_t                RandomSeed;            ///< State of the random number generator used by the random dimension.  
   
             void ProcessEvents(EngineChannel* pEngineChannel, uint Samples);  
             void RenderActiveVoices(EngineChannel* pEngineChannel, uint Samples);  
             void RenderStolenVoices(uint Samples);  
             void PostProcess(EngineChannel* pEngineChannel);  
             void ClearEventLists();  
             void ImportEvents(uint Samples);  
             void ProcessNoteOn(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent);  
             void ProcessNoteOff(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOffEvent);  
             void ProcessPitchbend(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itPitchbendEvent);  
             void ProcessControlChange(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itControlChangeEvent);  
             void ProcessSysex(Pool<Event>::Iterator& itSysexEvent);  
             Pool<Voice>::Iterator LaunchVoice(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent, int iLayer, bool ReleaseTriggerVoice, bool VoiceStealing);  
             void StealVoice(EngineChannel* pEngineChannel, Pool<Event>::Iterator& itNoteOnEvent);  
             void FreeVoice(EngineChannel* pEngineChannel, Pool<Voice>::Iterator& itVoice);  
             void FreeKey(EngineChannel* pEngineChannel, midi_key_info_t* pKey);  
             void ResetSynthesisParameters(Event::destination_t dst, float val);  
             void ResetInternal();  
   
             static Engine* AcquireEngine(LinuxSampler::gig::EngineChannel* pChannel, AudioOutputDevice* pDevice);  
             static void    FreeEngine(LinuxSampler::gig::EngineChannel* pChannel, AudioOutputDevice* pDevice);  
   
             void DisableAndLock(); // FIXME: should at least be protected  
   
53              friend class Voice;              friend class Voice;
             friend class EGADSR;  
             friend class EGDecay;  
             friend class VCAManipulator;  
             friend class VCFCManipulator;  
             friend class VCOManipulator;  
         private:  
             ArrayList<EngineChannel*> engineChannels; ///< All engine channels of a gig::Engine instance.  
54    
55              static std::map<AudioOutputDevice*,Engine*> engines; ///< All instances of gig::Engine.          protected:
56                virtual DiskThread* CreateDiskThread();
57    
58              uint8_t GSCheckSum(const RingBuffer<uint8_t>::NonVolatileReader AddrReader, uint DataSize);              virtual Pool<Voice>::Iterator LaunchVoice (
59              void    AdjustScale(int8_t ScaleTunes[12]);                  LinuxSampler::EngineChannel* pEngineChannel,
60                    Pool<Event>::Iterator&       itNoteOnEvent,
61                    int                          iLayer,
62                    bool                         ReleaseTriggerVoice,
63                    bool                         VoiceStealing,
64                    bool                         HandleKeyGroupConflicts
65                );
66    
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.460  
changed lines
  Added in v.2600

  ViewVC Help
Powered by ViewVC