# [LAD] Wave shapes & forms

Harry van Haaren harryhaaren at gmail.com
Tue Oct 21 14:25:52 UTC 2014

```On Tue, Oct 21, 2014 at 2:56 PM, Philippe Coatmeur <philcm at gnu.org> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxaudio.org/pipermail/linux-audio-dev/attachments/20141021/294d998e/attachment.html>
```