microbit-foundation / micropython-microbit-v2

Temporary home for MicroPython for micro:bit v2 as we stablise it before pushing upstream
MIT License
41 stars 22 forks source link

`AudioFrame` internal `used_size` marker accessors #196

Open microbit-carlos opened 2 months ago

microbit-carlos commented 2 months ago

AudioFrame has an internal marker to indicate how much data has been recorded into it already.

This marker is moved via:

We still need to document this in the docs, and having a document hidden feature without a way to access it is not ideal.

We were waiting for cases when having these accessors was beneficial, mostly following the general philosophy of "it's easier to add something later than it is to remove it or modify it".

Cases where we would have found these accessors useful:

In the case we'd like to implement this, we have a couple options:

  1. seek(offset, whence) and tell() from the Python file object
  2. set_position() and get_position()
    • Or similar to this, but with a different word than "position"

Option 1) is more standard, but option 2) might be simpler to understand, and matches similar accessors already used in the micro:bit API. So, my vote would be for option 2).

microbit-carlos commented 2 months ago

While being able to provide accessors to the current implementation of AudioFrame will be beneficial, this new proposal would replace this suggestion: