;; code_3.sal ;; Roger B. Dannenberg ;; January 2013 ;; ;;;;;;;;;;;;;;;;;;;;;;;;AM EXAMPLES;;;;;;;;;;;;;;;;;;;; ; multiply two sine tones play (hzosc(1000.0) * hzosc(500.0)) ~ 2 ; multiply sine by increasing frequency ; if you listen closely, you can hear the lower sideband ; go to zero, then "wrap around" to sweep upward play (hzosc(500.0) * hzosc(pwlv(100, 1, 2000))) ~ 2 ; ring modulation example -- melody without, then with modulation load "pianosyn" ; load the piano synthesizer define function tone(p, d) return piano-note(d, p, 100) define function melody() return seq(tone(g4, i), tone(a4, i), tone(b4, i), tone(g4, i), tone(g4, i), tone(a4, i), tone(b4, i), tone(g4, i), tone(b4, i), tone(c5, i), tone(d5, q), tone(b4, i), tone(c5, i), tone(d5, q)) play melody() ; now with ring modulation play osc(d3, 100) * melody() ;;;;;;;;;;;;;;;;;;;;;;;;;; ;; lfo(6) vs 2 + lfo(6) ;; ;;;;;;;;;;;;;;;;;;;;;;;;;; ;; make a pluck sound and multiply by lfo(6) play (pluck(c2) * lfo(6)) ~ 4 ;; You should hear a rapid amplitude vibrato. ;; How rapid? It is 12 Hz (!) because the 6 Hz ;; sinusoid generated by lfo(6) alternates swings ;; to the positive and negative. Each "swing" acts ;; as a short envelope. There are 12 of these ;; "envelopes" per second, so you hear a 12 Hz ;; vibrato. ;; Now use 2 + lfo(6) play (pluck(c2) * (2 + lfo(6))) ~ 4 ;; You should hear a slower amplitude vibrato. ;; How slow? It is 6 Hz as you might expect. The ;; expression 2 + lfo(6) varies in amplitude from ;; 1 to 3, and the variation happens 6 times per ;; second. Hence, only 6 Hz. ;; Using 1 + depth * lfo(6), with depth < 1, ;; you can control the depth of vibrato: ;; Shallow vibrato: play (pluck(c2) * (1 + 0.15 * lfo(6))) ~ 4 ;; Deep vibrato: play (pluck(c2) * (1 + 0.9 * lfo(6))) ~ 4 ;; Time-varying depth of vibrato: function depth() return pwl(0.5, 0.9, 1, 0.9, 1) exec s-plot(depth()) play (pluck(c2) * (1 + depth() * lfo(6))) ~ 4