{"id":263,"date":"2019-10-22T22:24:53","date_gmt":"2019-10-22T22:24:53","guid":{"rendered":"https:\/\/synthnotes.ucsd.edu\/wp7\/?p=263"},"modified":"2019-10-31T19:25:33","modified_gmt":"2019-10-31T19:25:33","slug":"tremolo-and-autopan","status":"publish","type":"post","link":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/2019\/10\/22\/tremolo-and-autopan\/","title":{"rendered":"Tremolo and Autopan"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Tremolo <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In DSP, tremolo (not to be confused with vibrato) is a periodic amplitude variation of a signal. Most often, it appears in the form of a sine wave that <em>subtracts<\/em> from the amplitude of the signal, though technically any waveform could be used. &#8220;Classic&#8221; tremolo can be charactarized as having two parts: speed and depth which are the frequency of the sine wave (modulator) and the degree to which it modifies the signal its being applied to (the modulators amplitude). It is, essentially, a very slow amplitude modulation. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Technique<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">What needs to happen is to create a new signal such that if the depth of the tremolo is 0.5, the signal we multiply to the carrier oscillates between 1 and 0.5. If the depth is 0.25, then it must oscillate between 1 and 0.75, and so on. The equation we follow is:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"> <span class=\"wp-katex-eq\" data-display=\"false\">S_{m} = 1 - d \\bigg( \\frac{S_{sin}}{2} + 0.5 \\bigg)<\/span><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Where: <\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>S<\/em><sub><em>m<\/em><\/sub> is the modulator (the signal that makes the tremolo effect)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><em>S<\/em><sub><em>sine<\/em><\/sub> is a sinewave input (oscillating between -1 and +1)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">  <em>d<\/em> is the depth of the tremolo between 0 and 1 <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This assumes that the frequency of the tremolo signal, <em>S<\/em><sub><em>sine<\/em><\/sub>, is set when generating that signal. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Implementation <\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For the input signal (signal we want tremolo on), let&#8217;s use a guitar chord: <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"370\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/input-1024x370.png\" alt=\"\" class=\"wp-image-267\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/input-1024x370.png 1024w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/input-300x108.png 300w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/input-768x278.png 768w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/input-624x225.png 624w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">[Listen]<\/p>\n\n\n\n<figure class=\"wp-block-audio\"><audio controls src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/chord.wav\"><\/audio><figcaption>Unprocessed Guitar Chord<\/figcaption><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">For a tremolo with a depth of 0.5 and a frequency of 2Hz, we get the following: <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"370\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-1024x370.png\" alt=\"\" class=\"wp-image-268\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-1024x370.png 1024w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-300x108.png 300w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-768x278.png 768w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-624x225.png 624w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">When we multiply the input and the tremolo together, we get: <\/p>\n\n\n\n<figure class=\"wp-block-image\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"370\" src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-output-1024x370.png\" alt=\"\" class=\"wp-image-270\" srcset=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-output-1024x370.png 1024w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-output-300x108.png 300w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-output-768x278.png 768w, https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/trem-output-624x225.png 624w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"> <\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this plot, the tremolo signal and the output are superimposed to show the relationship.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">[Listen]<\/p>\n\n\n\n<figure class=\"wp-block-audio\"><audio controls src=\"https:\/\/synthnotes.ucsd.edu\/wp7\/wp-content\/uploads\/2019\/10\/chord_trem.wav\"><\/audio><figcaption>Guitar Chord through Tremolo<\/figcaption><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Autopan<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">An autopan effect can be created with a slight modification of our tremolo effect. The input signal will be sent to both left and right output, with gain controls on each. To make the signal appear in the center, the gain will be 0.5 for both outputs. To appear on the left, the gain will be 1.0 on the left output and 0.0 on the right output. As the left gain and right gain add up to 1.0, the right gain can be calculated as 1.0 &#8211; left gain. By using a sine wave (or other low frequency oscillator) for the left gain, an autopan effect is created. Simple C code for this effect is below.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">\/\/ the samplerate in Hz\nsampleRate = 44100;\n\/\/ the frequency of autopan - once every 2 seconds\nfrequency = 0.5;\n\/\/ initial phase\nphase = 0.0;\n\nvoid Autopan(float *input, float *outputL, float *outputR, float frequency, long samples)\n{\n    long sample;\n    float leftgain, rightgain;\n    \/\/ calculate for each sample in a block\n    for(sample = 0; sample &lt; samples; sample++)\n    {\n        \/\/ get the phase increment for this sample\n        phaseIncrement = frequency\/sampleRate;\n\n        \/\/ calculate the gain factors\n        leftgain = (sin(phase * 6.283185307179586) + 1.0) * 0.5;\n        rightgain = 1.0 - leftgain;\n\n        \/\/ calculate the output for this sample\n        *(outputL+sample) = *(input+sample) * leftgain; \n        *(outputR+sample) = *(input+sample) * rightgain; \n\n        \/\/ increment the phase\n        phase = phase + phaseIncrement;\n        if(phase &gt;= 1.0)\n            phase = phase - 1.0;\n    }\n}<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Tremolo In DSP, tremolo (not to be confused with vibrato) is a periodic amplitude variation of a signal. Most often, it appears in the form of a sine wave that subtracts from the amplitude of the signal, though technically any waveform could be used. &#8220;Classic&#8221; tremolo can be charactarized as having two parts: speed and [&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-263","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\/263","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=263"}],"version-history":[{"count":8,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts\/263\/revisions"}],"predecessor-version":[{"id":312,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/posts\/263\/revisions\/312"}],"wp:attachment":[{"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/media?parent=263"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/categories?post=263"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/synthnotes.ucsd.edu\/wp7\/index.php\/wp-json\/wp\/v2\/tags?post=263"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}