audiocore: Add MP3File using Adafruit_MP3 library

This commit is contained in:
Jeff Epler 2019-11-26 09:29:55 -06:00
parent a484a93b29
commit a08d9e6d8e
28 changed files with 1007 additions and 36 deletions

3
.gitmodules vendored
View File

@ -102,3 +102,6 @@
[submodule "ports/cxd56/spresense-exported-sdk"]
path = ports/cxd56/spresense-exported-sdk
url = https://github.com/sonydevworld/spresense-exported-sdk.git
[submodule "lib/mp3"]
path = lib/mp3
url = https://github.com/adafruit/Adafruit_MP3

1
lib/mp3 Submodule

@ -0,0 +1 @@
Subproject commit 2a3cc7873b5c642d4bb60043dc14d2555e3377a5

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -496,11 +496,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr "Tidak dapat menginisialisasi UART"
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
msgid "Couldn't allocate first buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr ""
@ -613,6 +623,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1779,7 +1793,7 @@ msgstr "argumen keyword ekstra telah diberikan"
msgid "extra positional arguments given"
msgstr "argumen posisi ekstra telah diberikan"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -486,11 +486,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
msgid "Couldn't allocate first buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr ""
@ -602,6 +612,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1749,7 +1763,7 @@ msgstr ""
msgid "extra positional arguments given"
msgstr ""
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Pascal Deneaux\n"
"Language-Team: Sebastian Plamauer, Pascal Deneaux\n"
@ -490,11 +490,21 @@ msgstr "Beschädigter raw code"
msgid "Could not initialize UART"
msgstr "Konnte UART nicht initialisieren"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr "Konnte first buffer nicht zuteilen"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr "Konnte second buffer nicht zuteilen"
@ -606,6 +616,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr "Verbindung nicht erfolgreich: timeout"
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1798,7 +1812,7 @@ msgstr "Es wurden zusätzliche Keyword-Argumente angegeben"
msgid "extra positional arguments given"
msgstr "Es wurden zusätzliche Argumente ohne Keyword angegeben"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -486,11 +486,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
msgid "Couldn't allocate first buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr ""
@ -602,6 +612,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1749,7 +1763,7 @@ msgstr ""
msgid "extra positional arguments given"
msgstr ""
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: @sommersoft, @MrCertainly\n"
@ -490,11 +490,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
msgid "Couldn't allocate first buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr ""
@ -606,6 +616,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1753,7 +1767,7 @@ msgstr ""
msgid "extra positional arguments given"
msgstr ""
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -494,11 +494,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr "No se puede inicializar la UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr "No se pudo asignar el primer buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr "No se pudo asignar el segundo buffer"
@ -610,6 +620,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1802,7 +1816,7 @@ msgstr "argumento(s) por palabra clave adicionales fueron dados"
msgid "extra positional arguments given"
msgstr "argumento posicional adicional dado"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr "el archivo deberia ser una archivo abierto en modo byte"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -495,11 +495,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr "Hindi ma-initialize ang UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr "Hindi ma-iallocate ang first buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr "Hindi ma-iallocate ang second buffer"
@ -616,6 +626,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1810,7 +1824,7 @@ msgstr "dagdag na keyword argument na ibinigay"
msgid "extra positional arguments given"
msgstr "dagdag na positional argument na ibinigay"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr "file ay dapat buksan sa byte mode"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2019-04-14 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@ -501,11 +501,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr "L'UART n'a pu être initialisé"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr "Impossible d'allouer le 1er tampon"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr "Impossible d'allouer le 2e tampon"
@ -620,6 +630,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1842,7 +1856,7 @@ msgstr "argument(s) nommé(s) supplémentaire(s) donné(s)"
msgid "extra positional arguments given"
msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr "le fichier doit être un fichier ouvert en mode 'byte'"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -496,11 +496,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr "Impossibile inizializzare l'UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr "Impossibile allocare il primo buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr "Impossibile allocare il secondo buffer"
@ -616,6 +626,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1803,7 +1817,7 @@ msgstr "argomento nominato aggiuntivo fornito"
msgid "extra positional arguments given"
msgstr "argomenti posizonali extra dati"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr ""

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2019-05-06 14:22-0700\n"
"Last-Translator: \n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -490,11 +490,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
msgid "Couldn't allocate first buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr ""
@ -606,6 +616,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1754,7 +1768,7 @@ msgstr ""
msgid "extra positional arguments given"
msgstr ""
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2019-03-19 18:37-0700\n"
"Last-Translator: Radomir Dopieralski <circuitpython@sheep.art.pl>\n"
"Language-Team: pl\n"
@ -489,11 +489,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr "Ustawienie UART nie powiodło się"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr "Nie udała się alokacja pierwszego bufora"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr "Nie udała się alokacja drugiego bufora"
@ -605,6 +615,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1774,7 +1788,7 @@ msgstr "nadmiarowe argumenty nazwane"
msgid "extra positional arguments given"
msgstr "nadmiarowe argumenty pozycyjne"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr "file musi być otwarte w trybie bajtowym"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -492,11 +492,21 @@ msgstr ""
msgid "Could not initialize UART"
msgstr "Não foi possível inicializar o UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr "Não pôde alocar primeiro buffer"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr "Não pôde alocar segundo buffer"
@ -611,6 +621,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr ""
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, fuzzy, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1771,7 +1785,7 @@ msgstr "argumentos extras de palavras-chave passados"
msgid "extra positional arguments given"
msgstr "argumentos extra posicionais passados"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr ""

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: circuitpython-cn\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-12-06 13:25-0600\n"
"POT-Creation-Date: 2019-12-10 13:55-0600\n"
"PO-Revision-Date: 2019-04-13 10:10-0700\n"
"Last-Translator: hexthat\n"
"Language-Team: Chinese Hanyu Pinyin\n"
@ -490,11 +490,21 @@ msgstr "Sǔnhuài de yuánshǐ dàimǎ"
msgid "Could not initialize UART"
msgstr "Wúfǎ chūshǐhuà UART"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate decoder"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate first buffer"
msgstr "Wúfǎ fēnpèi dì yī gè huǎnchōng qū"
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate input buffer"
msgstr ""
#: shared-module/audiocore/WaveFile.c shared-module/audiomixer/Mixer.c
#: shared-module/audiomp3/MP3File.c
msgid "Couldn't allocate second buffer"
msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū"
@ -606,6 +616,10 @@ msgstr ""
msgid "Failed to connect: timeout"
msgstr "Liánjiē shībài: Chāoshí"
#: shared-module/audiomp3/MP3File.c
msgid "Failed to parse MP3 file"
msgstr ""
#: ports/nrf/sd_mutex.c
#, c-format
msgid "Failed to release mutex, err 0x%04x"
@ -1785,7 +1799,7 @@ msgstr "éwài de guānjiàn cí cānshù"
msgid "extra positional arguments given"
msgstr "gěi chūle éwài de wèizhì cānshù"
#: shared-bindings/audiocore/WaveFile.c
#: shared-bindings/audiocore/WaveFile.c shared-bindings/audiomp3/MP3File.c
#: shared-bindings/displayio/OnDiskBitmap.c
msgid "file must be a file opened in byte mode"
msgstr "wénjiàn bìxū shì zài zì jié móshì xià dǎkāi de wénjiàn"

View File

@ -16,3 +16,4 @@ CIRCUITPY_AUDIOBUSIO = 0
CIRCUITPY_DISPLAYIO = 0
CIRCUITPY_NETWORK = 0
CIRCUITPY_PS2IO = 0
CIRCUITPY_AUDIOMP3 = 0

View File

@ -21,6 +21,10 @@ ifndef CIRCUITPY_AUDIOMIXER
CIRCUITPY_AUDIOMIXER = 0
endif
ifndef CIRCUITPY_AUDIOMP3
CIRCUITPY_AUDIOMP3 = 0
endif
ifndef CIRCUITPY_FREQUENCYIO
CIRCUITPY_FREQUENCYIO = 0
endif

View File

@ -117,6 +117,9 @@ endif
ifeq ($(CIRCUITPY_AUDIOMIXER),1)
SRC_PATTERNS += audiomixer/%
endif
ifeq ($(CIRCUITPY_AUDIOMP3),1)
SRC_PATTERNS += audiomp3/%
endif
ifeq ($(CIRCUITPY_BITBANGIO),1)
SRC_PATTERNS += bitbangio/%
endif
@ -319,6 +322,8 @@ SRC_SHARED_MODULE_ALL = \
audiomixer/__init__.c \
audiomixer/Mixer.c \
audiomixer/MixerVoice.c \
audiomp3/__init__.c \
audiomp3/MP3File.c \
bitbangio/I2C.c \
bitbangio/OneWire.c \
bitbangio/SPI.c \
@ -371,6 +376,26 @@ SRC_SHARED_MODULE_ALL += \
touchio/TouchIn.c \
touchio/__init__.c
endif
ifeq ($(CIRCUITPY_AUDIOMP3),1)
SRC_MOD += $(addprefix lib/mp3/src/, \
bitstream.c \
buffers.c \
dct32.c \
dequant.c \
dqchan.c \
huffman.c \
hufftabs.c \
imdct.c \
mp3dec.c \
mp3tabs.c \
polyphase.c \
scalfact.c \
stproc.c \
subband.c \
trigtabs.c \
)
$(BUILD)/lib/mp3/src/buffers.o: CFLAGS += -include "py/misc.h" -D'MPDEC_ALLOCATOR(x)=m_malloc(x,0)' -D'MPDEC_FREE(x)=m_free(x)'
endif
# All possible sources are listed here, and are filtered by SRC_PATTERNS.
SRC_SHARED_MODULE_INTERNAL = \

