Difference between revisions of "256-fall-2008/hw1"
From CCRMA Wiki
Line 8: | Line 8: | ||
=== Specification (part 1 of 2): Real-time Audio === | === Specification (part 1 of 2): Real-time Audio === | ||
− | * create a program that is capable of real-time audio input/output | + | * create a program that is capable of real-time audio input/output, call it something (e.g., sig-gen; creative names are always welcome) |
* 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): | ||
Line 28: | Line 28: | ||
=== Specification (part 2 of 2): Waveforms === | === Specification (part 2 of 2): Waveforms === | ||
+ | * modify your program to generate different waveforms, 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 | ||
+ | * this means that you'll also need to implement a simple command line parser, with basic error checking (e.g., what to do when invalid/irrelevant parameters are provided?) | ||
=== Note === | === Note === | ||
− | * | + | * have fun with it!!! |
+ | * comment your code! | ||
+ | * choose your own coding conventions - but '''be consistent''' | ||
Revision as of 21:56, 28 September 2008
Contents
Homework #1: Real-time Audio, Buffers, and Waveforms
Due date: 2008.10.8 11:59:59pm (or thereabout), Wednesday.
Let's get cookin'.
Specification (part 1 of 2): Real-time Audio
- create a program that is capable of real-time audio input/output, call it something (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 (may need to make changes)
- next, add real-time, using the RtAudio Library (version 4.0.4)
- download it from 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, please study
- it may be also useful to browse the RtAudio documentation, the example programs in the RtAudio distribution
- NOTE: even though the code is nearly all there, it's infinitely more useful to actually write the code from scratch - even if you 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 2): Waveforms
- modify your program to generate different waveforms, 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
- this means that you'll also need to implement a simple command line parser, with basic error checking (e.g., what to do when invalid/irrelevant parameters are provided?)
Note
- have fun with it!!!
- comment your code!
- choose your own coding conventions - but be consistent
Deliverables
turn in all files by putting them in your Library/Web/154/hw1/ directory, and concise online documentation + readme
- 1) source code to the project (*.h, *.cpp, *.c makefile, etc.)
- 2) online page for your project (should be viewable at http://ccrma.stanford.edu/~YOURID/154/hw1/). It should include:
- links to your files of various kinds
- instructions on building the project (for example, anyone in the class should be able to download
- a short README text section that:
- conveys your ideas/comments in constructing each program
- describes any difficulties you encountered in the process
- 3) email Ge with the link to your web page, as a confirmation that you are turning the homework in