91 |
if (hSocket >= 0) close(hSocket); |
if (hSocket >= 0) close(hSocket); |
92 |
} |
} |
93 |
|
|
94 |
void LSCPServer::LscpChannelCountListener::ChannelCountChanged(int NewCount) { |
void LSCPServer::EventHandler::ChannelCountChanged(int NewCount) { |
95 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_channel_count, NewCount)); |
96 |
} |
} |
97 |
|
|
98 |
void LSCPServer::LscpAudioDeviceCountListener::AudioDeviceCountChanged(int NewCount) { |
void LSCPServer::EventHandler::AudioDeviceCountChanged(int NewCount) { |
99 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_count, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_audio_device_count, NewCount)); |
100 |
} |
} |
101 |
|
|
102 |
void LSCPServer::LscpMidiDeviceCountListener::MidiDeviceCountChanged(int NewCount) { |
void LSCPServer::EventHandler::MidiDeviceCountChanged(int NewCount) { |
103 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_count, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_device_count, NewCount)); |
104 |
} |
} |
105 |
|
|
106 |
void LSCPServer::LscpMidiInstrumentCountListener::MidiInstrumentCountChanged(int MapId, int NewCount) { |
void LSCPServer::EventHandler::MidiInstrumentCountChanged(int MapId, int NewCount) { |
107 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_count, MapId, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_count, MapId, NewCount)); |
108 |
} |
} |
109 |
|
|
110 |
void LSCPServer::LscpMidiInstrumentInfoListener::MidiInstrumentInfoChanged(int MapId, int Bank, int Program) { |
void LSCPServer::EventHandler::MidiInstrumentInfoChanged(int MapId, int Bank, int Program) { |
111 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_info, MapId, Bank, Program)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_info, MapId, Bank, Program)); |
112 |
} |
} |
113 |
|
|
114 |
void LSCPServer::LscpMidiInstrumentMapCountListener::MidiInstrumentMapCountChanged(int NewCount) { |
void LSCPServer::EventHandler::MidiInstrumentMapCountChanged(int NewCount) { |
115 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_count, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_count, NewCount)); |
116 |
} |
} |
117 |
|
|
118 |
void LSCPServer::LscpMidiInstrumentMapInfoListener::MidiInstrumentMapInfoChanged(int MapId) { |
void LSCPServer::EventHandler::MidiInstrumentMapInfoChanged(int MapId) { |
119 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_info, MapId)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_midi_instr_map_info, MapId)); |
120 |
} |
} |
121 |
|
|
122 |
void LSCPServer::LscpFxSendCountListener::FxSendCountChanged(int ChannelId, int NewCount) { |
void LSCPServer::EventHandler::FxSendCountChanged(int ChannelId, int NewCount) { |
123 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_count, ChannelId, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_count, ChannelId, NewCount)); |
124 |
} |
} |
125 |
|
|
126 |
void LSCPServer::LscpVoiceCountListener::VoiceCountChanged(int ChannelId, int NewCount) { |
void LSCPServer::EventHandler::VoiceCountChanged(int ChannelId, int NewCount) { |
127 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_voice_count, ChannelId, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_voice_count, ChannelId, NewCount)); |
128 |
} |
} |
129 |
|
|
130 |
void LSCPServer::LscpStreamCountListener::StreamCountChanged(int ChannelId, int NewCount) { |
void LSCPServer::EventHandler::StreamCountChanged(int ChannelId, int NewCount) { |
131 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_stream_count, ChannelId, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_stream_count, ChannelId, NewCount)); |
132 |
} |
} |
133 |
|
|
134 |
void LSCPServer::LscpBufferFillListener::BufferFillChanged(int ChannelId, String FillData) { |
void LSCPServer::EventHandler::BufferFillChanged(int ChannelId, String FillData) { |
135 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_buffer_fill, ChannelId, FillData)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_buffer_fill, ChannelId, FillData)); |
136 |
} |
} |
137 |
|
|
138 |
void LSCPServer::LscpTotalVoiceCountListener::TotalVoiceCountChanged(int NewCount) { |
void LSCPServer::EventHandler::TotalVoiceCountChanged(int NewCount) { |
139 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, NewCount)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, NewCount)); |
140 |
} |
} |
141 |
|
|
182 |
Initialized.Set(true); |
Initialized.Set(true); |
183 |
|
|
184 |
// Registering event listeners |
// Registering event listeners |
185 |
pSampler->AddChannelCountListener(&channelCountListener); |
pSampler->AddChannelCountListener(&eventHandler); |
186 |
pSampler->AddAudioDeviceCountListener(&audioDeviceCountListener); |
pSampler->AddAudioDeviceCountListener(&eventHandler); |
187 |
pSampler->AddMidiDeviceCountListener(&midiDeviceCountListener); |
pSampler->AddMidiDeviceCountListener(&eventHandler); |
188 |
pSampler->AddVoiceCountListener(&voiceCountListener); |
pSampler->AddVoiceCountListener(&eventHandler); |
189 |
pSampler->AddStreamCountListener(&streamCountListener); |
pSampler->AddStreamCountListener(&eventHandler); |
190 |
pSampler->AddBufferFillListener(&bufferFillListener); |
pSampler->AddBufferFillListener(&eventHandler); |
191 |
pSampler->AddTotalVoiceCountListener(&totalVoiceCountListener); |
pSampler->AddTotalVoiceCountListener(&eventHandler); |
192 |
pSampler->AddFxSendCountListener(&fxSendCountListener); |
pSampler->AddFxSendCountListener(&eventHandler); |
193 |
MidiInstrumentMapper::AddMidiInstrumentCountListener(&midiInstrumentCountListener); |
MidiInstrumentMapper::AddMidiInstrumentCountListener(&eventHandler); |
194 |
MidiInstrumentMapper::AddMidiInstrumentInfoListener(&midiInstrumentInfoListener); |
MidiInstrumentMapper::AddMidiInstrumentInfoListener(&eventHandler); |
195 |
MidiInstrumentMapper::AddMidiInstrumentMapCountListener(&midiInstrumentMapCountListener); |
MidiInstrumentMapper::AddMidiInstrumentMapCountListener(&eventHandler); |
196 |
MidiInstrumentMapper::AddMidiInstrumentMapInfoListener(&midiInstrumentMapInfoListener); |
MidiInstrumentMapper::AddMidiInstrumentMapInfoListener(&eventHandler); |
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; |
565 |
return result.Produce(); |
return result.Produce(); |
566 |
} |
} |
567 |
|
|
568 |
|
EngineChannel* LSCPServer::GetEngineChannel(uint uiSamplerChannel) { |
569 |
|
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
570 |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
571 |
|
|
572 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
573 |
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
574 |
|
|
575 |
|
return pEngineChannel; |
576 |
|
} |
577 |
|
|
578 |
/** |
/** |
579 |
* Will be called by the parser to load an instrument. |
* Will be called by the parser to load an instrument. |
580 |
*/ |
*/ |
1909 |
LSCPResultSet result; |
LSCPResultSet result; |
1910 |
try { |
try { |
1911 |
result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID)); |
result.Add("NAME", MidiInstrumentMapper::MapName(MidiMapID)); |
1912 |
|
result.Add("DEFAULT", MidiInstrumentMapper::GetDefaultMap() == MidiMapID); |
1913 |
} catch (Exception e) { |
} catch (Exception e) { |
1914 |
result.Error(e); |
result.Error(e); |
1915 |
} |
} |
1958 |
dmsg(2,("LSCPServer: CreateFxSend()\n")); |
dmsg(2,("LSCPServer: CreateFxSend()\n")); |
1959 |
LSCPResultSet result; |
LSCPResultSet result; |
1960 |
try { |
try { |
1961 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
1962 |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
|
|
|
|
1963 |
FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name); |
FxSend* pFxSend = pEngineChannel->AddFxSend(MidiCtrl, Name); |
1964 |
if (!pFxSend) throw Exception("Could not add FxSend, don't ask, I don't know why (probably a bug)"); |
if (!pFxSend) throw Exception("Could not add FxSend, don't ask, I don't know why (probably a bug)"); |
1965 |
|
|
1974 |
dmsg(2,("LSCPServer: DestroyFxSend()\n")); |
dmsg(2,("LSCPServer: DestroyFxSend()\n")); |
1975 |
LSCPResultSet result; |
LSCPResultSet result; |
1976 |
try { |
try { |
1977 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
|
1978 |
|
|
1979 |
FxSend* pFxSend = NULL; |
FxSend* pFxSend = NULL; |
1980 |
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
1995 |
dmsg(2,("LSCPServer: GetFxSends()\n")); |
dmsg(2,("LSCPServer: GetFxSends()\n")); |
1996 |
LSCPResultSet result; |
LSCPResultSet result; |
1997 |
try { |
try { |
1998 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
|
1999 |
|
|
2000 |
result.Add(pEngineChannel->GetFxSendCount()); |
result.Add(pEngineChannel->GetFxSendCount()); |
2001 |
} catch (Exception e) { |
} catch (Exception e) { |
2009 |
LSCPResultSet result; |
LSCPResultSet result; |
2010 |
String list; |
String list; |
2011 |
try { |
try { |
2012 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
|
2013 |
|
|
2014 |
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2015 |
FxSend* pFxSend = pEngineChannel->GetFxSend(i); |
FxSend* pFxSend = pEngineChannel->GetFxSend(i); |
2023 |
return result.Produce(); |
return result.Produce(); |
2024 |
} |
} |
2025 |
|
|
2026 |
|
FxSend* LSCPServer::GetFxSend(uint uiSamplerChannel, uint FxSendID) { |
2027 |
|
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
2028 |
|
|
2029 |
|
FxSend* pFxSend = NULL; |
2030 |
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
2031 |
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
2032 |
|
pFxSend = pEngineChannel->GetFxSend(i); |
2033 |
|
break; |
2034 |
|
} |
2035 |
|
} |
2036 |
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
2037 |
|
return pFxSend; |
2038 |
|
} |
2039 |
|
|
2040 |
String LSCPServer::GetFxSendInfo(uint uiSamplerChannel, uint FxSendID) { |
String LSCPServer::GetFxSendInfo(uint uiSamplerChannel, uint FxSendID) { |
2041 |
dmsg(2,("LSCPServer: GetFxSendInfo()\n")); |
dmsg(2,("LSCPServer: GetFxSendInfo()\n")); |
2042 |
LSCPResultSet result; |
LSCPResultSet result; |
2043 |
try { |
try { |
2044 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
EngineChannel* pEngineChannel = GetEngineChannel(uiSamplerChannel); |
2045 |
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
2046 |
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
|
|
|
|
|
FxSend* pFxSend = NULL; |
|
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
|
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
|
|
pFxSend = pEngineChannel->GetFxSend(i); |
|
|
break; |
|
|
} |
|
|
} |
|
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
|
|
|
|
2047 |
// gather audio routing informations |
// gather audio routing informations |
2048 |
String AudioRouting; |
String AudioRouting; |
2049 |
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
for (int chan = 0; chan < pEngineChannel->Channels(); chan++) { |
2062 |
return result.Produce(); |
return result.Produce(); |
2063 |
} |
} |
2064 |
|
|
2065 |
String LSCPServer::SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel) { |
String LSCPServer::SetFxSendName(uint uiSamplerChannel, uint FxSendID, String Name) { |
2066 |
dmsg(2,("LSCPServer: SetFxSendAudioOutputChannel()\n")); |
dmsg(2,("LSCPServer: SetFxSendName()\n")); |
2067 |
LSCPResultSet result; |
LSCPResultSet result; |
2068 |
try { |
try { |
2069 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
2070 |
|
|
2071 |
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
pFxSend->SetName(Name); |
2072 |
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
2073 |
|
} catch (Exception e) { |
2074 |
|
result.Error(e); |
2075 |
|
} |
2076 |
|
return result.Produce(); |
2077 |
|
} |
2078 |
|
|
2079 |
FxSend* pFxSend = NULL; |
String LSCPServer::SetFxSendAudioOutputChannel(uint uiSamplerChannel, uint FxSendID, uint FxSendChannel, uint DeviceChannel) { |
2080 |
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
dmsg(2,("LSCPServer: SetFxSendAudioOutputChannel()\n")); |
2081 |
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
LSCPResultSet result; |
2082 |
pFxSend = pEngineChannel->GetFxSend(i); |
try { |
2083 |
break; |
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
|
} |
|
|
} |
|
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
|
2084 |
|
|
2085 |
pFxSend->SetDestinationChannel(FxSendChannel, DeviceChannel); |
pFxSend->SetDestinationChannel(FxSendChannel, DeviceChannel); |
2086 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
2094 |
dmsg(2,("LSCPServer: SetFxSendMidiController()\n")); |
dmsg(2,("LSCPServer: SetFxSendMidiController()\n")); |
2095 |
LSCPResultSet result; |
LSCPResultSet result; |
2096 |
try { |
try { |
2097 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
|
|
|
|
|
FxSend* pFxSend = NULL; |
|
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
|
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
|
|
pFxSend = pEngineChannel->GetFxSend(i); |
|
|
break; |
|
|
} |
|
|
} |
|
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
|
2098 |
|
|
2099 |
pFxSend->SetMidiController(MidiController); |
pFxSend->SetMidiController(MidiController); |
2100 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
2108 |
dmsg(2,("LSCPServer: SetFxSendLevel()\n")); |
dmsg(2,("LSCPServer: SetFxSendLevel()\n")); |
2109 |
LSCPResultSet result; |
LSCPResultSet result; |
2110 |
try { |
try { |
2111 |
SamplerChannel* pSamplerChannel = pSampler->GetSamplerChannel(uiSamplerChannel); |
FxSend* pFxSend = GetFxSend(uiSamplerChannel, FxSendID); |
|
if (!pSamplerChannel) throw Exception("Invalid sampler channel number " + ToString(uiSamplerChannel)); |
|
|
|
|
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
|
|
if (!pEngineChannel) throw Exception("There is no engine deployed on this sampler channel yet"); |
|
|
|
|
|
FxSend* pFxSend = NULL; |
|
|
for (int i = 0; i < pEngineChannel->GetFxSendCount(); i++) { |
|
|
if (pEngineChannel->GetFxSend(i)->Id() == FxSendID) { |
|
|
pFxSend = pEngineChannel->GetFxSend(i); |
|
|
break; |
|
|
} |
|
|
} |
|
|
if (!pFxSend) throw Exception("There is no FxSend with that ID on the given sampler channel"); |
|
2112 |
|
|
2113 |
pFxSend->SetLevel((float)dLevel); |
pFxSend->SetLevel((float)dLevel); |
2114 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_fx_send_info, uiSamplerChannel, FxSendID)); |