Commit graph

36376 commits

Author SHA1 Message Date
cb295c57d7 MP3Decoder: Make it possible to start in the middle of an MP3
You can now, e.g.,
```
with open("/whatever.mp3") as mp3_file:
    mp3_file.seek(16000*30)
    decoder.file = mp3_file
    i2s.play(decoder)
```
to start about 30 seconds into a 128kbit/s CBR track.

If a track is looped, the loop will start at the beginning.

This also changes the behavior if the track is started & stopped: it will
continue from where it left off, except if it had prevously run to
completion. To get other behavior, you can seek the file and then re-assign
the file property.
2024-06-05 10:33:40 -05:00
Dan Halbert
d86e072e54
Merge pull request #9292 from skerr92/rpga_feather
add odt rpga feather
2024-06-05 10:17:26 -04:00
Seth Kerr
5dcefaf551 add odt rpga feather 2024-06-05 07:58:25 -06:00
Dan Halbert
22850e6292
Merge pull request #9308 from UnexpectedCircuitPython/um_feathers3_neo_90x
Add UM FeatherS3 Neo board support for 9.0.x
2024-06-04 21:40:41 -04:00
Dan Halbert
604b862949
Merge pull request #9307 from UnexpectedCircuitPython/um_feathers3_neo
Added new UM FeatherS3 Neo.
2024-06-04 21:17:48 -04:00
Seon Rozenblum
c5324c0e9d Add UM FeatherS3 Neo board support for 9.0.x 2024-06-05 11:08:47 +10:00
Seon Rozenblum
bb1f1abad4 Added new UM FeatherS3 Neo. 2024-06-05 10:19:18 +10:00
6f6b680c18 MP3Decoder: improve some comments 2024-06-04 12:24:34 -05:00
4465f85027 evo m51: disable MP3 playback
& sort block of configuration settings
2024-06-04 12:18:29 -05:00
f4993b9b8a monster m4sk: disable a bunch of non-applicable modules
this hardware lacks the necessary I/O to connect any of these buses.

(re)enable synthio, it should fit now.
2024-06-04 12:18:04 -05:00
Dan Halbert
90cce2f36b
Merge pull request #9299 from tannewt/time_to_refresh
Make time_to_refresh return 0 correctly
2024-06-04 12:34:56 -04:00
Dan Halbert
597d5ccd2a
Merge pull request #9297 from weblate/weblate-circuitpython-main
Translations update from Hosted Weblate
2024-06-04 12:33:35 -04:00
Dan Halbert
46b172e168 picow: turn off CIRCUITPY_USB_HOST and CIRCUITPY_PICODVI 2024-06-04 12:31:57 -04:00
Hosted Weblate
1a8f3e22bf
Merge remote-tracking branch 'origin/main' 2024-06-04 18:27:58 +02:00
Scott Shawcroft
4cb4abf56a
Merge pull request #9296 from squix78/pendrive-s3
Add support for ThingPulse Pendrive S3
2024-06-04 09:27:54 -07:00
Bill Sideris
ccdcecc252
Initial nodemcu_esp32c2 board configuration (dupe creator id) 2024-06-04 15:56:27 +03:00
Daniel Eichhorn
3855d82f86
Use PID allocated in Espressif Repository 2024-06-04 07:37:39 +02:00
Daniel Eichhorn
d7975afa83
Merge branch 'adafruit:main' into pendrive-s3 2024-06-04 07:34:24 +02:00
Scott Shawcroft
254cac059e
Make time_to_refresh return 0 correctly
Redo Feather C6 pinout so it include standard D# labels for feathers

