2 |
* * |
* * |
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-2007 Christian Schoenebeck * |
7 |
* * |
* * |
8 |
* This program is free software; you can redistribute it and/or modify * |
* This program 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 <getopt.h> |
#include <getopt.h> |
25 |
#include <signal.h> |
#include <signal.h> |
26 |
|
|
27 |
|
#if defined(WIN32) |
28 |
|
// require at least Windows 2000 for the GlobalMemoryStatusEx() call |
29 |
|
#define _WIN32_WINNT 0x0500 |
30 |
|
#endif |
31 |
|
|
32 |
#include "Sampler.h" |
#include "Sampler.h" |
33 |
|
#include "common/global_private.h" |
34 |
|
#include "engines/EngineFactory.h" |
35 |
|
#include "plugins/InstrumentEditorFactory.h" |
36 |
#include "drivers/midi/MidiInputDeviceFactory.h" |
#include "drivers/midi/MidiInputDeviceFactory.h" |
37 |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
38 |
|
#include "engines/gig/Profiler.h" |
39 |
#include "network/lscpserver.h" |
#include "network/lscpserver.h" |
40 |
#include "common/stacktrace.h" |
#include "common/stacktrace.h" |
41 |
#include "common/Features.h" |
#include "common/Features.h" |
44 |
|
|
45 |
Sampler* pSampler = NULL; |
Sampler* pSampler = NULL; |
46 |
LSCPServer* pLSCPServer = NULL; |
LSCPServer* pLSCPServer = NULL; |
47 |
|
#if defined(WIN32) |
48 |
|
// inet_aton seems missing under WIN32 |
49 |
|
#ifndef INADDR_NONE |
50 |
|
#define INADDR_NONE 0xffffffff |
51 |
|
#endif |
52 |
|
|
53 |
|
int inet_aton(const char *cp, struct in_addr *addr) |
54 |
|
{ |
55 |
|
addr->s_addr = inet_addr(cp); |
56 |
|
return (addr->s_addr == INADDR_NONE) ? 0 : 1; |
57 |
|
} |
58 |
|
|
59 |
|
DWORD main_thread; |
60 |
|
#else |
61 |
pthread_t main_thread; |
pthread_t main_thread; |
62 |
|
pid_t main_pid; |
63 |
|
#endif |
64 |
|
bool bPrintStatistics = false; |
65 |
|
bool profile = false; |
66 |
|
bool tune = true; |
67 |
|
unsigned long int lscp_addr; |
68 |
|
unsigned short int lscp_port; |
69 |
|
|
70 |
void parse_options(int argc, char **argv); |
void parse_options(int argc, char **argv); |
71 |
void signal_handler(int signal); |
void signal_handler(int signal); |
76 |
// initialize the stack trace mechanism with our binary file |
// initialize the stack trace mechanism with our binary file |
77 |
StackTraceInit(argv[0], -1); |
StackTraceInit(argv[0], -1); |
78 |
|
|
79 |
|
#if defined(WIN32) |
80 |
|
// some WIN32 memory info code which tries to determine the maximum lockable amount of memory (for debug purposes) |
81 |
|
SYSTEM_INFO siSysInfo; |
82 |
|
long physical_memory; |
83 |
|
GetSystemInfo(&siSysInfo); |
84 |
|
dmsg(1,("page size=%d\n", siSysInfo.dwPageSize)); |
85 |
|
|
86 |
|
MEMORYSTATUSEX statex; |
87 |
|
statex.dwLength = sizeof (statex); |
88 |
|
GlobalMemoryStatusEx (&statex); |
89 |
|
dmsg(1, ("There are %*I64d total Kbytes of physical memory.\n", |
90 |
|
8, statex.ullTotalPhys)); |
91 |
|
dmsg(1, ("There are %*I64d free Kbytes of physical memory.\n", |
92 |
|
8, statex.ullAvailPhys)); |
93 |
|
physical_memory = statex.ullTotalPhys; |
94 |
|
|
95 |
|
HANDLE hProcess = GetCurrentProcess(); |
96 |
|
|
97 |
|
unsigned long MinimumWorkingSetSize, MaximumWorkingSetSize; |
98 |
|
unsigned long DefaultMinimumWorkingSetSize, DefaultMaximumWorkingSetSize; |
99 |
|
unsigned long RequestedMinimumWorkingSetSize, RequestedMaximumWorkingSetSize; |
100 |
|
int res; |
101 |
|
|
102 |
|
res = GetProcessWorkingSetSize(hProcess, &DefaultMinimumWorkingSetSize, &DefaultMaximumWorkingSetSize); |
103 |
|
|
104 |
|
RequestedMaximumWorkingSetSize = physical_memory - 2*1024*1024; |
105 |
|
RequestedMinimumWorkingSetSize = RequestedMaximumWorkingSetSize; |
106 |
|
|
107 |
|
for(;;) { |
108 |
|
dmsg(2,("TRYING VALUES RequestedMinimumWorkingSetSize=%d, RequestedMaximumWorkingSetSize=%d\n", RequestedMinimumWorkingSetSize, RequestedMaximumWorkingSetSize)); |
109 |
|
res = SetProcessWorkingSetSize(hProcess, RequestedMinimumWorkingSetSize, RequestedMaximumWorkingSetSize); |
110 |
|
dmsg(2,("AFTER SET: res = %d RequestedMinimumWorkingSetSize=%d, RequestedMaximumWorkingSetSize=%d\n", res,RequestedMinimumWorkingSetSize, RequestedMaximumWorkingSetSize)); |
111 |
|
|
112 |
|
res = GetProcessWorkingSetSize(hProcess, &MinimumWorkingSetSize, &MaximumWorkingSetSize); |
113 |
|
dmsg(2,("AFTER GET: res = %d MinimumWorkingSetSize=%d, MaximumWorkingSetSize=%d\n", res,MinimumWorkingSetSize, MaximumWorkingSetSize)); |
114 |
|
|
115 |
|
if( RequestedMinimumWorkingSetSize == MinimumWorkingSetSize ) { |
116 |
|
dmsg(2,("RequestedMinimumWorkingSetSize == MinimumWorkingSetSize. OK !\n")); |
117 |
|
break; |
118 |
|
} |
119 |
|
|
120 |
|
RequestedMinimumWorkingSetSize -= 10*1024*1024; |
121 |
|
if(RequestedMinimumWorkingSetSize < DefaultMinimumWorkingSetSize) break; |
122 |
|
} |
123 |
|
|
124 |
|
dmsg(1,("AFTER GetProcessWorkingSetSize: res = %d MinimumWorkingSetSize=%d, MaximumWorkingSetSize=%d\n", res,MinimumWorkingSetSize, MaximumWorkingSetSize)); |
125 |
|
#endif |
126 |
|
|
127 |
|
#if defined(WIN32) |
128 |
|
main_thread = GetCurrentThreadId(); |
129 |
|
#else |
130 |
|
main_pid = getpid(); |
131 |
main_thread = pthread_self(); |
main_thread = pthread_self(); |
132 |
|
#endif |
133 |
|
|
134 |
// setting signal handler for catching SIGINT (thus e.g. <CTRL><C>) |
// setting signal handler for catching SIGINT (thus e.g. <CTRL><C>) |
135 |
signal(SIGINT, signal_handler); |
signal(SIGINT, signal_handler); |
136 |
|
|
137 |
|
#if defined(WIN32) |
138 |
|
// FIXME: sigaction() not supported on WIN32, we ignore it for now |
139 |
|
#else |
140 |
// register signal handler for all unusual signals |
// register signal handler for all unusual signals |
141 |
// (we will print the stack trace and exit) |
// (we will print the stack trace and exit) |
142 |
struct sigaction sact; |
struct sigaction sact; |
149 |
sigaction(SIGFPE, &sact, NULL); |
sigaction(SIGFPE, &sact, NULL); |
150 |
sigaction(SIGUSR1, &sact, NULL); |
sigaction(SIGUSR1, &sact, NULL); |
151 |
sigaction(SIGUSR2, &sact, NULL); |
sigaction(SIGUSR2, &sact, NULL); |
152 |
|
#endif |
153 |
|
|
154 |
|
lscp_addr = htonl(LSCP_ADDR); |
155 |
|
lscp_port = htons(LSCP_PORT); |
156 |
|
|
157 |
// parse and assign command line options |
// parse and assign command line options |
158 |
//parse_options(argc, argv); |
parse_options(argc, argv); |
159 |
|
|
160 |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
161 |
dmsg(1,("Copyright (C) 2003, 2004 by Benno Senoner and Christian Schoenebeck\n")); |
dmsg(1,("Copyright (C) 2003,2004 by Benno Senoner and Christian Schoenebeck\n")); |
162 |
|
dmsg(1,("Copyright (C) 2005-2007 Christian Schoenebeck\n")); |
163 |
|
|
164 |
// detect and print system / CPU specific features |
if (tune) { |
165 |
String sFeatures; |
// detect and print system / CPU specific features |
166 |
Features::detect(); |
Features::detect(); |
167 |
#if ARCH_X86 |
dmsg(1,("Detected features: %s\n", Features::featuresAsString().c_str())); |
168 |
if (Features::supportsMMX()) sFeatures += " MMX"; |
// prevent slow denormal FPU modes |
169 |
if (Features::supportsSSE()) sFeatures += " SSE"; |
Features::enableDenormalsAreZeroMode(); |
170 |
#endif // ARCH_X86 |
} |
|
if (!sFeatures.size()) sFeatures = " None"; |
|
|
dmsg(1,("Detected features:%s\n",sFeatures.c_str())); |
|
171 |
|
|
172 |
// create LinuxSampler instance |
// create LinuxSampler instance |
173 |
dmsg(1,("Creating Sampler...")); |
dmsg(1,("Creating Sampler...")); |
174 |
pSampler = new Sampler; |
pSampler = new Sampler; |
175 |
dmsg(1,("OK\n")); |
dmsg(1,("OK\n")); |
176 |
|
|
177 |
|
dmsg(1,("Registered sampler engines: %s\n", EngineFactory::AvailableEngineTypesAsString().c_str())); |
178 |
dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); |
dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); |
179 |
dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); |
dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); |
180 |
|
dmsg(1,("Registered instrument editors: %s\n", InstrumentEditorFactory::AvailableEditorsAsString().c_str())); |
181 |
|
|
182 |
// start LSCP network server |
// start LSCP network server |
183 |
dmsg(1,("Starting LSCP network server (on TCP port %d)...", LSCP_PORT)); |
struct in_addr addr; |
184 |
pLSCPServer = new LSCPServer(pSampler); |
addr.s_addr = lscp_addr; |
185 |
|
dmsg(1,("Starting LSCP network server (%s:%d)...", inet_ntoa(addr), ntohs(lscp_port))); |
186 |
|
pLSCPServer = new LSCPServer(pSampler, lscp_addr, lscp_port); |
187 |
pLSCPServer->StartThread(); |
pLSCPServer->StartThread(); |
188 |
pLSCPServer->WaitUntilInitialized(); |
pLSCPServer->WaitUntilInitialized(); |
189 |
dmsg(1,("OK\n")); |
dmsg(1,("OK\n")); |
190 |
|
|
191 |
printf("LinuxSampler initialization completed.\n"); |
if (profile) |
192 |
|
{ |
193 |
|
dmsg(1,("Calibrating profiler...")); |
194 |
|
LinuxSampler::gig::Profiler::Calibrate(); |
195 |
|
LinuxSampler::gig::Profiler::Reset(); |
196 |
|
LinuxSampler::gig::Profiler::enable(); |
197 |
|
dmsg(1,("OK\n")); |
198 |
|
} |
199 |
|
|
200 |
|
printf("LinuxSampler initialization completed. :-)\n\n"); |
201 |
|
|
202 |
|
std::list<LSCPEvent::event_t> rtEvents; |
203 |
|
rtEvents.push_back(LSCPEvent::event_voice_count); |
204 |
|
rtEvents.push_back(LSCPEvent::event_stream_count); |
205 |
|
rtEvents.push_back(LSCPEvent::event_buffer_fill); |
206 |
|
rtEvents.push_back(LSCPEvent::event_total_voice_count); |
207 |
|
|
208 |
|
while (true) { |
209 |
|
if (bPrintStatistics) { |
210 |
|
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
211 |
|
std::set<Engine*>::iterator itEngine = engines.begin(); |
212 |
|
for (int i = 0; itEngine != engines.end(); itEngine++, i++) { |
213 |
|
Engine* pEngine = *itEngine; |
214 |
|
printf("Engine %d) Voices: %3.3d (Max: %3.3d) Streams: %3.3d (Max: %3.3d)\n", i, |
215 |
|
pEngine->VoiceCount(), pEngine->VoiceCountMax(), |
216 |
|
pEngine->DiskStreamCount(), pEngine->DiskStreamCountMax() |
217 |
|
); |
218 |
|
fflush(stdout); |
219 |
|
} |
220 |
|
} |
221 |
|
|
222 |
|
sleep(1); |
223 |
|
if (profile) |
224 |
|
{ |
225 |
|
unsigned int samplingFreq = 48000; //FIXME: hardcoded for now |
226 |
|
unsigned int bv = LinuxSampler::gig::Profiler::GetBogoVoices(samplingFreq); |
227 |
|
if (bv != 0) |
228 |
|
{ |
229 |
|
printf(" BogoVoices: %i \r", bv); |
230 |
|
fflush(stdout); |
231 |
|
} |
232 |
|
} |
233 |
|
|
234 |
|
if (LSCPServer::EventSubscribers(rtEvents)) |
235 |
|
{ |
236 |
|
LSCPServer::LockRTNotify(); |
237 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
238 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
239 |
|
for (; iter != channels.end(); iter++) { |
240 |
|
SamplerChannel* pSamplerChannel = iter->second; |
241 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
242 |
|
if (!pEngineChannel) continue; |
243 |
|
Engine* pEngine = pEngineChannel->GetEngine(); |
244 |
|
if (!pEngine) continue; |
245 |
|
pSampler->fireVoiceCountChanged(iter->first, pEngineChannel->GetVoiceCount()); |
246 |
|
pSampler->fireStreamCountChanged(iter->first, pEngineChannel->GetDiskStreamCount()); |
247 |
|
pSampler->fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); |
248 |
|
pSampler->fireTotalVoiceCountChanged(pSampler->GetVoiceCount()); |
249 |
|
} |
250 |
|
LSCPServer::UnlockRTNotify(); |
251 |
|
} |
252 |
|
|
|
while(true) { |
|
|
/*printf("Voices: %3.3d (Max: %3.3d) Streams: %3.3d (Max: %3.3d, Unused: %3.3d)\r", |
|
|
pEngine->ActiveVoiceCount, pEngine->ActiveVoiceCountMax, |
|
|
pEngine->pDiskThread->ActiveStreamCount, pEngine->pDiskThread->ActiveStreamCountMax, Stream::GetUnusedStreams()); |
|
|
fflush(stdout);*/ |
|
|
usleep(500000); |
|
253 |
} |
} |
254 |
|
|
255 |
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
258 |
void signal_handler(int iSignal) { |
void signal_handler(int iSignal) { |
259 |
switch (iSignal) { |
switch (iSignal) { |
260 |
case SIGINT: { |
case SIGINT: { |
261 |
|
#if defined(WIN32) |
262 |
|
if( GetCurrentThreadId() == main_thread ) { |
263 |
|
#else |
264 |
if (pthread_equal(pthread_self(), main_thread)) { |
if (pthread_equal(pthread_self(), main_thread)) { |
265 |
if (pLSCPServer) { |
#endif |
266 |
pLSCPServer->StopThread(); |
if (pLSCPServer) pLSCPServer->StopThread(); |
267 |
delete pLSCPServer; |
// the delete order here is important: the Sampler |
268 |
} |
// destructor sends notifications to the lscpserver |
269 |
if (pSampler) delete pSampler; |
if (pSampler) delete pSampler; |
270 |
|
if (pLSCPServer) delete pLSCPServer; |
271 |
|
#if HAVE_SQLITE3 |
272 |
|
InstrumentsDb::Destroy(); |
273 |
|
#endif |
274 |
printf("LinuxSampler stopped due to SIGINT.\n"); |
printf("LinuxSampler stopped due to SIGINT.\n"); |
275 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
276 |
} |
} |
277 |
return; |
return; |
278 |
} |
} |
279 |
|
#if defined(WIN32) |
280 |
|
// FIXME: under WIN32 we ignore the signals below due to the missing sigaction call |
281 |
|
#else |
282 |
case SIGSEGV: |
case SIGSEGV: |
283 |
std::cerr << ">>> FATAL ERROR: Segmentation fault (SIGSEGV) occured! <<<\n" << std::flush; |
std::cerr << ">>> FATAL ERROR: Segmentation fault (SIGSEGV) occured! <<<\n" << std::flush; |
284 |
break; |
break; |
297 |
case SIGUSR2: |
case SIGUSR2: |
298 |
std::cerr << ">>> User defined signal 2 (SIGUSR2) received <<<\n" << std::flush; |
std::cerr << ">>> User defined signal 2 (SIGUSR2) received <<<\n" << std::flush; |
299 |
break; |
break; |
300 |
|
#endif |
301 |
default: { // this should never happen, as we register for the signals we want |
default: { // this should never happen, as we register for the signals we want |
302 |
std::cerr << ">>> FATAL ERROR: Unknown signal received! <<<\n" << std::flush; |
std::cerr << ">>> FATAL ERROR: Unknown signal received! <<<\n" << std::flush; |
303 |
break; |
break; |
312 |
} |
} |
313 |
|
|
314 |
void kill_app() { |
void kill_app() { |
315 |
kill(main_thread, SIGKILL); |
#if defined(WIN32) |
316 |
|
// FIXME: do we need to do anything at this point under WIN32 ? is exit(0) ok ? |
317 |
|
exit(0); |
318 |
|
#else |
319 |
|
kill(main_pid, SIGKILL); |
320 |
|
#endif |
321 |
} |
} |
322 |
|
|
323 |
/*void parse_options(int argc, char **argv) { |
void parse_options(int argc, char **argv) { |
324 |
int res; |
int res; |
325 |
int option_index = 0; |
int option_index = 0; |
326 |
static struct option long_options[] = |
static struct option long_options[] = |
327 |
{ |
{ |
|
{"numfragments",1,0,0}, |
|
|
{"fragmentsize",1,0,0}, |
|
|
{"volume",1,0,0}, |
|
|
{"dls",0,0,0}, |
|
|
{"gig",0,0,0}, |
|
|
{"instrument",1,0,0}, |
|
|
{"inputclient",1,0,0}, |
|
|
{"alsaout",1,0,0}, |
|
|
{"jackout",1,0,0}, |
|
|
{"samplerate",1,0,0}, |
|
|
{"server",0,0,0}, |
|
328 |
{"help",0,0,0}, |
{"help",0,0,0}, |
329 |
|
{"version",0,0,0}, |
330 |
|
{"profile",0,0,0}, |
331 |
|
{"no-tune",0,0,0}, |
332 |
|
{"statistics",0,0,0}, |
333 |
|
{"instruments-db-location",1,0,0}, |
334 |
|
{"create-instruments-db",1,0,0}, |
335 |
|
{"lscp-addr",1,0,0}, |
336 |
|
{"lscp-port",1,0,0}, |
337 |
{0,0,0,0} |
{0,0,0,0} |
338 |
}; |
}; |
339 |
|
|
340 |
while (true) { |
while (true) { |
341 |
res = getopt_long_only(argc, argv, "", long_options, &option_index); |
/* |
342 |
|
Stephane Letz : letz@grame.fr |
343 |
|
getopt_long_only does not exist on OSX : replaced by getopt_long for now. |
344 |
|
*/ |
345 |
|
res = getopt_long(argc, argv, "", long_options, &option_index); |
346 |
if(res == -1) break; |
if(res == -1) break; |
347 |
if (res == 0) { |
if (res == 0) { |
348 |
switch(option_index) { |
switch(option_index) { |
349 |
case 0: // --numfragments |
case 0: // --help |
350 |
num_fragments = atoi(optarg); |
printf("usage: linuxsampler [OPTIONS]\n\n"); |
351 |
break; |
printf("--help prints this message\n"); |
352 |
case 1: // --fragmentsize |
printf("--version prints version information\n"); |
353 |
fragmentsize = atoi(optarg); |
printf("--profile profile synthesis algorithms\n"); |
354 |
break; |
printf("--no-tune disable assembly optimization\n"); |
355 |
case 2: // --volume |
printf("--statistics periodically prints statistics\n"); |
356 |
volume = atof(optarg); |
printf("--lscp-addr set LSCP address (default: any)\n"); |
357 |
break; |
printf("--lscp-port set LSCP port (default: 8888)\n"); |
358 |
case 3: // --dls |
printf("--create-instruments-db creates an instruments DB\n"); |
359 |
patch_format = patch_format_dls; |
printf("--instruments-db-location specifies the instruments DB file\n"); |
360 |
|
exit(EXIT_SUCCESS); |
361 |
break; |
break; |
362 |
case 4: // --gig |
case 1: // --version |
363 |
patch_format = patch_format_gig; |
printf("LinuxSampler %s\n", VERSION); |
364 |
|
exit(EXIT_SUCCESS); |
365 |
break; |
break; |
366 |
case 5: // --instrument |
case 2: // --profile |
367 |
instrument_index = atoi(optarg); |
profile = true; |
368 |
break; |
break; |
369 |
case 6: // --inputclient |
case 3: // --no-tune |
370 |
input_client = optarg; |
tune = false; |
371 |
break; |
break; |
372 |
case 7: // --alsaout |
case 4: // --statistics |
373 |
alsaout = optarg; |
bPrintStatistics = true; |
|
use_jack = false; // If this option is specified do not connect to jack |
|
374 |
break; |
break; |
375 |
case 8: { // --jackout |
case 5: // --instruments-db-location |
376 |
|
#if HAVE_SQLITE3 |
377 |
try { |
try { |
378 |
String arg(optarg); |
if (optarg) { |
379 |
// remove outer apostrophes |
struct stat statBuf; |
380 |
arg = arg.substr(arg.find('\'') + 1, arg.rfind('\'') - (arg.find('\'') + 1)); |
int res = stat(optarg, &statBuf); |
381 |
// split in two arguments |
|
382 |
jack_playback[0] = arg.substr(0, arg.find("\' ")); |
if (res) { |
383 |
jack_playback[1] = arg.substr(arg.find("\' ") + 2, arg.size() - (arg.find("\' ") + 2)); |
std::stringstream ss; |
384 |
// remove inner apostrophes |
ss << "Failed to stat `" << optarg << "`: " << strerror(errno); |
385 |
jack_playback[0] = jack_playback[0].substr(0, jack_playback[0].find('\'')); |
throw Exception(ss.str()); |
386 |
jack_playback[1] = jack_playback[1].substr(jack_playback[1].find('\'') + 1, jack_playback[1].size() - jack_playback[1].find('\'')); |
} |
387 |
// this is the default but set it up anyway in case alsa_card was also used. |
|
388 |
use_jack = true; |
if (!S_ISREG(statBuf.st_mode)) { |
389 |
} |
std::stringstream ss; |
390 |
catch (...) { |
ss << "`" << optarg << "` is not a regular file"; |
391 |
fprintf(stderr, "Invalid argument '%s' for parameter --jackout\n", optarg); |
throw Exception(ss.str()); |
392 |
|
} |
393 |
|
|
394 |
|
InstrumentsDb::GetInstrumentsDb()->SetDbFile(String(optarg)); |
395 |
|
} |
396 |
|
} catch(Exception e) { |
397 |
|
std::cerr << "Could not open instruments DB file: " |
398 |
|
<< e.Message() << std::endl; |
399 |
exit(EXIT_FAILURE); |
exit(EXIT_FAILURE); |
400 |
} |
} |
401 |
break; |
break; |
402 |
} |
#else |
403 |
case 9: // --samplerate |
std::cerr << "LinuxSampler was not build with "; |
404 |
samplerate = atoi(optarg); |
std::cerr << "instruments database support!\n"; |
405 |
break; |
exit(EXIT_FAILURE); |
406 |
case 10: // --server |
break; |
407 |
run_server = true; |
#endif |
408 |
break; |
case 6: // --create-instruments-db |
409 |
case 11: // --help |
#if HAVE_SQLITE3 |
410 |
printf("usage: linuxsampler [OPTIONS] <INSTRUMENTFILE>\n\n"); |
try { |
411 |
printf("--gig loads a Gigasampler instrument\n"); |
if (optarg) { |
412 |
printf("--dls loads a DLS instrument\n"); |
std::cout << "Creating instruments database..." << std::endl; |
413 |
printf("--instrument index of the instrument in the instrument file if it\n"); |
InstrumentsDb::CreateInstrumentsDb(String(optarg)); |
414 |
printf(" contains more than one (default: 0)\n"); |
InstrumentsDb::Destroy(); |
415 |
printf("--numfragments sets the number of audio fragments\n"); |
std::cout << "Done" << std::endl; |
416 |
printf("--fragmentsize sets the fragment size\n"); |
} |
417 |
printf("--volume sets global volume gain factor (a value > 1.0 means\n"); |
} catch(Exception e) { |
418 |
printf(" amplification, a value < 1.0 means attenuation,\n"); |
std::cerr << e.Message() << std::endl; |
419 |
printf(" default: 0.25)\n"); |
exit(EXIT_FAILURE); |
420 |
printf("--inputclient connects to an Alsa sequencer input client on startup\n"); |
return; |
421 |
printf(" (e.g. 64:0 to connect to a client with ID 64 and port 0)\n"); |
} |
422 |
printf("--alsaout connects to the given Alsa sound device on startup\n"); |
|
|
printf(" (e.g. 0,0 to connect to hw:0,0 or plughw:0,0)\n"); |
|
|
printf("--jackout connects to the given Jack playback ports on startup\n"); |
|
|
printf(" (e.g. \"\'alsa_pcm:playback_1\' \'alsa_pcm:playback_2\'\"\n"); |
|
|
printf(" in case of stereo output)\n"); |
|
|
printf("--samplerate sets sample rate if supported by audio output system\n"); |
|
|
printf(" (e.g. 44100)\n"); |
|
|
printf("--server launch network server for remote control\n"); |
|
423 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
424 |
|
return; |
425 |
|
#else |
426 |
|
std::cerr << "Failed to create the database. LinuxSampler was "; |
427 |
|
std::cerr << "not build with instruments database support!\n"; |
428 |
|
exit(EXIT_FAILURE); |
429 |
|
return; |
430 |
|
#endif |
431 |
|
case 7: // --lscp-addr |
432 |
|
struct in_addr addr; |
433 |
|
if (inet_aton(optarg, &addr) == 0) |
434 |
|
printf("WARNING: Failed to parse lscp-addr argument, ignoring!\n"); |
435 |
|
else |
436 |
|
lscp_addr = addr.s_addr; |
437 |
|
break; |
438 |
|
case 8: // --lscp-port |
439 |
|
long unsigned int port = 0; |
440 |
|
if ((sscanf(optarg, "%u", &port) != 1) || (port == 0) || (port > 65535)) |
441 |
|
printf("WARNING: Failed to parse lscp-port argument, ignoring!\n"); |
442 |
|
else |
443 |
|
lscp_port = htons(port); |
444 |
break; |
break; |
445 |
} |
} |
446 |
} |
} |
447 |
} |
} |
448 |
}*/ |
} |