headphone vs speaker usage

Short examples showing how to set volume and play WAV files for both headphone 3.5mm jack and mini speaker.
This commit is contained in:
Mikey Sklar 2025-08-14 12:32:14 -07:00
parent 3aebe8dc9d
commit 0e0ab5431f
5 changed files with 52 additions and 0 deletions

View file

@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT
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
FILES = ["beep.wav", "dip.wav", "rise.wav"]
VOLUMES_DB = [12, 6, 0, -6, -12]
while True:
print("\n=== Headphones Test ===")
for vol in VOLUMES_DB:
dac.dac_volume = vol
print(f"Headphones volume: {vol} dB")
for f in FILES:
print(f" -> {f}")
pobj.play_file(f)
time.sleep(0.2)
time.sleep(1.0)

View file

@ -0,0 +1,26 @@
# SPDX-FileCopyrightText: Copyright (c) 2025 Tim Cocks for Adafruit Industries
#
# SPDX-License-Identifier: MIT
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
FILES = ["beep.wav", "dip.wav", "rise.wav"]
VOLUMES_DB = [12, 6, 0, -6, -12]
while True:
print("\n=== Speaker Test ===")
for vol in VOLUMES_DB:
dac.dac_volume = vol
print(f"Speaker volume: {vol} dB")
for f in FILES:
print(f" -> {f}")
pobj.play_file(f)
time.sleep(0.2)
time.sleep(1.0)

BIN
examples/wav/beep.wav Executable file

Binary file not shown.

BIN
examples/wav/dip.wav Executable file

Binary file not shown.

BIN
examples/wav/rise.wav Executable file

Binary file not shown.