Skip to content

Commit 8a56460

Browse files
committed
synthio: this modified biquad test lets me hear what I'm hunting
1 parent 5f7998e commit 8a56460

File tree

1 file changed

+18
-35
lines changed
  • tests/circuitpython-manual/synthio/note

1 file changed

+18
-35
lines changed

tests/circuitpython-manual/synthio/note/biquad.py

Lines changed: 18 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
random.seed(9)
1414

1515
envelope = synthio.Envelope(
16-
attack_time=0, decay_time=0, release_time=0, attack_level=0.8, sustain_level=1.0
16+
attack_time=0.15, decay_time=0, release_time=0.08, attack_level=1.0, sustain_level=1.0
1717
)
1818

1919
SAMPLE_SIZE = 1024
@@ -30,41 +30,24 @@ def synthesize(synth):
3030
for waveform in (sine, None, noise):
3131
for biquad in (
3232
None,
33-
synth.low_pass_filter(330),
34-
synth.low_pass_filter(660),
35-
synth.high_pass_filter(330),
36-
synth.high_pass_filter(660),
37-
synth.band_pass_filter(330),
38-
synth.band_pass_filter(660),
33+
synth.low_pass_filter(120),
3934
):
40-
n = synthio.Note(
41-
frequency=80,
42-
envelope=envelope,
43-
filter=biquad,
44-
waveform=waveform,
45-
bend=synthio.LFO(bend_out, once=True, rate=1 / 2, scale=5),
46-
)
47-
48-
synth.press(n)
49-
print(synth, n)
50-
yield 2 * 48000 // 256
51-
synth.release_all()
52-
yield 36
53-
54-
for waveform in (sine, None, noise):
55-
n = synthio.Note(
56-
frequency=555,
57-
envelope=envelope,
58-
waveform=waveform,
59-
)
60-
synth.press(n)
61-
i = 220
62-
while i < 1760:
63-
n.filter = synth.band_pass_filter(i)
64-
i *= 1.00579
65-
yield 1
66-
synth.release_all()
67-
yield 6
35+
for midi_note in range(24, 90, 3):
36+
n = synthio.Note(
37+
frequency=synthio.midi_to_hz(midi_note),
38+
envelope=envelope,
39+
filter=biquad,
40+
waveform=waveform,
41+
bend=synthio.LFO(bend_out, once=True, rate=1 / 2, scale=5),
42+
)
43+
44+
synth.press(n)
45+
print(n.frequency)
46+
yield 24
47+
synth.release_all()
48+
yield 16
49+
yield 24
50+
yield 48
6851

6952

7053
with wave.open("biquad.wav", "w") as f:

0 commit comments

Comments
 (0)