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 * |
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 * |
25 |
#include <signal.h> |
#include <signal.h> |
26 |
|
|
27 |
#include "Sampler.h" |
#include "Sampler.h" |
28 |
|
#include "engines/EngineFactory.h" |
29 |
#include "drivers/midi/MidiInputDeviceFactory.h" |
#include "drivers/midi/MidiInputDeviceFactory.h" |
30 |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
#include "drivers/audio/AudioOutputDeviceFactory.h" |
31 |
#include "engines/gig/Profiler.h" |
#include "engines/gig/Profiler.h" |
38 |
Sampler* pSampler = NULL; |
Sampler* pSampler = NULL; |
39 |
LSCPServer* pLSCPServer = NULL; |
LSCPServer* pLSCPServer = NULL; |
40 |
pthread_t main_thread; |
pthread_t main_thread; |
41 |
|
bool bPrintStatistics = false; |
42 |
bool profile = false; |
bool profile = false; |
43 |
bool tune = true; |
bool tune = true; |
44 |
|
|
74 |
|
|
75 |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
dmsg(1,("LinuxSampler %s\n", VERSION)); |
76 |
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")); |
77 |
|
dmsg(1,("Copyright (C) 2005 Christian Schoenebeck\n")); |
78 |
|
|
79 |
if (tune) |
if (tune) { |
80 |
{ |
// detect and print system / CPU specific features |
81 |
// detect and print system / CPU specific features |
Features::detect(); |
82 |
String sFeatures; |
dmsg(1,("Detected features: %s\n", Features::featuresAsString().c_str())); |
83 |
Features::detect(); |
// prevent slow denormal FPU modes |
84 |
#if ARCH_X86 |
Features::enableDenormalsAreZeroMode(); |
|
if (Features::supportsMMX()) sFeatures += " MMX"; |
|
|
if (Features::supportsSSE()) sFeatures += " SSE"; |
|
|
#endif // ARCH_X86 |
|
|
if (!sFeatures.size()) sFeatures = " None"; |
|
|
dmsg(1,("Detected features:%s\n",sFeatures.c_str())); |
|
85 |
} |
} |
86 |
|
|
87 |
// create LinuxSampler instance |
// create LinuxSampler instance |
101 |
|
|
102 |
if (profile) |
if (profile) |
103 |
{ |
{ |
104 |
dmsg(1,("Calibrating profiler...")); |
dmsg(1,("Calibrating profiler...")); |
105 |
gig::Profiler::Calibrate(); |
gig::Profiler::Calibrate(); |
106 |
gig::Profiler::Reset(); |
gig::Profiler::Reset(); |
107 |
dmsg(1,("OK\n")); |
dmsg(1,("OK\n")); |
108 |
} |
} |
109 |
|
|
110 |
printf("LinuxSampler initialization completed.\n"); |
printf("LinuxSampler initialization completed. :-)\n\n"); |
111 |
|
|
112 |
|
std::list<LSCPEvent::event_t> rtEvents; |
113 |
|
rtEvents.push_back(LSCPEvent::event_voice_count); |
114 |
|
rtEvents.push_back(LSCPEvent::event_stream_count); |
115 |
|
rtEvents.push_back(LSCPEvent::event_buffer_fill); |
116 |
|
|
117 |
|
while (true) { |
118 |
|
if (bPrintStatistics) { |
119 |
|
std::set<Engine*> engines = EngineFactory::EngineInstances(); |
120 |
|
std::set<Engine*>::iterator itEngine = engines.begin(); |
121 |
|
for (int i = 0; itEngine != engines.end(); itEngine++, i++) { |
122 |
|
Engine* pEngine = *itEngine; |
123 |
|
printf("Engine %d) Voices: %3.3d (Max: %3.3d) Streams: %3.3d (Max: %3.3d)\n", i, |
124 |
|
pEngine->VoiceCount(), pEngine->VoiceCountMax(), |
125 |
|
pEngine->DiskStreamCount(), pEngine->DiskStreamCountMax() |
126 |
|
); |
127 |
|
fflush(stdout); |
128 |
|
} |
129 |
|
} |
130 |
|
|
|
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);*/ |
|
131 |
sleep(1); |
sleep(1); |
132 |
if (profile) |
if (profile) |
133 |
{ |
{ |
134 |
unsigned int samplingFreq = 48000; //FIXME: hardcoded for now |
unsigned int samplingFreq = 48000; //FIXME: hardcoded for now |
135 |
unsigned int bv = gig::Profiler::GetBogoVoices(samplingFreq); |
unsigned int bv = gig::Profiler::GetBogoVoices(samplingFreq); |
136 |
if (bv != 0) |
if (bv != 0) |
137 |
{ |
{ |
138 |
printf(" BogoVoices: %i \r", bv); |
printf(" BogoVoices: %i \r", bv); |
139 |
fflush(stdout); |
fflush(stdout); |
140 |
} |
} |
141 |
} |
} |
142 |
|
|
143 |
|
if (LSCPServer::EventSubscribers(rtEvents)) |
144 |
|
{ |
145 |
|
LSCPServer::LockRTNotify(); |
146 |
|
std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels(); |
147 |
|
std::map<uint,SamplerChannel*>::iterator iter = channels.begin(); |
148 |
|
for (; iter != channels.end(); iter++) { |
149 |
|
SamplerChannel* pSamplerChannel = iter->second; |
150 |
|
EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel(); |
151 |
|
if (!pEngineChannel) continue; |
152 |
|
Engine* pEngine = pEngineChannel->GetEngine(); |
153 |
|
if (!pEngine) continue; |
154 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_voice_count, iter->first, pEngine->VoiceCount())); |
155 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_stream_count, iter->first, pEngine->DiskStreamCount())); |
156 |
|
LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_buffer_fill, iter->first, pEngine->DiskStreamBufferFillPercentage())); |
157 |
|
} |
158 |
|
LSCPServer::UnlockRTNotify(); |
159 |
|
} |
160 |
|
|
161 |
} |
} |
162 |
|
|
163 |
return EXIT_SUCCESS; |
return EXIT_SUCCESS; |
221 |
{"version",0,0,0}, |
{"version",0,0,0}, |
222 |
{"profile",0,0,0}, |
{"profile",0,0,0}, |
223 |
{"no-tune",0,0,0}, |
{"no-tune",0,0,0}, |
224 |
|
{"statistics",0,0,0}, |
225 |
{0,0,0,0} |
{0,0,0,0} |
226 |
}; |
}; |
227 |
|
|
228 |
while (true) { |
while (true) { |
229 |
res = getopt_long_only(argc, argv, "", long_options, &option_index); |
/* |
230 |
|
Stephane Letz : letz@grame.fr |
231 |
|
getopt_long_only does not exist on OSX : replaced by getopt_long for now. |
232 |
|
*/ |
233 |
|
res = getopt_long(argc, argv, "", long_options, &option_index); |
234 |
if(res == -1) break; |
if(res == -1) break; |
235 |
if (res == 0) { |
if (res == 0) { |
236 |
switch(option_index) { |
switch(option_index) { |
240 |
printf("--version prints version information\n"); |
printf("--version prints version information\n"); |
241 |
printf("--profile profile synthesis algorithms\n"); |
printf("--profile profile synthesis algorithms\n"); |
242 |
printf("--no-tune disable assembly optimization\n"); |
printf("--no-tune disable assembly optimization\n"); |
243 |
|
printf("--statistics prints periodically statistics\n"); |
244 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
245 |
break; |
break; |
246 |
case 1: // --version |
case 1: // --version |
248 |
exit(EXIT_SUCCESS); |
exit(EXIT_SUCCESS); |
249 |
break; |
break; |
250 |
case 2: // --profile |
case 2: // --profile |
251 |
profile = true; |
profile = true; |
252 |
break; |
break; |
253 |
case 3: // --no-tune |
case 3: // --no-tune |
254 |
tune = false; |
tune = false; |
255 |
|
break; |
256 |
|
case 4: // --statistics |
257 |
|
bPrintStatistics = true; |
258 |
break; |
break; |
259 |
} |
} |
260 |
} |
} |