3 |
* LinuxSampler - modular, streaming capable sampler * |
* LinuxSampler - modular, streaming capable sampler * |
4 |
* * |
* * |
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, 2006 Christian Schoenebeck * |
* Copyright (C) 2005 - 2007 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This library is free software; you can redistribute it and/or modify * |
* This library is free software; you can redistribute it and/or modify * |
9 |
* 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 * |
24 |
#include "lscpserver.h" |
#include "lscpserver.h" |
25 |
#include "lscpresultset.h" |
#include "lscpresultset.h" |
26 |
#include "lscpevent.h" |
#include "lscpevent.h" |
27 |
//#include "../common/global.h" |
#include "../common/global.h" |
28 |
|
|
29 |
#include <fcntl.h> |
#include <fcntl.h> |
30 |
|
|
66 |
SocketAddress.sin_addr.s_addr = addr; |
SocketAddress.sin_addr.s_addr = addr; |
67 |
SocketAddress.sin_port = port; |
SocketAddress.sin_port = port; |
68 |
this->pSampler = pSampler; |
this->pSampler = pSampler; |
69 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_count, "AUDIO_OUTPUT_DEVICE_COUNT"); |
70 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_audio_device_info, "AUDIO_OUTPUT_DEVICE_INFO"); |
71 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_device_count, "MIDI_INPUT_DEVICE_COUNT"); |
72 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_device_info, "MIDI_INPUT_DEVICE_INFO"); |
73 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_count, "CHANNEL_COUNT"); |
74 |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_voice_count, "VOICE_COUNT"); |
75 |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_stream_count, "STREAM_COUNT"); |
76 |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_buffer_fill, "BUFFER_FILL"); |
77 |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_channel_info, "CHANNEL_INFO"); |
78 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_fx_send_count, "FX_SEND_COUNT"); |
79 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_fx_send_info, "FX_SEND_INFO"); |
80 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_map_count, "MIDI_INSTRUMENT_MAP_COUNT"); |
81 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_map_info, "MIDI_INSTRUMENT_MAP_INFO"); |
82 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_count, "MIDI_INSTRUMENT_COUNT"); |
83 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_midi_instr_info, "MIDI_INSTRUMENT_INFO"); |
84 |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_misc, "MISCELLANEOUS"); |
85 |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
LSCPEvent::RegisterEvent(LSCPEvent::event_total_voice_count, "TOTAL_VOICE_COUNT"); |
86 |
|
LSCPEvent::RegisterEvent(LSCPEvent::event_global_info, "GLOBAL_INFO"); |
87 |
hSocket = -1; |
hSocket = -1; |
88 |
} |
} |
89 |
|
|
91 |
if (hSocket >= 0) close(hSocket); |
if (hSocket >= 0) close(hSocket); |
92 |
} |
} |
93 |
|
|
94 |
|
void LSCPServer::LscpChannelCountListener::ChannelCountChanged(int NewCount) { |
95 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, NewCount)); |
96 |
|
} |
97 |
|
|
98 |
|
void LSCPServer::LscpAudioDeviceCountListener::AudioDeviceCountChanged(int NewCount) { |
99 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_count, NewCount)); |
100 |
|
} |
101 |
|
|
102 |
|
void LSCPServer::LscpMidiDeviceCountListener::MidiDeviceCountChanged(int NewCount) { |
103 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_count, NewCount)); |
104 |
|
} |
105 |
|
|
106 |
|
void LSCPServer::LscpMidiInstrumentCountListener::MidiInstrumentCountChanged(int MapId, int NewCount) { |
107 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_count, MapId, NewCount)); |
108 |
|
} |
109 |
|
|
110 |
|
void LSCPServer::LscpMidiInstrumentInfoListener::MidiInstrumentInfoChanged(int MapId, int Bank, int Program) { |
111 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_info, MapId, Bank, Program)); |
112 |
|
} |
113 |
|
|
114 |
|
void LSCPServer::LscpMidiInstrumentMapCountListener::MidiInstrumentMapCountChanged(int NewCount) { |
115 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_count, NewCount)); |
116 |
|
} |
117 |
|
|
118 |
|
void LSCPServer::LscpMidiInstrumentMapInfoListener::MidiInstrumentMapInfoChanged(int MapId) { |
119 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_info, MapId)); |
120 |
|
} |
121 |
|
|
122 |
|
void LSCPServer::LscpFxSendCountListener::FxSendCountChanged(int ChannelId, int NewCount) { |
123 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_count, ChannelId, NewCount)); |
124 |
|
} |
125 |
|
|
126 |
|
void LSCPServer::LscpVoiceCountListener::VoiceCountChanged(int ChannelId, int NewCount) { |
127 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_voice_count, ChannelId, NewCount)); |
128 |
|
} |
129 |
|
|
130 |
|
void LSCPServer::LscpStreamCountListener::StreamCountChanged(int ChannelId, int NewCount) { |
131 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_stream_count, ChannelId, NewCount)); |
132 |
|
} |
133 |
|
|
134 |
|
void LSCPServer::LscpBufferFillListener::BufferFillChanged(int ChannelId, String FillData) { |
135 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_buffer_fill, ChannelId, FillData)); |
136 |
|
} |
137 |
|
|
138 |
|
void LSCPServer::LscpTotalVoiceCountListener::TotalVoiceCountChanged(int NewCount) { |
139 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, NewCount)); |
140 |
|
} |
141 |
|
|
142 |
|
|
143 |
/** |
/** |
144 |
* Blocks the calling thread until the LSCP Server is initialized and |
* Blocks the calling thread until the LSCP Server is initialized and |
145 |
* accepting socket connections, if the server is already initialized then |
* accepting socket connections, if the server is already initialized then |
180 |
|
|
181 |
listen(hSocket, 1); |
listen(hSocket, 1); |
182 |
Initialized.Set(true); |
Initialized.Set(true); |
183 |
|
|
184 |
|
// Registering event listeners |
185 |
|
pSampler->AddChannelCountListener(&channelCountListener); |
186 |
|
pSampler->AddAudioDeviceCountListener(&audioDeviceCountListener); |
187 |
|
pSampler->AddMidiDeviceCountListener(&midiDeviceCountListener); |
188 |
|
pSampler->AddVoiceCountListener(&voiceCountListener); |
189 |
|
pSampler->AddStreamCountListener(&streamCountListener); |
190 |
|
pSampler->AddBufferFillListener(&bufferFillListener); |
191 |
|
pSampler->AddTotalVoiceCountListener(&totalVoiceCountListener); |
192 |
|
pSampler->AddFxSendCountListener(&fxSendCountListener); |
193 |
|
MidiInstrumentMapper::AddMidiInstrumentCountListener(&midiInstrumentCountListener); |
194 |
|
MidiInstrumentMapper::AddMidiInstrumentInfoListener(&midiInstrumentInfoListener); |
195 |
|
MidiInstrumentMapper::AddMidiInstrumentMapCountListener(&midiInstrumentMapCountListener); |
196 |
|
MidiInstrumentMapper::AddMidiInstrumentMapInfoListener(&midiInstrumentMapInfoListener); |
197 |
|
|
198 |
// now wait for client connections and handle their requests |
// now wait for client connections and handle their requests |
199 |
sockaddr_in client; |
sockaddr_in client; |
214 |
if ((*itEngineChannel)->StatusChanged()) { |
if ((*itEngineChannel)->StatusChanged()) { |
215 |
SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex)); |
SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_info, (*itEngineChannel)->iSamplerChannelIndex)); |
216 |
} |
} |
217 |
|
|
218 |
|
for (int i = 0; i < (*itEngineChannel)->GetFxSendCount(); i++) { |
219 |
|
FxSend* fxs = (*itEngineChannel)->GetFxSend(i); |
220 |
|
if(fxs != NULL && fxs->IsInfoChanged()) { |
221 |
|
int chn = (*itEngineChannel)->iSamplerChannelIndex; |
222 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, chn, fxs->Id())); |
223 |
|
fxs->SetInfoChanged(false); |
224 |
|
} |
225 |
|
} |
226 |
} |
} |
227 |
} |
} |
228 |
|
|
745 |
String AudioRouting; |
String AudioRouting; |
746 |
int Mute = 0; |
int Mute = 0; |
747 |
bool Solo = false; |
bool Solo = false; |
748 |
|
String MidiInstrumentMap = "NONE"; |
749 |
|
|
750 |
if (pEngineChannel) { |
if (pEngineChannel) { |
751 |
EngineName = pEngineChannel->EngineName(); |
EngineName = pEngineChannel->EngineName(); |
763 |
} |
} |
764 |
Mute = pEngineChannel->GetMute(); |
Mute = pEngineChannel->GetMute(); |
765 |
Solo = pEngineChannel->GetSolo(); |
Solo = pEngineChannel->GetSolo(); |
766 |
|
if (pEngineChannel->UsesNoMidiInstrumentMap()) |
767 |
|
MidiInstrumentMap = "NONE"; |
768 |
|
else if (pEngineChannel->UsesDefaultMidiInstrumentMap()) |
769 |
|
MidiInstrumentMap = "DEFAULT"; |
770 |
|
else |
771 |
|
MidiInstrumentMap = ToString(pEngineChannel->GetMidiInstrumentMap()); |
772 |
} |
} |
773 |
|
|
774 |
result.Add("ENGINE_NAME", EngineName); |
result.Add("ENGINE_NAME", EngineName); |
790 |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
result.Add("INSTRUMENT_STATUS", InstrumentStatus); |
791 |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
result.Add("MUTE", Mute == -1 ? "MUTED_BY_SOLO" : (Mute ? "true" : "false")); |
792 |
result.Add("SOLO", Solo); |
result.Add("SOLO", Solo); |
793 |
|
result.Add("MIDI_INSTRUMENT_MAP", MidiInstrumentMap); |
794 |
} |
} |
795 |
catch (Exception e) { |
catch (Exception e) { |
796 |
result.Error(e); |
result.Error(e); |
1268 |
|
|
1269 |
// set new channel parameter value |
// set new channel parameter value |
1270 |
pParameter->SetValue(ParamVal); |
pParameter->SetValue(ParamVal); |
1271 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_info, DeviceId)); |
1272 |
} |
} |
1273 |
catch (Exception e) { |
catch (Exception e) { |
1274 |
result.Error(e); |
result.Error(e); |
1286 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1287 |
if (!parameters.count(ParamKey)) throw Exception("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("Audio output device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
1288 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1289 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_info, DeviceIndex)); |
1290 |
} |
} |
1291 |
catch (Exception e) { |
catch (Exception e) { |
1292 |
result.Error(e); |
result.Error(e); |
1304 |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
std::map<String,DeviceCreationParameter*> parameters = pDevice->DeviceParameters(); |
1305 |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(DeviceIndex) + " does not have a device parameter '" + ParamKey + "'"); |
1306 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1307 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_info, DeviceIndex)); |
1308 |
} |
} |
1309 |
catch (Exception e) { |
catch (Exception e) { |
1310 |
result.Error(e); |
result.Error(e); |
1329 |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
std::map<String,DeviceRuntimeParameter*> parameters = pMidiInputPort->PortParameters(); |
1330 |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
if (!parameters.count(ParamKey)) throw Exception("MIDI input device " + ToString(PortIndex) + " does not have a parameter '" + ParamKey + "'"); |
1331 |
parameters[ParamKey]->SetValue(ParamVal); |
parameters[ParamKey]->SetValue(ParamVal); |
1332 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_info, DeviceIndex)); |
1333 |
} |
} |
1334 |
catch (Exception e) { |
catch (Exception e) { |
1335 |
result.Error(e); |
result.Error(e); |
1577 |
|
|
1578 |
bool oldSolo = pEngineChannel->GetSolo(); |
bool oldSolo = pEngineChannel->GetSolo(); |
1579 |
bool hadSoloChannel = HasSoloChannel(); |
bool hadSoloChannel = HasSoloChannel(); |
1580 |
|
|
1581 |
pEngineChannel->SetSolo(bSolo); |
pEngineChannel->SetSolo(bSolo); |
1582 |
|
|
1583 |
if(!oldSolo && bSolo) { |
if(!oldSolo && bSolo) { |
1584 |
if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0); |
if(pEngineChannel->GetMute() == -1) pEngineChannel->SetMute(0); |
1585 |
if(!hadSoloChannel) MuteNonSoloChannels(); |
if(!hadSoloChannel) MuteNonSoloChannels(); |
1586 |
} |
} |
1587 |
|
|
1588 |
if(oldSolo && !bSolo) { |
if(oldSolo && !bSolo) { |
1589 |
if(!HasSoloChannel()) UnmuteChannels(); |
if(!HasSoloChannel()) UnmuteChannels(); |
1590 |
else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1); |
else if(!pEngineChannel->GetMute()) pEngineChannel->SetMute(-1); |
1642 |
} |
} |
1643 |
} |
} |
1644 |
|
|
1645 |
String LSCPServer::AddOrReplaceMIDIInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg, String EngineType, String InstrumentFile, uint InstrumentIndex, float Volume, MidiInstrumentMapper::mode_t LoadMode, String Name) { |
String LSCPServer::AddOrReplaceMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg, String EngineType, String InstrumentFile, uint InstrumentIndex, float Volume, MidiInstrumentMapper::mode_t LoadMode, String Name, bool bModal) { |
1646 |
dmsg(2,("LSCPServer: AddOrReplaceMIDIInstrumentMapping()\n")); |
dmsg(2,("LSCPServer: AddOrReplaceMIDIInstrumentMapping()\n")); |
1647 |
|
|
1648 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1649 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1650 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1651 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1652 |
|
|
1653 |
MidiInstrumentMapper::entry_t entry; |
MidiInstrumentMapper::entry_t entry; |
1660 |
|
|
1661 |
LSCPResultSet result; |
LSCPResultSet result; |
1662 |
try { |
try { |
1663 |
// PERSISTENT mapping commands might bloock for a long time, so in |
// PERSISTENT mapping commands might block for a long time, so in |
1664 |
// that case we add/replace the mapping in another thread |
// that case we add/replace the mapping in another thread in case |
1665 |
bool bInBackground = (entry.LoadMode == MidiInstrumentMapper::PERSISTENT); |
// the NON_MODAL argument was supplied, non persistent mappings |
1666 |
MidiInstrumentMapper::AddOrReplaceMapping(idx, entry, bInBackground); |
// should return immediately, so we don't need to do that for them |
1667 |
|
bool bInBackground = (entry.LoadMode == MidiInstrumentMapper::PERSISTENT && !bModal); |
1668 |
|
MidiInstrumentMapper::AddOrReplaceEntry(MidiMapID, idx, entry, bInBackground); |
1669 |
} catch (Exception e) { |
} catch (Exception e) { |
1670 |
result.Error(e); |
result.Error(e); |
1671 |
} |
} |
1672 |
return result.Produce(); |
return result.Produce(); |
1673 |
} |
} |
1674 |
|
|
1675 |
String LSCPServer::RemoveMIDIInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg) { |
String LSCPServer::RemoveMIDIInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) { |
1676 |
dmsg(2,("LSCPServer: RemoveMIDIInstrumentMapping()\n")); |
dmsg(2,("LSCPServer: RemoveMIDIInstrumentMapping()\n")); |
1677 |
|
|
1678 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1679 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1680 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1681 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1682 |
|
|
1683 |
LSCPResultSet result; |
LSCPResultSet result; |
1684 |
try { |
try { |
1685 |
MidiInstrumentMapper::RemoveMapping(idx); |
MidiInstrumentMapper::RemoveEntry(MidiMapID, idx); |
1686 |
} catch (Exception e) { |
} catch (Exception e) { |
1687 |
result.Error(e); |
result.Error(e); |
1688 |
} |
} |
1689 |
return result.Produce(); |
return result.Produce(); |
1690 |
} |
} |
1691 |
|
|
1692 |
String LSCPServer::GetMidiIstrumentMappings() { |
String LSCPServer::GetMidiInstrumentMappings(uint MidiMapID) { |
1693 |
dmsg(2,("LSCPServer: GetMidiIstrumentMappings()\n")); |
dmsg(2,("LSCPServer: GetMidiInstrumentMappings()\n")); |
1694 |
LSCPResultSet result; |
LSCPResultSet result; |
1695 |
result.Add(MidiInstrumentMapper::Mappings().size()); |
try { |
1696 |
|
result.Add(MidiInstrumentMapper::Entries(MidiMapID).size()); |
1697 |
|
} catch (Exception e) { |
1698 |
|
result.Error(e); |
1699 |
|
} |
1700 |
return result.Produce(); |
return result.Produce(); |
1701 |
} |
} |
1702 |
|
|
1703 |
String LSCPServer::GetMidiInstrumentMapping(uint MidiBankMSB, uint MidiBankLSB, uint MidiProg) { |
|
1704 |
|
String LSCPServer::GetAllMidiInstrumentMappings() { |
1705 |
|
dmsg(2,("LSCPServer: GetAllMidiInstrumentMappings()\n")); |
1706 |
|
LSCPResultSet result; |
1707 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1708 |
|
int totalMappings = 0; |
1709 |
|
for (int i = 0; i < maps.size(); i++) { |
1710 |
|
try { |
1711 |
|
totalMappings += MidiInstrumentMapper::Entries(maps[i]).size(); |
1712 |
|
} catch (Exception e) { /*NOOP*/ } |
1713 |
|
} |
1714 |
|
result.Add(totalMappings); |
1715 |
|
return result.Produce(); |
1716 |
|
} |
1717 |
|
|
1718 |
|
String LSCPServer::GetMidiInstrumentMapping(uint MidiMapID, uint MidiBank, uint MidiProg) { |
1719 |
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
dmsg(2,("LSCPServer: GetMidiIstrumentMapping()\n")); |
1720 |
LSCPResultSet result; |
LSCPResultSet result; |
1721 |
try { |
try { |
1722 |
midi_prog_index_t idx; |
midi_prog_index_t idx; |
1723 |
idx.midi_bank_msb = MidiBankMSB; |
idx.midi_bank_msb = (MidiBank >> 7) & 0x7f; |
1724 |
idx.midi_bank_lsb = MidiBankLSB; |
idx.midi_bank_lsb = MidiBank & 0x7f; |
1725 |
idx.midi_prog = MidiProg; |
idx.midi_prog = MidiProg; |
1726 |
|
|
1727 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Mappings(); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID); |
1728 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.find(idx); |
1729 |
if (iter == mappings.end()) result.Error("there is no map entry with that index"); |
if (iter == mappings.end()) result.Error("there is no map entry with that index"); |
1730 |
else { // found |
else { // found |
1765 |
return result.Produce(); |
return result.Produce(); |
1766 |
} |
} |
1767 |
|
|
1768 |
String LSCPServer::ListMidiInstrumentMappings() { |
String LSCPServer::ListMidiInstrumentMappings(uint MidiMapID) { |
1769 |
dmsg(2,("LSCPServer: ListMidiIstrumentMappings()\n")); |
dmsg(2,("LSCPServer: ListMidiInstrumentMappings()\n")); |
1770 |
LSCPResultSet result; |
LSCPResultSet result; |
1771 |
try { |
try { |
1772 |
String s; |
String s; |
1773 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Mappings(); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(MidiMapID); |
1774 |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
1775 |
for (; iter != mappings.end(); iter++) { |
for (; iter != mappings.end(); iter++) { |
1776 |
if (s.size()) s += ","; |
if (s.size()) s += ","; |
1777 |
s += "{" + ToString(int(iter->first.midi_bank_msb)) + "," |
s += "{" + ToString(MidiMapID) + "," |
1778 |
+ ToString(int(iter->first.midi_bank_lsb)) + "," |
+ ToString((int(iter->first.midi_bank_msb) << 7) | int(iter->first.midi_bank_lsb)) + "," |
1779 |
+ ToString(int(iter->first.midi_prog)) + "}"; |
+ ToString(int(iter->first.midi_prog)) + "}"; |
1780 |
|
} |
1781 |
|
result.Add(s); |
1782 |
|
} catch (Exception e) { |
1783 |
|
result.Error(e); |
1784 |
|
} |
1785 |
|
return result.Produce(); |
1786 |
|
} |
1787 |
|
|
1788 |
|
String LSCPServer::ListAllMidiInstrumentMappings() { |
1789 |
|
dmsg(2,("LSCPServer: ListAllMidiInstrumentMappings()\n")); |
1790 |
|
LSCPResultSet result; |
1791 |
|
try { |
1792 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1793 |
|
String s; |
1794 |
|
for (int i = 0; i < maps.size(); i++) { |
1795 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t> mappings = MidiInstrumentMapper::Entries(maps[i]); |
1796 |
|
std::map<midi_prog_index_t,MidiInstrumentMapper::entry_t>::iterator iter = mappings.begin(); |
1797 |
|
for (; iter != mappings.end(); iter++) { |
1798 |
|
if (s.size()) s += ","; |
1799 |
|
s += "{" + ToString(maps[i]) + "," |
1800 |
|
+ ToString((int(iter->first.midi_bank_msb) << 7) | int(iter->first.midi_bank_lsb)) + "," |
1801 |
|
+ ToString(int(iter->first.midi_prog)) + "}"; |
1802 |
|
} |
1803 |
} |
} |
1804 |
result.Add(s); |
result.Add(s); |
1805 |
} catch (Exception e) { |
} catch (Exception e) { |
1808 |
return result.Produce(); |
return result.Produce(); |
1809 |
} |
} |
1810 |
|
|
1811 |
String LSCPServer::ClearMidiInstrumentMappings() { |
String LSCPServer::ClearMidiInstrumentMappings(uint MidiMapID) { |
1812 |
dmsg(2,("LSCPServer: ClearMidiInstrumentMappings()\n")); |
dmsg(2,("LSCPServer: ClearMidiInstrumentMappings()\n")); |
1813 |
LSCPResultSet result; |
LSCPResultSet result; |
1814 |
try { |
try { |
1815 |
MidiInstrumentMapper::RemoveAllMappings(); |
MidiInstrumentMapper::RemoveAllEntries(MidiMapID); |
1816 |
|
} catch (Exception e) { |
1817 |
|
result.Error(e); |
1818 |
|
} |
1819 |
|
return result.Produce(); |
1820 |
|
} |
1821 |
|
|
1822 |
|
String LSCPServer::ClearAllMidiInstrumentMappings() { |
1823 |
|
dmsg(2,("LSCPServer: ClearAllMidiInstrumentMappings()\n")); |
1824 |
|
LSCPResultSet result; |
1825 |
|
try { |
1826 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1827 |
|
for (int i = 0; i < maps.size(); i++) |
1828 |
|
MidiInstrumentMapper::RemoveAllEntries(maps[i]); |
1829 |
|
} catch (Exception e) { |
1830 |
|
result.Error(e); |
1831 |
|
} |
1832 |
|
return result.Produce(); |
1833 |
|
} |
1834 |
|
|
1835 |
|
String LSCPServer::AddMidiInstrumentMap(String MapName) { |
1836 |
|
dmsg(2,("LSCPServer: AddMidiInstrumentMap()\n")); |
1837 |
|
LSCPResultSet result; |
1838 |
|
try { |
1839 |
|
int MapID = MidiInstrumentMapper::AddMap(MapName); |
1840 |
|
result = LSCPResultSet(MapID); |
1841 |
|
} catch (Exception e) { |
1842 |
|
result.Error(e); |
1843 |
|
} |
1844 |
|
return result.Produce(); |
1845 |
|
} |
1846 |
|
|
1847 |
|
String LSCPServer::RemoveMidiInstrumentMap(uint MidiMapID) { |
1848 |
|
dmsg(2,("LSCPServer: RemoveMidiInstrumentMap()\n")); |
1849 |
|
LSCPResultSet result; |
1850 |
|
try { |
1851 |
|
MidiInstrumentMapper::RemoveMap(MidiMapID); |
1852 |
|
} catch (Exception e) { |
1853 |
|
result.Error(e); |
1854 |
|
} |
1855 |
|
return result.Produce(); |
1856 |
|
} |
1857 |
|
|
1858 |
|
String LSCPServer::RemoveAllMidiInstrumentMaps() { |
1859 |
|
dmsg(2,("LSCPServer: RemoveAllMidiInstrumentMaps()\n")); |
1860 |
|
LSCPResultSet result; |
1861 |
|
try { |
1862 |
|
MidiInstrumentMapper::RemoveAllMaps(); |
1863 |
|
} catch (Exception e) { |
1864 |
|
result.Error(e); |
1865 |
|
} |
1866 |
|
return result.Produce(); |
1867 |
|
} |
1868 |
|
|
1869 |
|
String LSCPServer::GetMidiInstrumentMaps() { |
1870 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMaps()\n")); |
1871 |
|
LSCPResultSet result; |
1872 |
|
try { |
1873 |
|
result.Add(MidiInstrumentMapper::Maps().size()); |
1874 |
|
} catch (Exception e) { |
1875 |
|
result.Error(e); |
1876 |
|
} |
1877 |
|
return result.Produce(); |
1878 |
|
} |
1879 |
|
|
1880 |
|
String LSCPServer::ListMidiInstrumentMaps() { |
1881 |
|
dmsg(2,("LSCPServer: ListMidiInstrumentMaps()\n")); |
1882 |
|
LSCPResultSet result; |
1883 |
|
try { |
1884 |
|
std::vector<int> maps = MidiInstrumentMapper::Maps(); |
1885 |
|
String sList; |
1886 |
|
for (int i = 0; i < maps.size(); i++) { |
1887 |
|
if (sList != "") sList += ","; |
1888 |
|
sList += ToString(maps[i]); |
1889 |
|
} |
1890 |
|
result.Add(sList); |
1891 |
|
} catch (Exception e) { |
1892 |
|
result.Error(e); |
1893 |
|
} |
1894 |
|
return result.Produce(); |
1895 |
|
} |
1896 |
|
|
1897 |
|
String LSCPServer::GetMidiInstrumentMap(uint MidiMapID) { |
1898 |
|
dmsg(2,("LSCPServer: GetMidiInstrumentMap()\n")); |
1899 |
|
LSCPResultSet result; |
1900 |
|
try { |
1901 |
|
result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID)); |
1902 |
|
} catch (Exception e) { |
1903 |
|
result.Error(e); |
1904 |
|
} |
1905 |
|
return result.Produce(); |
1906 |
|
} |
1907 |
|
|
1908 |
|
String LSCPServer::SetMidiInstrumentMapName(uint MidiMapID, String NewName) { |
1909 |
|
dmsg(2,("LSCPServer: SetMidiInstrumentMapName()\n")); |
1910 |
|
LSCPResultSet result; |
1911 |
|
try { |
1912 |
|
MidiInstrumentMapper::RenameMap(MidiMapID, NewName); |
1913 |
|
} catch (Exception e) { |
1914 |
|
result.Error(e); |
1915 |
|
} |
1916 |
|
return result.Produce(); |
1917 |
|
} |
1918 |
|
|
1919 |
|
/** |
1920 |
|
* Set the MIDI instrument map the given sampler channel shall use for |
1921 |
|
* handling MIDI program change messages. There are the following two |
1922 |
|
* special (negative) values: |
1923 |
|
* |
1924 |
|
* - (-1) : set to NONE (ignore program changes) |
1925 |
|
* - (-2) : set to DEFAULT map |
1926 |
|
*/ |
1927 |
|
String LSCPServer::SetChannelMap(uint uiSamplerChannel, int MidiMapID) { |
1928 |
|
dmsg(2,("LSCPServer: SetChannelMap()\n")); |
1929 |
|
LSCPResultSet result; |
1930 |
|
try { |
1931 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1932 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1933 |
|
|
1934 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1935 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1936 |
|
|
1937 |
|
if (MidiMapID == -1) pEngineChannel->SetMidiInstrumentMapToNone(); |
1938 |
|
else if (MidiMapID == -2) pEngineChannel->SetMidiInstrumentMapToDefault(); |
1939 |
|
else pEngineChannel->SetMidiInstrumentMap(MidiMapID); |
1940 |
|
} catch (Exception e) { |
1941 |
|
result.Error(e); |
1942 |
|
} |
1943 |
|
return result.Produce(); |
1944 |
|
} |
1945 |
|
|
1946 |
|
String LSCPServer::CreateFxSend(uint uiSamplerChannel, uint MidiCtrl, String Name) { |
1947 |
|
dmsg(2,("LSCPServer: CreateFxSend()\n")); |
1948 |
|
LSCPResultSet result; |
1949 |
|
try { |
1950 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1951 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1952 |
|
|
1953 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1954 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1955 |
|
|
1956 |
|
FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name); |
1957 |
|
if (!pFxSend) throw Exception("Could not add FxSend, don't ask, I don't know why (probably a bug)"); |
1958 |
|
|
1959 |
|
result = LSCPResultSet(pFxSend->Id()); // success |
1960 |
|
} catch (Exception e) { |
1961 |
|
result.Error(e); |
1962 |
|
} |
1963 |
|
return result.Produce(); |
1964 |
|
} |
1965 |
|
|
1966 |
|
String LSCPServer::DestroyFxSend(uint uiSamplerChannel, uint FxSendID) { |
1967 |
|
dmsg(2,("LSCPServer: DestroyFxSend()\n")); |
1968 |
|
LSCPResultSet result; |
1969 |
|
try { |
1970 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1971 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1972 |
|
|
1973 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1974 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
1975 |
|
|
1976 |
|
FxSend* pFxSend = NULL; |
1977 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
1978 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
1979 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
1980 |
|
break; |
1981 |
|
} |
1982 |
|
} |
1983 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
1984 |
|
pEngineChannel->RemoveFxSend(pFxSend); |
1985 |
|
} catch (Exception e) { |
1986 |
|
result.Error(e); |
1987 |
|
} |
1988 |
|
return result.Produce(); |
1989 |
|
} |
1990 |
|
|
1991 |
|
String LSCPServer::GetFxSends(uint uiSamplerChannel) { |
1992 |
|
dmsg(2,("LSCPServer: GetFxSends()\n")); |
1993 |
|
LSCPResultSet result; |
1994 |
|
try { |
1995 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
1996 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
1997 |
|
|
1998 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
1999 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
2000 |
|
|
2001 |
|
result.Add(pEngineChannel->GetFxSendCount()); |
2002 |
|
} catch (Exception e) { |
2003 |
|
result.Error(e); |
2004 |
|
} |
2005 |
|
return result.Produce(); |
2006 |
|
} |
2007 |
|
|
2008 |
|
String LSCPServer::ListFxSends(uint uiSamplerChannel) { |
2009 |
|
dmsg(2,("LSCPServer: ListFxSends()\n")); |
2010 |
|
LSCPResultSet result; |
2011 |
|
String list; |
2012 |
|
try { |
2013 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
2014 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2015 |
|
|
2016 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2017 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
2018 |
|
|
2019 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2020 |
|
FxSend* pFxSend = pEngineChannel->GetFxSend(i); |
2021 |
|
if (list != "") list += ","; |
2022 |
|
list += ToString(pFxSend->Id()); |
2023 |
|
} |
2024 |
|
result.Add(list); |
2025 |
|
} catch (Exception e) { |
2026 |
|
result.Error(e); |
2027 |
|
} |
2028 |
|
return result.Produce(); |
2029 |
|
} |
2030 |
|
|
2031 |
|
String LSCPServer::GetFxSendInfo(uint uiSamplerChannel, uint FxSendID) { |
2032 |
|
dmsg(2,("LSCPServer: GetFxSendInfo()\n")); |
2033 |
|
LSCPResultSet result; |
2034 |
|
try { |
2035 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
2036 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2037 |
|
|
2038 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2039 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
2040 |
|
|
2041 |
|
FxSend* pFxSend = NULL; |
2042 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2043 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
2044 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
2045 |
|
break; |
2046 |
|
} |
2047 |
|
} |
2048 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
2049 |
|
|
2050 |
|
// gather audio routing informations |
2051 |
|
String AudioRouting; |
2052 |
|
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
2053 |
|
if (AudioRouting != "") AudioRouting += ","; |
2054 |
|
AudioRouting += ToString(pFxSend->DestinationChannel(chan)); |
2055 |
|
} |
2056 |
|
|
2057 |
|
// success |
2058 |
|
result.Add("NAME", pFxSend->Name()); |
2059 |
|
result.Add("MIDI_CONTROLLER", pFxSend->MidiController()); |
2060 |
|
result.Add("LEVEL", ToString(pFxSend->Level())); |
2061 |
|
result.Add("AUDIO_OUTPUT_ROUTING", AudioRouting); |
2062 |
|
} catch (Exception e) { |
2063 |
|
result.Error(e); |
2064 |
|
} |
2065 |
|
return result.Produce(); |
2066 |
|
} |
2067 |
|
|
2068 |
|
String LSCPServer::SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel) { |
2069 |
|
dmsg(2,("LSCPServer: SetFxSendAudioOutputChannel()\n")); |
2070 |
|
LSCPResultSet result; |
2071 |
|
try { |
2072 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
2073 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2074 |
|
|
2075 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2076 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
2077 |
|
|
2078 |
|
FxSend* pFxSend = NULL; |
2079 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2080 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
2081 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
2082 |
|
break; |
2083 |
|
} |
2084 |
|
} |
2085 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
2086 |
|
|
2087 |
|
pFxSend->SetDestinationChannel(FxSendChannel, DeviceChannel); |
2088 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
2089 |
|
} catch (Exception e) { |
2090 |
|
result.Error(e); |
2091 |
|
} |
2092 |
|
return result.Produce(); |
2093 |
|
} |
2094 |
|
|
2095 |
|
String LSCPServer::SetFxSendMidiController(uint uiSamplerChannel, uint FxSendID, uint MidiController) { |
2096 |
|
dmsg(2,("LSCPServer: SetFxSendMidiController()\n")); |
2097 |
|
LSCPResultSet result; |
2098 |
|
try { |
2099 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
2100 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2101 |
|
|
2102 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2103 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
2104 |
|
|
2105 |
|
FxSend* pFxSend = NULL; |
2106 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2107 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
2108 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
2109 |
|
break; |
2110 |
|
} |
2111 |
|
} |
2112 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
2113 |
|
|
2114 |
|
pFxSend->SetMidiController(MidiController); |
2115 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
2116 |
|
} catch (Exception e) { |
2117 |
|
result.Error(e); |
2118 |
|
} |
2119 |
|
return result.Produce(); |
2120 |
|
} |
2121 |
|
|
2122 |
|
String LSCPServer::SetFxSendLevel(uint uiSamplerChannel, uint FxSendID, double dLevel) { |
2123 |
|
dmsg(2,("LSCPServer: SetFxSendLevel()\n")); |
2124 |
|
LSCPResultSet result; |
2125 |
|
try { |
2126 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
2127 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
2128 |
|
|
2129 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
2130 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
2131 |
|
|
2132 |
|
FxSend* pFxSend = NULL; |
2133 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2134 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
2135 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
2136 |
|
break; |
2137 |
|
} |
2138 |
|
} |
2139 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
2140 |
|
|
2141 |
|
pFxSend->SetLevel((float)dLevel); |
2142 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
2143 |
} catch (Exception e) { |
} catch (Exception e) { |
2144 |
result.Error(e); |
result.Error(e); |
2145 |
} |
} |
2208 |
return result.Produce(); |
return result.Produce(); |
2209 |
} |
} |
2210 |
|
|
2211 |
|
String LSCPServer::GetGlobalVolume() { |
2212 |
|
LSCPResultSet result; |
2213 |
|
result.Add(ToString(GLOBAL_VOLUME)); // see common/global.cpp |
2214 |
|
return result.Produce(); |
2215 |
|
} |
2216 |
|
|
2217 |
|
String LSCPServer::SetGlobalVolume(double dVolume) { |
2218 |
|
LSCPResultSet result; |
2219 |
|
try { |
2220 |
|
if (dVolume < 0) throw Exception("Volume may not be negative"); |
2221 |
|
GLOBAL_VOLUME = dVolume; // see common/global.cpp |
2222 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_global_info, "VOLUME", GLOBAL_VOLUME)); |
2223 |
|
} catch (Exception e) { |
2224 |
|
result.Error(e); |
2225 |
|
} |
2226 |
|
return result.Produce(); |
2227 |
|
} |
2228 |
|
|
2229 |
/** |
/** |
2230 |
* Will be called by the parser to subscribe a client (frontend) on the |
* Will be called by the parser to subscribe a client (frontend) on the |
2231 |
* server for receiving event messages. |
* server for receiving event messages. |