Difference between revisions of "256a-fall-2011/hw1"

From CCRMA Wiki
Jump to: navigation, search
(Deliverables)
(Deliverables)
 
(One intermediate revision by one other user not shown)
Line 12: Line 12:
 
* start with a blank C++ program
 
* start with a blank C++ program
 
* create a minimally compilable program (e.g., something like HelloWorld):
 
* create a minimally compilable program (e.g., something like HelloWorld):
** if you'd like, you can start with this very basic [http://ccrma.stanford.edu/courses/256a-fall-2010/lectures/1b/HelloSine/makefile makefile] (will need to make changes). For a simple introduction to make files, check out this [http://linuxdevcenter.com/lpt/a/1426 link]
+
** if you'd like, you can start with this very basic [http://ccrma.stanford.edu/courses/256a-fall-2011/lectures/1b/HelloSine/makefile makefile] (will need to make changes). For a simple introduction to make files, check out this [http://linuxdevcenter.com/lpt/a/1426 link]
 
* next, add real-time audio support, using the RtAudio Library (version 4.0.4)
 
* next, add real-time audio support, using the RtAudio Library (version 4.0.4)
** download it from [http://ccrma.stanford.edu/courses/256a-fall-2010/lectures/1b/HelloSine/ HelloSine] above OR get the most recent (and potentially different) version [http://www.music.mcgill.ca/~gary/rtaudio/ here]
+
** download it from [http://ccrma.stanford.edu/courses/256a-fall-2011/lectures/1b/HelloSine/ HelloSine] above OR get the most recent (and potentially different) version [http://www.music.mcgill.ca/~gary/rtaudio/ here]
 
** even though it's useful to briefly look through the package, the only files you'll need are:
 
** even though it's useful to briefly look through the package, the only files you'll need are:
 
*** RtAudio.h (the header file for RtAudio, it contains the class definitions)
 
*** RtAudio.h (the header file for RtAudio, it contains the class definitions)
 
*** RtAudio.cpp (the implementation)
 
*** RtAudio.cpp (the implementation)
 
*** RtError.h (header containing various error handling constructs for RtAudio)
 
*** RtError.h (header containing various error handling constructs for RtAudio)
* this is similar to (but not identical to) the example we did in class (see [http://ccrma.stanford.edu/courses/256a-fall-2010/lectures/1b/HelloSine/ HelloSine]):
+
* this is similar to (but not identical to) the example we did in class (see [http://ccrma.stanford.edu/courses/256a-fall-2011/lectures/1b/HelloSine/ HelloSine]):
 
** your program is using an updated RtAudio interface, which is different from the one we used in class
 
** your program is using an updated RtAudio interface, which is different from the one we used in class
 
** it may be also useful to browse the RtAudio documentation and the example programs in the RtAudio distribution
 
** it may be also useful to browse the RtAudio documentation and the example programs in the RtAudio distribution
Line 70: Line 70:
 
=== Deliverables ===
 
=== Deliverables ===
  
'''turn in all files by putting them in your Library/Web/256/hw1/ directory, and concise online documentation + readme'''
+
'''turn in all files + readme through coursework'''
  
* 1) source code to the project (*.h, *.cpp, *.c makefile, etc.)
+
* 1) Log into [http://coursework.stanford.edu coursework] and go to Dropbox.
* 2) online page for your project (should be viewable at http://ccrma.stanford.edu/~YOURID/256a/hw1/).  It should include:
+
* 2) Create a folder named hw1 and put all the files in there. The required files are:
** links to your files of various kinds
+
** source code to the project (*.h, *.cpp, *.c makefile, etc.)
** instructions on building the project (for example, anyone in the class should be able to download
+
 
** a short README text section that:
 
** a short README text section that:
 +
*** instructions on building the project (for example, anyone in the class should be able to download
 
*** conveys your ideas/comments in constructing each program  
 
*** conveys your ideas/comments in constructing each program  
 
*** describes any difficulties you encountered in the process
 
*** describes any difficulties you encountered in the process
 
*** lists any collaborators
 
*** lists any collaborators
* 3) '''email Ge and Jorge''' with the link to your web page, as a confirmation that you are submitting the assignment
 
** ge /at/ ccrma.stanford.edu
 
** jorgeh /at/ ccrma.stanford.edu
 

Latest revision as of 15:23, 3 October 2011

Homework #1: Real-time Audio, Buffers, and Waveforms

Due date: 2011.10.05 11:59:59pm (or thereabout), Wednesday.

Ingredients.jpg

Let's get cookin'.


Specification (part 1 of 3): Real-time Audio

  • create a program that is capable of real-time audio input/output
  • give it name (e.g., sig-gen; creative names are always welcome)
  • start with a blank C++ program
  • create a minimally compilable program (e.g., something like HelloWorld):
    • if you'd like, you can start with this very basic makefile (will need to make changes). For a simple introduction to make files, check out this link
  • next, add real-time audio support, using the RtAudio Library (version 4.0.4)
    • download it from HelloSine above OR get the most recent (and potentially different) version here
    • even though it's useful to briefly look through the package, the only files you'll need are:
      • RtAudio.h (the header file for RtAudio, it contains the class definitions)
      • RtAudio.cpp (the implementation)
      • RtError.h (header containing various error handling constructs for RtAudio)
  • this is similar to (but not identical to) the example we did in class (see HelloSine):
    • your program is using an updated RtAudio interface, which is different from the one we used in class
    • it may be also useful to browse the RtAudio documentation and the example programs in the RtAudio distribution
    • NOTE: even though the code is nearly all there in the example, it's infinitely more useful to actually write the code from scratch - even if you copy/type it in line by line!
  • implement the callback function to generate the expect number of samples per call for a sine wave at 440Hz
  • the overall behavior when you run the program should be a continuous sine tone at 440hz...
  • to quit: press ctrl-c

Specification (part 2 of 3): Waveforms

  • modify your program to take command line arguments and generate different signals, depending the command line flag you specify:
    sig-gen [type] [frequency] [width]
        [type]: --sine | --saw | --pulse | --noise | --impulse
        [frequency]: (a number > 0, only applicable to some signal types)
        [width]: pulse width (only applicable to some signal types)
  • where the flags correspond to the following signals:
    • --sine : sine wave
    • --saw : saw tooth, the width is a number between 0.0 and 1.0 the determines the shape of the wave (e.g., width=.5 should result in a triangle wave)
    • --pulse : rectangular pulse wave, the width ([0.0-1.0]) controls the pulse width (e.g., width=.5 should result in a square wave)
    • --noise : white noise
    • --impulse : impluse train, the frequency should determine the impulse train's fundamental period
  • it might be a good idea to output the usage (as show above), if insufficient or incorrect parameters are given
  • you'll need to implement a simple command line parser, with basic error checking (e.g., what to do when invalid/irrelevant parameters are provided?)
  • you'll also need to organize your code a bit, to selectively generate the request signal

See Signal generator hints if needed.

Specification (part 3 of 3): One Ring to Modulate Them All

  • Lastly, add another command line flag:
    • --input : mic/line input (make sure to enable it in the code when initializing RtAudio)
  • if specified, this flag tells the program to take the mic/line input and and multiply it against the signal being generated, and output the result!


Note

  • have fun with it!!!
  • your code should compile and run on the CCRMA machines
  • comment your code!
  • choose your own coding conventions - but be consistent
  • you are welcome to work together, but you must do/turn in your own work (you'll likely get more out of it this way)
  • some considerations:
    • how to organize the code for the various types of signals?
    • how much error-checking and error-reporting on the command line arguments?


Testing Audio Output

Testing audio output

Deliverables

turn in all files + readme through coursework

  • 1) Log into coursework and go to Dropbox.
  • 2) Create a folder named hw1 and put all the files in there. The required files are:
    • source code to the project (*.h, *.cpp, *.c makefile, etc.)
    • a short README text section that:
      • instructions on building the project (for example, anyone in the class should be able to download
      • conveys your ideas/comments in constructing each program
      • describes any difficulties you encountered in the process
      • lists any collaborators