View File

@ -252,6 +252,13 @@ extern const struct _mp_obj_module_t audiomixer_module;
#define AUDIOMIXER_MODULE
#endif
#if CIRCUITPY_AUDIOMP3
#define AUDIOMP3_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiomp3), (mp_obj_t)&audiomp3_module },
extern const struct _mp_obj_module_t audiomp3_module;
#else
#define AUDIOMP3_MODULE
#endif
#if CIRCUITPY_AUDIOPWMIO
#define AUDIOPWMIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiopwmio), (mp_obj_t)&audiopwmio_module },
extern const struct _mp_obj_module_t audiopwmio_module;
@ -582,6 +589,7 @@ extern const struct _mp_obj_module_t ustack_module;
AUDIOCORE_MODULE \
AUDIOIO_MODULE \
AUDIOMIXER_MODULE \
AUDIOMP3_MODULE \
AUDIOPWMIO_MODULE \
BITBANGIO_MODULE \
BLEIO_MODULE \

View File

@ -104,6 +104,15 @@ CIRCUITPY_AUDIOMIXER = $(CIRCUITPY_AUDIOIO)
endif
CFLAGS += -DCIRCUITPY_AUDIOMIXER=$(CIRCUITPY_AUDIOMIXER)
ifndef CIRCUITPY_AUDIOMP3
ifeq ($(CIRCUITPY_FULL_BUILD),1)
CIRCUITPY_AUDIOMP3 = $(CIRCUITPY_AUDIOCORE)
else
CIRCUITPY_AUDIOMP3 = 0
endif
endif
CFLAGS += -DCIRCUITPY_AUDIOMP3=$(CIRCUITPY_AUDIOMP3)
ifndef CIRCUITPY_BITBANGIO
CIRCUITPY_BITBANGIO = $(CIRCUITPY_FULL_BUILD)
endif

View File

