<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Oct 21, 2014 at 2:56 PM, Philippe Coatmeur <span dir="ltr"><<a href="mailto:philcm@gnu.org" target="_blank">philcm@gnu.org</a>></span> wrote:<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    Sends a sine wave to output (this is the standard <a href="http://www.cplusplus.com/reference/cmath/sin/" target="_blank">sin</a> math
    function, right?) then what would send a square wave? What would
    send noise?<br></div></blockquote><div><br></div><div>If only it were so simple... Sine waves are a single frequency, which makes it "easy";</div><div>-Generate the sine using sin() from <math.h>, input desired freq in rads.</div><div><br></div><div>Noise is random().. that's a good hint.</div><div><br></div><div>For square waves (or any "complex" signal actually), you need to be aware of aliasing[1].</div><div>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.</div><div><br></div><div>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!</div><div><br></div><div>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.</div><div><br></div><div>HTH, -Harry</div></div><div><br></div>-- <br>[1] <a href="http://en.wikipedia.org/wiki/Aliasing#Sampling_sinusoidal_functions">http://en.wikipedia.org/wiki/Aliasing#Sampling_sinusoidal_functions</a></div><div class="gmail_extra">[2] <a href="http://musicdsp.org/archive.php?classid=1">http://musicdsp.org/archive.php?classid=1</a></div><div class="gmail_extra">[3] <a href="http://openavproductions.com/ninja">http://openavproductions.com/ninja</a><br><a href="http://www.openavproductions.com" target="_blank">http://www.openavproductions.com</a>
</div></div>