Skip to content
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

memoryview of an AudioFrame returns signed 8-bit values #187

Closed
microbit-carlos opened this issue Apr 9, 2024 · 2 comments
Closed

memoryview of an AudioFrame returns signed 8-bit values #187

microbit-carlos opened this issue Apr 9, 2024 · 2 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@microbit-carlos
Copy link
Contributor

microbit-carlos commented Apr 9, 2024

Tested with v2.1.2 and the latest version (at the time of writing) of the recording & playback branch: 0b06914

>>> a = audio.AudioFrame()
>>> m = memoryview(a)
>>> a[0], m[0]
(128, -128)
>>> a[0] = 255
>>> a[0], m[0]
(255, -1)
>>> 

Compared with a bytes or bytearray object, where memory view values are 8-bit unsigned:

>>> b = bytes([128, 255])
>>> ba = bytearray([128, 255])
>>> m1 = memoryview(b)
>>> m2 = memoryview(ba)
>>> (b[1], m1[1]), (ba[1], m2[1])
((255, 255), (255, 255))
>>> 

Does AudioFrame change the values from unsigned to signed as a CODAL requirement?

@microbit-carlos
Copy link
Contributor Author

@dpgeorge based on our conversation this is a bug that should be fixable without any (or minimal) effect on the current AudioFrame implementation.

@dpgeorge
Copy link
Collaborator

Now fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants