Skip to content

Commit fe66f8d

Browse files
committed
finally checking audiodelays examples in
1 parent a32e8cc commit fe66f8d

11 files changed

+275
-13
lines changed

1_getting_started/code_generative_penta.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
scale_pentatonic = [0, 2, 4, 7, 9, 12, 14, 16, 19, 21] # two octaves of offsets
1010

1111
while True:
12-
midi_note = random.choice( [root_note+x for x in scale_pentatonic] )
12+
midi_note = root_note + random.choice(scale_pentatonic)
1313
print("playing!", midi_note)
1414
synth.press(midi_note)
1515
time.sleep(0.1)

6_audio_effects/code_chorus.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# 6_effects/code_chorus.py
2+
# part of todbot circuitpython synthio tutorial
3+
# 14 Apr 2025 - @todbot / Tod Kurt
4+
import time, random
5+
import synthio
6+
import audiodelays, audiofilters
7+
from synth_setup import mixer, synth, SAMPLE_RATE, CHANNEL_COUNT, knobA
8+
9+
chorus1 = audiodelays.Chorus(
10+
channel_count=CHANNEL_COUNT,
11+
sample_rate=SAMPLE_RATE,
12+
mix = 0.5,
13+
voices = 3,
14+
max_delay_ms = 50,
15+
delay_ms = synthio.LFO(rate=0.5, offset=15, scale=5),
16+
)
17+
18+
mixer.voice[0].play(chorus1) # plug effect into the mixer (unplugs synth)
19+
chorus1.play(synth) # and plug synth into effect
20+
21+
while True:
22+
midi_note = random.randint(36,64)
23+
v = knobA.value/65535
24+
chorus1.mix = v
25+
print("playing %d mix: %.2f" % (midi_note,v))
26+
synth.press(midi_note)
27+
time.sleep(0.5)
28+
synth.release(midi_note)
29+
time.sleep(1)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# 6_effects/code_chorus_penta.py
2+
# part of todbot circuitpython synthio tutorial
3+
# 14 Apr 2025 - @todbot / Tod Kurt
4+
import time, random
5+
import ulab.numpy as np
6+
import synthio
7+
import audiodelays, audiofilters
8+
from synth_setup import mixer, synth, SAMPLE_RATE, CHANNEL_COUNT, knobA, knobB
9+
10+
time.sleep(1)
11+
12+
chorus1 = audiodelays.Chorus(
13+
channel_count=CHANNEL_COUNT,
14+
sample_rate=SAMPLE_RATE,
15+
mix = 0.5,
16+
voices = 3,
17+
max_delay_ms = 50,
18+
delay_ms = synthio.LFO(rate=0.5, offset=15, scale=5),
19+
)
20+
21+
mixer.voice[0].play(chorus1) # plug effect into the mixer (unplugs synth)
22+
chorus1.play(synth) # and plug synth into effect
23+
24+
# make a quicky saw wave for chorus demo
25+
wave_saw = np.linspace(32000, -32000, num=128, dtype=np.int16)
26+
# and a filter to tame the high end
27+
lpf = synthio.Biquad(synthio.FilterMode.LOW_PASS, frequency=3000, Q=1.25)
28+
29+
scale_pentatonic = [0, 2, 4, 7, 9, 12, 14, 16, 19, 21] # two octaves of offsets
30+
31+
i=0
32+
while True:
33+
midi_note = 48 + random.choice(scale_pentatonic)
34+
notes = [synthio.Note(synthio.midi_to_hz(midi_note), waveform=wave_saw, filter=lpf),]
35+
if knobB.value > 32000:
36+
notes.append(synthio.Note(synthio.midi_to_hz(midi_note+7), waveform=wave_saw, filter=lpf))
37+
vA = knobA.value/65535
38+
#chorus1.delay_ms.offset = (knobB.value/65535)*25 + 0.001
39+
chorus1.mix = knobA.value/65535
40+
print("playing %d mix: %.2f %d" % (midi_note,vA, len(notes)))
41+
synth.press(notes)
42+
time.sleep(0.1)
43+
synth.release(notes)
44+
time.sleep(0.25 if i%2 else 0.12 ) # give it a little groove
45+
i=i+1

6_audio_effects/code_echo.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# 6_effects/code_echo.py
22
# part of todbot circuitpython synthio tutorial
3-
# 10 Feb 2025 - @todbot / Tod Kurt
3+
# 14 Apr 2025 - @todbot / Tod Kurt
44
import time, random
55
import synthio
66
import audiodelays
@@ -15,8 +15,8 @@
1515
channel_count = CHANNEL_COUNT,
1616
)
1717

