--- linuxsampler/trunk/src/engines/AbstractEngineChannel.h 2009/10/23 17:53:17 2012 +++ linuxsampler/trunk/src/engines/AbstractEngineChannel.h 2012/12/02 16:30:42 2382 @@ -3,8 +3,8 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005-2009 Christian Schoenebeck * - * Copyright (C) 2009 Grigor Iliev * + * Copyright (C) 2005-2008 Christian Schoenebeck * + * Copyright (C) 2009-2012 Christian Schoenebeck and Grigor Iliev * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -23,7 +23,7 @@ ***************************************************************************/ #ifndef __LS_ABSTRACTENGINECHANNEL_H__ -#define __LS_ABSTRACTENGINECHANNEL_H__ +#define __LS_ABSTRACTENGINECHANNEL_H__ #include "EngineChannel.h" #include "AbstractEngine.h" @@ -38,14 +38,14 @@ // implementation of abstract methods derived from interface class 'LinuxSampler::EngineChannel' virtual void PrepareLoadInstrument(const char* FileName, uint Instrument); virtual void Reset(); - virtual void SendNoteOn(uint8_t Key, uint8_t Velocity); - virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, int32_t FragmentPos); - virtual void SendNoteOff(uint8_t Key, uint8_t Velocity); - virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, int32_t FragmentPos); - virtual void SendPitchbend(int Pitch); - virtual void SendPitchbend(int Pitch, int32_t FragmentPos); - virtual void SendControlChange(uint8_t Controller, uint8_t Value); - virtual void SendControlChange(uint8_t Controller, uint8_t Value, int32_t FragmentPos); + virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel); + virtual void SendNoteOn(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel, int32_t FragmentPos); + virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel); + virtual void SendNoteOff(uint8_t Key, uint8_t Velocity, uint8_t MidiChannel, int32_t FragmentPos); + virtual void SendPitchbend(int Pitch, uint8_t MidiChannel); + virtual void SendPitchbend(int Pitch, uint8_t MidiChannel, int32_t FragmentPos); + virtual void SendControlChange(uint8_t Controller, uint8_t Value, uint8_t MidiChannel); + virtual void SendControlChange(uint8_t Controller, uint8_t Value, uint8_t MidiChannel, int32_t FragmentPos); virtual bool StatusChanged(bool bNewStatus = false); virtual float Volume(); virtual void Volume(float f); @@ -63,7 +63,7 @@ virtual String InstrumentName(); virtual int InstrumentIndex(); virtual int InstrumentStatus(); - virtual LinuxSampler::Engine* GetEngine(); + virtual Engine* GetEngine(); virtual String EngineName(); virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception); virtual FxSend* GetFxSend(uint FxSendIndex); @@ -75,14 +75,21 @@ virtual AbstractEngine::Format GetEngineFormat() = 0; + AudioOutputDevice* GetAudioOutputDeviceSafe(); + + friend class AbstractVoice; friend class AbstractEngine; template friend class EngineBase; + template friend class VoiceBase; protected: AbstractEngineChannel(); virtual ~AbstractEngineChannel(); AbstractEngine* pEngine; + Mutex EngineMutex; ///< protects the Engine from access by the instrument loader thread when lscp is disconnecting + + protected: AudioChannel* pChannelLeft; ///< encapsulates the audio rendering buffer (left) AudioChannel* pChannelRight; ///< encapsulates the audio rendering buffer (right) int AudioDeviceChannelLeft; ///< audio device channel number to which the left channel is connected to @@ -98,8 +105,6 @@ int InstrumentStat; double GlobalVolume; ///< Master volume factor set through the C++ API / LSCP (a value < 1.0 means attenuation, a value > 1.0 means amplification) double MidiVolume; ///< Volume factor altered by MIDI CC#7 (a value < 1.0 means attenuation, a value > 1.0 means amplification) - float GlobalPanLeft; - float GlobalPanRight; int Pitch; ///< Current (absolute) MIDI pitch value. float CurrentKeyDimension; ///< Current value (0-1.0) for the keyboard dimension, altered by pressing a keyswitching key. bool PortamentoMode; ///< in Portamento Mode we slide the pitch from the last note to the current note. @@ -110,19 +115,43 @@ int iLastPanRequest; ///< just for the return value of Pan(), so we don't have to make an injective function int iEngineIndexSelf; ///< Reflects the index of this EngineChannel in the Engine's ArrayList. bool bStatusChanged; ///< true in case an engine parameter has changed (e.g. new instrument, another volumet) + uint32_t RoundRobinIndex; ///< counter for round robin sample selection, incremented for each note on SynchronizedConfig< ArrayList > virtualMidiDevices; SynchronizedConfig< ArrayList >::Reader virtualMidiDevicesReader_AudioThread; SynchronizedConfig< ArrayList >::Reader virtualMidiDevicesReader_MidiThread; + // specialization of RTList that doesn't require the pool + // to be provided at construction time + template + class LazyList : public RTList { + public: + using RTList::allocAppend; + using RTList::pPool; + + LazyList() : RTList(0) { } + typename RTList::Iterator allocAppend(Pool* pool) { + pPool = pool; + return allocAppend(); + } + }; + + typedef std::map*> ActiveKeyGroupMap; + ActiveKeyGroupMap ActiveKeyGroups; ///< Contains event queues for key groups, ordered by key group ID. + virtual void ResetControllers(); virtual void ResetInternal(); virtual void RemoveAllFxSends(); void ImportEvents(uint Samples); + + void AddGroup(uint group); + void HandleKeyGroupConflicts(uint KeyGroup, Pool::Iterator& itNoteOnEvent); + void ClearGroupEventLists(); + void DeleteGroupEventLists(); }; } // namespace LinuxSampler -#endif /* __LS_ABSTRACTENGINECHANNEL_H__ */ +#endif /* __LS_ABSTRACTENGINECHANNEL_H__ */