/[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 18 by schoenebeck, Sun Dec 7 05:03:43 2003 UTC revision 20 by schoenebeck, Thu Dec 25 00:02:45 2003 UTC
# Line 27  Line 27 
27  #include <signal.h>  #include <signal.h>
28  #include <pthread.h>  #include <pthread.h>
29    
30    #include <string>
31    
32  #include "global.h"  #include "global.h"
33  #include "audioio.h"  #include "audioio.h"
34  #include "diskthread.h"  #include "diskthread.h"
# Line 54  MidiIn*          pMidiInThread; Line 56  MidiIn*          pMidiInThread;
56  RIFF::File*      pRIFF;  RIFF::File*      pRIFF;
57  gig::File*       pGig;  gig::File*       pGig;
58  gig::Instrument* pInstrument;  gig::Instrument* pInstrument;
59    uint             instrument_index;
60    double           volume;
61  int              num_fragments;  int              num_fragments;
62  int              fragmentsize;  int              fragmentsize;
63    std::string      input_client;
64  pthread_t        signalhandlerthread;  pthread_t        signalhandlerthread;
65    
66  void parse_options(int argc, char **argv);  void parse_options(int argc, char **argv);
# Line 71  int main(int argc, char **argv) { Line 76  int main(int argc, char **argv) {
76      signal(SIGINT, signal_handler);      signal(SIGINT, signal_handler);
77    
78      patch_format      = patch_format_unknown;      patch_format      = patch_format_unknown;
79        instrument_index  = 0;
80      num_fragments     = AUDIO_FRAGMENTS;      num_fragments     = AUDIO_FRAGMENTS;
81      fragmentsize      = AUDIO_FRAGMENTSIZE;      fragmentsize      = AUDIO_FRAGMENTSIZE;
82        volume            = 0.25; // default volume
83    
84      // parse and assign command line options      // parse and assign command line options
85      parse_options(argc, argv);      parse_options(argc, argv);
86    
87      if (patch_format != patch_format_gig) {      if (patch_format != patch_format_gig) {
88          printf("Sorry only Gigasampler loading migrated in LinuxSampler so far, use --gig to load a .gig file!\n");          printf("Sorry only Gigasampler loading migrated in LinuxSampler so far, use --gig to load a .gig file!\n");
89            printf("Use 'linuxsampler --help' to see all available options.\n");
90          return EXIT_FAILURE;          return EXIT_FAILURE;
91      }      }
92    
# Line 94  int main(int argc, char **argv) { Line 102  int main(int argc, char **argv) {
102          fflush(stdout);          fflush(stdout);
103          pRIFF       = new RIFF::File(argv[argc - 1]);          pRIFF       = new RIFF::File(argv[argc - 1]);
104          pGig        = new gig::File(pRIFF);          pGig        = new gig::File(pRIFF);
105          pInstrument = pGig->GetFirstInstrument();          pInstrument = pGig->GetInstrument(instrument_index);
106            if (!pInstrument) {
107                printf("there's no instrument with index %d.\n", instrument_index);
108                exit(EXIT_FAILURE);
109            }
110          pGig->GetFirstSample(); // just to complete instrument loading before we enter the realtime part          pGig->GetFirstSample(); // just to complete instrument loading before we enter the realtime part
111          printf("OK\n");          printf("OK\n");
112          fflush(stdout);          fflush(stdout);
# Line 116  int main(int argc, char **argv) { Line 128  int main(int argc, char **argv) {
128      pDiskThread->StartThread();      pDiskThread->StartThread();
129      dmsg(1,("OK\n"));      dmsg(1,("OK\n"));
130      dmsg(1,("Starting MIDI in thread..."));      dmsg(1,("Starting MIDI in thread..."));
131        if (input_client.size() > 0) pMidiInThread->SubscribeToClient(input_client.c_str());
132      pMidiInThread->StartThread();      pMidiInThread->StartThread();
133      dmsg(1,("OK\n"));      dmsg(1,("OK\n"));
134    
135      sleep(1);      sleep(1);
136      dmsg(1,("Starting audio thread..."));      dmsg(1,("Starting audio thread..."));
137        pAudioThread->Volume = volume;
138      pAudioThread->StartThread();      pAudioThread->StartThread();
139      dmsg(1,("OK\n"));      dmsg(1,("OK\n"));
140    
# Line 138  int main(int argc, char **argv) { Line 152  int main(int argc, char **argv) {
152  }  }
153    
154  void signal_handler(int signal) {  void signal_handler(int signal) {
155      if (pthread_equal(pthread_self(), signalhandlerthread) && signal == SIGINT) {          if (pthread_equal(pthread_self(), signalhandlerthread) && signal == SIGINT) {
156          // stop all threads          // stop all threads
157          if (pMidiInThread) pMidiInThread->StopThread();          if (pMidiInThread) pMidiInThread->StopThread();
158          if (pAudioThread)  pAudioThread->StopThread();          if (pAudioThread)  pAudioThread->StopThread();
# Line 164  void parse_options(int argc, char **argv Line 178  void parse_options(int argc, char **argv
178          {          {
179              {"numfragments",1,0,0},              {"numfragments",1,0,0},
180              {"fragmentsize",1,0,0},              {"fragmentsize",1,0,0},
181                {"volume",1,0,0},
182              {"dls",0,0,0},              {"dls",0,0,0},
183              {"gig",0,0,0},              {"gig",0,0,0},
184                {"instrument",1,0,0},
185                {"inputclient",1,0,0},
186              {"help",0,0,0},              {"help",0,0,0},
187              {0,0,0,0}              {0,0,0,0}
188          };          };
# Line 182  void parse_options(int argc, char **argv Line 199  void parse_options(int argc, char **argv
199                      fragmentsize = atoi(optarg);                      fragmentsize = atoi(optarg);
200                      break;                      break;
201                  case 2:                  case 2:
202                      patch_format = patch_format_dls;                      volume = atof(optarg);
203                      break;                      break;
204                  case 3:                  case 3:
205                      patch_format = patch_format_gig;                      patch_format = patch_format_dls;
206                      break;                      break;
207                  case 4:                  case 4:
208                        patch_format = patch_format_gig;
209                        break;
210                    case 5:
211                        instrument_index = atoi(optarg);
212                        break;
213                    case 6:
214                        input_client = optarg;
215                        break;
216                    case 7:
217                      printf("usage: linuxsampler [OPTIONS] <INSTRUMENTFILE>\n\n");                      printf("usage: linuxsampler [OPTIONS] <INSTRUMENTFILE>\n\n");
218                        printf("--gig              loads a Gigasampler instrument\n");
219                        printf("--dls              loads a DLS instrument\n");
220                        printf("--instrument       index of the instrument in the instrument file if it\n");
221                        printf("                   contains more than one (default: 0)\n");
222                      printf("--numfragments     sets the number of audio fragments\n");                      printf("--numfragments     sets the number of audio fragments\n");
223                      printf("--fragmentsize     sets the fragment size\n");                      printf("--fragmentsize     sets the fragment size\n");
224                      printf("--dls              loads a DLS instrument\n");                      printf("--volume           sets global volume gain factor (a value > 1.0 means\n");
225                      printf("--gig              loads a Gigasampler instrument\n");                      printf("                   amplification, a value < 1.0 means attenuation,\n");
226                        printf("                   default: 0.25)\n");
227                        printf("--inputclient      connects to an Alsa sequencer input client on startup\n");
228                        printf("                   (e.g. 64:0 to connect to a client with ID 64 and port 0)\n");
229                      exit(0);                      exit(0);
230                      break;                      break;
231              }              }

Legend:
Removed from v.18  
changed lines
  Added in v.20

  ViewVC Help
Powered by ViewVC