- ////////////////////////////////////////////////////////////
- // helloWaveset2.c
- ////////////////////////////////////////////////////////////
- // Using the approach from "hellosine", this file prompts
- // the user for a wavefile and a timestretch factor and
- // and generates a score for waveset using those values.
- ////////////////////////////////////////////////////////////
- // to compile and run: $ gcc -o helloWaveset2 helloWaveset2.c && ./helloWaveset2
- ////////////////////////////////////////////////////////////
- #include <stdio.h>
- int main()
- {
- // Declare some variables
- char filename[256];
- char filename2[256];
- int duration, timestretch, timestretch2;
- float level1, level2;
- // Introduction
- printf("\n========= Welcome to \"helloWaveset2\" =========\n\n");
- // Prompt the user for a path to an audiofile
- printf("Enter a path to audio file 1 to time stretch: ");
- scanf("%s", &filename);
- printf("Enter a path to audio file 2 to time stretch: ");
- scanf("%s", &filename2);
- // Prompt the user for some stretch factors
- printf("\nEnter a time stretch factor (integer) for file 1: ");
- scanf("%d", ×tretch);
- printf("\nEnter a time stretch factor (integer) for file 2: ");
- scanf("%d", ×tretch2);
- // Prompt the user for some scaling factors (to mix and balance the 2 sources)
- printf("\nEnter a amplitude scaling factor (float: 0 - 1) for file 1: ");
- scanf("%f", &level1);
- printf("\nEnter a amplitude scaling factor (float: 0 - 1) for file 2: ");
- scanf("%f", &level2);
- // Prompt the user for the overall duration of the rendered file
- printf("\nEnter a duration for the synthesized result (seconds): ");
- scanf("%d", &duration);
- // Print instructions to the user
- printf("\nCopy the following Csound code to a file named: helloWaveset1.csd\n");
- printf("Next you will Render the file you created by using the following command-line:\n\n");
- printf("csound -odac -d -O null helloWaveset2.csd\n\n");
- // Print out the score with the user specified parameters
- printf("<CsoundSynthesizer>\n");
- printf("<CsInstruments>\n");
- printf("instr helloWaveset2\n");
- printf("asig soundin \"%s\"\n", filename);
- printf("asig2 soundin \"%s\"\n", filename2);
- printf("a1 waveset asig, %d\n", timestretch);
- printf("a2 waveset asig2, %d\n", timestretch2);
- printf("ilevel1 = %f\n", level1);
- printf("ilevel2 = %f\n", level2);
- printf("out (a1 * ilevel1) + (a2 * ilevel2)\n");
- printf("endin\n");
- printf("</CsInstruments>\n");
- printf("<CsScore>\n");
- printf("i \"helloWaveset2\" 0 %d\n", duration);
- printf("</CsScore>\n");
- printf("</CsoundSynthesizer>\n\n\n\n");
- return 0;
- }