{"id":13800851,"url":"https://github.com/peterhinch/micropython-vs1053","last_synced_at":"2025-04-30T15:31:30.060Z","repository":{"id":50325326,"uuid":"261098355","full_name":"peterhinch/micropython-vs1053","owner":"peterhinch","description":"Synchronous and asynchronous drivers for VS1053b MP3/FLAC player","archived":false,"fork":false,"pushed_at":"2023-05-14T10:05:00.000Z","size":395,"stargazers_count":25,"open_issues_count":4,"forks_count":7,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-08-04T00:05:34.539Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/peterhinch.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-04T06:36:04.000Z","updated_at":"2024-08-04T00:05:36.912Z","dependencies_parsed_at":"2024-08-04T00:16:15.057Z","dependency_job_id":null,"html_url":"https://github.com/peterhinch/micropython-vs1053","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-vs1053","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-vs1053/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-vs1053/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/peterhinch%2Fmicropython-vs1053/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/peterhinch","download_url":"https://codeload.github.com/peterhinch/micropython-vs1053/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224215505,"owners_count":17274798,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-04T00:01:16.936Z","updated_at":"2024-11-12T04:21:12.616Z","avatar_url":"https://github.com/peterhinch.png","language":"Python","readme":"# 1. Device drivers for VS1053b\n\nThe VS1053b is an audio player capable of handling MP3 files. Development was\ndone with this [Adafruit breakout](https://www.adafruit.com/product/1381). This\nincludes an SD card adaptor which may be used to store MP3 files. MP3 bit rates\nup to 256Kbps and VBR (variable bit rate) files are supported. Adafruit \"Music\nMaker\" Arduino shields [e.g. this one](https://www.adafruit.com/product/1790)\nhave also been used with a MicroPython host running these drivers. See\n[this ref](https://github.com/peterhinch/micropython-vs1053/issues/4) for use\nwith the Arduino shield.\n\nIt should be noted that these drivers run the adaptor board's SD card at a\nhigher clock rate than the official SD card driver. If this slot is used, good\nquality SD cards should be used.\n\nThe interface uses seven I/O pins. However the Adafruit card provides 8 GPIO\npins which are supported by the driver. You gain a pin :).\n\nThere are two versions of the driver: synchronous and asynchronous. The\nasynchronous version uses `uasyncio` to enable tasks (such as a GUI interface)\nto run concurrently while playing audio files. Sadly the overhead of `uasyncio`\nprevents audio playback on ESP8266.\n\n## 1.1 Version log\n\nV0.1.5 Aug 2022 Asynchronous version has an optional buffered mode. This may\nimprove performance. It overcomes an apparent firmware bug which prevents the\nnormal version from working on ESP32.\n\nV0.1.4 Aug 2022 The performance of the asynchronous driver is substantially\nimproved, with some improvement to the synchronous driver. Both drivers have\nthe means to enable I2S output from the VS1053b chip.\n\n### [Asynchronous driver docs](./ASYNC.md)\n\nThe synchronous driver has been tested on ESP8266 and ESP32. On Pyboards and\nthe Pio CD quality audio may be achieved using FLAC files.\n\n### [Synchronous driver docs](./SYNCHRONOUS.md)\n\n# 2. Compatibility matrix\n\nMusic formats (lower MP3 rates exist but aren't considered music quality).\n\n| Format   | Bits/s   | Bytes/s | Notes            |\n|:---------|:---------|:--------|:-----------------|\n| CD       | 1.4M     | 176.4K  |                  |\n| FLAC     | 700K     | 88.2K   | CD quality       |\n| MP3 320K | 320K     | 40K     | Maximum MP3 rate |\n| MP3 VBR  | 220-260K | \u003c= 33K  | V0 Variable rate |\n| MP3 250K | 250K     | 31.25K  |                  |\n| MP3 192K | 192K     | 24K     |                  |\n| MP3 128K | 128K     | 16K     |                  |\n\nThe capability of the platform and driver combination is defined by the maximum\nrate that can be sustained. All lower rates can be assumed to work. In testing\nthe following were the highest usable rates:\n\n| Platform     | Synchronous    | Asynchronous   |\n|:-------------|:---------------|:---------------|\n| Pyboard 1.x  | FLAC           | FLAC           |\n| Pyboard D    | FLAC           | FLAC           |\n| Pyboard Lite | Not yet tested | MP3 \u003c= 128Kbps |\n| Pico         | FLAC           | FLAC           |\n| ESP32        | FLAC           | VBR            |\n| ESP8266      | MP3 \u003c= 256Kbps | Unsupported    |\n\nThe synchronous driver also supports recording audio to an IMA ADPCM `wav` file\nwhich can be played by the VS1053b or by other applications.\n\n[Converting FLAC to MP3](https://wiki.archlinux.org/title/Convert_FLAC_to_MP3)\n\n# 3. Troubleshooting\n\nTimeout messages, e.g. \"timeout waiting for response\", are indicative of an SD\ncard which cannot handle the required data rate. High quality cards are\nessential.\n\nDropouts when using the asynchronous driver indicate that the driver can't\nsupply data at the required rate. This can result from user tasks which demand\ntoo much processor time. Solutions are to reduce blocking, to use a lower MP3\nbit rate or to use the synchronous driver.\n\n# 4. Plugins\n\nThese are available from\n[VLSI solutions](http://www.vlsi.fi/en/support/software/vs10xxpatches.html).\nThey have a `.plg` extension but are C source files, intended for linking with\nuser C applications. For use with Python these need to be converted to binary\nfiles. The supplied `patch.bin` file provides FLAC decoding and possibly bug\nfixes. It is current as of August 2022.\n\nThe following describes the simple hack I used to convert from\n`vs1053b-patches-flac.plg` to `patch.bin`: this can be amended for other `.plg`\nfiles.\n\nAppend the following code to the end of the `plg` file:\n```C\n#include \u003cstdio.h\u003e\nvoid main(){\n    FILE *file;\n    file = fopen(\"patch.bin\", \"w\");\n    char c;\n    int n;\n    unsigned short v;\n    n = 0;\n    while (n \u003c PLUGIN_SIZE){\n        v = plugin[n++];\n        c = v \u0026 0xFF;\n        putc(c, file);\n        c = v \u003e\u003e 8;\n        putc(c, file);\n    }\n    fclose(file);\n}\n```\nRename the file to have a `.c` extension, compile and run with:\n```bash\n$ mv vs1053b-patches-flac.plg vs1053b-patches-flac.c\n$ gcc -o rats vs1053b-patches-flac.c\n$ chmod a+x rats\n$ ./rats\n```\n","funding_links":[],"categories":["Libraries"],"sub_categories":["Audio"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhinch%2Fmicropython-vs1053","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeterhinch%2Fmicropython-vs1053","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeterhinch%2Fmicropython-vs1053/lists"}