@ -0,0 +1,226 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
* Copyright (c) 2019 Jeff Epler for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdint.h>
#include "lib/utils/context_manager_helpers.h"
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/audiomp3/MP3File.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate.h"
//| .. currentmodule:: audiomp3
//|
//| :class:`MP3` -- Load a mp3 file for audio playback
//| ========================================================
//|
//| A .mp3 file prepped for audio playback. Only mono and stereo files are supported. Samples must
//| be 8 bit unsigned or 16 bit signed. If a buffer is provided, it will be used instead of allocating
//| an internal buffer.
//|
//| .. class:: MP3(file[, buffer])
//|
//| Load a .mp3 file for playback with `audioio.AudioOut` or `audiobusio.I2SOut`.
//|
//| :param typing.BinaryIO file: Already opened mp3 file
//| :param bytearray buffer: Optional pre-allocated buffer, that will be split in half and used for double-buffering of the data. If not provided, two buffers are allocated internally. The specific buffer size required depends on the mp3 file.
//|
//|
//| Playing a mp3 file from flash::
//|
//| import board
//| import audiomp3
//| import audioio
//| import digitalio
//|
//| # Required for CircuitPlayground Express
//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE)
//| speaker_enable.switch_to_output(value=True)
//|
//| data = open("cplay-16bit-16khz-64kbps.mp3", "rb")
//| mp3 = audiomp3.MP3File(data)
//| a = audioio.AudioOut(board.A0)
//|
//| print("playing")
//| a.play(mp3)
//| while a.playing:
//| pass
//| print("stopped")
//|
STATIC mp_obj_t audiomp3_mp3file_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *args, mp_map_t *kw_args) {
mp_arg_check_num(n_args, kw_args, 1, 2, false);
audiomp3_mp3file_obj_t *self = m_new_obj(audiomp3_mp3file_obj_t);
self->base.type = &audiomp3_mp3file_type;
if (!MP_OBJ_IS_TYPE(args[0], &mp_type_fileio)) {
mp_raise_TypeError(translate("file must be a file opened in byte mode"));
}
uint8_t *buffer = NULL;
size_t buffer_size = 0;
if (n_args >= 2) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_WRITE);
buffer = bufinfo.buf;
buffer_size = bufinfo.len;
}
common_hal_audiomp3_mp3file_construct(self, MP_OBJ_TO_PTR(args[0]),
buffer, buffer_size);
return MP_OBJ_FROM_PTR(self);
}
//| .. method:: deinit()
//|
//| Deinitialises the MP3 and releases all memory resources for reuse.
//|
STATIC mp_obj_t audiomp3_mp3file_deinit(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
common_hal_audiomp3_mp3file_deinit(self);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_deinit_obj, audiomp3_mp3file_deinit);
STATIC void check_for_deinit(audiomp3_mp3file_obj_t *self) {
if (common_hal_audiomp3_mp3file_deinited(self)) {
raise_deinited_error();
}
}
//| .. method:: __enter__()
//|
//| No-op used by Context Managers.
//|
// Provided by context manager helper.
//| .. method:: __exit__()
//|
//| Automatically deinitializes the hardware when exiting a context. See
//| :ref:`lifetime-and-contextmanagers` for more info.
//|
STATIC mp_obj_t audiomp3_mp3file_obj___exit__(size_t n_args, const mp_obj_t *args) {
(void)n_args;
common_hal_audiomp3_mp3file_deinit(args[0]);
return mp_const_none;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiomp3_mp3file___exit___obj, 4, 4, audiomp3_mp3file_obj___exit__);
//| .. attribute:: sample_rate
//|
//| 32 bit value that dictates how quickly samples are loaded into the DAC
//| in Hertz (cycles per second). When the sample is looped, this can change
//| the pitch output without changing the underlying sample.
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_sample_rate(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return MP_OBJ_NEW_SMALL_INT(common_hal_audiomp3_mp3file_get_sample_rate(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_sample_rate_obj, audiomp3_mp3file_obj_get_sample_rate);
STATIC mp_obj_t audiomp3_mp3file_obj_set_sample_rate(mp_obj_t self_in, mp_obj_t sample_rate) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
common_hal_audiomp3_mp3file_set_sample_rate(self, mp_obj_get_int(sample_rate));
return mp_const_none;
}
MP_DEFINE_CONST_FUN_OBJ_2(audiomp3_mp3file_set_sample_rate_obj, audiomp3_mp3file_obj_set_sample_rate);
const mp_obj_property_t audiomp3_mp3file_sample_rate_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&audiomp3_mp3file_get_sample_rate_obj,
(mp_obj_t)&audiomp3_mp3file_set_sample_rate_obj,
(mp_obj_t)&mp_const_none_obj},
};
//| .. attribute:: bits_per_sample
//|
//| Bits per sample. (read only)
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_bits_per_sample(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return MP_OBJ_NEW_SMALL_INT(common_hal_audiomp3_mp3file_get_bits_per_sample(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_bits_per_sample_obj, audiomp3_mp3file_obj_get_bits_per_sample);
const mp_obj_property_t audiomp3_mp3file_bits_per_sample_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&audiomp3_mp3file_get_bits_per_sample_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
//| .. attribute:: channel_count
//|
//| Number of audio channels. (read only)
//|
STATIC mp_obj_t audiomp3_mp3file_obj_get_channel_count(mp_obj_t self_in) {
audiomp3_mp3file_obj_t *self = MP_OBJ_TO_PTR(self_in);
check_for_deinit(self);
return MP_OBJ_NEW_SMALL_INT(common_hal_audiomp3_mp3file_get_channel_count(self));
}
MP_DEFINE_CONST_FUN_OBJ_1(audiomp3_mp3file_get_channel_count_obj, audiomp3_mp3file_obj_get_channel_count);
const mp_obj_property_t audiomp3_mp3file_channel_count_obj = {
.base.type = &mp_type_property,
.proxy = {(mp_obj_t)&audiomp3_mp3file_get_channel_count_obj,
(mp_obj_t)&mp_const_none_obj,
(mp_obj_t)&mp_const_none_obj},
};
STATIC const mp_rom_map_elem_t audiomp3_mp3file_locals_dict_table[] = {
// Methods
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiomp3_mp3file_deinit_obj) },
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiomp3_mp3file___exit___obj) },
// Properties
{ MP_ROM_QSTR(MP_QSTR_sample_rate), MP_ROM_PTR(&audiomp3_mp3file_sample_rate_obj) },
{ MP_ROM_QSTR(MP_QSTR_bits_per_sample), MP_ROM_PTR(&audiomp3_mp3file_bits_per_sample_obj) },
{ MP_ROM_QSTR(MP_QSTR_channel_count), MP_ROM_PTR(&audiomp3_mp3file_channel_count_obj) },
};
STATIC MP_DEFINE_CONST_DICT(audiomp3_mp3file_locals_dict, audiomp3_mp3file_locals_dict_table);
STATIC const audiosample_p_t audiomp3_mp3file_proto = {
MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample)
.sample_rate = (audiosample_sample_rate_fun)common_hal_audiomp3_mp3file_get_sample_rate,
.bits_per_sample = (audiosample_bits_per_sample_fun)common_hal_audiomp3_mp3file_get_bits_per_sample,
.channel_count = (audiosample_channel_count_fun)common_hal_audiomp3_mp3file_get_channel_count,
.reset_buffer = (audiosample_reset_buffer_fun)audiomp3_mp3file_reset_buffer,
.get_buffer = (audiosample_get_buffer_fun)audiomp3_mp3file_get_buffer,
.get_buffer_structure = (audiosample_get_buffer_structure_fun)audiomp3_mp3file_get_buffer_structure,
};
const mp_obj_type_t audiomp3_mp3file_type = {
{ &mp_type_type },
.name = MP_QSTR_MP3File,
.make_new = audiomp3_mp3file_make_new,
.locals_dict = (mp_obj_dict_t*)&audiomp3_mp3file_locals_dict,
.protocol = &audiomp3_mp3file_proto,
};

