1 |
/*************************************************************************** |
/*************************************************************************** |
2 |
* * |
* * |
3 |
* Copyright (C) 2008 - 2009 Andreas Persson * |
* Copyright (C) 2008 - 2011 Andreas Persson * |
4 |
* * |
* * |
5 |
* This program is free software; you can redistribute it and/or modify * |
* This program is free software; you can redistribute it and/or modify * |
6 |
* 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 * |
48 |
|
|
49 |
pSampler = new Sampler; |
pSampler = new Sampler; |
50 |
|
|
51 |
|
#if defined(__APPLE__) |
52 |
|
// AU plugin sometimes hangs if bound to loopback |
53 |
|
pLSCPServer = new LSCPServer(pSampler, htonl(INADDR_ANY), htons(LSCP_PORT)); |
54 |
|
#else |
55 |
// using LOOPBACK instead of ANY to prevent windows firewall |
// using LOOPBACK instead of ANY to prevent windows firewall |
56 |
// warnings |
// warnings |
57 |
pLSCPServer = new LSCPServer(pSampler, htonl(INADDR_LOOPBACK), |
pLSCPServer = new LSCPServer(pSampler, htonl(INADDR_LOOPBACK), htons(LSCP_PORT)); |
58 |
htons(LSCP_PORT)); |
#endif |
59 |
|
|
60 |
pLSCPServer->StartThread(); |
pLSCPServer->StartThread(); |
61 |
pLSCPServer->WaitUntilInitialized(); |
pLSCPServer->WaitUntilInitialized(); |
62 |
|
|
126 |
if (pAudioDevice) { |
if (pAudioDevice) { |
127 |
oldState = GetState(); |
oldState = GetState(); |
128 |
RemoveChannels(); |
RemoveChannels(); |
129 |
global->pSampler->DestroyAudioOutputDevice(pAudioDevice); |
AudioOutputDeviceFactory::DestroyPrivate(pAudioDevice); |
130 |
} |
} |
131 |
std::map<String, String> params; |
std::map<String, String> params; |
132 |
params["SAMPLERATE"] = ToString(SampleRate); |
params["SAMPLERATE"] = ToString(SampleRate); |
133 |
params["FRAGMENTSIZE"] = ToString(FragmentSize); |
params["FRAGMENTSIZE"] = ToString(FragmentSize); |
134 |
if (Channels > 0) params["CHANNELS"] = ToString(Channels); |
if (Channels > 0) params["CHANNELS"] = ToString(Channels); |
135 |
pAudioDevice = dynamic_cast<AudioOutputDevicePlugin*>( |
pAudioDevice = dynamic_cast<AudioOutputDevicePlugin*>( |
136 |
global->pSampler->CreateAudioOutputDevice(AudioOutputDevicePlugin::Name(), params)); |
AudioOutputDeviceFactory::CreatePrivate( |
137 |
|
AudioOutputDevicePlugin::Name(), params |
138 |
|
) |
139 |
|
); |
140 |
|
|
141 |
if (!pMidiDevice) { |
if (!pMidiDevice) { |
142 |
pMidiDevice = dynamic_cast<MidiInputDevicePlugin*>( |
pMidiDevice = dynamic_cast<MidiInputDevicePlugin*>( |
143 |
global->pSampler->CreateMidiInputDevice(MidiInputDevicePlugin::Name(), |
MidiInputDeviceFactory::CreatePrivate( |
144 |
std::map<String,String>())); |
MidiInputDevicePlugin::Name(), std::map<String,String>(), |
145 |
|
global->pSampler |
146 |
|
) |
147 |
|
); |
148 |
} |
} |
149 |
|
|
150 |
if (!oldState.empty()) { |
if (!oldState.empty()) { |
154 |
|
|
155 |
Plugin::~Plugin() { |
Plugin::~Plugin() { |
156 |
RemoveChannels(); |
RemoveChannels(); |
157 |
if (pAudioDevice) global->pSampler->DestroyAudioOutputDevice(pAudioDevice); |
if (pAudioDevice) AudioOutputDeviceFactory::DestroyPrivate(pAudioDevice); |
158 |
if (pMidiDevice) global->pSampler->DestroyMidiInputDevice(pMidiDevice); |
if (pMidiDevice) MidiInputDeviceFactory::DestroyPrivate(pMidiDevice); |
159 |
if (bPreInitDone) { |
if (bPreInitDone) { |
160 |
if (--global->RefCount == 0) { |
if (--global->RefCount == 0) { |
161 |
delete global; |
delete global; |
248 |
engine_channel->OutputChannel(1) << ' ' << |
engine_channel->OutputChannel(1) << ' ' << |
249 |
(engine_channel->UsesNoMidiInstrumentMap() ? -2 : |
(engine_channel->UsesNoMidiInstrumentMap() ? -2 : |
250 |
(engine_channel->UsesDefaultMidiInstrumentMap() ? -1 : |
(engine_channel->UsesDefaultMidiInstrumentMap() ? -1 : |
251 |
engine_channel->GetMidiInstrumentMap())) << '\n'; |
engine_channel->GetMidiInstrumentMap())) << ' ' << |
252 |
|
engine_channel->EngineName() << '\n'; |
253 |
|
|
254 |
for (int i = 0 ; i < engine_channel->GetFxSendCount() ; i++) { |
for (int i = 0 ; i < engine_channel->GetFxSendCount() ; i++) { |
255 |
FxSend* fxsend = engine_channel->GetFxSend(i); |
FxSend* fxsend = engine_channel->GetFxSend(i); |
303 |
bool mute; |
bool mute; |
304 |
s >> index >> solo >> mute; |
s >> index >> solo >> mute; |
305 |
|
|
306 |
|
int left = -1; |
307 |
|
int right; |
308 |
|
int oldMapId; |
309 |
|
String engineType = "gig"; |
310 |
|
if (s.get() == ' ') { |
311 |
|
s >> left >> right >> oldMapId; |
312 |
|
if (s.get() == ' ') { |
313 |
|
s >> engineType; |
314 |
|
// skip rest of line |
315 |
|
s.ignore(std::numeric_limits<int>::max(), '\n'); |
316 |
|
} |
317 |
|
} |
318 |
SamplerChannel* channel = global->pSampler->AddSamplerChannel(); |
SamplerChannel* channel = global->pSampler->AddSamplerChannel(); |
319 |
channel->SetEngineType("gig"); |
channel->SetEngineType(engineType); |
320 |
channel->SetAudioOutputDevice(pAudioDevice); |
channel->SetAudioOutputDevice(pAudioDevice); |
321 |
channel->SetMidiInputDevice(pMidiDevice); |
channel->SetMidiInputDevice(pMidiDevice); |
322 |
channel->SetMidiInputChannel(midi_chan_t(midiChannel)); |
channel->SetMidiInputChannel(midi_chan_t(midiChannel)); |
323 |
|
|
324 |
engine_channel = channel->GetEngineChannel(); |
engine_channel = channel->GetEngineChannel(); |
325 |
engine_channel->Volume(volume); |
engine_channel->Volume(volume); |
326 |
if (s.get() == ' ') { |
|
327 |
int left; |
if (left != -1) { |
|
int right; |
|
|
int oldMapId; |
|
|
s >> left >> right >> oldMapId; |
|
328 |
engine_channel->SetOutputChannel(0, left); |
engine_channel->SetOutputChannel(0, left); |
329 |
engine_channel->SetOutputChannel(1, right); |
engine_channel->SetOutputChannel(1, right); |
330 |
|
|
333 |
} else if (oldMapId >= 0) { |
} else if (oldMapId >= 0) { |
334 |
engine_channel->SetMidiInstrumentMap(oldToNewId[oldMapId]); |
engine_channel->SetMidiInstrumentMap(oldToNewId[oldMapId]); |
335 |
} |
} |
|
// skip rest of line |
|
|
s.ignore(std::numeric_limits<int>::max(), '\n'); |
|
336 |
} |
} |
337 |
if (!filename.empty() && index != -1) { |
if (!filename.empty() && index != -1) { |
338 |
InstrumentManager::instrument_id_t id; |
InstrumentManager::instrument_id_t id; |
401 |
|
|
402 |
return true; |
return true; |
403 |
} |
} |
404 |
|
|
405 |
|
void Plugin::DestroyDevice(AudioOutputDevicePlugin* pDevice) { |
406 |
|
AudioOutputDeviceFactory::DestroyPrivate(pDevice); |
407 |
|
} |
408 |
|
|
409 |
|
void Plugin::DestroyDevice(MidiInputDevicePlugin* pDevice) { |
410 |
|
MidiInputDeviceFactory::DestroyPrivate(pDevice); |
411 |
|
} |
412 |
} |
} |