Fixes #9244
2024-06-03 15:33:11 -07:00
f81a3aed68 MP3Decoder: avoid all blocking reads in background
This gets MP3 playback of a soma.fm stream working for up to a minute
at a time, though it's still vulnerable to network glitches.

 * the buffer can empty, in which case a single block of audio
   plays repeatedly in max headroom stutter fashion
 * the server eventually (after 1 to 5 5 minutes) stops getting packets
   at all. At this point stream playback stops, with the internal error
   indicating a problem MP3 decoding (which doesn't quite make sense):
   -9, ERR_MP3_INVALID_HUFFCODES.
 * other combinations of audiomixer buffer & mp3 buffer might give
   different results
```py
import time

import adafruit_connection_manager
import adafruit_requests
import audiobusio
import audiomixer
import audiomp3
import board
import wifi

pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
requests = adafruit_requests.Session(pool, ssl_context)

# todo: parse PLS files like https://somafm.com/nossl/dronezone.pls
# todo: figure out why https URLs don't work at all (missing select?)
# STREAMING_URL = "http://ice2.somafm.com/dronezone-128-mp3"
STREAMING_URL = "http://ice4.somafm.com/tikitime-128-mp3"


def get_mp3_stream():
    if STREAMING_URL.startswith("http:") or STREAMING_URL.startswith("https:"):
        return requests.get(STREAMING_URL, headers={"connection": "close"}).socket
    return open(STREAMING_URL, "rb")


mixer_buffer_size = 1152 * 2
mp3_buffer = bytearray(32768)

with audiobusio.I2SOut(
    bit_clock=board.D12, word_select=board.D13, data=board.D11
) as i2s, get_mp3_stream() as stream, audiomp3.MP3Decoder(
    stream, mp3_buffer
) as sample, audiomixer.Mixer(
    channel_count=2, sample_rate=44100, buffer_size=mixer_buffer_size
) as m:

    v = m.voice[0]
    print(sample)

    i2s.play(m)

    v.play(sample, loop=False)
    while v.playing:
        time.sleep(0.1)
```
2024-06-03 15:49:14 -05:00
Hosted Weblate
c2b374c7f8
Merge remote-tracking branch 'origin/main' 2024-06-03 22:19:29 +02:00
Dan Halbert
b1e4bc3073
Merge pull request #9298 from tyeth/correct-branch-logic-custom-builds
Correct custom board build branch logic
2024-06-03 16:19:24 -04:00
tyeth
d687580c3d Correct custom board build branch logic 2024-06-03 20:07:08 +01:00
Hosted Weblate
6f6821d61a
Update translation files
Updated by "Update PO files to match POT (msgmerge)" hook in Weblate.

Translation: CircuitPython/main
Translate-URL: https://hosted.weblate.org/projects/circuitpython/main/
2024-06-03 19:22:08 +02:00
Scott Shawcroft
dc3edf4e24
Merge pull request #9277 from Sola85/improve_espulp
Fix "espulp module broken in CircuitPython 9"
2024-06-03 10:21:56 -07:00
Dan Halbert
8db7a85756
Merge pull request #9295 from dhalbert/pypi-uncrustify
Use micropython-uncrustify from pypi instead of apt package
2024-06-03 11:33:50 -04:00
Dan Halbert
b2a350e49f
Merge pull request #9293 from tyeth/custom_builds_for_forks_and_branches
Custom builds for forks and branches
2024-06-03 11:33:34 -04:00
Dan Halbert
13b31ca8c7 requirements-dev.txt: silabs needs setuptools 2024-06-02 15:00:51 -04:00
Daniel Eichhorn
3cbad86140 Use unique PID 2024-06-02 19:15:53 +02:00
Daniel Eichhorn
089b3862e4 Add support for ThingPulse Pendrive S3 2024-06-02 17:59:40 +02:00
Dan Halbert
a63470aa9a Use micropython-uncrustify from pypi instead of apt package 2024-06-02 09:55:08 -04:00
Dan Halbert
c581eb91a4
Merge pull request #9294 from bablokb/code_cleanup
remove definition of board_display_obj
2024-06-02 09:02:44 -04:00
Tyeth Gundry
5d1a8964bb Add branch + fork compatibility 2024-06-01 23:57:21 +01:00
Tobias Schmale
55028d0a2d espulp: improve error messages 2024-06-01 16:06:45 +00:00
Bernhard Bablok
2ddae3d96c removed definition of board_display_obj 2024-06-01 16:58:15 +02:00
Dan Halbert
f810f4d088
Merge pull request #9289 from tannewt/esp_ble_bonding
Support BLE pairing and bonding on ESP
2024-05-31 23:21:55 -04:00
Dan Halbert
387654d843 Add adafruit_feather_rp2040_adalogger 2024-05-31 18:40:00 -04:00
Scott Shawcroft
79ef1f73b3
Support BLE pairing and bonding on ESP 2024-05-31 15:05:48 -07:00
Scott Shawcroft
7a27366182
Merge pull request #9285 from dhalbert/nordic-gc-event-handlers
nordic/bluetooth/ble_drv.c: gc entire event handler list
2024-05-31 10:16:54 -07:00
Dan Halbert
c47f013b9f
Merge pull request #9287 from fetsnleds/another-missing-pin-esp32s3-devkitm
Add another missing pin for ESP32-S3-DevKitM-1
2024-05-31 09:50:16 -04:00
Thomas Raffler
3913251437 add missing GPIO33 to esp32s3_devkitm 2024-05-31 14:57:02 +02:00
Tobias Schmale
660822ab97 update esp-idf and enable riscv ulp 2024-05-31 08:38:05 +00:00
a5c4a86349 MP3Decoder: ssize_t type is not portable, don't use it 2024-05-30 16:45:35 -05:00
Dan Halbert
86f8210127 nordic/bluetooth/ble_drv.c: gc entire event handler list 2024-05-30 16:47:58 -04:00
2f3d371762 update expected result due to addition of audiomp3 module 2024-05-30 14:49:09 -05:00
dffc55ee17 MP3Decoder: STATIC -> static 2024-05-30 14:32:48 -05:00
9bc89f5fba MP3Decoder: better handle INDATA_UNDERFLOW & MAINDATA_UNDERFLOW
This allows playback of some 128k http streams from somafm, though
glitches occur with some regularity.

```py
import time

import adafruit_connection_manager
import adafruit_requests
import audiobusio
import audiomixer
import audiomp3
import board
import wifi

pool = adafruit_connection_manager.get_radio_socketpool(wifi.radio)
ssl_context = adafruit_connection_manager.get_radio_ssl_context(wifi.radio)
requests = adafruit_requests.Session(pool, ssl_context)

# todo: parse PLS files like https://somafm.com/nossl/dronezone.pls
# todo: figure out why https URLs don't work at all (missing select?)
# STREAMING_URL = "http://ice2.somafm.com/dronezone-128-mp3"
STREAMING_URL = "http://ice4.somafm.com/tikitime-128-mp3"


def get_mp3_stream():
    if STREAMING_URL.startswith("http:") or STREAMING_URL.startswith("https:"):
        return requests.get(STREAMING_URL, headers={"connection": "close"}).socket
    return open(STREAMING_URL, "rb")


mixer_buffer_size = 1152 * 16
mp3_buffer = bytearray(16384)

with audiobusio.I2SOut(
    bit_clock=board.D12, word_select=board.D13, data=board.D11
) as i2s, get_mp3_stream() as stream, audiomp3.MP3Decoder(
    stream, mp3_buffer
) as sample, audiomixer.Mixer(
    channel_count=2, sample_rate=44100, buffer_size=mixer_buffer_size
) as m:

    v = m.voice[0]
    print(sample)

    i2s.play(m)

    v.play(sample, loop=False)
    while v.playing:
        time.sleep(0.1)
```
2024-05-30 14:22:51 -05:00
974b21a079 MP3Decoder: do better at keeping stream buffer full 2024-05-30 14:22:51 -05:00
a80311d4c0 MP3Decoder: make testable in coverage build
An mp3 decoder (note that this needs `audiocore.get_buffer`, not
enabled on devices):
```py
import sys
import audiomp3
import audiocore

GET_BUFFER_DONE, GET_BUFFER_MORE_DATA, GET_BUFFER_ERROR = range(3)

with audiomp3.MP3Decoder(sys.argv[1]) as decoder, open(sys.argv[2], "wb") as target:

    while True:
        res, samples = audiocore.get_buffer(decoder)
        if res != GET_BUFFER_ERROR:
            target.write(samples)
        if res != GET_BUFFER_MORE_DATA:
            break
```

this doesn't actually add any tests though
2024-05-30 14:22:39 -05:00
d6ddd55462 MP3Decoder: Allow passing any stream-like object
This can sort-of play MP3s from a http request, but the buffering is
not good enough to play glitch-free. A new kind of buffer that can
read ahead further without blocking is needed.
2024-05-30 14:21:34 -05:00