From CCRMA Wiki
Revision as of 09:58, 7 October 2010 by Njb (→Specification (part 1 of 3): Delay + Feedback + Moving Average)
Homework #2: Delay, Feedback, Moving Average, and Polyphony
Due date: 2010.10.12 11:59:59pm (or thereabout), Tuesday.
See 256a-fall-2010/hw2_hints if needed.
Specification (part 1 of 3): Delay + Feedback + Moving Average
- create a program that is capable of real-time audio input/output (suggestion: use the skeleton framework from HW1)
- craft the framework for a delay by implementing a circular buffer:
- think about how to implement a delay element that delays the input signal by some integer number of samples
- think about how to implement this efficiently, without shifting all the elements for each sample
- an array of samples
- two pointers: one for reading, and another for writing, initialize them
- test with with the microphone (with varying delay lengths)
- now add feedback, with some attenuation factor (<1)
- take each output sample of the delay, multiply it by attenuation factor (<1), and add it into the input
- test with the microphone (with varying delay lengths)
- next, modify the feedback by adding a 2-point moving average filter into the feedback loop: simply average the current output sample with the previous output sample.
- final test: on demand (e.g., via console input), load the array with white noise, and let it run
Specification (part 2 of 3): Polyphony
- abstract the above into something you can reuse
- design an interface for straightforward control
- add RtMIDI support with polyphony, so we can play our construction above
- NOTE: If you do not have a MIDI keyboard, you can download a virtual midi keyboard to trigger your synthesis such as Midi Keys
Specification (part 3 of 3): Sonic/Musical Statement
- use the framework above, algorithmically generate and/or play a sonic/musical statement
- record it turn it in
- have fun with it!!!
- your code should compile and run on the CCRMA machines
- comment your code and have consistent style
- 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:
- DelayLine - a class to represent the audio delay line
- Moving Average (in office hours I called it a OneZero filter) - a class to represent the moving average filter needed for the Karplus-Strong algorithm. The one zero is a signal processing reference to one root in the numerator in of a difference equation (not important for this, but I wanted to stay consistent from the office hours). The one zero class should simply implement something like: y[n] = .5*(x[n] + x[n-1])
- KarplusSynth - a class to hold both the delay line and one zero filter. This should be the main synthesis object that wires up the onezero and delayline objects. You'll have a limited number of these (say 16 of them) to do polyphony.
- MidiEvent - a class to represent the concept of the midi note velocity and pitch
- MidiEventQ - some data structure to store the incoming MidiEvents and drain them when needed (produced in the midi callback and consumed in the audio callback)
turn in all files by putting them in your Library/Web/256/hw2/ directory, and concise online documentation + readme
- 1) source code to the project in a single zip file (*.h, *.cpp, *.c makefile, etc.). It must compile on the CCRMA linux machines.
- 2) online page for your project (should be viewable at http://ccrma.stanford.edu/~YOURID/256/hw2/). 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
- lists any collaborators
- 3) email Nick and Ge with the link to your web page, as a confirmation that you are submitting the assignment