--- linuxsampler/trunk/src/network/lscpserver.h 2007/12/03 13:59:03 1535 +++ linuxsampler/trunk/src/network/lscpserver.h 2010/09/30 20:00:43 2135 @@ -3,7 +3,7 @@ * LinuxSampler - modular, streaming capable sampler * * * * Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck * - * Copyright (C) 2005 - 2007 Christian Schoenebeck * + * Copyright (C) 2005 - 2008 Christian Schoenebeck * * * * This library is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * @@ -43,7 +43,6 @@ #include "lscp.h" #include "lscpparser.h" -#include "lscp.h" #include "lscpevent.h" #include "../Sampler.h" #include "../common/Thread.h" @@ -52,6 +51,7 @@ #include "../common/global_private.h" #include "../drivers/midi/MidiInstrumentMapper.h" +#include "../drivers/midi/VirtualMidiDevice.h" #if HAVE_SQLITE3 #include "../db/InstrumentsDb.h" @@ -64,10 +64,11 @@ /// try up to 3 minutes to bind server socket #define LSCP_SERVER_BIND_TIMEOUT 180 -using namespace LinuxSampler; - // External references to the main scanner and parser functions extern int yyparse(void* YYPARSE_PARAM); + +namespace LinuxSampler { + extern void restart(yyparse_param_t* pparam, int& yychar); /** @@ -78,6 +79,7 @@ LSCPServer(Sampler* pSampler, long int addr, short int port); virtual ~LSCPServer(); int WaitUntilInitialized(long TimeoutSeconds = 0L, long TimeoutNanoSeconds = 0L); + void RemoveListeners(); // Methods called by the parser String DestroyAudioOutputDevice(uint DeviceIndex); @@ -164,6 +166,28 @@ String SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel); String SetFxSendMidiController(uint uiSamplerChannel, uint FxSendID, uint MidiController); String SetFxSendLevel(uint uiSamplerChannel, uint FxSendID, double dLevel); + + // effect commands + String GetAvailableEffects(); + String ListAvailableEffects(); + String GetEffectInfo(int iEffectIndex); + String CreateEffectInstance(int index); + String CreateEffectInstance(String effectSystem, String module, String effectName); + String DestroyEffectInstance(int iEffectID); + String GetEffectInstances(); + String ListEffectInstances(); + String GetEffectInstanceInfo(int iEffectInstanceIndex); + String GetEffectInstanceInputControlInfo(int iEffectInstanceIndex, int iInputControlIndex); + String SetEffectInstanceInputControl(int iEffectInstanceIndex, int iInputControlIndex, double dValue); + String GetMasterEffectChains(int iAudioOutputDevice); + String ListMasterEffectChains(int iAudioOutputDevice); + String AddMasterEffectChain(int iAudioOutputDevice); + String RemoveMasterEffectChain(int iAudioOutputDevice, int iMasterEffectChain); + String GetMasterEffectChainInfo(int iAudioOutputDevice, int iMasterEffectChain); + String AppendMasterEffectChainEffect(int iAudioOutputDevice, int iMasterEffectChain, int iEffectInstance); + String InsertMasterEffectChainEffect(int iAudioOutputDevice, int iMasterEffectChain, int iEffectInstance, int iEffectChainPosition); + String RemoveMasterEffectChainEffect(int iAudioOutputDevice, int iMasterEffectChain, int iEffectInstance); + String AddDbInstrumentDirectory(String Dir); String RemoveDbInstrumentDirectory(String Dir, bool Force = false); String GetDbInstrumentDirectoryCount(String Dir, bool Recursive = false); @@ -175,7 +199,7 @@ String SetDbInstrumentDirectoryDescription(String Dir, String Desc); String FindDbInstrumentDirectories(String Dir, std::map Parameters, bool Recursive = true); String AddDbInstruments(String DbDir, String FilePath, int Index = -1, bool bBackground = false); - String AddDbInstruments(String ScanMode, String DbDir, String FsDir, bool bBackground = false); + String AddDbInstruments(String ScanMode, String DbDir, String FsDir, bool bBackground = false, bool insDir = false); String RemoveDbInstrument(String Instr); String GetDbInstrumentCount(String Dir, bool Recursive = false); String GetDbInstruments(String Dir, bool Recursive = false); @@ -184,6 +208,8 @@ String MoveDbInstrument(String Instr, String Dst); String CopyDbInstrument(String Instr, String Dst); String SetDbInstrumentDescription(String Instr, String Desc); + String SetDbInstrumentFilePath(String OldPath, String NewPath); + String FindLostDbInstrumentFiles(); String FindDbInstruments(String Dir, std::map Parameters, bool Recursive = true); String FormatInstrumentsDb(); String EditSamplerChannelInstrument(uint uiSamplerChannel); @@ -191,25 +217,32 @@ String ResetChannel(uint uiSamplerChannel); String ResetSampler(); String GetServerInfo(); + String GetTotalStreamCount(); String GetTotalVoiceCount(); String GetTotalVoiceCountMax(); + String GetGlobalMaxVoices(); + String SetGlobalMaxVoices(int iVoices); + String GetGlobalMaxStreams(); + String SetGlobalMaxStreams(int iStreams); String GetGlobalVolume(); String SetGlobalVolume(double dVolume); String GetFileInstruments(String Filename); String ListFileInstruments(String Filename); String GetFileInstrumentInfo(String Filename, uint InstrumentID); + String SendChannelMidiData(String MidiMsg, uint uiSamplerChannel, uint Arg1, uint Arg2); String SubscribeNotification(LSCPEvent::event_t); String UnsubscribeNotification(LSCPEvent::event_t); String SetEcho(yyparse_param_t* pSession, double boolean_value); void AnswerClient(String ReturnMessage); + void CloseAllConnections(); static int currentSocket; static std::map bufferedCommands; static void SendLSCPNotify( LSCPEvent Event ); static int EventSubscribers( std::list events ); - static void LockRTNotify( void ) { RTNotifyMutex.Lock(); } - static void UnlockRTNotify( void ) { RTNotifyMutex.Unlock(); } + static void LockRTNotify(); + static void UnlockRTNotify(); static String FilterEndlines(String s); protected: @@ -242,7 +275,7 @@ bool HasSoloChannel(); void MuteNonSoloChannels(); void UnmuteChannels(); - + /** * Throws an exception if the specified file is not found or * if directory is specified. @@ -268,15 +301,20 @@ public MidiDeviceCountListener, public MidiInstrumentCountListener, public MidiInstrumentInfoListener, public MidiInstrumentMapCountListener, public MidiInstrumentMapInfoListener, public FxSendCountListener, - public VoiceCountListener, public StreamCountListener, - public BufferFillListener, public TotalVoiceCountListener { + public VoiceCountListener, public StreamCountListener, public BufferFillListener, + public TotalStreamCountListener, public TotalVoiceCountListener, + public EngineChangeListener, public MidiPortCountListener { public: + EventHandler(LSCPServer* pParent); + /** * Invoked when the number of sampler channels has changed. * @param NewCount The new number of sampler channels. */ virtual void ChannelCountChanged(int NewCount); + virtual void ChannelAdded(SamplerChannel* pChannel); + virtual void ChannelToBeRemoved(SamplerChannel* pChannel); /** * Invoked when the number of audio output devices has changed. @@ -291,6 +329,40 @@ virtual void MidiDeviceCountChanged(int NewCount); /** + * Invoked right before the supplied MIDI input device is going + * to be destroyed. + * @param pDevice MidiInputDevice to be deleted + */ + virtual void MidiDeviceToBeDestroyed(MidiInputDevice* pDevice); + + /** + * Invoked to inform that a new MidiInputDevice has just been + * created. + * @param pDevice newly created MidiInputDevice + */ + virtual void MidiDeviceCreated(MidiInputDevice* pDevice); + + /** + * Invoked when the number of MIDI input ports has changed. + * @param NewCount The new number of MIDI input ports. + */ + virtual void MidiPortCountChanged(int NewCount); + + /** + * Invoked right before the supplied MIDI input port is going + * to be destroyed. + * @param pPort MidiInputPort to be deleted + */ + virtual void MidiPortToBeRemoved(MidiInputPort* pPort); + + /** + * Invoked to inform that a new MidiInputPort has just been + * added. + * @param pPort newly created MidiInputPort + */ + virtual void MidiPortAdded(MidiInputPort* pPort); + + /** * Invoked when the number of MIDI instruments has changed. * @param MapId The numerical ID of the MIDI instrument map. * @param NewCount The new number of MIDI instruments. @@ -354,6 +426,31 @@ * @param NewCount The new number of active voices. */ virtual void TotalVoiceCountChanged(int NewCount); + virtual void TotalStreamCountChanged(int NewCount); + + virtual void EngineToBeChanged(int ChannelId); + virtual void EngineChanged(int ChannelId); + + virtual ~EventHandler(); + + struct midi_listener_entry { + SamplerChannel* pSamplerChannel; + EngineChannel* pEngineChannel; + VirtualMidiDevice* pMidiListener; + }; + + std::vector channelMidiListeners; + + struct device_midi_listener_entry { + MidiInputPort* pPort; + VirtualMidiDevice* pMidiListener; + uint uiDeviceID; + }; + + std::vector deviceMidiListeners; + + private: + LSCPServer* pParent; } eventHandler; #if HAVE_SQLITE3 @@ -370,4 +467,6 @@ #endif // HAVE_SQLITE3 }; +} + #endif // __LSCPSERVER_H_