Skip to content

Commit 4998356

Browse files
committed
add synthio example.
1 parent a722ba1 commit 4998356

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
2+
#
3+
# SPDX-License-Identifier: MIT
4+
import time
5+
6+
import synthio
7+
8+
import adafruit_fruitjam
9+
10+
pobj = adafruit_fruitjam.peripherals.Peripherals(audio_output="headphone")
11+
12+
synth = synthio.Synthesizer(sample_rate=44100)
13+
pobj.audio.play(synth)
14+
VOLUMES = [5, 7, 10, 12, 15]
15+
C_major_scale = [60, 62, 64, 65, 67, 69, 71, 72, 71, 69, 67, 65, 64, 62, 60]
16+
while True:
17+
print("\n=== Synthio Test ===")
18+
for vol in VOLUMES:
19+
pobj.volume = vol
20+
print(f"Speaker volume: {vol}")
21+
for note in C_major_scale:
22+
synth.press(note)
23+
time.sleep(0.1)
24+
synth.release(note)
25+
time.sleep(0.05)
26+
27+
time.sleep(1.0)

0 commit comments

Comments
 (0)