Skip to content

Commit 9825076

Browse files
committed
update audio examples to use new volume API.
1 parent c332f74 commit 9825076

File tree

2 files changed

+10
-20
lines changed

2 files changed

+10
-20
lines changed

examples/fruitjam_headphone.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,16 @@
55

66
import adafruit_fruitjam
77

8-
pobj = adafruit_fruitjam.peripherals.Peripherals()
9-
dac = pobj.dac # use Fruit Jam's codec
10-
11-
# Route once for headphones
12-
dac.headphone_output = True
13-
dac.speaker_output = False
8+
pobj = adafruit_fruitjam.peripherals.Peripherals(audio_output="headphone")
149

1510
FILES = ["beep.wav", "dip.wav", "rise.wav"]
16-
VOLUMES_DB = [12, 6, 0, -6, -12]
11+
VOLUMES = [5, 7, 10, 12, 15]
1712

1813
while True:
1914
print("\n=== Headphones Test ===")
20-
for vol in VOLUMES_DB:
21-
dac.dac_volume = vol
22-
print(f"Headphones volume: {vol} dB")
15+
for vol in VOLUMES:
16+
pobj.volume = vol
17+
print(f"Headphones volume: {vol}")
2318
for f in FILES:
2419
print(f" -> {f}")
2520
pobj.play_file(f)

examples/fruitjam_speaker.py

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,16 @@
55

66
import adafruit_fruitjam
77

8-
pobj = adafruit_fruitjam.peripherals.Peripherals()
9-
dac = pobj.dac # use Fruit Jam's codec
10-
11-
# Route once for speaker
12-
dac.headphone_output = False
13-
dac.speaker_output = True
8+
pobj = adafruit_fruitjam.peripherals.Peripherals(audio_output="speaker")
149

1510
FILES = ["beep.wav", "dip.wav", "rise.wav"]
16-
VOLUMES_DB = [12, 6, 0, -6, -12]
11+
VOLUMES = [5, 7, 10, 12, 15]
1712

1813
while True:
1914
print("\n=== Speaker Test ===")
20-
for vol in VOLUMES_DB:
21-
dac.dac_volume = vol
22-
print(f"Speaker volume: {vol} dB")
15+
for vol in VOLUMES:
16+
pobj.volume = vol
17+
print(f"Speaker volume: {vol}")
2318
for f in FILES:
2419
print(f" -> {f}")
2520
pobj.play_file(f)

0 commit comments

Comments
 (0)