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 Christian Schoenebeck * |
* 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 * |
38 |
Sampler* pSampler = NULL; |
Sampler* pSampler = NULL; |
39 |
LSCPServer* pLSCPServer = NULL; |
LSCPServer* pLSCPServer = NULL; |
40 |
pthread_t main_thread; |
pthread_t main_thread; |
41 |
|
pid_t main_pid; |
42 |
bool bPrintStatistics = false; |
bool bPrintStatistics = false; |
43 |
bool profile = false; |
bool profile = false; |
44 |
bool tune = true; |
bool tune = true; |
54 |
// initialize the stack trace mechanism with our binary file |
// initialize the stack trace mechanism with our binary file |
55 |
StackTraceInit(argv[0], -1); |
StackTraceInit(argv[0], -1); |
56 |
|
|
57 |
|
main_pid = getpid(); |
58 |
main_thread = pthread_self(); |
main_thread = pthread_self(); |
59 |
|
|
60 |
// setting signal handler for catching SIGINT (thus e.g. <CTRL><C>) |
// setting signal handler for catching SIGINT (thus e.g. <CTRL><C>) |
80 |
parse_options(argc, argv); |
parse_options(argc, argv); |
81 |
|
|
82 |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
83 |
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")); |
84 |
dmsg(1,("Copyright (C) 2005 Christian Schoenebeck\n")); |
dmsg(1,("Copyright (C) 2005-2007 Christian Schoenebeck\n")); |
85 |
|
|
86 |
if (tune) { |
if (tune) { |
87 |
// detect and print system / CPU specific features |
// detect and print system / CPU specific features |
96 |
pSampler = new Sampler; |
pSampler = new Sampler; |
97 |
dmsg(1,("OK\n")); |
dmsg(1,("OK\n")); |
98 |
|
|
99 |
|
dmsg(1,("Registered sampler engines: %s\n", EngineFactory::AvailableEngineTypesAsString().c_str())); |
100 |
dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); |
dmsg(1,("Registered MIDI input drivers: %s\n", MidiInputDeviceFactory::AvailableDriversAsString().c_str())); |
101 |
dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); |
dmsg(1,("Registered audio output drivers: %s\n", AudioOutputDeviceFactory::AvailableDriversAsString().c_str())); |
102 |
|
|
112 |
if (profile) |
if (profile) |
113 |
{ |
{ |
114 |
dmsg(1,("Calibrating profiler...")); |
dmsg(1,("Calibrating profiler...")); |
115 |
gig::Profiler::Calibrate(); |
LinuxSampler::gig::Profiler::Calibrate(); |
116 |
gig::Profiler::Reset(); |
LinuxSampler::gig::Profiler::Reset(); |
117 |
gig::Profiler::enable(); |
LinuxSampler::gig::Profiler::enable(); |
118 |
dmsg(1,("OK\n")); |
dmsg(1,("OK\n")); |
119 |
} |
} |
120 |
|
|
128 |
|
|
129 |
while (true) { |
while (true) { |
130 |
if (bPrintStatistics) { |
if (bPrintStatistics) { |
131 |
std::set<Engine*> engines = EngineFactory::EngineInstances(); |
const std::set<Engine*>& engines = EngineFactory::EngineInstances(); |
132 |
std::set<Engine*>::iterator itEngine = engines.begin(); |
std::set<Engine*>::iterator itEngine = engines.begin(); |
133 |
for (int i = 0; itEngine != engines.end(); itEngine++, i++) { |
for (int i = 0; itEngine != engines.end(); itEngine++, i++) { |
134 |
Engine* pEngine = *itEngine; |
Engine* pEngine = *itEngine; |
144 |
if (profile) |
if (profile) |
145 |
{ |
{ |
146 |
unsigned int samplingFreq = 48000; //FIXME: hardcoded for now |
unsigned int samplingFreq = 48000; //FIXME: hardcoded for now |
147 |
unsigned int bv = gig::Profiler::GetBogoVoices(samplingFreq); |
unsigned int bv = LinuxSampler::gig::Profiler::GetBogoVoices(samplingFreq); |
148 |
if (bv != 0) |
if (bv != 0) |
149 |
{ |
{ |
150 |
printf(" BogoVoices: %i \r", bv); |
printf(" BogoVoices: %i \r", bv); |
163 |
if (!pEngineChannel) continue; |
if (!pEngineChannel) continue; |
164 |
Engine* pEngine = pEngineChannel->GetEngine(); |
Engine* pEngine = pEngineChannel->GetEngine(); |
165 |
if (!pEngine) continue; |
if (!pEngine) continue; |
166 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_voice_count, iter->first, pEngine->VoiceCount())); |
pSampler->fireVoiceCountChanged(iter->first, pEngine->VoiceCount()); |
167 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_stream_count, iter->first, pEngine->DiskStreamCount())); |
pSampler->fireStreamCountChanged(iter->first, pEngine->DiskStreamCount()); |
168 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_buffer_fill, iter->first, pEngine->DiskStreamBufferFillPercentage())); |
pSampler->fireBufferFillChanged(iter->first, pEngine->DiskStreamBufferFillPercentage()); |
169 |
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_total_voice_count, pSampler->GetVoiceCount())); |
pSampler->fireTotalVoiceCountChanged(pSampler->GetVoiceCount()); |
170 |
} |
} |
171 |
LSCPServer::UnlockRTNotify(); |
LSCPServer::UnlockRTNotify(); |
172 |
} |
} |
185 |
delete pLSCPServer; |
delete pLSCPServer; |
186 |
} |
} |
187 |
if (pSampler) delete pSampler; |
if (pSampler) delete pSampler; |
188 |
|
#if HAVE_SQLITE3 |
189 |
|
InstrumentsDb::Destroy(); |
190 |
|
#endif |
191 |
printf("LinuxSampler stopped due to SIGINT.\n"); |
printf("LinuxSampler stopped due to SIGINT.\n"); |
192 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
193 |
} |
} |
225 |
} |
} |
226 |
|
|
227 |
void kill_app() { |
void kill_app() { |
228 |
kill(main_thread, SIGKILL); |
kill(main_pid, SIGKILL); |
229 |
} |
} |
230 |
|
|
231 |
void parse_options(int argc, char **argv) { |
void parse_options(int argc, char **argv) { |