18-
mixer.voice[0].play(echo1) # plug echo into the mixer (unplugs synth)
19-
echo1.play(synth) # and plug synth into echo
18+
mixer.voice[0].play(echo1) # plug effect into the mixer (unplugs synth)
19+
echo1.play(synth) # and plug synth into effect
2020

2121
while True:
2222
midi_note = random.randint(36,64) # knobA controls echo mix

6_audio_effects/code_filters.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# 6_effects/code_filters.py
2+
# part of todbot circuitpython synthio tutorial
3+
# 10 Feb 2025 - @todbot / Tod Kurt
4+
import time, random
5+
import synthio
6+
import audiodelays, audiofilters
7+
from synth_setup import mixer, synth, SAMPLE_RATE, CHANNEL_COUNT, knobA
8+
9+
time.sleep(1)
10+
11+
filter1 = audiofilters.Filter(buffer_size=1024,
12+
channel_count=CHANNEL_COUNT,
13+
sample_rate=SAMPLE_RATE,
14+
mix=1.0)
15+
filter2 = audiofilters.Filter(buffer_size=1024,
16+
channel_count=CHANNEL_COUNT,
17+
sample_rate=SAMPLE_RATE,
18+
mix=1.0)
19+
filter1.filter = synthio.Biquad(synthio.FilterMode.LOW_PASS, frequency=2000, Q=2.25)
20+
filter2.filter = synthio.Biquad(synthio.FilterMode.LOW_PASS, frequency=2000, Q=2.25)
21+
filter1.filter.frequency = synthio.LFO(rate=2, offset=1000, scale=800)
22+
filter2.filter.frequency = synthio.LFO(rate=2, offset=1000, scale=800)
23+
24+
mixer.voice[1].play(filter1) # plug filter1 into the mixer (unplugs synth)
25+
filter1.play(filter2) # plug filter2 into filter1
26+
filter2.play(synth) # and plug synth into filter2
27+
28+
while True:
29+
print("ping")
30+
synth.press(48)
31+
time.sleep(1)
32+
synth.release(48)
33+
time.sleep(2.0)

6_audio_effects/code_flange0.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
# 6_effects/code_echo.py
1+
# 6_effects/code_flange.py
22
# part of todbot circuitpython synthio tutorial
3-
# 10 Feb 2025 - @todbot / Tod Kurt
3+
# 14 Apr 2025 - @todbot / Tod Kurt
44
import time
55
import ulab.numpy as np
66
import synthio
7-
import audiodelays
7+
import audiodelays, audiofilters
88
from synth_setup import mixer, synth, SAMPLE_RATE, CHANNEL_COUNT, knobA
99

1010
time.sleep(1)
@@ -21,9 +21,8 @@
2121
buffer_size = 1024,
2222
)
2323

24-
mixer.voice[0].play(echo1) # plug echo into the mixer (unplugs synth)
25-
echo1.play(synth) # and plug synth into echo
26-
24+
mixer.voice[0].play(echo1) # plug effect into the mixer (unplugs synth)
25+
echo1.play(synth) # and plug synth into effect
2726

2827
while True:
2928
print("ping")

README-1-Getting-Started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ root_note = 48
249249
scale_pentatonic = (0, 2, 4, 7, 9, 12, 14, 16, 19, 21) # two octaves of offsets
250250

251251
while True:
252-
midi_note = random.choice( [root_note+x for x in scale_pentatonic] )
252+
midi_note = root_note + random.choice(scale_pentatonic)
253253
print("playing!", midi_note)
254254
synth.press(midi_note)
255255
time.sleep(0.1)

README-2-Modulation.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
* [Fade in LFO, using LERP](#fade-in-lfo-using-lerp)
1414
* [Bend-in pitch envelope](#bend-in-pitch-envelope)
1515
* [Portamento: glide between notes](#portamento-glide-between-notes)
16+
* [Next steps](#next-steps)
1617
<!--te-->
1718

1819
Modulation is the automation of changing a parameter over time in a synthesizer.

README-3-Filters.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
* [Changing filter with LFO](#changing-filter-with-lfo)
1010
* [Creating filter envelope with LFOs](#creating-filter-envelope-with-lfos)
1111
* [Creating filter envelope with lerp LFOs](#creating-filter-envelope-with-lerp-lfos)
12+
* [Next steps](#next-steps)
1213
<!--te-->
1314

1415
## About Filters

README-4-Oscillators-Wavetables.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* [Wavetable scanning](#wavetable-scanning)
1212
* [Fun with wavetables: wavetabledrone](#fun-with-wavetables-wavetabledrone)
1313
* [Wavetable in RAM, one approach](#wavetable-in-ram-one-approach)
14+
* [Next Steps](#next-steps)
1415
<!--te-->
1516

1617
## About Oscillators

0 commit comments

Comments
 (0)