View File

@ -0,0 +1,48 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
* Copyright (c) 2019 Jeff Epler for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H
#include "py/obj.h"
#include "extmod/vfs_fat.h"
#include "shared-module/audiomp3/MP3File.h"
extern const mp_obj_type_t audiomp3_mp3file_type;
void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self,
pyb_file_obj_t* file, uint8_t *buffer, size_t buffer_size);
void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t* self);
bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t* self);
uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t* self);
void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t* self, uint32_t sample_rate);
uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t* self);
uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t* self);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO_MP3FILE_H

View File

@ -0,0 +1,60 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Jeff Epler for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include <stdint.h>
#include "py/obj.h"
#include "py/runtime.h"
#include "shared-bindings/audiomp3/MP3File.h"
//| :mod:`audiomp3` --- Support for MP3-compressed audio files
//| ==========================================================
//|
//| .. module:: audiomp3
//| :synopsis: Support for mp3 files
//|
//| The `audiomp3` module contains an mp3 decoder
//|
//| Libraries
//|
//| .. toctree::
//| :maxdepth: 3
//|
//| MP3File
//|
STATIC const mp_rom_map_elem_t audiomp3_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiomp3) },
{ MP_ROM_QSTR(MP_QSTR_MP3File), MP_ROM_PTR(&audiomp3_mp3file_type) },
};
STATIC MP_DEFINE_CONST_DICT(audiomp3_module_globals, audiomp3_module_globals_table);
const mp_obj_module_t audiomp3_module = {
.base = { &mp_type_module },
.globals = (mp_obj_dict_t*)&audiomp3_module_globals,
};

