Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 1st, 2012  |  syntax: None  |  size: 2.65 KB  |  hits: 13  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ////////////////////////////////////////////////////////////
  2. // helloWaveset2.c                    
  3. ////////////////////////////////////////////////////////////
  4. // Using the approach from "hellosine", this file prompts
  5. // the user for a wavefile and a timestretch factor and
  6. // and generates a score for waveset using those values.
  7. ////////////////////////////////////////////////////////////
  8. // to compile and run: $ gcc -o helloWaveset2 helloWaveset2.c && ./helloWaveset2
  9. ////////////////////////////////////////////////////////////
  10.  
  11. #include <stdio.h>
  12.  
  13. int main()
  14. {
  15.         // Declare some variables
  16.         char filename[256];
  17.         char filename2[256];
  18.         int duration, timestretch, timestretch2;
  19.         float level1, level2;
  20.  
  21.         // Introduction
  22.         printf("\n========= Welcome to \"helloWaveset2\" =========\n\n");
  23.  
  24.         // Prompt the user for a path to an audiofile
  25.         printf("Enter a path to audio file 1 to time stretch: ");
  26.         scanf("%s", &filename);
  27.  
  28.         printf("Enter a path to audio file 2 to time stretch: ");
  29.         scanf("%s", &filename2);
  30.  
  31.         // Prompt the user for some stretch factors
  32.         printf("\nEnter a time stretch factor (integer) for file 1: ");
  33.         scanf("%d", &timestretch);
  34.  
  35.         printf("\nEnter a time stretch factor (integer) for file 2: ");
  36.         scanf("%d", &timestretch2);
  37.  
  38.         // Prompt the user for some scaling factors (to mix and balance the 2 sources)
  39.         printf("\nEnter a amplitude scaling factor (float: 0 - 1) for file 1: ");
  40.         scanf("%f", &level1);
  41.  
  42.         printf("\nEnter a amplitude scaling factor (float: 0 - 1) for file 2: ");
  43.         scanf("%f", &level2);
  44.  
  45.         // Prompt the user for the overall duration of the rendered file
  46.         printf("\nEnter a duration for the synthesized result (seconds): ");
  47.         scanf("%d", &duration);
  48.  
  49.         // Print instructions to the user
  50.         printf("\nCopy the following Csound code to a file named: helloWaveset1.csd\n");
  51.         printf("Next you will Render the file you created by using the following command-line:\n\n");
  52.         printf("csound -odac -d -O null helloWaveset2.csd\n\n");
  53.  
  54.         // Print out the score with the user specified parameters
  55.         printf("<CsoundSynthesizer>\n");
  56.         printf("<CsInstruments>\n");
  57.         printf("instr helloWaveset2\n");
  58.         printf("asig soundin \"%s\"\n", filename);
  59.         printf("asig2 soundin \"%s\"\n", filename2);
  60.         printf("a1 waveset asig, %d\n", timestretch);
  61.         printf("a2 waveset asig2, %d\n", timestretch2);
  62.         printf("ilevel1 = %f\n", level1);
  63.         printf("ilevel2 = %f\n", level2);
  64.         printf("out (a1 * ilevel1) + (a2 * ilevel2)\n");
  65.         printf("endin\n");
  66.         printf("</CsInstruments>\n");
  67.         printf("<CsScore>\n");
  68.         printf("i \"helloWaveset2\" 0 %d\n", duration);
  69.         printf("</CsScore>\n");
  70.         printf("</CsoundSynthesizer>\n\n\n\n");
  71.        
  72.         return 0;      
  73. }