/[svn]/linuxsampler/trunk/src/linuxsampler.cpp
ViewVC logotype

Diff of /linuxsampler/trunk/src/linuxsampler.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 325 by senkov, Tue Dec 21 04:54:37 2004 UTC revision 420 by schoenebeck, Thu Mar 3 03:25:17 2005 UTC
# Line 3  Line 3 
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  *
# Line 24  Line 25 
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"
# Line 36  using namespace LinuxSampler; Line 38  using namespace LinuxSampler;
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    
# Line 71  int main(int argc, char **argv) { Line 74  int main(int argc, char **argv) {
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      {      {
# Line 110  int main(int argc, char **argv) { Line 114  int main(int argc, char **argv) {
114    
115      printf("LinuxSampler initialization completed.\n");      printf("LinuxSampler initialization completed.\n");
116    
117      while(true)  {      std::list<LSCPEvent::event_t> rtEvents;
118        /*printf("Voices: %3.3d (Max: %3.3d) Streams: %3.3d (Max: %3.3d, Unused: %3.3d)\r",      rtEvents.push_back(LSCPEvent::event_voice_count);
119              pEngine->ActiveVoiceCount, pEngine->ActiveVoiceCountMax,      rtEvents.push_back(LSCPEvent::event_stream_count);
120              pEngine->pDiskThread->ActiveStreamCount, pEngine->pDiskThread->ActiveStreamCountMax, Stream::GetUnusedStreams());      rtEvents.push_back(LSCPEvent::event_buffer_fill);
121        fflush(stdout);*/  
122        while (true) {
123            if (bPrintStatistics) {
124                std::set<Engine*> engines = EngineFactory::EngineInstances();
125                std::set<Engine*>::iterator itEngine = engines.begin();
126                for (int i = 0; itEngine != engines.end(); itEngine++, i++) {
127                    Engine* pEngine = *itEngine;
128                    printf("Engine %d) Voices: %3.3d (Max: %3.3d) Streams: %3.3d (Max: %3.3d)\n", i,
129                        pEngine->VoiceCount(), pEngine->VoiceCountMax(),
130                        pEngine->DiskStreamCount(), pEngine->DiskStreamCountMax()
131                    );
132                    fflush(stdout);
133                }
134            }
135            
136        sleep(1);        sleep(1);
137        if (profile)        if (profile)
138        {        {
# Line 126  int main(int argc, char **argv) { Line 144  int main(int argc, char **argv) {
144                        fflush(stdout);                        fflush(stdout);
145                }                }
146        }        }
147          
148          if (LSCPServer::EventSubscribers(rtEvents))
149          {
150                  LSCPServer::LockRTNotify();
151                  std::map<uint,SamplerChannel*> channels = pSampler->GetSamplerChannels();
152                  std::map<uint,SamplerChannel*>::iterator iter = channels.begin();
153                  for (; iter != channels.end(); iter++) {
154                          SamplerChannel* pSamplerChannel = iter->second;
155                          EngineChannel* pEngineChannel = pSamplerChannel->GetEngineChannel();
156                          if (!pEngineChannel) continue;
157                          Engine* pEngine = pEngineChannel->GetEngine();
158                          if (!pEngine) continue;
159                          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_voice_count, iter->first, pEngine->VoiceCount()));
160                          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_stream_count, iter->first, pEngine->DiskStreamCount()));
161                          LSCPServer::SendLSCPNotify(LSCPEvent(LSCPEvent::event_buffer_fill, iter->first, pEngine->DiskStreamBufferFillPercentage()));
162                  }
163                  LSCPServer::UnlockRTNotify();
164          }
165    
166      }      }
167    
168      return EXIT_SUCCESS;      return EXIT_SUCCESS;
# Line 189  void parse_options(int argc, char **argv Line 226  void parse_options(int argc, char **argv
226              {"version",0,0,0},              {"version",0,0,0},
227              {"profile",0,0,0},              {"profile",0,0,0},
228              {"no-tune",0,0,0},              {"no-tune",0,0,0},
229                {"statistics",0,0,0},
230              {0,0,0,0}              {0,0,0,0}
231          };          };
232    
233      while (true) {      while (true) {
234          res = getopt_long_only(argc, argv, "", long_options, &option_index);          /*
235              Stephane Letz : letz@grame.fr
236              getopt_long_only does not exist on OSX : replaced by getopt_long for now.
237            */
238            res = getopt_long(argc, argv, "", long_options, &option_index);
239          if(res == -1) break;          if(res == -1) break;
240          if (res == 0) {          if (res == 0) {
241              switch(option_index) {              switch(option_index) {
# Line 203  void parse_options(int argc, char **argv Line 245  void parse_options(int argc, char **argv
245                      printf("--version          prints version information\n");                      printf("--version          prints version information\n");
246                      printf("--profile          profile synthesis algorithms\n");                      printf("--profile          profile synthesis algorithms\n");
247                      printf("--no-tune          disable assembly optimization\n");                      printf("--no-tune          disable assembly optimization\n");
248                        printf("--statistics       prints periodically statistics\n");
249                      exit(EXIT_SUCCESS);                      exit(EXIT_SUCCESS);
250                      break;                      break;
251                  case 1: // --version                  case 1: // --version
252                      printf("LinuxSampler %s\n", VERSION);                      printf("LinuxSampler %s\n", VERSION);
253                        exit(EXIT_SUCCESS);
254                      break;                      break;
255                  case 2: // --profile                  case 2: // --profile
256                      profile = true;                      profile = true;
# Line 214  void parse_options(int argc, char **argv Line 258  void parse_options(int argc, char **argv
258                  case 3: // --no-tune                  case 3: // --no-tune
259                      tune = false;                      tune = false;
260                      break;                      break;
261                    case 4: // --statistics
262                        bPrintStatistics = true;
263                        break;
264              }              }
265          }          }
266      }      }

Legend:
Removed from v.325  
changed lines
  Added in v.420

  ViewVC Help
Powered by ViewVC