On Tue, Oct 21, 2014 at 2:56 PM, Philippe Coatmeur <philcm@email-addr-hidden> wrote:
>
> Sends a sine wave to output (this is the standard sin
> <http://www.cplusplus.com/reference/cmath/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.
HTH, -Harry
-- [1] http://en.wikipedia.org/wiki/Aliasing#Sampling_sinusoidal_functions [2] http://musicdsp.org/archive.php?classid=1 [3] http://openavproductions.com/ninja http://www.openavproductions.com
_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Tue Oct 21 20:15:01 2014
This archive was generated by hypermail 2.1.8 : Tue Oct 21 2014 - 20:15:02 EEST