update audio examples to use new volume API.

This commit is contained in:
foamyguy 2025-08-19 16:07:54 -05:00
parent c332f74892
commit 9825076bcf
2 changed files with 10 additions and 20 deletions

View file

@ -5,21 +5,16 @@ import time
import adafruit_fruitjam
pobj = adafruit_fruitjam.peripherals.Peripherals()
dac = pobj.dac # use Fruit Jam's codec
# Route once for headphones
dac.headphone_output = True
dac.speaker_output = False
pobj = adafruit_fruitjam.peripherals.Peripherals(audio_output="headphone")
FILES = ["beep.wav", "dip.wav", "rise.wav"]
VOLUMES_DB = [12, 6, 0, -6, -12]
VOLUMES = [5, 7, 10, 12, 15]
while True:
print("\n=== Headphones Test ===")
for vol in VOLUMES_DB:
dac.dac_volume = vol
print(f"Headphones volume: {vol} dB")
for vol in VOLUMES:
pobj.volume = vol
print(f"Headphones volume: {vol}")
for f in FILES:
print(f" -> {f}")
pobj.play_file(f)

View file

@ -5,21 +5,16 @@ import time
import adafruit_fruitjam
pobj = adafruit_fruitjam.peripherals.Peripherals()
dac = pobj.dac # use Fruit Jam's codec
# Route once for speaker
dac.headphone_output = False
dac.speaker_output = True
pobj = adafruit_fruitjam.peripherals.Peripherals(audio_output="speaker")
FILES = ["beep.wav", "dip.wav", "rise.wav"]
VOLUMES_DB = [12, 6, 0, -6, -12]
VOLUMES = [5, 7, 10, 12, 15]
while True:
print("\n=== Speaker Test ===")
for vol in VOLUMES_DB:
dac.dac_volume = vol
print(f"Speaker volume: {vol} dB")
for vol in VOLUMES:
pobj.volume = vol
print(f"Speaker volume: {vol}")
for f in FILES:
print(f" -> {f}")
pobj.play_file(f)