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

Diff of /linuxsampler/trunk/src/engines/AbstractEngineChannel.h

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

revision 2559 by schoenebeck, Sun May 18 17:38:25 2014 UTC revision 2948 by schoenebeck, Fri Jul 15 15:29:04 2016 UTC
# Line 5  Line 5 
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                         *   *   Copyright (C) 2005-2008 Christian Schoenebeck                         *
7   *   Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev        *   *   Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev        *
8   *   Copyright (C) 2013-2014 Christian Schoenebeck and Andreas Persson     *   *   Copyright (C) 2012-2016 Christian Schoenebeck and Andreas Persson     *
9   *                                                                         *   *                                                                         *
10   *   This program is free software; you can redistribute it and/or modify  *   *   This program is free software; you can redistribute it and/or modify  *
11   *   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 31  Line 31 
31    
32  #include "../common/Pool.h"  #include "../common/Pool.h"
33  #include "../common/RingBuffer.h"  #include "../common/RingBuffer.h"
34    #include "../common/ResourceManager.h"
35    #include "common/AbstractInstrumentManager.h"
36    #include "common/InstrumentScriptVM.h"
37    
38    #define CTRL_TABLE_IDX_AFTERTOUCH   128
39    #define CTRL_TABLE_IDX_PITCHBEND    129
40    
41  namespace LinuxSampler {  namespace LinuxSampler {
42    
43      class AbstractEngineChannel: public EngineChannel {      class MidiKeyboardManagerBase;
44    
45        class AbstractEngineChannel: public EngineChannel, public InstrumentScriptConsumer {
46          public:          public:
47              // implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel'              // implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel'
48              virtual void    PrepareLoadInstrument(const char* FileName, uint Instrument) OVERRIDE;              virtual void    PrepareLoadInstrument(const char* FileName, uint Instrument) OVERRIDE;
# Line 83  namespace LinuxSampler { Line 91  namespace LinuxSampler {
91              virtual void    Connect(VirtualMidiDevice* pDevice) OVERRIDE;              virtual void    Connect(VirtualMidiDevice* pDevice) OVERRIDE;
92              virtual void    Disconnect(VirtualMidiDevice* pDevice) OVERRIDE;              virtual void    Disconnect(VirtualMidiDevice* pDevice) OVERRIDE;
93    
94                // implementation of abstract methods derived from AbstractEngine::ScriptConsumer
95                virtual void ResourceToBeUpdated(VMParserContext* pResource, void*& pUpdateArg) OVERRIDE {}
96                virtual void ResourceUpdated(VMParserContext* pOldResource, VMParserContext* pNewResource, void* pUpdateArg) OVERRIDE {}
97                virtual void OnResourceProgress(float fProgress) OVERRIDE {}
98    
99              virtual AbstractEngine::Format GetEngineFormat() = 0;              virtual AbstractEngine::Format GetEngineFormat() = 0;
100                virtual MidiKeyboardManagerBase* GetMidiKeyboardManager() = 0;
101    
102              AudioOutputDevice* GetAudioOutputDeviceSafe();              AudioOutputDevice* GetAudioOutputDeviceSafe();
103    
104                script_callback_id_t GetScriptCallbackID(const ScriptEvent* e) const {
105                    return pScript->pEvents->getID(e);
106                }
107    
108                RTList<ScriptEvent>::Iterator ScriptCallbackByID(script_callback_id_t id) const {
109                    return pScript->pEvents->fromID(id);
110                }
111    
112                void ScheduleResumeOfScriptCallback(RTList<ScriptEvent>::Iterator& itCallback, sched_time_t now, bool forever);
113    
114              friend class AbstractVoice;              friend class AbstractVoice;
115              friend class AbstractEngine;              friend class AbstractEngine;
116              template<class TV, class TRR, class TR, class TD, class TIM, class TI> friend class EngineBase;              template<class TV, class TRR, class TR, class TD, class TIM, class TI> friend class EngineBase;
117              template<class EC, class R, class S, class D> friend class VoiceBase;              template<class EC, class R, class S, class D> friend class VoiceBase;
118    
119          protected:          //protected:
120              AbstractEngineChannel();              AbstractEngineChannel();
121              virtual ~AbstractEngineChannel();              virtual ~AbstractEngineChannel();
122    
# Line 101  namespace LinuxSampler { Line 124  namespace LinuxSampler {
124              Mutex                     EngineMutex; ///< protects the Engine from access by the instrument loader thread when lscp is disconnecting              Mutex                     EngineMutex; ///< protects the Engine from access by the instrument loader thread when lscp is disconnecting
125              Mutex                     MidiInputMutex; ///< Introduced when support for multiple MIDI inputs per engine channel was added: protects the MIDI event input ringbuffer on this engine channel to be accessed concurrently by multiple midi input threads. As alternative one might also move the ringbuffer from this engine channel to the individual MIDI ports/devices and let the sampler engine read the events from there instead of receiving them here.              Mutex                     MidiInputMutex; ///< Introduced when support for multiple MIDI inputs per engine channel was added: protects the MIDI event input ringbuffer on this engine channel to be accessed concurrently by multiple midi input threads. As alternative one might also move the ringbuffer from this engine channel to the individual MIDI ports/devices and let the sampler engine read the events from there instead of receiving them here.
126    
127          protected:          //protected:
128              AudioChannel*             pChannelLeft;             ///< encapsulates the audio rendering buffer (left)              AudioChannel*             pChannelLeft;             ///< encapsulates the audio rendering buffer (left)
129              AudioChannel*             pChannelRight;            ///< encapsulates the audio rendering buffer (right)              AudioChannel*             pChannelRight;            ///< encapsulates the audio rendering buffer (right)
130              int                       AudioDeviceChannelLeft;   ///< audio device channel number to which the left channel is connected to              int                       AudioDeviceChannelLeft;   ///< audio device channel number to which the left channel is connected to
# Line 110  namespace LinuxSampler { Line 133  namespace LinuxSampler {
133              midi_chan_t               midiChannel;              ///< MIDI channel(s) on which this engine channel listens to (on all MIDI input ports).              midi_chan_t               midiChannel;              ///< MIDI channel(s) on which this engine channel listens to (on all MIDI input ports).
134              RingBuffer<Event,false>*  pEventQueue;              ///< Input event queue.              RingBuffer<Event,false>*  pEventQueue;              ///< Input event queue.
135              RTList<Event>*            pEvents;                  ///< All engine channel specific events for the current audio fragment.              RTList<Event>*            pEvents;                  ///< All engine channel specific events for the current audio fragment.
136              uint8_t                   ControllerTable[129];     ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel. Number 128 is for channel pressure (mono aftertouch).              struct _DelayedEvents {
137                    RTList<Event>*            pList; ///< Unsorted list where all delayed events are moved to and remain here until they're finally processed.
138                    Pool<ScheduledEvent>      schedulerNodes; ///< Nodes used to sort the delayed events (stored on pList) with time sorted queue.
139                    RTAVLTree<ScheduledEvent> queue; ///< Used to access the delayed events (from pList) in time sorted manner.
140    
141                    _DelayedEvents() : pList(NULL), schedulerNodes(CONFIG_MAX_EVENTS_PER_FRAGMENT) {}
142    
143                    inline void clear() {
144                        if (pList) pList->clear();
145                        schedulerNodes.clear();
146                        queue.clear();
147                    }
148                } delayedEvents;
149                uint8_t                   ControllerTable[130];     ///< Reflects the current values (0-127) of all MIDI controllers for this engine / sampler channel. Number 128 is for channel pressure (mono aftertouch), 129 for pitch bend.
150              String                    InstrumentFile;              String                    InstrumentFile;
151              int                       InstrumentIdx;              int                       InstrumentIdx;
152              String                    InstrumentIdxName;              String                    InstrumentIdxName;
# Line 128  namespace LinuxSampler { Line 164  namespace LinuxSampler {
164              int                       iEngineIndexSelf;         ///< Reflects the index of this EngineChannel in the Engine's ArrayList.              int                       iEngineIndexSelf;         ///< Reflects the index of this EngineChannel in the Engine's ArrayList.
165              bool                      bStatusChanged;           ///< true in case an engine parameter has changed (e.g. new instrument, another volumet)              bool                      bStatusChanged;           ///< true in case an engine parameter has changed (e.g. new instrument, another volumet)
166              uint32_t                  RoundRobinIndex;          ///< counter for round robin sample selection, incremented for each note on              uint32_t                  RoundRobinIndex;          ///< counter for round robin sample selection, incremented for each note on
167                InstrumentScript*         pScript;                  ///< Points to the real-time instrument script(s) to be executed, NULL if current instrument does not have an instrument script. Even though the underlying VM representation of the script is shared among multiple sampler channels, the InstrumentScript object here is not shared though, it exists for each sampler channel separately.
168    
169              SynchronizedConfig< ArrayList<VirtualMidiDevice*> > virtualMidiDevices;              SynchronizedConfig< ArrayList<VirtualMidiDevice*> > virtualMidiDevices;
170              SynchronizedConfig< ArrayList<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader_AudioThread;              SynchronizedConfig< ArrayList<VirtualMidiDevice*> >::Reader virtualMidiDevicesReader_AudioThread;
# Line 152  namespace LinuxSampler { Line 189  namespace LinuxSampler {
189              ActiveKeyGroupMap ActiveKeyGroups;      ///< Contains event queues for key groups, ordered by key group ID.              ActiveKeyGroupMap ActiveKeyGroups;      ///< Contains event queues for key groups, ordered by key group ID.
190    
191              virtual void ResetControllers();              virtual void ResetControllers();
192              virtual void ResetInternal();              virtual void ResetInternal(bool bResetEngine);
193              virtual void RemoveAllFxSends();              virtual void RemoveAllFxSends();
194    
195              void ImportEvents(uint Samples);              void ImportEvents(uint Samples);
196                virtual note_id_t ScheduleNoteMicroSec(const Event* pEvent, int delay) = 0;
197                event_id_t ScheduleEventMicroSec(const Event* pEvent, int delay);
198                void IgnoreEvent(event_id_t id);
199                virtual void IgnoreNote(note_id_t id) = 0;
200                void IgnoreEventByScriptID(const ScriptID& id);
201    
202              void AddGroup(uint group);              void AddGroup(uint group);
203              void HandleKeyGroupConflicts(uint KeyGroup, Pool<Event>::Iterator& itNoteOnEvent);              void HandleKeyGroupConflicts(uint KeyGroup, Pool<Event>::Iterator& itNoteOnEvent);
# Line 175  namespace LinuxSampler { Line 217  namespace LinuxSampler {
217                  //FIXME: leaves tiny time frames open (shortly after 1->2 devices connected or 2->1 disconnected) which could lead to concurrency issue for the purpose described above, however in practice it "should" be acceptable                  //FIXME: leaves tiny time frames open (shortly after 1->2 devices connected or 2->1 disconnected) which could lead to concurrency issue for the purpose described above, however in practice it "should" be acceptable
218                  return midiInputs.unsafeBack().size() > 1;                  return midiInputs.unsafeBack().size() > 1;
219              }              }
220    
221                inline bool applyTranspose(Event* event);
222      };      };
223    
224  } // namespace LinuxSampler  } // namespace LinuxSampler

Legend:
Removed from v.2559  
changed lines
  Added in v.2948

  ViewVC Help
Powered by ViewVC