/[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 32 by schoenebeck, Sun Jan 18 20:31:31 2004 UTC revision 33 by schoenebeck, Mon Feb 16 19:30:42 2004 UTC
# Line 27  Line 27 
27  #include <signal.h>  #include <signal.h>
28  #include <pthread.h>  #include <pthread.h>
29    
 #include <string>  
   
30  #include "global.h"  #include "global.h"
31  #include "diskthread.h"  #include "diskthread.h"
32  #include "audiothread.h"  #include "audiothread.h"
# Line 61  uint             instrument_index; Line 59  uint             instrument_index;
59  double           volume;  double           volume;
60  int              num_fragments;  int              num_fragments;
61  int              fragmentsize;  int              fragmentsize;
62  std::string      input_client;  String           input_client;
63    String           alsaout;
64    String           jack_playback[2];
65    bool             use_jack;
66  pthread_t        signalhandlerthread;  pthread_t        signalhandlerthread;
67    uint             samplerate;
68    
69  void parse_options(int argc, char **argv);  void parse_options(int argc, char **argv);
70  void signal_handler(int signal);  void signal_handler(int signal);
# Line 81  int main(int argc, char **argv) { Line 83  int main(int argc, char **argv) {
83      num_fragments     = AUDIO_FRAGMENTS;      num_fragments     = AUDIO_FRAGMENTS;
84      fragmentsize      = AUDIO_FRAGMENTSIZE;      fragmentsize      = AUDIO_FRAGMENTSIZE;
85      volume            = 0.25; // default volume      volume            = 0.25; // default volume
86        alsaout           = "0,0"; // default card
87        jack_playback[0]  = "";
88        jack_playback[1]  = "";
89        samplerate        = AUDIO_SAMPLERATE;
90        use_jack          = true;
91    
92      // parse and assign command line options      // parse and assign command line options
93      parse_options(argc, argv);      parse_options(argc, argv);
# Line 91  int main(int argc, char **argv) { Line 98  int main(int argc, char **argv) {
98          return EXIT_FAILURE;          return EXIT_FAILURE;
99      }      }
100    
101        int error = 1;
102  #if HAVE_JACK  #if HAVE_JACK
103      dmsg(1,("Initializing audio output (Jack)..."));      if (use_jack) {
104      pAudioIO = new JackIO();          dmsg(1,("Initializing audio output (Jack)..."));
105      int error = ((JackIO*)pAudioIO)->Initialize(AUDIO_CHANNELS);          pAudioIO = new JackIO();
106            error = ((JackIO*)pAudioIO)->Initialize(AUDIO_CHANNELS, jack_playback);
107            if (error) dmsg(1,("Trying Alsa output instead.\n"));
108        }
109    #endif // HAVE_JACK
110      if (error) {      if (error) {
         dmsg(1,("Trying Alsa output instead.\n"));  
111          dmsg(1,("Initializing audio output (Alsa)..."));          dmsg(1,("Initializing audio output (Alsa)..."));
112          pAudioIO = new AlsaIO();          pAudioIO = new AlsaIO();
113          int error = ((AlsaIO*)pAudioIO)->Initialize(AUDIO_CHANNELS, AUDIO_SAMPLERATE, num_fragments, fragmentsize);          int error = ((AlsaIO*)pAudioIO)->Initialize(AUDIO_CHANNELS, samplerate, num_fragments, fragmentsize, alsaout);
114          if (error) return EXIT_FAILURE;          if (error) return EXIT_FAILURE;
115      }      }
116      dmsg(1,("OK\n"));      dmsg(1,("OK\n"));
 #else // Alsa only  
     dmsg(1,("Initializing audio output (Alsa)..."));  
     pAudioIO = new AlsaIO();  
     int error = ((AlsaIO*)pAudioIO)->Initialize(AUDIO_CHANNELS, AUDIO_SAMPLERATE, num_fragments, fragmentsize);  
     if (error) return EXIT_FAILURE;  
     dmsg(1,("OK\n"));  
 #endif // HAVE_JACK  
