--- linuxsampler/trunk/src/network/lscpserver.h 2006/11/27 21:34:55 947 +++ linuxsampler/trunk/src/network/lscpserver.h 2007/09/17 23:15:25 1353 @@ -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 - 2007 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 * @@ -44,9 +44,14 @@ #include "../common/Thread.h" #include "../common/Mutex.h" #include "../common/Condition.h" +#include "../common/global.h" #include "../drivers/midi/MidiInstrumentMapper.h" +#if HAVE_SQLITE3 +#include "../db/InstrumentsDb.h" +#endif + /// TCP Port on which the server should listen for connection requests. #define LSCP_ADDR INADDR_ANY #define LSCP_PORT 8888 @@ -128,20 +133,65 @@ String SetVolume(double dVolume, uint uiSamplerChannel); String SetChannelMute(bool bMute, uint uiSamplerChannel); String SetChannelSolo(bool bSolo, uint uiSamplerChannel); - String AddOrReplaceMIDIInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg, String EngineType, String InstrumentFile, uint InstrumentIndex, float Volume, MidiInstrumentMapper::mode_t LoadMode, String Name); - String RemoveMIDIInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg); - String GetMidiIstrumentMappings(); - String GetMidiInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg); - String ListMidiInstrumentMappings(); - String ClearMidiInstrumentMappings(); + String AddOrReplaceMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg, String EngineType, String InstrumentFile, uint InstrumentIndex, float Volume, MidiInstrumentMapper::mode_t LoadMode, String Name, bool bModal); + String RemoveMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg); + String GetMidiInstrumentMappings(uint MidiMapID); + String GetAllMidiInstrumentMappings(); + String GetMidiInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg); + String ListMidiInstrumentMappings(uint MidiMapID); + String ListAllMidiInstrumentMappings(); + String ClearMidiInstrumentMappings(uint MidiMapID); + String ClearAllMidiInstrumentMappings(); + String AddMidiInstrumentMap(String MapName = ""); + String RemoveMidiInstrumentMap(uint MidiMapID); + String RemoveAllMidiInstrumentMaps(); + String GetMidiInstrumentMaps(); + String ListMidiInstrumentMaps(); + String GetMidiInstrumentMap(uint MidiMapID); + String SetMidiInstrumentMapName(uint MidiMapID, String NewName); + String SetChannelMap(uint uiSamplerChannel, int MidiMapID); + String CreateFxSend(uint uiSamplerChannel, uint MidiCtrl, String Name = ""); + String DestroyFxSend(uint uiSamplerChannel, uint FxSendID); + String GetFxSends(uint uiSamplerChannel); + String ListFxSends(uint uiSamplerChannel); + String GetFxSendInfo(uint uiSamplerChannel, uint FxSendID); + String SetFxSendName(uint uiSamplerChannel, uint FxSendID, String Name); + 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); + String AddDbInstrumentDirectory(String Dir); + String RemoveDbInstrumentDirectory(String Dir, bool Force = false); + String GetDbInstrumentDirectoryCount(String Dir, bool Recursive = false); + String GetDbInstrumentDirectories(String Dir, bool Recursive = false); + String GetDbInstrumentDirectoryInfo(String Dir); + String SetDbInstrumentDirectoryName(String Dir, String Name); + String MoveDbInstrumentDirectory(String Dir, String Dst); + String CopyDbInstrumentDirectory(String Dir, String Dst); + 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 RemoveDbInstrument(String Instr); + String GetDbInstrumentCount(String Dir, bool Recursive = false); + String GetDbInstruments(String Dir, bool Recursive = false); + String GetDbInstrumentInfo(String Instr); + String SetDbInstrumentName(String Instr, String Name); + String MoveDbInstrument(String Instr, String Dst); + String CopyDbInstrument(String Instr, String Dst); + String SetDbInstrumentDescription(String Instr, String Desc); + String FindDbInstruments(String Dir, std::map Parameters, bool Recursive = true); + String FormatInstrumentsDb(); + String EditSamplerChannelInstrument(uint uiSamplerChannel); + String GetDbInstrumentsJobInfo(int JobId); String ResetChannel(uint uiSamplerChannel); String ResetSampler(); String GetServerInfo(); String GetTotalVoiceCount(); String GetTotalVoiceCountMax(); + String GetGlobalVolume(); + String SetGlobalVolume(double dVolume); String SubscribeNotification(LSCPEvent::event_t); String UnsubscribeNotification(LSCPEvent::event_t); - String QueryDatabase(String query); String SetEcho(yyparse_param_t* pSession, double boolean_value); void AnswerClient(String ReturnMessage); @@ -152,6 +202,7 @@ static int EventSubscribers( std::list events ); static void LockRTNotify( void ) { RTNotifyMutex.Lock(); } static void UnlockRTNotify( void ) { RTNotifyMutex.Unlock(); } + static String FilterEndlines(String s); protected: int hSocket; @@ -173,6 +224,13 @@ */ int GetMidiInputDeviceIndex (MidiInputDevice *pDevice); + EngineChannel* GetEngineChannel(uint uiSamplerChannel); + + /** + * Gets the specified effect send on the specified sampler channel. + */ + FxSend* GetFxSend(uint uiSamplerChannel, uint FxSendID); + bool HasSoloChannel(); void MuteNonSoloChannels(); void UnmuteChannels(); @@ -191,6 +249,111 @@ //like voice count, stream count and buffer fill //from LSCP server removing engines and channels from underneath static Mutex RTNotifyMutex; + + class EventHandler : public ChannelCountListener, public AudioDeviceCountListener, + public MidiDeviceCountListener, public MidiInstrumentCountListener, + public MidiInstrumentInfoListener, public MidiInstrumentMapCountListener, + public MidiInstrumentMapInfoListener, public FxSendCountListener, + public VoiceCountListener, public StreamCountListener, + public BufferFillListener, public TotalVoiceCountListener { + + public: + /** + * Invoked when the number of sampler channels has changed. + * @param NewCount The new number of sampler channels. + */ + virtual void ChannelCountChanged(int NewCount); + + /** + * Invoked when the number of audio output devices has changed. + * @param NewCount The new number of audio output devices. + */ + virtual void AudioDeviceCountChanged(int NewCount); + + /** + * Invoked when the number of MIDI input devices has changed. + * @param NewCount The new number of MIDI input devices. + */ + virtual void MidiDeviceCountChanged(int NewCount); + + /** + * 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. + */ + virtual void MidiInstrumentCountChanged(int MapId, int NewCount); + + /** + * Invoked when a MIDI instrument in a MIDI instrument map is changed. + * @param MapId The numerical ID of the MIDI instrument map. + * @param Bank The index of the MIDI bank, containing the instrument. + * @param Program The MIDI program number of the instrument. + */ + virtual void MidiInstrumentInfoChanged(int MapId, int Bank, int Program); + + /** + * Invoked when the number of MIDI instrument maps has changed. + * @param NewCount The new number of MIDI instruments. + */ + virtual void MidiInstrumentMapCountChanged(int NewCount); + + /** + * Invoked when the settings of a MIDI instrument map are changed. + * @param MapId The numerical ID of the MIDI instrument map. + */ + virtual void MidiInstrumentMapInfoChanged(int MapId); + + /** + * Invoked when the number of effect sends + * on the specified sampler channel has changed. + * @param ChannelId The numerical ID of the sampler channel. + * @param NewCount The new number of effect sends. + */ + virtual void FxSendCountChanged(int ChannelId, int NewCount); + + /** + * Invoked when the number of active voices + * on the specified sampler channel has changed. + * @param ChannelId The numerical ID of the sampler channel. + * @param NewCount The new number of active voices. + */ + virtual void VoiceCountChanged(int ChannelId, int NewCount); + + /** + * Invoked when the number of active disk streams + * on the specified sampler channel has changed. + * @param ChannelId The numerical ID of the sampler channel. + * @param NewCount The new number of active disk streams. + */ + virtual void StreamCountChanged(int ChannelId, int NewCount); + + /** + * Invoked when the fill state of the disk stream + * buffers on the specified sampler channel is changed. + * @param ChannelId The numerical ID of the sampler channel. + * @param FillData The buffer fill data for the specified sampler channel. + */ + virtual void BufferFillChanged(int ChannelId, String FillData); + + /** + * Invoked when the total number of active voices is changed. + * @param NewCount The new number of active voices. + */ + virtual void TotalVoiceCountChanged(int NewCount); + } eventHandler; + +#if HAVE_SQLITE3 + class DbInstrumentsEventHandler : public InstrumentsDb::Listener { + public: + virtual void DirectoryCountChanged(String Dir); + virtual void DirectoryInfoChanged(String Dir); + virtual void DirectoryNameChanged(String Dir, String NewName); + virtual void InstrumentCountChanged(String Dir); + virtual void InstrumentInfoChanged(String Instr); + virtual void InstrumentNameChanged(String Instr, String NewName); + virtual void JobStatusChanged(int JobId); + } dbInstrumentsEventHandler; +#endif // HAVE_SQLITE3 }; #endif // __LSCPSERVER_H_