View File

@ -0,0 +1,34 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Jeff Epler for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMP3___INIT___H
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMP3___INIT___H
#include "py/obj.h"
// Nothing now.
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMP3___INIT___H

View File

@ -0,0 +1,270 @@
/*
* This file is part of the Micro Python project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Scott Shawcroft for Adafruit Industries
* Copyright (c) 2019 Jeff Epler for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#include "shared-bindings/audiomp3/MP3File.h"
#include <stdint.h>
#include <string.h>
#include "py/mperrno.h"
#include "py/runtime.h"
#include "shared-module/audiomp3/MP3File.h"
#include "supervisor/shared/translate.h"
#include "lib/mp3/src/mp3common.h"
/** Fill the input buffer if it is less than half full.
*
* Returns true if the input buffer contains any useful data,
* false otherwise. (The input buffer will be padded to the end with
* 0 bytes, which do not interfere with MP3 decoding)
*
* Raises OSError if f_read fails.
*
* Sets self->eof if any read of the file returns 0 bytes
*/
STATIC bool mp3file_update_inbuf(audiomp3_mp3file_obj_t* self) {
// If buffer is over half full, do nothing
if (self->inbuf_offset < self->inbuf_length/2) return true;
// If we didn't previously reach the end of file, we can try reading now
if (!self->eof) {
// Move the unconsumed portion of the buffer to the start
uint8_t *end_of_buffer = self->inbuf + self->inbuf_length;
uint8_t *new_end_of_data = self->inbuf + self->inbuf_length - self->inbuf_offset;
memmove(self->inbuf, self->inbuf + self->inbuf_offset,
self->inbuf_length - self->inbuf_offset);
self->inbuf_offset = 0;
UINT to_read = end_of_buffer - new_end_of_data;
UINT bytes_read = 0;
memset(new_end_of_data, 0, to_read);
if (f_read(&self->file->fp, new_end_of_data, to_read, &bytes_read) != FR_OK) {
self->eof = true;
mp_raise_OSError(MP_EIO);
}
if (bytes_read == 0) {
self->eof = true;
}
if (to_read != bytes_read) {
new_end_of_data += bytes_read;
memset(new_end_of_data, 0, end_of_buffer - new_end_of_data);
}
}
// Return true iff there are at least some useful bytes in the buffer
return self->inbuf_offset < self->inbuf_length;
}
#define READ_PTR(self) (self->inbuf + self->inbuf_offset)
#define BYTES_LEFT(self) (self->inbuf_length - self->inbuf_offset)
#define CONSUME(self, n) (self->inbuf_offset += n)
/* If a sync word can be found, advance to it and return true. Otherwise,
* return false.
*/
STATIC bool mp3file_find_sync_word(audiomp3_mp3file_obj_t* self) {
do {
mp3file_update_inbuf(self);
int offset = MP3FindSyncWord(READ_PTR(self), BYTES_LEFT(self));
if (offset >= 0) {
CONSUME(self, offset);
mp3file_update_inbuf(self);
return true;
}
CONSUME(self, MAX(0, BYTES_LEFT(self) - 16));
} while (!self->eof);
return false;
}
STATIC bool mp3file_get_next_frame_info(audiomp3_mp3file_obj_t* self, MP3FrameInfo* fi) {
int err = MP3GetNextFrameInfo(self->decoder, fi, READ_PTR(self));
return err == ERR_MP3_NONE;
}
void common_hal_audiomp3_mp3file_construct(audiomp3_mp3file_obj_t* self,
pyb_file_obj_t* file,
uint8_t *buffer,
size_t buffer_size) {
// XXX Adafruit_MP3 uses a 2kB input buffer and two 4kB output buffers.
// for a whopping total of 10kB buffers (+mp3 decoder state and frame buffer)
// At 44kHz, that's 23ms of output audio data.
//
// We will choose a slightly different allocation strategy for the output:
// Make sure the buffers are sized exactly to match (a multiple of) the
// frame size; this is typically 2304 * 2 bytes, so a little bit bigger
// than the two 4kB output buffers, except that the alignment allows to
// never allocate that extra frame buffer.
self->file = file;
self->inbuf_length = 2048;
self->inbuf_offset = self->inbuf_length;
self->inbuf = m_malloc(self->inbuf_length, false);
if (self->inbuf == NULL) {
common_hal_audiomp3_mp3file_deinit(self);
mp_raise_msg(&mp_type_MemoryError,
translate("Couldn't allocate input buffer"));
}
self->decoder = MP3InitDecoder();
if (self->decoder == NULL) {
common_hal_audiomp3_mp3file_deinit(self);
mp_raise_msg(&mp_type_MemoryError,
translate("Couldn't allocate decoder"));
}
mp3file_find_sync_word(self);
MP3FrameInfo fi;
if(!mp3file_get_next_frame_info(self, &fi)) {
mp_raise_msg(&mp_type_RuntimeError,
translate("Failed to parse MP3 file"));
}
self->sample_rate = fi.samprate;
self->channel_count = fi.nChans;
self->frame_buffer_size = fi.outputSamps*sizeof(int16_t);
if (buffer_size >= 2 * self->frame_buffer_size) {
self->len = buffer_size / 2 / self->frame_buffer_size * self->frame_buffer_size;
self->buffers[0] = buffer;
self->buffers[1] = buffer + self->len;
} else {
self->len = 2 * self->frame_buffer_size;
self->buffers[0] = m_malloc(self->len, false);
if (self->buffers[0] == NULL) {
common_hal_audiomp3_mp3file_deinit(self);
mp_raise_msg(&mp_type_MemoryError,
translate("Couldn't allocate first buffer"));
}
self->buffers[1] = m_malloc(self->len, false);
if (self->buffers[1] == NULL) {
common_hal_audiomp3_mp3file_deinit(self);
mp_raise_msg(&mp_type_MemoryError,
translate("Couldn't allocate second buffer"));
}
}
}
void common_hal_audiomp3_mp3file_deinit(audiomp3_mp3file_obj_t* self) {
MP3FreeDecoder(self->decoder);
self->decoder = NULL;
self->inbuf = NULL;
self->buffers[0] = NULL;
self->buffers[1] = NULL;
self->file = NULL;
}
bool common_hal_audiomp3_mp3file_deinited(audiomp3_mp3file_obj_t* self) {
return self->buffers[0] == NULL;
}
uint32_t common_hal_audiomp3_mp3file_get_sample_rate(audiomp3_mp3file_obj_t* self) {
return self->sample_rate;
}
void common_hal_audiomp3_mp3file_set_sample_rate(audiomp3_mp3file_obj_t* self,
uint32_t sample_rate) {
self->sample_rate = sample_rate;
}
uint8_t common_hal_audiomp3_mp3file_get_bits_per_sample(audiomp3_mp3file_obj_t* self) {
return 16;
}
uint8_t common_hal_audiomp3_mp3file_get_channel_count(audiomp3_mp3file_obj_t* self) {
return self->channel_count;
}
bool audiomp3_mp3file_samples_signed(audiomp3_mp3file_obj_t* self) {
return true;
}
void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t* self,
bool single_channel,
uint8_t channel) {
if (single_channel && channel == 1) {
return;
}
// We don't reset the buffer index in case we're looping and we have an odd number of buffer
// loads
f_lseek(&self->file->fp, 0);
self->inbuf_offset = self->inbuf_length;
self->eof = 0;
mp3file_update_inbuf(self);
mp3file_find_sync_word(self);
}
audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* self,
bool single_channel,
uint8_t channel,
uint8_t** bufptr,
uint32_t* buffer_length) {
if (!single_channel) {
channel = 0;
}
uint16_t channel_read_count = self->channel_read_count[channel]++;
bool need_more_data = self->read_count++ == channel_read_count;
*bufptr = self->buffers[self->buffer_index] + channel;
*buffer_length = self->frame_buffer_size;
if (need_more_data) {
self->buffer_index = !self->buffer_index;
int16_t *buffer = (int16_t *)(void *)self->buffers[self->buffer_index];
if (!mp3file_find_sync_word(self)) {
return self->eof ? GET_BUFFER_DONE : GET_BUFFER_ERROR;
}
int bytes_left = BYTES_LEFT(self);
uint8_t *inbuf = READ_PTR(self);
int err = MP3Decode(self->decoder, &inbuf, &bytes_left, buffer, 0);
CONSUME(self, BYTES_LEFT(self) - bytes_left);
if (err) {
return GET_BUFFER_DONE;
}
}
return GET_BUFFER_MORE_DATA;
}
void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t* self, bool single_channel,
bool* single_buffer, bool* samples_signed,
uint32_t* max_buffer_length, uint8_t* spacing) {
*single_buffer = false;
*samples_signed = true;
*max_buffer_length = self->frame_buffer_size;
if (single_channel) {
*spacing = self->channel_count;
} else {
*spacing = 1;
}
}

