--- linuxsampler/trunk/src/engines/gig/EngineChannel.h 2006/07/22 14:22:53 903 +++ linuxsampler/trunk/src/engines/gig/EngineChannel.h 2008/02/03 00:13:27 1659 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005, 2006 Christian Schoenebeck * + * Copyright (C) 2005 - 2008 Christian Schoenebeck * * * * 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 * @@ -24,13 +24,12 @@ #ifndef __LS_GIG_ENGINECHANNEL_H__ #define __LS_GIG_ENGINECHANNEL_H__ -#if DEBUG_HEADERS -# warning EngineChannel.h included -#endif // DEBUG_HEADERS - #include "../common/Event.h" #include "../EngineChannel.h" #include "../../common/RingBuffer.h" +#include "../../common/ArrayList.h" +#include "../../drivers/audio/AudioChannel.h" +#include "../../drivers/midi/VirtualMidiDevice.h" #include "EngineGlobals.h" #include "Engine.h" #include "Voice.h" @@ -57,15 +56,20 @@ virtual void LoadInstrument(); 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 bool StatusChanged(bool bNewStatus = false); virtual float Volume(); virtual void Volume(float f); virtual uint Channels(); virtual void Connect(AudioOutputDevice* pAudioOut); virtual void DisconnectAudioOutputDevice(); + virtual AudioOutputDevice* GetAudioOutputDevice(); virtual void SetOutputChannel(uint EngineAudioChannel, uint AudioDeviceChannel); virtual int OutputChannel(uint EngineAudioChannel); virtual void Connect(MidiInputPort* pMidiPort, midi_chan_t MidiChannel); @@ -78,21 +82,28 @@ virtual int InstrumentStatus(); virtual LinuxSampler::Engine* GetEngine(); virtual String EngineName(); + virtual FxSend* AddFxSend(uint8_t MidiCtrl, String Name = "") throw (Exception); + virtual FxSend* GetFxSend(uint FxSendIndex); + virtual uint GetFxSendCount(); + virtual void RemoveFxSend(FxSend* pFxSend); // implementation of 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); virtual void OnResourceProgress(float fProgress); + void Connect(VirtualMidiDevice* pDevice); + void Disconnect(VirtualMidiDevice* pDevice); + //protected: Engine* pEngine; - float* pOutputLeft; ///< Audio output channel buffer (left) - float* pOutputRight; ///< Audio output channel buffer (right) + 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 int AudioDeviceChannelRight; ///< audio device channel number to which the right channel is connected to MidiInputPort* pMidiInputPort; ///< Points to the connected MIDI input port or NULL if none assigned. midi_chan_t midiChannel; ///< MIDI channel(s) on which this engine channel listens to. - RingBuffer* pEventQueue; ///< Input event queue. + RingBuffer* pEventQueue; ///< Input event queue. RTList* pEvents; ///< All engine channel specific events for the current audio fragment. 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). midi_key_info_t* pMIDIKeyInfo; ///< Contains all active voices sorted by MIDI key number and other informations to the respective MIDI key @@ -106,7 +117,8 @@ bool PortamentoMode; ///< in Portamento Mode we slide the pitch from the last note to the current note. float PortamentoTime; ///< How long it will take to glide from the previous note to the current (in seconds) float PortamentoPos; ///< Current position on the keyboard, that is integer and fractional part (only used if PortamentoMode is on) - double GlobalVolume; ///< overall volume (a value < 1.0 means attenuation, a value > 1.0 means amplification) + 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. @@ -117,6 +129,23 @@ int InstrumentStat; 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) + std::vector fxSends; + int GlobalTranspose; ///< amount of semi tones all notes should be transposed + + /// Command used by the instrument loader thread to + /// request an instrument change on a channel. + struct instrument_change_command_t { + bool bChangeInstrument; ///< Set to true by the loader when the channel should change instrument. + ::gig::Instrument* pInstrument; ///< The new instrument. Also used by the loader to read the previously loaded instrument. + RTList< ::gig::DimensionRegion*>* pDimRegionsInUse; ///< List of dimension regions in use by the currently loaded instrument. Continuously updated by the audio thread. + }; + SynchronizedConfig InstrumentChangeCommand; + SynchronizedConfig::Reader InstrumentChangeCommandReader; + + RTList< ::gig::DimensionRegion*>* pDimRegionsInUse; ///< temporary pointer into the instrument change command, used by the audio thread + + SynchronizedConfig< ArrayList > virtualMidiDevices; + SynchronizedConfig< ArrayList >::Reader virtualMidiDevicesReader; void ResetControllers(); void ClearEventLists(); @@ -128,6 +157,8 @@ private: void ResetInternal(); + void RemoveAllFxSends(); + instrument_change_command_t& ChangeInstrument(::gig::Instrument* pInstrument); }; }} // namespace LinuxSampler::gig