-
Notifications
You must be signed in to change notification settings - Fork 25
Add MP3 playback and example with files. #25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ | |
"audiopwmio", | ||
"audiocore", | ||
"adafruit_debouncer", | ||
"audiomp3", | ||
] | ||
|
||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2021 Kattni Rembor for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: CC-BY-SA-4.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2021 Kattni Rembor for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: CC-BY-SA-4.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2021 Kattni Rembor for Adafruit Industries | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should this file be examples/macropad_mp3/code.py? I am not sure about the new rules.
This comment was marked as duplicate.
Sorry, something went wrong. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For library code, Bundlefly automatically changes the file to code.py so that the files can continue to stay within library standards and Adabot remains happy. |
||
# | ||
# SPDX-License-Identifier: Unlicense | ||
""" | ||
MacroPad MP3 playback demo. Plays one of four different MP3 files when one of the first four keys | ||
is pressed. All keys light up a color of the rainbow when pressed, but no audio is played for the | ||
rest of the keys. | ||
""" | ||
from rainbowio import colorwheel | ||
from adafruit_macropad import MacroPad | ||
|
||
macropad = MacroPad() | ||
|
||
# To include more MP3 files, add the names to this list in the same manner as the others. | ||
# Then, add more key numbers below. | ||
audio_files = ["slow.mp3", "happy.mp3", "beats.mp3", "upbeats.mp3"] | ||
|
||
while True: | ||
key_event = macropad.keys.events.get() | ||
|
||
if key_event: | ||
if key_event.pressed: | ||
macropad.pixels[key_event.key_number] = colorwheel( | ||
int(255 / 12) * key_event.key_number | ||
) | ||
# If adding more MP3 files, add the appropriate key numbers to the tuple below. | ||
if key_event.key_number in (0, 1, 2, 3): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This works! Updated! |
||
macropad.play_file(audio_files[key_event.key_number]) | ||
|
||
else: | ||
macropad.pixels.fill((0, 0, 0)) | ||
macropad.stop_tone() |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2021 Kattni Rembor for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: CC-BY-SA-4.0 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# SPDX-FileCopyrightText: Copyright (c) 2021 Kattni Rembor for Adafruit Industries | ||
# | ||
# SPDX-License-Identifier: CC-BY-SA-4.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be Copyright Bartlebeats instead? (presumably the same for all tracks)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was wondering the same thing. Wasn't sure about who to add here. Good call.