117    
118      // Loading gig file      // Loading gig file
119      try {      try {
# Line 199  void parse_options(int argc, char **argv Line 203  void parse_options(int argc, char **argv
203              {"gig",0,0,0},              {"gig",0,0,0},
204              {"instrument",1,0,0},              {"instrument",1,0,0},
205              {"inputclient",1,0,0},              {"inputclient",1,0,0},
206                {"alsaout",1,0,0},
207                {"jackout",1,0,0},
208                {"samplerate",1,0,0},
209              {"help",0,0,0},              {"help",0,0,0},
210              {0,0,0,0}              {0,0,0,0}
211          };          };
# Line 208  void parse_options(int argc, char **argv Line 215  void parse_options(int argc, char **argv
215          if(res == -1) break;          if(res == -1) break;
216          if (res == 0) {          if (res == 0) {
217              switch(option_index) {              switch(option_index) {
218                  case 0:                  case 0: // --numfragments
219                      num_fragments = atoi(optarg);                      num_fragments = atoi(optarg);
220                      break;                      break;
221                  case 1:                  case 1: // --fragmentsize
222                      fragmentsize = atoi(optarg);                      fragmentsize = atoi(optarg);
223                      break;                      break;
224                  case 2:                  case 2: // --volume
225                      volume = atof(optarg);                      volume = atof(optarg);
226                      break;                      break;
227                  case 3:                  case 3: // --dls
228                      patch_format = patch_format_dls;                      patch_format = patch_format_dls;
229                      break;                      break;
230                  case 4:                  case 4: // --gig
231                      patch_format = patch_format_gig;                      patch_format = patch_format_gig;
232                      break;                      break;
233                  case 5:                  case 5: // --instrument
234                      instrument_index = atoi(optarg);                      instrument_index = atoi(optarg);
235                      break;                      break;
236                  case 6:                  case 6: // --inputclient
237                      input_client = optarg;                      input_client = optarg;
238                      break;                      break;
239                  case 7:                  case 7: // --alsaout
240                        alsaout = optarg;
241                        use_jack = false; // If this option is specified do not connect to jack
242                        break;
243                    case 8: { // --jackout
244                        try {
245                            String arg(optarg);
246                            // remove outer apostrophes
247                            arg = arg.substr(arg.find('\'') + 1, arg.rfind('\'') - (arg.find('\'') + 1));
248                            // split in two arguments
249                            jack_playback[0] = arg.substr(0, arg.find("\' "));
250                            jack_playback[1] = arg.substr(arg.find("\' ") + 2, arg.size() - (arg.find("\' ") + 2));
251                            // remove inner apostrophes
252                            jack_playback[0] = jack_playback[0].substr(0, jack_playback[0].find('\''));
253                            jack_playback[1] = jack_playback[1].substr(jack_playback[1].find('\'') + 1, jack_playback[1].size() - jack_playback[1].find('\''));
254                            // this is the default but set it up anyway in case alsa_card was also used.
255                            use_jack = true;
256                        }
257                        catch (...) {
258                            fprintf(stderr, "Invalid argument '%s' for parameter --jackout\n", optarg);
259                            exit(EXIT_FAILURE);
260                        }
261                        break;
262                    }
263                    case 9: // --samplerate
264                        samplerate = atoi(optarg);
265                        break;
266                    case 10: // --help
267                      printf("usage: linuxsampler [OPTIONS] <INSTRUMENTFILE>\n\n");                      printf("usage: linuxsampler [OPTIONS] <INSTRUMENTFILE>\n\n");
268                      printf("--gig              loads a Gigasampler instrument\n");                      printf("--gig              loads a Gigasampler instrument\n");
269                      printf("--dls              loads a DLS instrument\n");                      printf("--dls              loads a DLS instrument\n");
# Line 242  void parse_options(int argc, char **argv Line 276  void parse_options(int argc, char **argv
276                      printf("                   default: 0.25)\n");                      printf("                   default: 0.25)\n");
277                      printf("--inputclient      connects to an Alsa sequencer input client on startup\n");                      printf("--inputclient      connects to an Alsa sequencer input client on startup\n");
278                      printf("                   (e.g. 64:0 to connect to a client with ID 64 and port 0)\n");                      printf("                   (e.g. 64:0 to connect to a client with ID 64 and port 0)\n");
279                      exit(0);                      printf("--alsaout          connects to the given Alsa sound device on startup\n");
280                        printf("                   (e.g. 0,0 to connect to hw:0,0 or plughw:0,0)\n");
281                        printf("--jackout          connects to the given Jack playback ports on startup\n");
282                        printf("                   (e.g. \"\'alsa_pcm:playback_1\' \'alsa_pcm:playback_2\'\"\n");
283                        printf("                   in case of stereo output)\n");
284                        printf("--samplerate       sets sample rate if supported by audio output system\n");
285                        printf("                   (e.g. 44100)\n");
286                        exit(EXIT_SUCCESS);
287                      break;                      break;
288              }              }
289          }          }

Legend:
Removed from v.32  
changed lines
  Added in v.33

  ViewVC Help
Powered by ViewVC