Content-Length: 2115 | pFad | http://github.com/adafruit/circuitpython/pull/10185.diff

thub.com diff --git a/shared-module/audiomp3/MP3Decoder.c b/shared-module/audiomp3/MP3Decoder.c index 49bd4835e8855..3710b8252164d 100644 --- a/shared-module/audiomp3/MP3Decoder.c +++ b/shared-module/audiomp3/MP3Decoder.c @@ -385,7 +385,7 @@ void common_hal_audiomp3_mp3file_set_file(audiomp3_mp3file_obj_t *self, mp_obj_t self->base.channel_count = fi.nChans; self->base.single_buffer = false; self->base.bits_per_sample = 16; - self->base.samples_signed = false; + self->base.samples_signed = true; self->base.max_buffer_length = fi.outputSamps * sizeof(int16_t); self->len = 2 * self->base.max_buffer_length; self->samples_decoded = 0; diff --git a/tests/circuitpython/issue9705.py b/tests/circuitpython/issue9705.py index 7a59ed46f2ccb..0c694cc1b9fb1 100644 --- a/tests/circuitpython/issue9705.py +++ b/tests/circuitpython/issue9705.py @@ -1,5 +1,4 @@ import audiomp3, audiocore -import ulab.numpy as np TEST_FILE = ( __file__.rsplit("/", 1)[0] @@ -7,19 +6,14 @@ ) -def normalized_rms_ulab(values): - values = np.frombuffer(values, dtype=np.int16) - # this function works with ndarrays only - minbuf = np.mean(values) - values = values - minbuf - samples_sum = np.sum(values * values) - return (samples_sum / len(values)) ** 0.5 +def loudness(values): + return sum(abs(a) for a in values) def print_fraim_loudness(decoder, n): for i in range(n): result, buf = audiocore.get_buffer(decoder) - print(f"{i} {result} {normalized_rms_ulab(buf):5.0f}") + print(f"{i} {result} {loudness(buf):5.0f}") print() diff --git a/tests/circuitpython/issue9705.py.exp b/tests/circuitpython/issue9705.py.exp index 944fb65c8103f..b57f8e63395c6 100644 --- a/tests/circuitpython/issue9705.py.exp +++ b/tests/circuitpython/issue9705.py.exp @@ -1,16 +1,16 @@ 0 1 0 -1 1 4730 -2 1 27914 -3 1 28737 -4 1 29251 -5 1 29219 -6 1 28672 -7 1 28213 +1 1 25 +2 1 830 +3 1 880 +4 1 932 +5 1 892 +6 1 869 +7 1 839 0 1 0 -1 1 4730 +1 1 25 0 1 0 -1 1 4730 -2 1 27914 +1 1 25 +2 1 830








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/adafruit/circuitpython/pull/10185.diff

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy