Merge pull request #12 from mikeysklar/headphone-speaker
Some checks failed
Build CI / test (push) Has been cancelled
Some checks failed
Build CI / test (push) Has been cancelled
headphone vs speaker usage
This commit is contained in:
commit
a0327ac8e6
8 changed files with 63 additions and 0 deletions
27
examples/fruitjam_headphone.py
Normal file
27
examples/fruitjam_headphone.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# 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)
|
||||
27
examples/fruitjam_speaker.py
Normal file
27
examples/fruitjam_speaker.py
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
# 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
BIN
examples/wav/beep.wav
Executable file
Binary file not shown.
3
examples/wav/beep.wav.license
Normal file
3
examples/wav/beep.wav.license
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: CC-BY-4.0
|
||||
BIN
examples/wav/dip.wav
Executable file
BIN
examples/wav/dip.wav
Executable file
Binary file not shown.
3
examples/wav/dip.wav.license
Normal file
3
examples/wav/dip.wav.license
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: CC-BY-4.0
|
||||
BIN
examples/wav/rise.wav
Executable file
BIN
examples/wav/rise.wav
Executable file
Binary file not shown.
3
examples/wav/rise.wav.license
Normal file
3
examples/wav/rise.wav.license
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries
|
||||
#
|
||||
# SPDX-License-Identifier: CC-BY-4.0
|
||||
Loading…
Reference in a new issue