View File

@ -0,0 +1,70 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2018 Scott Shawcroft
* Copyright (c) 2019 Jeff Epler for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H
#define MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H
#include "extmod/vfs_fat.h"
#include "py/obj.h"
#include "shared-module/audiocore/__init__.h"
typedef struct {
mp_obj_base_t base;
struct _MP3DecInfo *decoder;
uint8_t* inbuf;
uint32_t inbuf_length;
uint32_t inbuf_offset;
uint8_t* buffers[2];
uint32_t len;
uint32_t frame_buffer_size;
uint32_t sample_rate;
pyb_file_obj_t* file;
uint8_t buffer_index;
uint8_t channel_count;
bool eof;
uint16_t read_count;
uint16_t channel_read_count[2];
} audiomp3_mp3file_obj_t;
// These are not available from Python because it may be called in an interrupt.
void audiomp3_mp3file_reset_buffer(audiomp3_mp3file_obj_t* self,
bool single_channel,
uint8_t channel);
audioio_get_buffer_result_t audiomp3_mp3file_get_buffer(audiomp3_mp3file_obj_t* self,
bool single_channel,
uint8_t channel,
uint8_t** buffer,
uint32_t* buffer_length); // length in bytes
void audiomp3_mp3file_get_buffer_structure(audiomp3_mp3file_obj_t* self, bool single_channel,
bool* single_buffer, bool* samples_signed,
uint32_t* max_buffer_length, uint8_t* spacing);
#endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_MP3FILE_H

View File

View File

@ -0,0 +1,30 @@
/*
* This file is part of the MicroPython project, http://micropython.org/
*
* The MIT License (MIT)
*
* Copyright (c) 2019 Jeff Epler for Adafruit Industries
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
#ifndef MICROPY_INCLUDED_SHARED_MODULE_AUDIOMP3__INIT__H
#define MICROPY_INCLUDED_SHARED_MODULE_AUDIOMP3__INIT__H
#endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOMP3__INIT__H