diff --git a/examples/fruitjam_headphone.py b/examples/fruitjam_headphone.py new file mode 100644 index 0000000..c5d3a94 --- /dev/null +++ b/examples/fruitjam_headphone.py @@ -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) diff --git a/examples/fruitjam_speaker.py b/examples/fruitjam_speaker.py new file mode 100644 index 0000000..02e75fa --- /dev/null +++ b/examples/fruitjam_speaker.py @@ -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) diff --git a/examples/wav/beep.wav b/examples/wav/beep.wav new file mode 100755 index 0000000..8a6eea6 Binary files /dev/null and b/examples/wav/beep.wav differ diff --git a/examples/wav/beep.wav.license b/examples/wav/beep.wav.license new file mode 100644 index 0000000..e840764 --- /dev/null +++ b/examples/wav/beep.wav.license @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries +# +# SPDX-License-Identifier: CC-BY-4.0 diff --git a/examples/wav/dip.wav b/examples/wav/dip.wav new file mode 100755 index 0000000..000d849 Binary files /dev/null and b/examples/wav/dip.wav differ diff --git a/examples/wav/dip.wav.license b/examples/wav/dip.wav.license new file mode 100644 index 0000000..e840764 --- /dev/null +++ b/examples/wav/dip.wav.license @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries +# +# SPDX-License-Identifier: CC-BY-4.0 diff --git a/examples/wav/rise.wav b/examples/wav/rise.wav new file mode 100755 index 0000000..f20a351 Binary files /dev/null and b/examples/wav/rise.wav differ diff --git a/examples/wav/rise.wav.license b/examples/wav/rise.wav.license new file mode 100644 index 0000000..e840764 --- /dev/null +++ b/examples/wav/rise.wav.license @@ -0,0 +1,3 @@ +# SPDX-FileCopyrightText: Copyright (c) 2025 Adafruit Industries +# +# SPDX-License-Identifier: CC-BY-4.0