// ====================================================================== // W space: Multi star - fractal sound creation tool // (CC) 2009 Jens Koeplinger, http://www.jenskoeplinger.com/P // License: Creative Commons Attribution "Share Alike 3.0 Unported" // http://creativecommons.org/licenses/by-sa/3.0 // See main file "wspacemultistarsound.c" for what this means to you! // ====================================================================== // run-wspacemultistarsound.c // ---------------------------------------------------------------------- // parses out the command line (runtime) parameters if ((argc == 1) || (argv[1][0] == '-')) { // no command line argument given, // or first argument started with dash; // --> print help and abort #include "help-wspacemultistarsound.c" return; } // at least one command line argument given; display raw printf("[NOTE] For help: run without arguments\n"); printf("-------------------------------------\n"); printf("Number of command line arguments = %d\n", argc); for (i = 0; i < argc; i++) { printf("- Arg. #%d = \"%s\"\n", i, argv[i]); } // (naively) parse command line parameters, if present, and // convert them, and overwrite global variables if (argc > 1) outputMode = atoi(argv[1]); switch (outputMode) { case 0: // calculate the multi-star sound fractal // set default values: baseFrequency = 50.; // base frequency, in Herz ( s^(-1) ) convergencePercentage = 1.; // convergence percentage of the outline to be played totalLength = 5.; // total length of the WAV file, in seconds convergenceSweepTo = 1.; // 2nd (target) convergence percentage (for sweep) isSweep = 0; // default: this is not a sweep sweepStepWidth = 0.; // default: continuous sweeps (if specified) isContinuous = -1; amplitudeMultiplier = 1.; // full amplitude (1.) amplitudeSweepTo = 1.; // 2nd (target) amplitude multiplier // read command line arguments, if present: if (argc > 2) baseFrequency = atof(argv[2]); if (argc > 3) convergencePercentage = atof(argv[3]); if (argc > 4) totalLength = atof(argv[4]); if (argc > 5) { convergenceSweepTo = atof(argv[5]); isSweep = -1; } if (argc > 6) sweepStepWidth = atof(argv[6]); if (argc > 7) { amplitudeMultiplier = atof(argv[7]); amplitudeSweepTo = amplitudeMultiplier; } if (argc > 8) amplitudeSweepTo = atof(argv[8]); if (argc > 9) { // ignore any additional arguments, but print a warning printf("More than 8 arguments provided; ignoring.\n"); } if (abs(sweepStepWidth) < 1E-20) { isContinuous = -1; sweepStepWidth = 0.; } else { isContinuous = 0; // *** TEMPORARY: ABORT (not implemented yet) printf("Stepped convergence percentages not implemented yet.\n"); printf("Aborting.\n"); return; } break; case 1: // test: sine case 2: // test: saw case 3: // test: square // set default values: testFLeft = 1000.; // frequency of the left channel testFRight = 1200.; testLength = 5.; // length of the sample in seconds testAmplitude = 5000.; // amplitude of the sample (0..32766) // read command line arguments, if present: if (argc > 2) testFLeft = atof(argv[2]); if (argc > 3) testFRight = atof(argv[3]); if (argc > 4) testLength = atof(argv[4]); if (argc > 5) testAmplitude = atof(argv[5]); if (argc > 6) { // ignore any additional arguments, but print a warning printf("More than 5 arguments provided; ignoring.\n"); } break; default: // huh? printf("Unknown outputMode=%d\n", outputMode); printf("Aborting.\n"); return; } // command line parameters parsing finished.