{"id":97,"date":"2019-10-01T15:31:26","date_gmt":"2019-10-01T15:31:26","guid":{"rendered":"https:\/\/synthnotes.ucsd.edu\/wp7\/?p=97"},"modified":"2020-08-18T22:01:39","modified_gmt":"2020-08-18T22:01:39","slug":"simple-ramp-and-sawtooth-oscillators","status":"publish","type":"post","link":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/2019\/10\/01\/simple-ramp-and-sawtooth-oscillators\/","title":{"rendered":"Simple Ramp and Sawtooth Oscillators"},"content":{"rendered":"<h1>Ramp and Sawtooth<\/h1>\n<p>The ramp wave and a sawtooth wave are mirror images of one another. The ramp ascends linearly from -1 to +1 while the sawtooth descends linearly from +1 to -1. The methods here will produce a non-bandlimited waveforms and will produce audible aliasing. This aliasing makes this type of\u00a0oscillator less desirable for audio. However, they can be useful as a source of modulation &#8211; as a low frequency oscillator (LFO).<\/p>\n<h2>Ramp<\/h2>\n<p>A ramp wave is essentially a phasor that goes from -1 to +1.<\/p>\n<span class=\"wp-katex-eq\" data-display=\"false\">x_{ramp}(t) = 2 \\bigg( \\frac{t}{p} \\text{mod } 1 \\bigg) - 1<\/span>\n<h3>Using algebra<\/h3>\n<p>Using the phasor as the starting point, it is fairly straightforward to create a ramp algebraically:<\/p>\n<p><a href=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp_blockDiagram.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-149\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp_blockDiagram.png\" alt=\"\" width=\"306\" height=\"257\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp_blockDiagram.png 306w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp_blockDiagram-300x252.png 300w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/a><\/p>\n<p>That is, take the phasor, multiply it by two and subtract one. This results in a ramp that ascends from -1 to +1. Or: `(phasor*2)-1`. This results in the following waveform, the first 512 samples of a 100Hz ramp at a samplerate of 8kHz:<\/p>\n<p><a href=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-151\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp.png\" alt=\"\" width=\"1740\" height=\"301\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp.png 1740w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp-300x52.png 300w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp-768x133.png 768w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp-1024x177.png 1024w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/ramp-624x108.png 624w\" sizes=\"auto, (max-width: 1740px) 100vw, 1740px\" \/><\/a><\/p>\n<h3>Listen<\/h3>\n<p>Notice that since this oscillator is not bandlimited one can hear the aliasing very clearly, especially when changing the frequency. [Click here to listen.](src\/ramp\/rampPlay.html)<\/p>\n<h2>Sawtooth<\/h2>\n<p>A sawtooth wave is ramp that _descends_ from +1 to -1.<\/p>\n<h3>Using algebra<\/h3>\n<p>Using the phasor as the starting point, it is fairly straightforward to create a ramp algebraically:<\/p>\n<span class=\"wp-katex-eq\" data-display=\"false\">x_{sawtooth}(t) = -2 \\bigg( \\frac{t}{p} \\text{mod } 1 \\bigg) + 1<\/span>\n<p><a href=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth_blockDiagram.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-152\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth_blockDiagram.png\" alt=\"\" width=\"306\" height=\"257\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth_blockDiagram.png 306w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth_blockDiagram-300x252.png 300w\" sizes=\"auto, (max-width: 306px) 100vw, 306px\" \/><\/a><\/p>\n<p>That is, take the phasor, multiply it by two and subtract one. This results in a sawtooth wave that descends from +1 to -1. Or: `(phasor * -2) + 1`. This results in the following waveform, the first 512 samples of a 100Hz sawtooth at a samplerate of 8kHz:<\/p>\n<p><a href=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-153\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth.png\" alt=\"\" width=\"1740\" height=\"301\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth.png 1740w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth-300x52.png 300w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth-768x133.png 768w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth-1024x177.png 1024w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/sawtooth-624x108.png 624w\" sizes=\"auto, (max-width: 1740px) 100vw, 1740px\" \/><\/a><\/p>\n<h3>Listen<\/h3>\n<p>Notice that since this oscillator is not bandlimited one can hear the aliasing very clearly, especially when changing the frequency. It sounds identical to the ramp.<\/p>\n<audio class=\"wp-audio-shortcode\" id=\"audio-97-1\" preload=\"none\" style=\"width: 100%;\" controls=\"controls\"><source type=\"audio\/wav\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2020\/08\/rampalias.wav?_=1\" \/><a href=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2020\/08\/rampalias.wav\">https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2020\/08\/rampalias.wav<\/a><\/audio>\n","protected":false},"excerpt":{"rendered":"<p>Ramp and Sawtooth The ramp wave and a sawtooth wave are mirror images of one another. The ramp ascends linearly from -1 to +1 while the sawtooth descends linearly from +1 to -1. The methods here will produce a non-bandlimited waveforms and will produce audible aliasing. This aliasing makes this type of\u00a0oscillator less desirable for [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-97","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts\/97","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/comments?post=97"}],"version-history":[{"count":7,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts\/97\/revisions"}],"predecessor-version":[{"id":567,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts\/97\/revisions\/567"}],"wp:attachment":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/media?parent=97"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/categories?post=97"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/tags?post=97"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}