-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path07-fun-mod-modifiers.Rmd
802 lines (659 loc) · 73.6 KB
/
07-fun-mod-modifiers.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
# Modifiers
Modifiers modify incoming signals that may be either audio or control signals.
Chapter \@ref(basic-modeling-concepts) introduced voltage controlled amplifiers (VCAs) that modify the amplitude of incoming signals, which can be either audio or control voltage.
That chapter also introduced envelopes that modify control voltage, and we have routinely used envelopes to control VCAs in order to model the dynamics of various instruments.
This chapter expands upon audio modifiers specifically and focuses on two foundational categories of modifiers, effects and voltage controlled filters.
Effects can substantially enrich the sounds you create both in terms of thickness of sound and sense of acoustic space, and voltage controlled filters create some of the most defining sounds in electronic music.
## Time-based effects
There are perhaps an infinite number of possible audio effects.
This section focuses on time-based effects, as the ideas behind these are complementary to the following discussion of voltage controlled filters.
Time and phase are closely related when we're talking about a repeating waveshape.
Imagine you put a red dot on the outside of a car tire and start driving.
At any moment, you can stop the car and the red dot will be in a certain position, which you can describe as an angle relative to the ground.
If the car has been moving at the same speed the entire time, you can exactly predict where the red dot will be.
Figure \@ref(fig:wheel-sine) shows an abstract rendering of this example, highlighting the relationship between the rotation of the wheel (in radians) and the shape of a sine wave.
(ref:wheel-sine) [Relation](https://upload.wikimedia.org/wikipedia/commons/0/08/Sine_curve_drawing_animation.gif) between a unit circle and a sine wave. Image [© Brews ohare/CC-BY-4.0](https://commons.wikimedia.org/wiki/File:Sine_curve_drawing_animation.gif).
```{r wheel-sine, echo=F, out.width="80%", fig.cap="(ref:wheel-sine)"}
embed_linked_media("images/wheel-sine.gif")
```
The discussion of simultaneously-sounding oscillators in Chapter \@ref(generators) emphasized phase relationships between the oscillators as well as slight tuning differences between the oscillators, both of which can give a fuller sound.
Phase captures everything about the relationship between *continuous* tones because the amount one signal has been offset relative to another can always be reduced to between 0 and 360 degrees (or $2pi$).^[If the offset is more than 360 degrees, it simply wraps around to a value equivalent to a value between 0 and 360 degrees, e.g. 370 degrees is the same as 10 degrees.]
However, music does not consist of continuous tones.
When we begin to consider music more broadly, it makes sense to think of phase and offset distance being decoupled depending on how much time has passed.
In real music, simultaneous sounds don't repeat forever but rather change over fairly short timescales, e.g. the envelope of a kick drum.
For brief moments of time, phase relationships capture most everything, but for longer offset distances, the amount of time that has passed is more relevant than phase relationships.
For this reason, time-based effects for short periods of time are often described in terms of phase, and longer-period effects are described in terms to time.
Figure \@ref(fig:moon-phase-time) illustrates this idea with 6 seconds of natural sound (upper) compared to .03 seconds of that same sound (lower).
While the longer stretch is clearly not repeating, the shorter stretch is approximately repeating and could be usefully characterized in terms of phase.
(ref:moon-phase-time) Six seconds of natural sound (upper) with no clear repeating structure and .03 seconds of that same sound (lower) with approximate repeating structure.
```{r moon-phase-time, echo=F, out.width="88%", fig.cap="(ref:moon-phase-time)"}
knitr::include_graphics("images/moon-phase-time.png")
```
Unlike the topics we've previously covered, time-based effects tend to be implemented by single modules rather than by collections of modules working together.
Therefore our discussion will focus on the concepts behind these effects and modules that implement them.
We'll begin with effects operating on the longest time scales and move progressively downward until the effects are based in phase.
### Delays
A [delay effect](https://en.wikipedia.org/wiki/Delay_(audio_effect)) copies some portion of of the signal and then replays it, typically mixed in with the original signal.
The ratio of original signal to processed signal is commonly referred to as dry/wet, where dry is the original signal and wet is the processed signal.
Common parameters of delays include the length of the delayed and the number of times it repeats.
Often a decay parameter is applied so that the delayed copy gets attenuated with each repetition.
Some delays can play back multiple copies at once, which blurs the boundary between a delay effect and reverb.
An example delay effect is shown in Figure \@ref(fig:moonshot-delay2s).
The original signal ([JFK's famous moon speech](https://en.wikipedia.org/wiki/We_choose_to_go_to_the_Moon)), is copied and then a delay effect applied to the copy, with decay.
Note that the delay effect extends well beyond the length of the original audio.
Delay is the longest time-based effect we will discuss, typically ranging from a hundred milliseconds to multiple seconds.
(ref:moonshot-delay2s) [Delay](https://olney.ai/ct-modular-book/images/moonshot-delay2s.png-moonshot-delay2s.ogg-local.html) applied to an audio clip. The original sound (upper) is duplicated (lower) and the effect applied. The decaying echos of the delay make the lower track significantly longer than the original.
```{r, moonshot-delay2s, out.width='100%', fig.cap="(ref:moonshot-delay2s)", dev='png', cache=TRUE, screenshot.opts=list(vwidth=400,cliprect = c(0, 0, 400, 300)), echo=F}
image_ogg_figure("moonshot-delay2s.png","moonshot-delay2s.ogg",height="370px")
```
Let's take a look at a delay module.
The main controls are the time (length of the delay offset), the feedback (amount of decay), and the wet/dry mix.
These parameters can be set using knobs for a consistent sound but also modulated to create very unusual sounds.
Try patching up a reverb into a single voice keyboard patch using the button in Figure \@ref(fig:twelvekey-env-delay).
(ref:twelvekey-env-delay) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=key-envelope_12key-vco-env-vca-scope-out.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2ftwelvekey-env-delay.png%27%3e&instructions=%3cul%3e%0a%3cli%3eAdd+Delay+between+Scope+and+Host+audio%3c%2fli%3e%0a%3cli%3eConnect+Scope+out+1+to+Delay+in%3c%2fli%3e%0a%3cli%3eConnect+Delay+wet+to+Host+Audio+L%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound%3cul%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+time+setting+on+the+delay%3c%2fli%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+feedback+setting+on+the+delay%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eChange+Delay+wet+out+to+mix+out+and+then+use+the+mix+knob+to+mix+the+dry%2fwet+sound%3c%2fli%3e%0a%3cli%3eConnect+ADSR+out+to+Delay+Time+in+and+FDBK+in%2c+make+their+attenuator+knobs+slightly+positive%2c+and+press+a+key%3c%2fli%3e%0a%3cli%3eYou+could+similarly+control+the+effect+using+an+LFO+or+other+modulator%3c%2fli%3e%0a%3c%2ful%3e%0a%3cdiv+class%3d%27d-flex+flex-row+justify-content-around%27%3e%0a%3cimg+class%3d%27rack-image%27+src%3d%27images%2fsolo-modules%2fdelay-solo.png%27%3e%0a%3c%2fdiv%3e%0a) for a delay effect.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("twelvekey-env-delay", starter_file="key-envelope_12key-vco-env-vca-scope-out.vcv", instructions_html="<ul>
<li>Add Delay between Scope and Host audio</li>
<li>Connect Scope out 1 to Delay in</li>
<li>Connect Delay wet to Host Audio L</li>
<li>Try the following and note the differences in the sound<ul>
<li>Periodically pressing the 12 key, change the time setting on the delay</li>
<li>Periodically pressing the 12 key, change the feedback setting on the delay</li>
</ul>
</li>
<li>Change Delay wet out to mix out and then use the mix knob to mix the dry/wet sound</li>
<li>Connect ADSR out to Delay Time in and FDBK in, make their attenuator knobs slightly positive, and press a key</li>
<li>You could similarly control the effect using an LFO or other modulator</li>
</ul>
<div class='d-flex flex-row justify-content-around'>
<img class='rack-image' src='images/solo-modules/delay-solo.png'>
</div>
",solution_html="<img class='rack-image' src='images/patch-solutions/twelvekey-env-delay.png'>")
```
<!-- CAPTION BLOCK -->
```{r twelvekey-env-delay, echo=F, out.width="100%", fig.cap="(ref:twelvekey-env-delay)"}
modular_caption()
```
### Reverb
A [reverb effect](https://en.wikipedia.org/wiki/Reverb_effect) is a delay-time effect with multiple overlapping copies and relatively fast decays.
Reverb conveys a sense of space, or room that the sound is occurring in, because it emulates the reflections of sound off various surfaces at different distances.
Sound travels at about 1100 feet per second, or a 1.1 feet per millisecond, so each foot of different distance in the reflection should cause an offset of about 1 millisecond relative to other reflections and the original sound.
One of the earliest ways of creating reverb was to take a recording and play it back in a particular space while simultaneously re-recording it with a microphone in that space.
The approach effectively "bakes in" the natural reverb of the room onto the recording.
Various electronic methods have been used to create a reverb effect using physical media.
Notably among these is the spring reverb, which passes the signal through a spring and uses the reflections created in the spring to model the reflections of sound.
Reverb has been added to the speech example in in Figure \@ref(fig:moonshot-reverb75), and like delay extends beyond the length of the original audio.
However, the duration it extends is much shorter (about 300 milliseconds), reflecting a faster decay time.
Note that this recording was taken in a stadium that already had significant natural reverb.
(ref:moonshot-reverb75) [Reverb](https://olney.ai/ct-modular-book/images/moonshot-reverb75.png-moonshot-reverb75.ogg-local.html) applied to an audio clip. The original sound (upper) is duplicated (lower) and the effect applied. The added reverb slightly extends the length of the original track and is most noticeable at that point due to the natural reverb in the original recording.
```{r, moonshot-reverb75, out.width='100%', fig.cap="(ref:moonshot-reverb75)", dev='png', cache=TRUE, screenshot.opts=list(vwidth=400,cliprect = c(0, 0, 400, 300)), echo=F}
image_ogg_figure("moonshot-reverb75.png","moonshot-reverb75.ogg",height="370px")
```
Let's take a look at a reverb module.
The main controls are the input level, high-pass filtering^[High-pass filtering will be explained in detail later in the chapter.], and the wet/dry mix.
This reverb module uses a combinations of sliders and knobs for parameter settings, but these can again be both manually set and modulated to create interesting sounds.
Try patching up a reverb into a single voice keyboard patch using the button in Figure \@ref(fig:twelvekey-env-reverb).
(ref:twelvekey-env-reverb) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=key-envelope_12key-vco-env-vca-scope-out.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2ftwelvekey-env-reverb.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eAdd+Spring+reverb+between+Scope+and+Host+audio%3c%2fli%3e%0a%3cli%3eConnect+Scope+out+1+to+Spring+reverb+in+1%3c%2fli%3e%0a%3cli%3eConnect+Spring+reverb+wet+to+Host+Audio+L+and+Scope+in+2%3c%2fli%3e%0a%3cli%3eMove+the+left+slider+on+Spring+reverb+up+to+set+the+level+of+the+effect%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound%3cul%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+level+setting+on+the+reverb%3c%2fli%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+HPF+%28high+pass+filter%29+setting+on+the+reverb%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eChange+Spring+reverb+wet+out+to+mix+out+and+then+use+the+mix+knob+to+mix+the+dry%2fwet+sound%3c%2fli%3e%0a%3cli%3eConnect+ADSR+out+to+Spring+reverb+CV+in+1+and+press+a+key+%28the+change+is+subtle%3b+see+the+level+difference+on+the+scope%3c%2fli%3e%0a%3cli%3eChange+the+ADSR+to+the+Gate+from+the+12+key%3b+this+will+produce+a+knocking+sound%3c%2fli%3e%0a%3c%2ful%3e%0a%3cdiv+class%3d%27d-flex+flex-row+justify-content-around%27%3e%0a%3cimg+class%3d%27rack-image%27+src%3d%27images%2fsolo-modules%2fbefaco-spring-reverb-solo.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e%0a%3c%2fdiv%3e%0a) for a reverb effect.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("twelvekey-env-reverb", starter_file="key-envelope_12key-vco-env-vca-scope-out.vcv", instructions_html="<ul>
<li>Add Spring reverb between Scope and Host audio</li>
<li>Connect Scope out 1 to Spring reverb in 1</li>
<li>Connect Spring reverb wet to Host Audio L and Scope in 2</li>
<li>Move the left slider on Spring reverb up to set the level of the effect</li>
<li>Try the following and note the differences in the sound<ul>
<li>Periodically pressing the 12 key, change the level setting on the reverb</li>
<li>Periodically pressing the 12 key, change the HPF (high pass filter) setting on the reverb</li>
</ul>
</li>
<li>Change Spring reverb wet out to mix out and then use the mix knob to mix the dry/wet sound</li>
<li>Connect ADSR out to Spring reverb CV in 1 and press a key (the change is subtle; see the level difference on the scope</li>
<li>Change the ADSR to the Gate from the 12 key; this will produce a knocking sound</li>
</ul>
<div class='d-flex flex-row justify-content-around'>
<img class='rack-image' src='images/solo-modules/befaco-spring-reverb-solo.png' style='height: 300px; width: auto'>
</div>
",solution_html="<img class='rack-image' src='images/patch-solutions/twelvekey-env-reverb.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r twelvekey-env-reverb, echo=F, out.width="100%", fig.cap="(ref:twelvekey-env-reverb)"}
modular_caption()
```
### Chorus {#chorus-effect}
A [chorus effect](https://en.wikipedia.org/wiki/Chorus_(audio_effect)) creates copies of the original signal with slight frequency and phase changes relative to the original.
We previously discussed chorus in Section \@ref(chorus-oscillators) in the context of multiple oscillators playing together.
The chorus effect is similar except that it applies to the overall audio signal, and it typically has an internal LFO that controls the phase offsets between copies of the signal.
Chorus has been added to the speech example in in Figure \@ref(fig:moonshot-chorus), and unlike the previous effects, does not noticeably extend beyond the length of the original audio.
Instead you can see an effect on the shape of the wave as the copies interfere with each other.
In this example, the chorus delay is 20 milliseconds, which is in the middle of the typical chorus range of 10-30 milliseconds.
(ref:moonshot-chorus) [Chorus](https://olney.ai/ct-modular-book/images/moonshot-chorus.png-moonshot-chorus.ogg-local.html) applied to an audio clip. The original sound (upper) is duplicated (lower) and the effect applied. The shape of the wave is affected by the interference of copies of the original signal delayed by 20 milliseconds.
```{r, moonshot-chorus, out.width='100%', fig.cap="(ref:moonshot-chorus)", dev='png', cache=TRUE, screenshot.opts=list(vwidth=400,cliprect = c(0, 0, 400, 300)), echo=F}
image_ogg_figure("moonshot-chorus.png","moonshot-chorus.ogg",height="372px")
```
Let's take a look at a chorus module.
The main controls are the rate and depth of the internal LFO and the wet/dry mix.
As before, the controls can be manually set or voltage-controlled.
Try patching up a chorus into a single voice keyboard patch using the button in Figure \@ref(fig:twelvekey-env-chorus).
(ref:twelvekey-env-chorus) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=key-envelope_12key-vco-env-vca-scope-out.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2ftwelvekey-env-chorus.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eAdd+Chorus+between+Scope+and+Host+audio%3c%2fli%3e%0a%3cli%3eConnect+Scope+out+1+to+Chours+in+L%3c%2fli%3e%0a%3cli%3eConnect+Chorus+out+L+to+Host+Audio+L+and+Scope+in+2%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound%3cul%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+range+setting+on+the+chorus%3c%2fli%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+speed+setting+on+the+chorus%3c%2fli%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+the+dry%2fwet+mix+on+the+chorus%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eConnect+ADSR+out+to+speed+and+range+to+get+some+bird-like+sounds%3c%2fli%3e%0a%3cli%3eYou+could+similarly+control+the+effect+using+an+LFO+or+other+modulator%3c%2fli%3e%0a%3c%2ful%3e%0a%3cdiv+class%3d%27d-flex+flex-row+justify-content-around%27%3e%0a%3cimg+class%3d%27rack-image%27+src%3d%27images%2fsolo-modules%2frackwindows-chorus-solo.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e%0a%3c%2fdiv%3e%0a) for a chorus effect.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("twelvekey-env-chorus", starter_file="key-envelope_12key-vco-env-vca-scope-out.vcv", instructions_html="<ul>
<li>Add Chorus between Scope and Host audio</li>
<li>Connect Scope out 1 to Chours in L</li>
<li>Connect Chorus out L to Host Audio L and Scope in 2</li>
<li>Try the following and note the differences in the sound<ul>
<li>Periodically pressing the 12 key, change the range setting on the chorus</li>
<li>Periodically pressing the 12 key, change the speed setting on the chorus</li>
<li>Periodically pressing the 12 key, change the the dry/wet mix on the chorus</li>
</ul>
</li>
<li>Connect ADSR out to speed and range to get some bird-like sounds</li>
<li>You could similarly control the effect using an LFO or other modulator</li>
</ul>
<div class='d-flex flex-row justify-content-around'>
<img class='rack-image' src='images/solo-modules/rackwindows-chorus-solo.png' style='height: 300px; width: auto'>
</div>
",solution_html="<img class='rack-image' src='images/patch-solutions/twelvekey-env-chorus.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r twelvekey-env-chorus, echo=F, out.width="100%", fig.cap="(ref:twelvekey-env-chorus)"}
modular_caption()
```
### Flanger
A [flanger, or flanging effect](https://en.wikipedia.org/wiki/Flanging#Comparison_with_phase_shifting) is created by creating one copy of the signal and delaying it very briefly, typically 1-5 milliseconds.
This slight shift causes harmonically-related frequencies in the signal to be amplified.
For example, 1 millisecond shift means that every 1000 Hz, the original signal will be doubled in amplitude through constructive interference.
This doubling will occur for all integer multiples of 1000 Hz, and so produces a harmonic series with 1000 Hz as the fundamental.
Thus a stable offset can create a harmonic sound even out of noise, as shown in Figure \@ref(fig:noise-comb).
Flangers typically use an LFO to vary the offset to create a sweep across such sounds.
(ref:noise-comb) [Youtube video](https://www.youtube.com/watch?v=k5ewou_8Abc) of pink noise with increasing 1 millisecond offsets. Note the harmonic noise that emerges as well as the comb shape of the frequency spectrum. Image [© Sweetwater](https://www.youtube.com/c/sweetwater).
```{r noise-comb, fig.cap="(ref:noise-comb)", echo = F}
embed_youtube("k5ewou_8Abc",0)
```
A flanger has been added to the speech example in in Figure \@ref(fig:moonshot-flanger5ms), and like chorus does not noticeably extend beyond the length of the original audio.
Additionally, and like chorus, you can see an effect on the shape of the wave as the delayed copy of the signal interferes with the original.
In this example, the flanger delay is 1 millisecond and so produces a sweeping tone around 1000 Hz.
(ref:moonshot-flanger5ms) [Flanger](https://olney.ai/ct-modular-book/images/moonshot-flanger5ms.png-moonshot-flanger5ms.ogg-local.html) applied to an audio clip. The original sound (upper) is duplicated (lower) and the effect applied. The shape of the wave is affected by the interference of a copy of the original signal delayed by 1 millisecond.
```{r, moonshot-flanger5ms, out.width='100%', fig.cap="(ref:moonshot-flanger5ms)", dev='png', cache=TRUE, screenshot.opts=list(vwidth=400,cliprect = c(0, 0, 400, 300)), echo=F}
image_ogg_figure("moonshot-flanger5ms.png","moonshot-flanger5ms.ogg",height="370px")
```
Let's take a look at a flanger module.
The main controls are the rate and depth of the internal LFO and the flanging offset.
As before, the controls can be manually set or voltage-controlled.
Try patching up a flanger into a single voice keyboard patch using the button in Figure \@ref(fig:twelvekey-env-flanger).
(ref:twelvekey-env-flanger) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=key-envelope_12key-vco-env-vca-scope-out.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2ftwelvekey-env-flanger.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eAdd+Vibrato+between+Scope+and+Host+audio%3c%2fli%3e%0a%3cli%3eConnect+Scope+out+1+to+Vibrato+in%3c%2fli%3e%0a%3cli%3eConnect+Vibrato+out+to+Host+Audio+L+and+Scope+in+2%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound%3cul%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+flange+setting%3c%2fli%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+frequency+setting%3c%2fli%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+width+setting%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eConnect+ADSR+out+to+freq%2c+width%2c+and+flange+to+get+some+bird-like+sounds%3c%2fli%3e%0a%3cli%3eUse+the+attenuator+knobs+below+these+jacks+to+change+the+depth+of+the+modulation+%3c%2fli%3e%0a%3cli%3eYou+could+similarly+control+the+effect+using+an+LFO+or+other+modulator%3c%2fli%3e%0a%3c%2ful%3e%0a%3cdiv+class%3d%27d-flex+flex-row+justify-content-around%27%3e%0a%3cimg+class%3d%27rack-image%27+src%3d%27images%2fsolo-modules%2fautinn-vibrato-solo.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e%0a%3c%2fdiv%3e%0a) for a flanger effect.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("twelvekey-env-flanger", starter_file="key-envelope_12key-vco-env-vca-scope-out.vcv", instructions_html="<ul>
<li>Add Vibrato between Scope and Host audio</li>
<li>Connect Scope out 1 to Vibrato in</li>
<li>Connect Vibrato out to Host Audio L and Scope in 2</li>
<li>Try the following and note the differences in the sound<ul>
<li>Periodically pressing the 12 key, change the flange setting</li>
<li>Periodically pressing the 12 key, change the frequency setting</li>
<li>Periodically pressing the 12 key, change the width setting</li>
</ul>
</li>
<li>Connect ADSR out to freq, width, and flange to get some bird-like sounds</li>
<li>Use the attenuator knobs below these jacks to change the depth of the modulation </li>
<li>You could similarly control the effect using an LFO or other modulator</li>
</ul>
<div class='d-flex flex-row justify-content-around'>
<img class='rack-image' src='images/solo-modules/autinn-vibrato-solo.png' style='height: 300px; width: auto'>
</div>
",solution_html="<img class='rack-image' src='images/patch-solutions/twelvekey-env-flanger.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r twelvekey-env-flanger, echo=F, out.width="100%", fig.cap="(ref:twelvekey-env-flanger)"}
modular_caption()
```
### Phaser
A [phaser effect](https://en.wikipedia.org/wiki/Phaser_(effect)) does not apply a delay.
Instead, a phaser shifts the phase of frequencies based on the values of those frequencies.
As a result, some frequencies are phase shifted behind the original signal while others are phase shifted ahead of the original signal.
Typically phasers have multiple stages of phase shifting to magnify the effect.
The variation in phase shifting means that while a phaser produces peaks in frequency spectrum like a flanger, those peaks are not harmonically related.
A rough analogy would be that a flanger is to a phaser like a single delay is to a reverb: the former cases use a single copy whereas the latter cases use multiple diffuse copies.
A phaser has been added to the speech example in in Figure \@ref(fig:moonshot-phaser), and like chorus and flanger does not noticeably extend beyond the length of the original audio.
The effect on the shape of the wave is quite subtle compared to the flanger, reflecting the constructive and destructive interference resulting from the phaser.
(ref:moonshot-phaser) [Phaser](https://olney.ai/ct-modular-book/images/moonshot-phaser.png-moonshot-phaser.ogg-local.html) applied to an audio clip. The original sound (upper) is duplicated (lower) and the effect applied. The effect on the shape of the wave is subtle and reflects both constructive and destructive interference.
```{r, moonshot-phaser, out.width='100%', fig.cap="(ref:moonshot-phaser)", dev='png', cache=TRUE, screenshot.opts=list(vwidth=400,cliprect = c(0, 0, 400, 300)), echo=F}
image_ogg_figure("moonshot-phaser.png","moonshot-phaser.ogg",height="372px")
```
Let's take a look at a phaser module.
The main controls are the rate and depth of the internal LFO and feedback.
As before, the controls can be manually set or voltage-controlled.
Try patching up a phaser into a single voice keyboard patch using the button in Figure \@ref(fig:twelvekey-env-phaser).
(ref:twelvekey-env-phaser) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=key-envelope_12key-vco-env-vca-scope-out.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2ftwelvekey-env-phaser.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eAdd+Phaser+FX+between+Scope+and+Host+audio%3c%2fli%3e%0a%3cli%3eConnect+Scope+out+1+to+Phaser+in%3c%2fli%3e%0a%3cli%3eConnect+Phaser+out+to+Host+Audio+L+and+Scope+in+2%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound%3cul%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+rate+setting%3c%2fli%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+feedback+setting+%28try+holding+down+the+key%29%3c%2fli%3e%0a%3cli%3ePeriodically+pressing+the+12+key%2c+change+the+depth+setting%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eConnect+ADSR+out+to+the+CV+inputs+for+these+knobs%3c%2fli%3e%0a%3cli%3eOnce+connected%2c+these+knobs+act+like+attenuators+and+control+the+depth+of+the+modulation+%3c%2fli%3e%0a%3cli%3eYou+could+similarly+control+the+effect+using+an+LFO+or+other+modulator%3c%2fli%3e%0a%3c%2ful%3e%0a%3cdiv+class%3d%27d-flex+flex-row+justify-content-around%27%3e%0a%3cimg+class%3d%27rack-image%27+src%3d%27images%2fsolo-modules%2fbitcrusher-solo.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e%0a%3c%2fdiv%3e%0a) for a phaser effect.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("twelvekey-env-phaser", starter_file="key-envelope_12key-vco-env-vca-scope-out.vcv", instructions_html="<ul>
<li>Add Phaser FX between Scope and Host audio</li>
<li>Connect Scope out 1 to Phaser in</li>
<li>Connect Phaser out to Host Audio L and Scope in 2</li>
<li>Try the following and note the differences in the sound<ul>
<li>Periodically pressing the 12 key, change the rate setting</li>
<li>Periodically pressing the 12 key, change the feedback setting (try holding down the key)</li>
<li>Periodically pressing the 12 key, change the depth setting</li>
</ul>
</li>
<li>Connect ADSR out to the CV inputs for these knobs</li>
<li>Once connected, these knobs act like attenuators and control the depth of the modulation </li>
<li>You could similarly control the effect using an LFO or other modulator</li>
</ul>
<div class='d-flex flex-row justify-content-around'>
<img class='rack-image' src='images/solo-modules/bitcrusher-solo.png' style='height: 300px; width: auto'>
</div>
",solution_html="<img class='rack-image' src='images/patch-solutions/twelvekey-env-phaser.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r twelvekey-env-phaser, echo=F, out.width="100%", fig.cap="(ref:twelvekey-env-phaser)"}
modular_caption()
```
## Voltage controlled filters
Voltage controlled filters (VCFs) are an essential component of subtractive synthesis.
Subtractive synthesis, as you recall, is characterized by taking harmonically complex waveshapes and then removing harmonic content to create the desired sounds.
The opposite approach, additive synthesis, takes harmonically simple waveshapes and adds them together to create desired sounds; however, this becomes complex in analogue circuitry and is better suited to digital computers, which is why subtractive synthesis has historically been the dominant approach to synthesis.
Filters, if you haven't already guessed, are a primary method for removing harmonic content, which is why VCFs are an essential component of subtractive synthesis.
### Filters are imperfect
As discussed in Chapter \@ref(harmonic-and-inharmonic-sounds), timbre is intimately connected to waveshape, and removing harmonic content affects both the shape of the wave and its timbre.
You may assume from our discussion of Fourier analysis that a filter will remove selected harmonics completely.
If that were the case, we might expect a square wave with all but the first two harmonics filtered to look like Figure \@ref(fig:square-fourier-2-harmonics-2).^[This figure was created using the simulator in Section \@ref(resonators-formants-and-frequency-spectrum) which you can use to further explore these concepts.]
(ref:square-fourier-2-harmonics-2) Fourier approximation of the first 11 harmonics of a square wave.
```{r square-fourier-2-harmonics-2, echo=F, out.width="100%", fig.cap="(ref:square-fourier-2-harmonics-2)"}
knitr::include_graphics("images/square-fourier-2-harmonics-2.png")
```
Using Fourier decomposition to understand VCFs is misleading in many respects, as will become clear by the end of this section.
It is also not practical to build a filter based on Fourier decomposition for two at least two reasons.
First, we want our filter to happen in real time, i.e. before a wave has even completed its cycle, which Fourier can't do.
Second, Fourier introduces [Gibbs error](https://en.wikipedia.org/wiki/Gibbs_phenomenon) that you can see in Figure \@ref(fig:square-fourier-2-harmonics-2) as peaks where there should be 90 degree angles in the square wave.
If we were to use Fourier as the basis of a filter, those peaks would introduce ringing artifacts.
(ref:vcf-square-out) VCF output on a square wave that has been aligned and scaled for comparison to Figure \@ref(fig:square-fourier-2-harmonics-2). Note the relatively flat low and high regions of the wave, which imply the presence of higher harmonics.
```{r vcf-square-out, echo=F, out.width="100%", fig.cap="(ref:vcf-square-out)"}
knitr::include_graphics("images/vcf-square-out.png")
```
The output of a real VCF filtering out all but the first 11 harmonics is shown in Figure \@ref(fig:vcf-square-out).
The VCF output has two striking differences with the Fourier example.
First, the transition from maximum positive to maximum negative (and vice versa) is substantially smoother for the VCF, creating rounder edges.
Second, the VCF has relatively flat maximum regions of the wave, which imply higher harmonics.
By comparing the Fourier and VCF outputs, we can see that the VCF is removing more low frequency content than we would expect (rounder edges) but that the VCF is removing less high frequency content than we would expect (flatter maximum regions of the wave).
So a VCF is not like a net that either lets harmonics through or not.
Instead, a VCF affects a range of harmonics, but within that range, it affects some harmonics more than others.
Let's take a look at this in some patches that filter white noise.
The advantage of filtering white noise is that white noise contains all frequencies, so it is easy to see the shape of the filter's effect.
The patches will use two common filters: low-pass filters and high-pass filters.
Low-pass filters (LPF) let low frequencies pass through relatively unaffected, and high-pass filters (HPF) let high frequencies pass through relatively unaffected.
The effect of each filter is controlled using the cutoff frequency, which defines a range of affected frequencies.
Try patching up the two filters using the button in Figure \@ref(fig:noiz-lfp-out-fft).
(ref:noiz-lfp-out-fft) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=empty.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2fnoiz-lfp-out-fft.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eAdd+Noiz%2c+VCF%2c+Host+audio+out%2c+and+Sassy+Scope%3c%2fli%3e%0a%3cli%3eConnect+Noiz+white+out+to+VCF+in+and+Sassy+input+1%3c%2fli%3e%0a%3cli%3eConnect+VCF+LPF+out+to+Host+audio+L+and+Sassy+input+2%3c%2fli%3e%0a%3cli%3eRight+click+the+Sassy+cable+inputs+to+change+the+colors+of+inputs+1%2f2+if+needed%3c%2fli%3e%0a%3cli%3eSet+Sassy+to+Freq+mode+using+button%2c+raise+nearby+slider+to+100ms+%3c%2fli%3e%0a%3cli%3eSassy+shows+the+frequency+spectrum+of+both+the+white+noise+and+filtered+noise%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound+and+spectrum%3cul%3e%0a%3cli%3eChange+the+cutoff+frequency+from+zero+to+far+right%3c%2fli%3e%0a%3cli%3eMouse+over+the+cutoff+knob+to+get+the+cutoff+freq%2c+then+mouse+over+spectrum+to+find+that+freq%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eRepeat+with+the+HPF+out+to+observe+high-pass+filtering%3c%2fli%3e%0a%3c%2ful%3e%0a%3cdiv+class%3d%27d-flex+flex-row+justify-content-around%27%3e%0a%3cimg+class%3d%27rack-image%27+src%3d%27images%2fsolo-modules%2fsassy-scope-solo.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e%0a%3c%2fdiv%3e%0a) for applying low- and high-pass filtering on white noise.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("noiz-lfp-out-fft", starter_file="empty.vcv", instructions_html="<ul>
<li>Add Noiz, VCF, Host audio out, and Sassy Scope</li>
<li>Connect Noiz white out to VCF in and Sassy input 1</li>
<li>Connect VCF LPF out to Host audio L and Sassy input 2</li>
<li>Right click the Sassy cable inputs to change the colors of inputs 1/2 if needed</li>
<li>Set Sassy to Freq mode using button, raise nearby slider to 100ms </li>
<li>Sassy shows the frequency spectrum of both the white noise and filtered noise</li>
<li>Try the following and note the differences in the sound and spectrum<ul>
<li>Change the cutoff frequency from zero to far right</li>
<li>Mouse over the cutoff knob to get the cutoff freq, then mouse over spectrum to find that freq</li>
</ul>
</li>
<li>Repeat with the HPF out to observe high-pass filtering</li>
</ul>
<div class='d-flex flex-row justify-content-around'>
<img class='rack-image' src='images/solo-modules/sassy-scope-solo.png' style='height: 300px; width: auto'>
</div>
",solution_html="<img class='rack-image' src='images/patch-solutions/noiz-lfp-out-fft.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r noiz-lfp-out-fft, echo=F, out.width="100%", fig.cap="(ref:noiz-lfp-out-fft)"}
modular_caption()
```
Let's take another look, this time with a square wave and an oscilloscope, which will let us look at the effect on the wave rather than the frequency spectrum.
Of course the disadvantage of white noise is that you can't usefully look at the effect
Try modifying your patch to use an audio rate LFO and an oscilloscope using the button in Figure \@ref(fig:lfo-lfp-out-scope-fft).
As you can see, LPF creates curious shapes that occasionally approximate shapes we recognize, like triangle and sine waves (though with reduced amplitude).
HPF creates perhaps even more curious shapes that quickly turn into increasingly sharp pulses.
(ref:lfo-lfp-out-scope-fft) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=noiz-lfp-out-fft.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2flfo-lfp-out-scope-fft.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eAdd+an+LFO+to+the+left+of+Noiz+and+Scope+between+Host+Audio+and+Sassy+Scope%3c%2fli%3e%0a%3cli%3eConnect+LFO+square+to+VCF+in%2c+Scope+in+1%2c+and+to+Sassy+input+1%3c%2fli%3e%0a%3cli%3eConnect+VCF+LPF+out+to+Host+audio+L%2c+Scope+i+n2%2c+and+Sassy+input+2%3c%2fli%3e%0a%3cli%3eRight+click+the+Sassy+cable+inputs+to+change+the+colors+of+inputs+1%2f2+if+needed%3c%2fli%3e%0a%3cli%3eSet+LFO+freq+to+around+100+Hz%2c+VCF+cutoff+to+around+400+Hz%2c+Scope+time+to+around+12+ms%2c+and+enable+Scope+TRG+%3c%2fli%3e%0a%3cli%3eThe+Scope+shows+the+square+wave+and+filtered+square+wave%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound+and+spectrum%3cul%3e%0a%3cli%3eChange+the+cutoff+frequency+from+zero+to+far+right%3c%2fli%3e%0a%3cli%3eAt+various+points%2c+the+wave+should+looke+more+like+a+triangle+wave+and+then+a+sine+wave%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eRepeat+with+the+HPF+out+to+observe+high-pass+filtering%3c%2fli%3e%0a%3c%2ful%3e%0a) for applying low- and high-pass filtering on a square wave.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("lfo-lfp-out-scope-fft", starter_file="noiz-lfp-out-fft.vcv", instructions_html="<ul>
<li>Add an LFO to the left of Noiz and Scope between Host Audio and Sassy Scope</li>
<li>Connect LFO square to VCF in, Scope in 1, and to Sassy input 1</li>
<li>Connect VCF LPF out to Host audio L, Scope i n2, and Sassy input 2</li>
<li>Right click the Sassy cable inputs to change the colors of inputs 1/2 if needed</li>
<li>Set LFO freq to around 100 Hz, VCF cutoff to around 400 Hz, Scope time to around 12 ms, and enable Scope TRG </li>
<li>The Scope shows the square wave and filtered square wave</li>
<li>Try the following and note the differences in the sound and spectrum<ul>
<li>Change the cutoff frequency from zero to far right</li>
<li>At various points, the wave should looke more like a triangle wave and then a sine wave</li>
</ul>
</li>
<li>Repeat with the HPF out to observe high-pass filtering</li>
</ul>
",solution_html="<img class='rack-image' src='images/patch-solutions/lfo-lfp-out-scope-fft.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r lfo-lfp-out-scope-fft, echo=F, out.width="100%", fig.cap="(ref:lfo-lfp-out-scope-fft)"}
modular_caption()
```
### Filters change frequency and phase
To understand why VCFs are behaving this way, we need to understand how they work.
The best way to understand VCFs, which are complex, is in terms of the passive [RC circuit](https://en.wikipedia.org/wiki/RC_circuit).
When a signal runs through an RC circuit, the circuit leeches out energy from certain parts of the waveshape and returns that energy at other parts, as shown in Figure \@ref(fig:square-lpf-hpf).
While a full explanation of how the RC circuit works is out of scope,^[For a good basic explanation of an RC circuit, see [this video](https://youtu.be/3tMGNI--ofU).] we can nevertheless describe what it does to explain what a VCF does.
The overarching idea is that when an RC circuit leeches energy out of a signal, it slows down or speeds up frequency components of the signal and so phase shifts those components.
Again, VCFs change more than just frequency spectrum - they also change phase across the frequency spectrum.
(ref:square-lpf-hpf) Square wave through a low-pass (left) and high-pass (right) filter. Note the symmetry of the difference between the square wave and the filtered signal: the shape of the filtered signal below the square wave in the positive region is the same as the filtered signal above the square wave in the negative region, but flipped.
```{r square-lpf-hpf, echo=F, out.width="100%", fig.cap="(ref:square-lpf-hpf)"}
knitr::include_graphics("images/square-lpf-hpf.png")
```
Let's look first at the LPF case, using the left side of Figure \@ref(fig:square-lpf-hpf) as a reference.
As the signal increases, the RC circuit leeches out energy until it fills up, at which point it has no effect on the signal.
Once the signal starts decreasing, the RC circuit releases energy until it runs out.
Sharp signal increases are slowed down, meaning they are phase shifted negatively. Slowing them means removing high frequencies.
Here's an analogy that might help.
Imagine you're driving on the freeway and a wind blows from ahead whenever you try to accelerate and blows from behind whenever you decelerate.
The wind is opposing your ability to change speed.
The RC circuit likewise is opposing the signal's voltage changes.
The HPF case on the right side of Figure \@ref(fig:square-lpf-hpf) is different.
As the signal increases and stops changing, the RC circuit leeches out energy until the capacitor fills up, at which point it has no effect on the signal.
Once the signal starts decreasing and stops changing, the capacitor releases energy until it runs out.
Flat signals are speeded up, meaning they are phase shifted positively.
Speeding them up means removing lower frequencies.
Using the wind and car analogy, imagine you're driving on the freeway and a wind blows whenever you try to keep a constant speed.^[More precisely, the wind blows from ahead when you start cruising after increasing speed, and the wind blows from behind when you start cruising after reducing speed.]
The wind is opposing your ability to maintain constant speed.
The RC circuit likewise is opposing the signal's constant voltage.
(ref:bode-low-pass) A Bode plot for a low-pass filter with a cutoff frequency of 100 Hz. Note the lines marked Bode pole represent idealized behavior of the filter and the Low Pass markers indicate actual behavior. The cutoff point is exactly aligned with a -45 degree phase shift. Image [public domain](https://commons.wikimedia.org/wiki/File:Sine_curve_drawing_animation.gif).
```{r bode-low-pass, echo=F, out.width="70%", fig.cap="(ref:bode-low-pass)"}
knitr::include_graphics("images/bode-low-pass.png")
```
The effect of the RC circuit on frequency and phase spectrum can be summarized by a [Bode plot](https://en.wikipedia.org/wiki/Bode_plot), as shown for an LPF in Figure \@ref(fig:bode-low-pass).
The lines labeled "Bode pole" are idealized and the actual behavior of the LPF is indicated by the markers.
Let's start with the upper subplot, which shows how the filter reduces the amplitude of the signal across frequencies.
The cutoff frequency occurs where the line changes from 0 dB to a downward angle.
As you can see, the actual behavior of the LPF is to reduce frequencies even before this point as shown by the markers below the line to the left of the cutoff point.
The decrease in amplitude at the cutoff frequency is 3 dB.^[Recall a 6 dB decrease means amplitude is cut in half.]
The decrease to the right of the cutoff point is 6 dB for each doubling of frequency, or 6 dB/Oct.
That means the amplitude of the signal will decrease by half for each additional octave above the cutoff frequency.
Let's look at the lower subplot, which shows phase shift how the filter changes phase across frequencies.
As previously explained, the LPF slows down higher frequency components of the wave, and creates a maximum phase shift of -90 degrees for those frequencies.
At the cutoff, the phase shift is already -45 degrees.
(ref:bode-high-pass) A Bode plot for a high-pass filter with a cutoff frequency of 100 Hz. Note the lines marked Bode pole represent idealized behavior of the filter and the High Pass markers indicate actual behavior. The cutoff point is exactly aligned with a 45 degree phase shift. Image [© Brews ohare/CC-BY-4.0](https://commons.wikimedia.org/wiki/File:Bode_High-Pass.PNG).
```{r bode-high-pass, echo=F, out.width="70%", fig.cap="(ref:bode-high-pass)"}
knitr::include_graphics("images/bode-high-pass.png")
```
The Bode plot for an HPF looks very similar to that of an LPF, but reversed as shown in Figure \@ref(fig:bode-high-pass).
As before the range of frequencies affected by the filter extends on both sides of the cutoff point, the signal is already attenuated by 3 dB at the cutoff point, and the decrease in amplitude (this time to the left of the cutoff) is 6 dB/Oct.
The main difference is in the sign of the phase shift in the lower subplot.
Instead of being negative because the frequencies have been slowed down, the phase shift is now positive because the affected frequencies have been sped up.
### Combining filters
In the previous Bode plots, the cutoff frequency marked the location past which the amplitude reduced by 6 dB/Oct.
This bend in the frequency response of the filter is called a pole, and the RC circuit is therefore an example of a 1-pole filter element.
To get greater reductions than 6 dB/Oct, multiple 1-pole filter elements can be combined.^[RC circuits cannot be simply combined, but they remain useful for understanding the additive effect of each element.]
Each filter element has a distinct pole, so the overall shape of the drop off has bends corresponding to these poles.
This means that a 4-pole filter would have four distinct regions of drop off rather than the single region we looked at before.
Each region would contribute both to amplitude attenuation and phase shift at a given frequency.
Common VCFs range from 1-4 poles and therefore implement 6, 12, 18, or 24 dB/Oct reductions in amplitude.
It should now be clear why filters have such characteristic sounds: the many different design choices in a filter, ranging from the selection of components to the arrangement of filter elements, each contributes to a specific effect on both amplitude attenuation and phase for each frequency filtered.
In addition to combining filters of the same type, we can also combine filters of different types.
As you might expect, multiple filters working in different frequency directions create complex phase relationships as each independently contributes to amplitude attenuation and phase for each frequency filtered.
A band-pass filter can be created by combining an LPF and HPF in series.
A band-pass filter mostly lets through frequencies within a range but more strongly attenuates frequencies outside that range.
Try making a band-pass filter using two VCFs using the button in Figure \@ref(fig:lfo-lpf-hpf-out-scope-fft).
Since there are now two cutoffs to control to hear the combined filter sweep, hook up an LFO to each VCF cutoff frequency.
(ref:lfo-lpf-hpf-out-scope-fft) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=lfo-lfp-out-scope-fft.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2flfo-lpf-hpf-out-scope-fft.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eAdd+another+VCF+to+the+right+of+the+existing+VCF.+The+left+will+be+LPF+and+the+right+HPF%3c%2fli%3e%0a%3cli%3eConnect+LPF+out+to+HPF+in+and+remove+all+other+connections+from+LPF+out%3c%2fli%3e%0a%3cli%3eConnect+HPF+out+to+Host+audio+L%2c+Scope+input+2%2c+and+Sassy+input+2%3c%2fli%3e%0a%3cli%3eYou+may+wish+to+use+a+square+wave+as+Scope+EXT+TRG%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound+and+spectrum%3cul%3e%0a%3cli%3eYour+two+VCFs+should+have+the+same+cutoff+freq+now%3c%2fli%3e%0a%3cli%3eTry+to+change+the+two+cutoffs+to+make+the+peak+higher+without+making+it+wider%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eAdd+an+LFO+to+control+the+cutoff+frequencies+of+both+VCFs%3c%2fli%3e%0a%3cli%3eConnect+that+LFO+triangle+out+to+both+VCF+cutoffs%3c%2fli%3e%0a%3cli%3eChange+the+VCF+cutoffs+attenuators+to+100%25+to+allow+the+full+LFO+signal%3c%2fli%3e%0a%3cli%3eSet+a+low+LFO+frequency+%28%3c+.5%29+and+note+the+changes+in+sound+and+the+spectrum%3c%2fli%3e%0a%3c%2ful%3e%0a) for combining LPF and HPF filters to make a band-pass filter and animating it with an LFO.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("lfo-lpf-hpf-out-scope-fft", starter_file="lfo-lfp-out-scope-fft.vcv", instructions_html="<ul>
<li>Add another VCF to the right of the existing VCF. The left will be LPF and the right HPF</li>
<li>Connect LPF out to HPF in and remove all other connections from LPF out</li>
<li>Connect HPF out to Host audio L, Scope input 2, and Sassy input 2</li>
<li>You may wish to use a square wave as Scope EXT TRG</li>
<li>Try the following and note the differences in the sound and spectrum<ul>
<li>Your two VCFs should have the same cutoff freq now</li>
<li>Try to change the two cutoffs to make the peak higher without making it wider</li>
</ul>
</li>
<li>Add an LFO to control the cutoff frequencies of both VCFs</li>
<li>Connect that LFO triangle out to both VCF cutoffs</li>
<li>Change the VCF cutoffs attenuators to 100% to allow the full LFO signal</li>
<li>Set a low LFO frequency (< .5) and note the changes in sound and the spectrum</li>
</ul>
",solution_html="<img class='rack-image' src='images/patch-solutions/lfo-lpf-hpf-out-scope-fft.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r lfo-lpf-hpf-out-scope-fft, echo=F, out.width="100%", fig.cap="(ref:lfo-lpf-hpf-out-scope-fft)"}
modular_caption()
```
A notch filter^[A notch filter is sometimes called a band-reject filter.] can be created by combining an LPF and HPF in parallel.
A notch filter mostly lets through every thing but frequencies within a range.
Try making a notch filter using two VCFs and a mixer using the button in Figure \@ref(fig:lfo-lfo-lpf-hpf-mixer-out-scope-fft).
As before, there are two cutoffs to control to hear the combined filter sweep, so an LFO can be used to control each VCF cutoff frequency.
(ref:lfo-lfo-lpf-hpf-mixer-out-scope-fft) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=lfo-lpf-hpf-out-scope-fft.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2flfo-lfo-lpf-hpf-mixer-out-scope-fft.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eChange+the+VCF+cutoffs+attenuators+to+0%25+to+temporarily+disable+the+LFO+signal+changing+those+cutoffs%3c%2fli%3e%0a%3cli%3eAdd+a+QuadVCA%2fMixer+between+the+last+VCF+and+Host+audio+out%3c%2fli%3e%0a%3cli%3eConnect+audio+rate+LFO+square+out+to+VCF+1+in+and+VCF+2+in%3c%2fli%3e%0a%3cli%3eConnect+VCF+1+LPF+out+to+QuadVCA+input+1+and+remove+all+other+connections+from+LPF+out%3c%2fli%3e%0a%3cli%3eConnect+VCF+2+HPF+out+to++QuadVCA+input+2%3c%2fli%3e%0a%3cli%3eConnect+QuadVCA+mix+out+to+Scope+input+2%2c+and+Sassy+input+2%2c+and+Host+audio+L%3c%2fli%3e%0a%3cli%3eAdjust+the+top+left+sliders+for+Sassy+to+1x%3b+this+will+make+it+easier+to+see+the+notch%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound+and+spectrum%3cul%3e%0a%3cli%3eYour+two+VCFs+should+have+the+same+cutoff+freq+now%3c%2fli%3e%0a%3cli%3eTry+to+change+the+two+cutoffs+to+make+the+notch+low+without+making+it+wide%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eChange+the+VCF+cutoffs+attenuators+to+100%25+to+allow+the+full+LFO+signal%3c%2fli%3e%0a%3cli%3eSet+a+low+LFO+frequency+%28%3c+.5%29+and+note+the+changes+in+sound+and+the+spectrum%3c%2fli%3e%0a%3c%2ful%3e%0a) for combining LPF and HPF filters to make a notch filter and animating it with an LFO.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("lfo-lfo-lpf-hpf-mixer-out-scope-fft", starter_file="lfo-lpf-hpf-out-scope-fft.vcv", instructions_html="<ul>
<li>Change the VCF cutoffs attenuators to 0% to temporarily disable the LFO signal changing those cutoffs</li>
<li>Add a QuadVCA/Mixer between the last VCF and Host audio out</li>
<li>Connect audio rate LFO square out to VCF 1 in and VCF 2 in</li>
<li>Connect VCF 1 LPF out to QuadVCA input 1 and remove all other connections from LPF out</li>
<li>Connect VCF 2 HPF out to QuadVCA input 2</li>
<li>Connect QuadVCA mix out to Scope input 2, and Sassy input 2, and Host audio L</li>
<li>Adjust the top left sliders for Sassy to 1x; this will make it easier to see the notch</li>
<li>Try the following and note the differences in the sound and spectrum<ul>
<li>Your two VCFs should have the same cutoff freq now</li>
<li>Try to change the two cutoffs to make the notch low without making it wide</li>
</ul>
</li>
<li>Change the VCF cutoffs attenuators to 100% to allow the full LFO signal</li>
<li>Set a low LFO frequency (< .5) and note the changes in sound and the spectrum</li>
</ul>
",solution_html="<img class='rack-image' src='images/patch-solutions/lfo-lfo-lpf-hpf-mixer-out-scope-fft.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r lfo-lfo-lpf-hpf-mixer-out-scope-fft, echo=F, out.width="100%", fig.cap="(ref:lfo-lfo-lpf-hpf-mixer-out-scope-fft)"}
modular_caption()
```
### Resonance
Resonant filters have been an important sound in electronic music even before modular synthesizers^[https://120years.net/wordpress/the-fonosynth-paul-ketoff-paolo-ketoff-julian-strini-gino-marinuzzi-jr-italy-1958/].
We previously discussed resonance in Section \@ref(resonators-formants-and-frequency-spectrum), but in terms of real instruments.
[Electrical resonance](https://en.wikipedia.org/wiki/Electrical_resonance) is similar and can be understood analogously to waves reflecting off the fixed end of a string to create a standing wave.
In the case of the filter, feedback from the frequency at the filter cutoff point "reflects" back into the circuit and interferes with the original signal.
As long as the two signals are aligned in phase, they will constructively interfere and amplify the frequencies at the cutoff point.
If the feedback increases beyond a certain point, the filter will begin to oscillate and effectively turn into a sine wave VCO.
Try patching up a resonant filter using white noise using the button in Figure \@ref(fig:noiz-lpf-out-scope-fft).
If you crank up the resonance on the filter, you will get a sine wave even though the input is just noise.
This illustrates that resonance is a property of the filter itself, not of the input.
Try also extending the patch using square wave input to see what resonant filter sweeps sound and look like on a wave.
You should see that the cutoff frequency and resonance interact in interesting ways and that resonance can, in some cases, add frequency content back into the sound that the filter had removed.
(ref:noiz-lpf-out-scope-fft) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=lfo-lfp-out-scope-fft.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2fnoiz-lpf-out-scope-fft.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eConnect+Noiz+white+out+to+VCF+in%2c+Scope+input+1%2c+and+Sassy+input+1%3c%2fli%3e%0a%3cli%3eConnect+VCF+LPF+out+to+Host+audio+L%2c+Scope+input+2%2c+and+Sassy+input+2%3c%2fli%3e%0a%3cli%3eConnect+VCF+LPF+out+to+Scope+EXT+TRG+%28external+trigger%29++%3c%2fli%3e%0a%3cli%3eTurn+the+VCF+resonance+up+until+you+see+a+sine+wave+on+the+scope+and+a+distinct+peak+on+Sassy%3c%2fli%3e%0a%3cli%3eNow+reconnect+everything+using+a+square+wave+as+your+VCF+input+and+EXT+TRG%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound+and+spectrum%3cul%3e%0a%3cli%3eSet+the+resonance+at+20%25+%3c%2fli%3e%0a%3cli%3eChange+the+cutoff+frequency+from+zero+to+far+right%3c%2fli%3e%0a%3cli%3eRepeat+with+the+resonace+at+50%25+and+80%25%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eRepeat+with+the+HPF+out+to+observe+high-pass+filtering%3c%2fli%3e%0a%3c%2ful%3e%0a) for applying resonant filtering on white noise and a square wave.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("noiz-lpf-out-scope-fft", starter_file="lfo-lfp-out-scope-fft.vcv", instructions_html="<ul>
<li>Connect Noiz white out to VCF in, Scope input 1, and Sassy input 1</li>
<li>Connect VCF LPF out to Host audio L, Scope input 2, and Sassy input 2</li>
<li>Connect VCF LPF out to Scope EXT TRG (external trigger) </li>
<li>Turn the VCF resonance up until you see a sine wave on the scope and a distinct peak on Sassy</li>
<li>Now reconnect everything using a square wave as your VCF input and EXT TRG</li>
<li>Try the following and note the differences in the sound and spectrum<ul>
<li>Set the resonance at 20% </li>
<li>Change the cutoff frequency from zero to far right</li>
<li>Repeat with the resonace at 50% and 80%</li>
</ul>
</li>
<li>Repeat with the HPF out to observe high-pass filtering</li>
</ul>
",solution_html="<img class='rack-image' src='images/patch-solutions/noiz-lpf-out-scope-fft.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r noiz-lpf-out-scope-fft, echo=F, out.width="100%", fig.cap="(ref:noiz-lpf-out-scope-fft)"}
modular_caption()
```
Although filter resonance has clear regions where the filter is self-oscillating or not, there is also an intermediate region where the filter begins to oscillate but the oscillation quickly dies out.
This is analogous to plucking a string or pushing on a pendulum.
Because energy is not continuously being introduced into the system, the dampening in the system brings it to rest.
The filter resonance region that acts as a dampened oscillator is used for an effect called pinging.
Pinging sends a gate or trigger to a filter in the dampened oscillator region of resonance.
That signal excites the filter enough to create a short oscillation that quickly decays.
So instead of using a VCO, VCA, and envelop to get a brief oscillation, one can simply ping a resonant filter.
This is particularly useful for percussive sounds.
Try to ping a filter using the button in Figure \@ref(fig:lfo-vcf-out-scope-fft).
Once the resonance is adjusted to be on the edge of oscillation, you can ping it by sending a pulse from a square LFO.
The pitch of the pinged response can be adjusted by the filter's cutoff.
Because the shape of the pulse used to ping a filter represents energy over time, the shape of the pulse will affect how the filter rings in response to the ping.
Any kind of pulse can be used to ping a filter, including envelopes.
(ref:lfo-vcf-out-scope-fft) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=lfo-lfp-out-scope-fft.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2flfo-vcf-out-scope-fft.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eSet+LFO+freq+to+.2+Hz%3c%2fli%3e%0a%3cli%3eSet+VCF+cutoff+to+280+Hz%3c%2fli%3e%0a%3cli%3eSet+VCF+resonance+to+60%25+%3c%2fli%3e%0a%3cli%3eSet+Scope+time+to+9+o%27clock%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound+and+spectrum%3cul%3e%0a%3cli%3eSlowly+move+resonance+between+40%25+and+63%25%3b+more+resonance+gives+longer+decay+%3c%2fli%3e%0a%3cli%3eWith+a+good+resonance%2c+move+the+cutoff+between+90+Hz+and+1000+Hz%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3cli%3eRepeat+with+the+HPF+out%3b+you+will+get+an+initial+click+and+a+brighter+sound%3c%2fli%3e%0a%3c%2ful%3e%0a) for applying resonant filtering on white noise and a square wave.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("lfo-vcf-out-scope-fft", starter_file="lfo-lfp-out-scope-fft.vcv", instructions_html="<ul>
<li>Set LFO freq to .2 Hz</li>
<li>Set VCF cutoff to 280 Hz</li>
<li>Set VCF resonance to 60% </li>
<li>Set Scope time to 9 o'clock</li>
<li>Try the following and note the differences in the sound and spectrum<ul>
<li>Slowly move resonance between 40% and 63%; more resonance gives longer decay </li>
<li>With a good resonance, move the cutoff between 90 Hz and 1000 Hz</li>
</ul>
</li>
<li>Repeat with the HPF out; you will get an initial click and a brighter sound</li>
</ul>
",solution_html="<img class='rack-image' src='images/patch-solutions/lfo-vcf-out-scope-fft.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r lfo-vcf-out-scope-fft, echo=F, out.width="100%", fig.cap="(ref:lfo-vcf-out-scope-fft)"}
modular_caption()
```
## Waveguides
Time-based effects and filters can be combined to make a synthesis technique called a [waveguide](https://en.wikipedia.org/wiki/Digital_waveguide_synthesis).
The simplest waveguide is known as the [Karplus-Strong algorithm](https://en.wikipedia.org/wiki/Karplus%E2%80%93Strong_string_synthesis).
The basic idea of a waveguide is somewhat similar to a resonant filter.
A resonant filter has a feedback path that cycles energy back into the circuit and sets up oscillation.
A waveguide creates a delayed copy of the signal (often noise), filters it, and the feeds back to mixes it in with the incoming signal as shown in Figure \@ref(fig:karplus-strong).
Unlike a resonant filter, however, waveguides are highly influenced by the nature of the delay.
The time-based effects discussed in this chapter apply to waveguides.
For example, the flanger effect of creating harmonics in a short delay will affect the harmonics of a waveguide.
While waveguides can be used to create a wide range of sounds, Karplus-Strong is typically used for string pluck sounds.
(ref:karplus-strong) A diagram of the Karplus-Strong algorithm. The plus symbol mixes the feedback path with the incoming signal. Image [© PoroCYon/CC-BY-SA-3.0](https://en.wikipedia.org/wiki/File:Karplus-strong-schematic.svg).
```{r karplus-strong, echo=F, out.width="80%", fig.cap="(ref:karplus-strong)"}
knitr::include_graphics("images/Karplus-strong-schematic.svg.png")
```
Try to create a guitar string pluck by waveguide using the button in Figure \@ref(fig:karplus-strong-guitar-env-delay-filter).
One of the tricky things about waveguides is that they have many parameters that depend on each other.
The initial sound source will bleed through more to the final sound if you use a wider envelope that lets more of it through.
The delay time will set the fundamental and have some effect on the amount of vibration.
However, much of the vibration, i.e. how long it takes the vibration to decay, is controlled by the filter cutoff, the mixer controlling feedback from the delay loop, and the amount of initial sound.
It's best to go back and forth between these settings to see what effect they have to get the sound you want.
(ref:karplus-strong-guitar-env-delay-filter) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=lfo-lfp-out-scope-fft.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2fkarplus-strong-guitar-env-delay-filter.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eDelete+LFO+and+Noiz%3c%2fli%3e%0a%3cli%3eAdd+BPM+Clock%2c+ADSR%2c+QuadVCA%2fMixer%2c+and+Delay%3c%2fli%3e%0a%3cli%3eConnect+Clock+beat+out+to+ADSR+gate+and+Scope+ext+trigger%3b+press+Scope+TRG+button%3c%2fli%3e%0a%3cli%3eConnect+ADSR+out+to+Mixer+input+1%3c%2fli%3e%0a%3cli%3eConnect+Delay+wet+out+to+VCF+in%2c+VCF+LPF+out+to+Mixer+input+2%2c+and+Mixer+mix+out+to+Delay+in%3c%2fli%3e%0a%3cli%3eNote+that+the+delay+path+starts+at+the+mixer+and+goes+back+to+the+mixer+-+this+is+the+feedback+loop+-+watch+out+because+you+can+create+out+of+control+feedback+quickly%3c%2fli%3e%0a%3cli%3eSet+ADSR+parameters+to+1ms%2f1%25%3c%2fli%3e%0a%3cli%3eSet+Mixer+A+level+to+100%25+and+B+level+on+the+high+end.+The+B+level+controls+the+length+of+the+vibration%3c%2fli%3e%0a%3cli%3eSet+Delay+time+between+7+o%27clock+and+midnight.+This+sets+the+fundamental+pitch%3c%2fli%3e%0a%3cli%3eSet+VCF+cutoff+between+9+o%27clock+and+3+o%27clock.+This+affects+timbre%2c+amplitude%2c+and+slightly+pitch%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound+and+spectrum%3cul%3e%0a%3cli%3eSlowly+change+ADSR+decay%3c%2fli%3e%0a%3cli%3eSlowly+change+Mixer+B+level+%28watch+out+for+feedback!%29%3c%2fli%3e%0a%3cli%3eSlowly+change+Delay+time%3c%2fli%3e%0a%3cli%3eSlowly+change+VCF+cutoff%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2fli%3e%0a%3c%2ful%3e%0a) for applying resonant filtering on white noise and a square wave.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("karplus-strong-guitar-env-delay-filter", starter_file="lfo-lfp-out-scope-fft.vcv", instructions_html="<ul>
<li>Delete LFO and Noiz</li>
<li>Add BPM Clock, ADSR, QuadVCA/Mixer, and Delay</li>
<li>Connect Clock beat out to ADSR gate and Scope ext trigger; press Scope TRG button</li>
<li>Connect ADSR out to Mixer input 1</li>
<li>Connect Delay wet out to VCF in, VCF LPF out to Mixer input 2, and Mixer mix out to Delay in</li>
<li>Note that the delay path starts at the mixer and goes back to the mixer - this is the feedback loop - watch out because you can create out of control feedback quickly</li>
<li>Set ADSR parameters to 1ms/1%</li>
<li>Set Mixer A level to 100% and B level on the high end. The B level controls the length of the vibration</li>
<li>Set Delay time between 7 o'clock and midnight. This sets the fundamental pitch</li>
<li>Set VCF cutoff between 9 o'clock and 3 o'clock. This affects timbre, amplitude, and slightly pitch</li>
<li>Try the following and note the differences in the sound and spectrum<ul>
<li>Slowly change ADSR decay</li>
<li>Slowly change Mixer B level (watch out for feedback!)</li>
<li>Slowly change Delay time</li>
<li>Slowly change VCF cutoff</li>
</ul>
</li>
</ul>
",solution_html="<img class='rack-image' src='images/patch-solutions/karplus-strong-guitar-env-delay-filter.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r karplus-strong-guitar-env-delay-filter, echo=F, out.width="100%", fig.cap="(ref:karplus-strong-guitar-env-delay-filter)"}
modular_caption()
```
## Bitcrushing
The bitcrushing effect is only somewhat related to time, but it is worth mentioning here not only because it is a popular effect but also because it directly connects to Section \@ref(samplers) in the last chapter.
Recall from that section that digital audio data is represented by two parameters that each represent a kind of resolution.
Bit depth is the resolution of the height of wave, i.e. amplitude.
The more bits are used the specify the height of the wave, the greater the range of loudness in our digital audio (often called [dynamic range](https://en.wikipedia.org/wiki/Dynamic_range)).
For example, 8-bit depth encodes 256 possible values ($2^8=256$), and 16-bit depth encodes about 65 thousand values ($2^{16}=65,536$).
Remember our perception of loudness is logarithmic, so we are more sensitive to changes in loudness when amplitude is small than when amplitude is large.
As a result, low bit depth particularly reduces dynamic range for quieter sounds, such that two sounds of different loudness will get represented with the same value - this is called [quantization noise](https://en.wikipedia.org/wiki/Quantization_(signal_processing)#Noise).
An example of quantization noise is shown in Figure \@ref(fig:bitcrush-scope-fft).
The stair-step pattern is atypical for analogue to digital conversion where interpolation is used, but it illustrates quantization and is typical of bit crushing effects.
Quantization noise depends on the signal, and this dependence on the signal makes quantization noise an effect rather than random noise.
However, quantization noise is still noise, so at very low bit depths, it might be hard for the ear to distinguish between quantization noise and random noise.
Older digital instruments and video games had lower bit depth, so using bit depth reduction as an effect can help recreate those sounds on modern instruments.
(ref:bitcrush-scope-fft) The effect of bit depth reduction (left) and sample rate reduction (right). Bit depth reduction is most easily observed as a stair-step quantization error. Sample rate reduction is most easily observed as the introduction of alias frequencies (green) for an input signal, here a sine wave (pink). Note that these effects in bit crushing differ from those in normal analogue to digital conversion, which uses additional techniques and processing to avoid such artifacts.
```{r bitcrush-scope-fft, echo=F, out.width="100%", fig.cap="(ref:bitcrush-scope-fft)"}
knitr::include_graphics("images/bitcrush-scope-fft.png")
```
Sample rate is resolution of the frequency of the wave; sample rate is the frequency at which the height of the wave is sampled.
As discussed in Section \@ref(samplers), the sample rate must be twice the highest frequency component of the signal to be accurately reconstructed, otherwise a doppelganger of that component, or alias, will appear.
One important tool in preventing aliasing is low-pass filtering, which only lets through those frequency components that are below the highest allowed frequency.
Because filters have a slope, some padding is needed on the sample rate in practical applications, which explains why we use a sampling rate of 44.1 kHz when the upper limit of human hearing is around 20 kHz.
But what does an alias look like and sound like?
Simply stated, an alias was supposed to be a higher frequency but was represented as a lower frequency due to the Nyquist limit.
Specifically, the aliases reflect off the sampling rate.
For example, given a sampling rate of 16 kHz, a 17 kHz frequency (16 kHz + 1 kHz) would show up as an alias at 16 kHz (16 kHz - 1 kHz).
Aliases therefore begin in the upper frequencies and can create inharmonic, metallic sounds, since the reflections of frequencies off the sampling rate are not guaranteed to be harmonically related to the original sounds.^[We will cover these ideas in more detail in Chapter \@ref(complex-generators).]
An example of aliasing on a sine wave is shown in Figure \@ref(fig:bitcrush-scope-fft).
Let's take a look at a bitcrusher module.
The main controls are the bit depth and the sample rate.
In this module, only the bit depth can be voltage-controlled.
Try patching up a bitcrusher into a single voice keyboard patch using the button in Figure \@ref(fig:bitcrush).
(ref:bitcrush) [Virtual modular](https://olney.ai/ct-modular-book/modular-for-pdf.html?starter=key-envelope_12key-vco-env-vca-scope-out.vcv&solution=%3cimg+class%3d%27rack-image%27+src%3d%27images%2fpatch-solutions%2fbitcrush.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e&instructions=%3cul%3e%0a%3cli%3eDelete+the+ADSR+module.+This+will+make+it+easier+to+hear+sweeps+of+the+bitcrusher+knobs.%3c%2fli%3e%0a%3cli%3eAdd+Bitcrusher+between+the+VCA+and+Scope%3c%2fli%3e%0a%3cli%3eAdd+Sassy+to+the+right+of+Host+Audio%3c%2fli%3e%0a%3cli%3eConnect+VCA+out+to+Scope+in+1+and+Bitcrusher+input%3c%2fli%3e%0a%3cli%3eConnect+Bitcrusher+out+to+Scope+in+2%3c%2fli%3e%0a%3cli%3eConnect+Scope+out+1+Sassy+in+1%3c%2fli%3e%0a%3cli%3eConnect+Scope+out+2+to+Host+Audio+L+and+Sassy+in+2%3c%2fli%3e%0a%3cli%3eSet+Sassy+to+frequency+mode%3c%2fli%3e%0a%3cli%3eTry+the+following+and+note+the+differences+in+the+sound+and+scopes%3cul%3e%0a%3cli%3eReduce+the+bit+rate+one+step+at+a+time+%28it+moves+in+increments+of+1%29+and+then+back+up.+Note+the+stair+steps+that+emerge+introduce+higher+frequency+components+to+the+sound+%3c%2fli%3e%0a%3cli%3eSet+to+the+lowest+bit+rate%2c+then+drag+the+VCA+level+down+to+about+half.+Note+the+audio+goes+silent+at+this+point.+This+is+the+quantization+error+previously+discussed+%3c%2fli%3e%0a%3cli%3eRaise+the+bit+rate+to+its+highest+setting%2c+then+sweep+the+sample+rate+down.+Note+the+introduction+of+higher+alias+frequencies+both+in+sound+and+on+scope%3c%2fli%3e%0a%3c%2ful%3e%0a%3c%2ful%3e%0a%3cdiv+class%3d%27d-flex+flex-row+justify-content-around%27%3e%0a%3cimg+class%3d%27rack-image%27+src%3d%27images%2fsolo-modules%2fbitcrusher-solo.png%27+style%3d%27height%3a+300px%3b+width%3a+auto%27%3e%0a%3c%2fdiv%3e%0a) for a bitcrusher effect.
<!-- MODAL HTML BLOCK -->
```{r echo=F, out.width="100%"}
modular_modal("bitcrush", starter_file="key-envelope_12key-vco-env-vca-scope-out.vcv", instructions_html="<ul>
<li>Delete the ADSR module. This will make it easier to hear sweeps of the bitcrusher knobs.</li>
<li>Add Bitcrusher between the VCA and Scope</li>
<li>Add Sassy to the right of Host Audio</li>
<li>Connect VCA out to Scope in 1 and Bitcrusher input</li>
<li>Connect Bitcrusher out to Scope in 2</li>
<li>Connect Scope out 1 Sassy in 1</li>
<li>Connect Scope out 2 to Host Audio L and Sassy in 2</li>
<li>Set Sassy to frequency mode</li>
<li>Try the following and note the differences in the sound and scopes<ul>
<li>Reduce the bit rate one step at a time (it moves in increments of 1) and then back up. Note the stair steps that emerge introduce higher frequency components to the sound </li>
<li>Set to the lowest bit rate, then drag the VCA level down to about half. Note the audio goes silent at this point. This is the quantization error previously discussed </li>
<li>Raise the bit rate to its highest setting, then sweep the sample rate down. Note the introduction of higher alias frequencies both in sound and on scope</li>
</ul>
</ul>
<div class='d-flex flex-row justify-content-around'>
<img class='rack-image' src='images/solo-modules/bitcrusher-solo.png' style='height: 300px; width: auto'>
</div>
",solution_html="<img class='rack-image' src='images/patch-solutions/bitcrush.png' style='height: 300px; width: auto'>")
```
<!-- CAPTION BLOCK -->
```{r bitcrush, echo=F, out.width="100%", fig.cap="(ref:bitcrush)"}
modular_caption()
```
## Check your understanding
1. `r mc_question("Which effect creates a harmonic series?", list( answer="flanger",
"chorus",
"phaser",
"delay"))`
2. `r mc_question("Which of the following is not a reason why the Fourier transform is impractical as a modular filter?", list( answer="diffraction",
"real-time processing",
"ringing artifacts"))`
3. `r mc_question("In a low pass filter, when the signal is decreasing, the energy in the RC circuit is:", list( answer="decreasing",
"holding steady",
"increasing",
"remaining the same"))`
3. `r mc_question("What is the phase shift at the cutoff point in a low pass filter?", list( answer="-45 degrees",
"-90 degrees",
"90 degrees",
"180 degrees"))`
4. `r mc_question("How much is the signal attenuated at the cutoff point in a low pass filter?", list( answer="3 dB",
"6 dB",
"0 dB",
"18 dB"))`
5. `r mc_question("Filter resonance is caused by", list( answer="feedback",
"self-oscillation",
"phase shift",
"poles"))`