--- linuxsampler/trunk/src/linuxsampler.cpp 2003/12/07 05:03:43 18 +++ linuxsampler/trunk/src/linuxsampler.cpp 2003/12/25 00:02:45 20 @@ -27,6 +27,8 @@ #include #include +#include + #include "global.h" #include "audioio.h" #include "diskthread.h" @@ -54,8 +56,11 @@ RIFF::File* pRIFF; gig::File* pGig; gig::Instrument* pInstrument; +uint instrument_index; +double volume; int num_fragments; int fragmentsize; +std::string input_client; pthread_t signalhandlerthread; void parse_options(int argc, char **argv); @@ -71,14 +76,17 @@ signal(SIGINT, signal_handler); patch_format = patch_format_unknown; + instrument_index = 0; num_fragments = AUDIO_FRAGMENTS; fragmentsize = AUDIO_FRAGMENTSIZE; + volume = 0.25; // default volume // parse and assign command line options parse_options(argc, argv); if (patch_format != patch_format_gig) { printf("Sorry only Gigasampler loading migrated in LinuxSampler so far, use --gig to load a .gig file!\n"); + printf("Use 'linuxsampler --help' to see all available options.\n"); return EXIT_FAILURE; } @@ -94,7 +102,11 @@ fflush(stdout); pRIFF = new RIFF::File(argv[argc - 1]); pGig = new gig::File(pRIFF); - pInstrument = pGig->GetFirstInstrument(); + pInstrument = pGig->GetInstrument(instrument_index); + if (!pInstrument) { + printf("there's no instrument with index %d.\n", instrument_index); + exit(EXIT_FAILURE); + } pGig->GetFirstSample(); // just to complete instrument loading before we enter the realtime part printf("OK\n"); fflush(stdout); @@ -116,11 +128,13 @@ pDiskThread->StartThread(); dmsg(1,("OK\n")); dmsg(1,("Starting MIDI in thread...")); + if (input_client.size() > 0) pMidiInThread->SubscribeToClient(input_client.c_str()); pMidiInThread->StartThread(); dmsg(1,("OK\n")); sleep(1); dmsg(1,("Starting audio thread...")); + pAudioThread->Volume = volume; pAudioThread->StartThread(); dmsg(1,("OK\n")); @@ -138,7 +152,7 @@ } void signal_handler(int signal) { - if (pthread_equal(pthread_self(), signalhandlerthread) && signal == SIGINT) { + if (pthread_equal(pthread_self(), signalhandlerthread) && signal == SIGINT) { // stop all threads if (pMidiInThread) pMidiInThread->StopThread(); if (pAudioThread) pAudioThread->StopThread(); @@ -164,8 +178,11 @@ { {"numfragments",1,0,0}, {"fragmentsize",1,0,0}, + {"volume",1,0,0}, {"dls",0,0,0}, {"gig",0,0,0}, + {"instrument",1,0,0}, + {"inputclient",1,0,0}, {"help",0,0,0}, {0,0,0,0} }; @@ -182,17 +199,33 @@ fragmentsize = atoi(optarg); break; case 2: - patch_format = patch_format_dls; + volume = atof(optarg); break; case 3: - patch_format = patch_format_gig; + patch_format = patch_format_dls; break; case 4: + patch_format = patch_format_gig; + break; + case 5: + instrument_index = atoi(optarg); + break; + case 6: + input_client = optarg; + break; + case 7: printf("usage: linuxsampler [OPTIONS] \n\n"); + printf("--gig loads a Gigasampler instrument\n"); + printf("--dls loads a DLS instrument\n"); + printf("--instrument index of the instrument in the instrument file if it\n"); + printf(" contains more than one (default: 0)\n"); printf("--numfragments sets the number of audio fragments\n"); printf("--fragmentsize sets the fragment size\n"); - printf("--dls loads a DLS instrument\n"); - printf("--gig loads a Gigasampler instrument\n"); + printf("--volume sets global volume gain factor (a value > 1.0 means\n"); + printf(" amplification, a value < 1.0 means attenuation,\n"); + printf(" default: 0.25)\n"); + printf("--inputclient connects to an Alsa sequencer input client on startup\n"); + printf(" (e.g. 64:0 to connect to a client with ID 64 and port 0)\n"); exit(0); break; }