On Tue, Oct 21, 2014 at 2:56 PM, Philippe Coatmeur <philcm@gnu.org> wrote:
Sends a sine wave to output (this is the standard sin math
function, right?) then what would send a square wave? What would
send noise?
If only it were so simple... Sine waves are a single frequency, which makes it "easy";
-Generate the sine using sin() from <math.h>, input desired freq in rads.
Noise is random().. that's a good hint.
For square waves (or any "complex" signal actually), you need to be aware of aliasing[1].
There are a number of ways of generating bandlimited square waves, but "additive synthesis" or adding of sines is probably the best way to learn / understand aliasing and its effects.
The guys at MusicDSP archives[2] have a variety of oscillators and other synth building blocks. If you're trying to get things done, I advise using other peoples code: things get very complex pretty quickly... unless your aim is to understand this stuff, then merry learning!
I've been doing a wavetable synth[3] which causes aliasing if done wrong very quickly, again, digging around the internet provides good resources to learn from.