26 |
|
|
27 |
#include "Sampler.h" |
#include "Sampler.h" |
28 |
#include "engines/EngineFactory.h" |
#include "engines/EngineFactory.h" |
29 |
|
#include "engines/InstrumentEditorFactory.h" |
30 |
#include "drivers/midi/MidiInputDeviceFactory.h" |
#include "drivers/midi/MidiInputDeviceFactory.h" |
31 |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
32 |
#include "engines/gig/Profiler.h" |
#include "engines/gig/Profiler.h" |
100 |
dmsg(1,("Registered sampler engines: %s\n", EngineFactory::AvailableEngineTypesAsString().c_str())); |
dmsg(1,("Registered sampler engines: %s\n", EngineFactory::AvailableEngineTypesAsString().c_str())); |
101 |
dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); |
dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); |
102 |
dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); |
dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); |
103 |
|
dmsg(1,("Registered instrument editors: %s\n", InstrumentEditorFactory::AvailableEditorsAsString().c_str())); |
104 |
|
|
105 |
// start LSCP network server |
// start LSCP network server |
106 |
struct in_addr addr; |
struct in_addr addr; |
165 |
if (!pEngineChannel) continue; |
if (!pEngineChannel) continue; |
166 |
Engine* pEngine = pEngineChannel->GetEngine(); |
Engine* pEngine = pEngineChannel->GetEngine(); |
167 |
if (!pEngine) continue; |
if (!pEngine) continue; |
168 |
pSampler->fireVoiceCountChanged(iter->first, pEngine->VoiceCount()); |
pSampler->fireVoiceCountChanged(iter->first, pEngineChannel->GetVoiceCount()); |
169 |
pSampler->fireStreamCountChanged(iter->first, pEngine->DiskStreamCount()); |
pSampler->fireStreamCountChanged(iter->first, pEngineChannel->GetDiskStreamCount()); |
170 |
pSampler->fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); |
pSampler->fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); |
171 |
pSampler->fireTotalVoiceCountChanged(pSampler->GetVoiceCount()); |
pSampler->fireTotalVoiceCountChanged(pSampler->GetVoiceCount()); |
172 |
} |
} |
182 |
switch (iSignal) { |
switch (iSignal) { |
183 |
case SIGINT: { |
case SIGINT: { |
184 |
if (pthread_equal(pthread_self(), main_thread)) { |
if (pthread_equal(pthread_self(), main_thread)) { |
185 |
if (pLSCPServer) { |
if (pLSCPServer) pLSCPServer->StopThread(); |
186 |
pLSCPServer->StopThread(); |
// the delete order here is important: the Sampler |
187 |
delete pLSCPServer; |
// destructor sends notifications to the lscpserver |
|
} |
|
188 |
if (pSampler) delete pSampler; |
if (pSampler) delete pSampler; |
189 |
|
if (pLSCPServer) delete pLSCPServer; |
190 |
#if HAVE_SQLITE3 |
#if HAVE_SQLITE3 |
191 |
InstrumentsDb::Destroy(); |
InstrumentsDb::Destroy(); |
192 |
#endif |
#endif |
240 |
{"profile",0,0,0}, |
{"profile",0,0,0}, |
241 |
{"no-tune",0,0,0}, |
{"no-tune",0,0,0}, |
242 |
{"statistics",0,0,0}, |
{"statistics",0,0,0}, |
243 |
|
{"instruments-db-location",1,0,0}, |
244 |
|
{"create-instruments-db",1,0,0}, |
245 |
{"lscp-addr",1,0,0}, |
{"lscp-addr",1,0,0}, |
246 |
{"lscp-port",1,0,0}, |
{"lscp-port",1,0,0}, |
247 |
{0,0,0,0} |
{0,0,0,0} |
258 |
switch(option_index) { |
switch(option_index) { |
259 |
case 0: // --help |
case 0: // --help |
260 |
printf("usage: linuxsampler [OPTIONS]\n\n"); |
printf("usage: linuxsampler [OPTIONS]\n\n"); |
261 |
printf("--help prints this message\n"); |
printf("--help prints this message\n"); |
262 |
printf("--version prints version information\n"); |
printf("--version prints version information\n"); |
263 |
printf("--profile profile synthesis algorithms\n"); |
printf("--profile profile synthesis algorithms\n"); |
264 |
printf("--no-tune disable assembly optimization\n"); |
printf("--no-tune disable assembly optimization\n"); |
265 |
printf("--statistics periodically prints statistics\n"); |
printf("--statistics periodically prints statistics\n"); |
266 |
printf("--lscp-addr set LSCP address (default: any)\n"); |
printf("--lscp-addr set LSCP address (default: any)\n"); |
267 |
printf("--lscp-port set LSCP port (default: 8888)\n"); |
printf("--lscp-port set LSCP port (default: 8888)\n"); |
268 |
|
printf("--create-instruments-db creates an instruments DB\n"); |
269 |
|
printf("--instruments-db-location specifies the instruments DB file\n"); |
270 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
271 |
break; |
break; |
272 |
case 1: // --version |
case 1: // --version |
282 |
case 4: // --statistics |
case 4: // --statistics |
283 |
bPrintStatistics = true; |
bPrintStatistics = true; |
284 |
break; |
break; |
285 |
case 5: // --lscp-addr |
case 5: // --instruments-db-location |
286 |
struct in_addr addr; |
#if HAVE_SQLITE3 |
287 |
if (inet_aton(optarg, &addr) == 0) |
try { |
288 |
printf("WARNING: Failed to parse lscp-addr argument, ignoring!\n"); |
if (optarg) { |
289 |
else |
struct stat statBuf; |
290 |
lscp_addr = addr.s_addr; |
int res = stat(optarg, &statBuf); |
291 |
|
|
292 |
|
if (res) { |
293 |
|
std::stringstream ss; |
294 |
|
ss << "Fail to stat `" << optarg << "`: " << strerror(errno); |
295 |
|
throw Exception(ss.str()); |
296 |
|
} |
297 |
|
|
298 |
|
if (!S_ISREG(statBuf.st_mode)) { |
299 |
|
std::stringstream ss; |
300 |
|
ss << "`" << optarg << "` is not a regular file"; |
301 |
|
throw Exception(ss.str()); |
302 |
|
} |
303 |
|
|
304 |
|
InstrumentsDb::GetInstrumentsDb()->SetDbFile(String(optarg)); |
305 |
|
} |
306 |
|
} catch(Exception e) { |
307 |
|
std::cerr << e.Message() << std::endl << std::endl; |
308 |
|
return; |
309 |
|
} |
310 |
|
|
311 |
|
return; |
312 |
|
#else |
313 |
|
std::cerr << "LinuxSampler was not build with "; |
314 |
|
std::cerr << "instruments database support." <<std::endl; |
315 |
|
return; |
316 |
|
#endif |
317 |
|
case 6: // --create-instruments-db |
318 |
|
#if HAVE_SQLITE3 |
319 |
|
try { |
320 |
|
if (optarg) { |
321 |
|
std::cout << "Creating instruments database..." << std::endl; |
322 |
|
InstrumentsDb::CreateInstrumentsDb(String(optarg)); |
323 |
|
InstrumentsDb::Destroy(); |
324 |
|
std::cout << "Done" << std::endl; |
325 |
|
} |
326 |
|
} catch(Exception e) { |
327 |
|
std::cerr << e.Message() << std::endl; |
328 |
|
exit(EXIT_FAILURE); |
329 |
|
return; |
330 |
|
} |
331 |
|
|
332 |
|
exit(EXIT_SUCCESS); |
333 |
|
return; |
334 |
|
#else |
335 |
|
std::cerr << "Failed to create the database. LinuxSampler was "; |
336 |
|
std::cerr << "not build with instruments database support." <<std::endl; |
337 |
|
exit(EXIT_FAILURE); |
338 |
|
return; |
339 |
|
#endif |
340 |
|
case 7: // --lscp-addr |
341 |
|
struct in_addr addr; |
342 |
|
if (inet_aton(optarg, &addr) == 0) |
343 |
|
printf("WARNING: Failed to parse lscp-addr argument, ignoring!\n"); |
344 |
|
else |
345 |
|
lscp_addr = addr.s_addr; |
346 |
break; |
break; |
347 |
case 6: // --lscp-port |
case 8: // --lscp-port |
348 |
long unsigned int port = 0; |
long unsigned int port = 0; |
349 |
if ((sscanf(optarg, "%u", &port) != 1) || (port == 0) || (port > 65535)) |
if ((sscanf(optarg, "%u", &port) != 1) || (port == 0) || (port > 65535)) |
350 |
printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); |
printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); |
351 |
else |
else |
352 |
lscp_port = htons(port); |
lscp_port = htons(port); |
353 |
break; |
break; |
354 |
} |
} |
355 |
} |
} |