From 0208aa96cc7891f43333ab69c8462c6a39590348 Mon Sep 17 00:00:00 2001 From: Tod Kurt Date: Fri, 27 Mar 2026 16:36:09 -0700 Subject: [PATCH 1/4] add new audiotools.SpeedChanger module for WAV/MP3 speed changing --- ports/raspberrypi/mpconfigport.mk | 1 + py/circuitpy_defns.mk | 5 + shared-bindings/audiotools/SpeedChanger.c | 138 +++++++++++++++++ shared-bindings/audiotools/SpeedChanger.h | 17 +++ shared-bindings/audiotools/__init__.c | 28 ++++ shared-bindings/audiotools/__init__.h | 7 + shared-module/audiotools/SpeedChanger.c | 175 ++++++++++++++++++++++ shared-module/audiotools/SpeedChanger.h | 35 +++++ shared-module/audiotools/__init__.c | 5 + shared-module/audiotools/__init__.h | 7 + 10 files changed, 418 insertions(+) create mode 100644 shared-bindings/audiotools/SpeedChanger.c create mode 100644 shared-bindings/audiotools/SpeedChanger.h create mode 100644 shared-bindings/audiotools/__init__.c create mode 100644 shared-bindings/audiotools/__init__.h create mode 100644 shared-module/audiotools/SpeedChanger.c create mode 100644 shared-module/audiotools/SpeedChanger.h create mode 100644 shared-module/audiotools/__init__.c create mode 100644 shared-module/audiotools/__init__.h diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index 8401c5d75453a..b8fc084322d5f 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -11,6 +11,7 @@ CIRCUITPY_FLOPPYIO ?= 1 CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_DISPLAYIO) CIRCUITPY_FULL_BUILD ?= 1 CIRCUITPY_AUDIOMP3 ?= 1 +CIRCUITPY_AUDIOTOOLS ?= 1 CIRCUITPY_BITOPS ?= 1 CIRCUITPY_HASHLIB ?= 1 CIRCUITPY_HASHLIB_MBEDTLS ?= 1 diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 886ba96f3e5fa..7e84d528c2613 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -146,6 +146,9 @@ endif ifeq ($(CIRCUITPY_AUDIOMP3),1) SRC_PATTERNS += audiomp3/% endif +ifeq ($(CIRCUITPY_AUDIOTOOLS),1) +SRC_PATTERNS += audiotools/% +endif ifeq ($(CIRCUITPY_AURORA_EPAPER),1) SRC_PATTERNS += aurora_epaper/% endif @@ -688,6 +691,8 @@ SRC_SHARED_MODULE_ALL = \ audiocore/RawSample.c \ audiocore/WaveFile.c \ audiocore/__init__.c \ + audiotools/SpeedChanger.c \ + audiotools/__init__.c \ audiodelays/Echo.c \ audiodelays/Chorus.c \ audiodelays/PitchShift.c \ diff --git a/shared-bindings/audiotools/SpeedChanger.c b/shared-bindings/audiotools/SpeedChanger.c new file mode 100644 index 0000000000000..ac46eb1dbc83e --- /dev/null +++ b/shared-bindings/audiotools/SpeedChanger.c @@ -0,0 +1,138 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#include + +#include "shared/runtime/context_manager_helpers.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/audiotools/SpeedChanger.h" +#include "shared-bindings/audiocore/__init__.h" +#include "shared-bindings/util.h" +#include "shared-module/audiotools/SpeedChanger.h" + +// Convert a Python float to 16.16 fixed-point rate +static uint32_t rate_to_fp(mp_obj_t rate_obj) { + mp_float_t rate = mp_arg_validate_obj_float_range(rate_obj, 0.001, 1000.0, MP_QSTR_rate); + return (uint32_t)(rate * (1 << 16)); +} + +// Convert 16.16 fixed-point rate to Python float +static mp_obj_t fp_to_rate(uint32_t rate_fp) { + return mp_obj_new_float((mp_float_t)rate_fp / (1 << 16)); +} + +//| class SpeedChanger: +//| """Wraps an audio sample to play it back at a different speed. +//| +//| Uses nearest-neighbor resampling with a fixed-point phase accumulator +//| for CPU-efficient variable-speed playback.""" +//| +//| def __init__(self, source: audiosample, rate: float = 1.0) -> None: +//| """Create a SpeedChanger that wraps ``source``. +//| +//| :param audiosample source: The audio source to resample. +//| :param float rate: Playback speed multiplier. 1.0 = normal, 2.0 = double speed, +//| 0.5 = half speed. Must be positive. +//| +//| Playing a wave file at 1.5x speed:: +//| +//| import board +//| import audiocore +//| import audiotools +//| import audioio +//| +//| wav = audiocore.WaveFile("drum.wav") +//| fast = audiotools.SpeedChanger(wav, rate=1.5) +//| audio = audioio.AudioOut(board.A0) +//| audio.play(fast) +//| +//| # Change speed during playback: +//| fast.rate = 2.0 # double speed +//| fast.rate = 0.5 # half speed +//| """ +//| ... +//| +static mp_obj_t audiotools_speedchanger_make_new(const mp_obj_type_t *type, + size_t n_args, size_t n_kw, const mp_obj_t *all_args) { + enum { ARG_source, ARG_rate }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_source, MP_ARG_REQUIRED | MP_ARG_OBJ }, + { MP_QSTR_rate, MP_ARG_OBJ, {.u_rom_obj = MP_ROM_NONE} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + // Validate source implements audiosample protocol + mp_obj_t source = args[ARG_source].u_obj; + audiosample_check(source); + + uint32_t rate_fp = 1 << 16; // default 1.0 + if (args[ARG_rate].u_obj != mp_const_none) { + rate_fp = rate_to_fp(args[ARG_rate].u_obj); + } + + audiotools_speedchanger_obj_t *self = mp_obj_malloc(audiotools_speedchanger_obj_t, &audiotools_speedchanger_type); + common_hal_audiotools_speedchanger_construct(self, source, rate_fp); + return MP_OBJ_FROM_PTR(self); +} + +//| def deinit(self) -> None: +//| """Deinitialises the SpeedChanger and releases all memory resources for reuse.""" +//| ... +//| +static mp_obj_t audiotools_speedchanger_deinit(mp_obj_t self_in) { + audiotools_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_audiotools_speedchanger_deinit(self); + return mp_const_none; +} +static MP_DEFINE_CONST_FUN_OBJ_1(audiotools_speedchanger_deinit_obj, audiotools_speedchanger_deinit); + +//| rate: float +//| """Playback speed multiplier. Can be changed during playback.""" +//| +static mp_obj_t audiotools_speedchanger_obj_get_rate(mp_obj_t self_in) { + audiotools_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); + audiosample_check_for_deinit(&self->base); + return fp_to_rate(common_hal_audiotools_speedchanger_get_rate(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(audiotools_speedchanger_get_rate_obj, audiotools_speedchanger_obj_get_rate); + +static mp_obj_t audiotools_speedchanger_obj_set_rate(mp_obj_t self_in, mp_obj_t rate_obj) { + audiotools_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); + audiosample_check_for_deinit(&self->base); + common_hal_audiotools_speedchanger_set_rate(self, rate_to_fp(rate_obj)); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_2(audiotools_speedchanger_set_rate_obj, audiotools_speedchanger_obj_set_rate); + +MP_PROPERTY_GETSET(audiotools_speedchanger_rate_obj, + (mp_obj_t)&audiotools_speedchanger_get_rate_obj, + (mp_obj_t)&audiotools_speedchanger_set_rate_obj); + +static const mp_rom_map_elem_t audiotools_speedchanger_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiotools_speedchanger_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR_rate), MP_ROM_PTR(&audiotools_speedchanger_rate_obj) }, + AUDIOSAMPLE_FIELDS, +}; +static MP_DEFINE_CONST_DICT(audiotools_speedchanger_locals_dict, audiotools_speedchanger_locals_dict_table); + +static const audiosample_p_t audiotools_speedchanger_proto = { + MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample) + .reset_buffer = (audiosample_reset_buffer_fun)audiotools_speedchanger_reset_buffer, + .get_buffer = (audiosample_get_buffer_fun)audiotools_speedchanger_get_buffer, +}; + +MP_DEFINE_CONST_OBJ_TYPE( + audiotools_speedchanger_type, + MP_QSTR_SpeedChanger, + MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, + make_new, audiotools_speedchanger_make_new, + locals_dict, &audiotools_speedchanger_locals_dict, + protocol, &audiotools_speedchanger_proto + ); diff --git a/shared-bindings/audiotools/SpeedChanger.h b/shared-bindings/audiotools/SpeedChanger.h new file mode 100644 index 0000000000000..d31ae6d6bdc9f --- /dev/null +++ b/shared-bindings/audiotools/SpeedChanger.h @@ -0,0 +1,17 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#pragma once + +#include "shared-module/audiotools/SpeedChanger.h" + +extern const mp_obj_type_t audiotools_speedchanger_type; + +void common_hal_audiotools_speedchanger_construct(audiotools_speedchanger_obj_t *self, + mp_obj_t source, uint32_t rate_fp); +void common_hal_audiotools_speedchanger_deinit(audiotools_speedchanger_obj_t *self); +void common_hal_audiotools_speedchanger_set_rate(audiotools_speedchanger_obj_t *self, uint32_t rate_fp); +uint32_t common_hal_audiotools_speedchanger_get_rate(audiotools_speedchanger_obj_t *self); diff --git a/shared-bindings/audiotools/__init__.c b/shared-bindings/audiotools/__init__.c new file mode 100644 index 0000000000000..3d610aa1dbf88 --- /dev/null +++ b/shared-bindings/audiotools/__init__.c @@ -0,0 +1,28 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#include + +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/audiotools/SpeedChanger.h" + +//| """Audio processing tools""" + +static const mp_rom_map_elem_t audiotools_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiotools) }, + { MP_ROM_QSTR(MP_QSTR_SpeedChanger), MP_ROM_PTR(&audiotools_speedchanger_type) }, +}; + +static MP_DEFINE_CONST_DICT(audiotools_module_globals, audiotools_module_globals_table); + +const mp_obj_module_t audiotools_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&audiotools_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_audiotools, audiotools_module); diff --git a/shared-bindings/audiotools/__init__.h b/shared-bindings/audiotools/__init__.h new file mode 100644 index 0000000000000..c4a52e5819d12 --- /dev/null +++ b/shared-bindings/audiotools/__init__.h @@ -0,0 +1,7 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#pragma once diff --git a/shared-module/audiotools/SpeedChanger.c b/shared-module/audiotools/SpeedChanger.c new file mode 100644 index 0000000000000..2bf03cf1aa919 --- /dev/null +++ b/shared-module/audiotools/SpeedChanger.c @@ -0,0 +1,175 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#include "shared-bindings/audiotools/SpeedChanger.h" + +#include +#include "py/runtime.h" +#include "py/gc.h" + +#include "shared-module/audiocore/WaveFile.h" +#include "shared-bindings/audiocore/__init__.h" + +#define OUTPUT_BUFFER_FRAMES 128 + +void common_hal_audiotools_speedchanger_construct(audiotools_speedchanger_obj_t *self, + mp_obj_t source, uint32_t rate_fp) { + audiosample_base_t *src_base = audiosample_check(source); + + self->source = source; + self->rate_fp = rate_fp; + self->phase = 0; + self->src_buffer = NULL; + self->src_buffer_length = 0; + self->src_sample_count = 0; + self->source_done = false; + self->source_exhausted = false; + + // Copy format from source + self->base.sample_rate = src_base->sample_rate; + self->base.channel_count = src_base->channel_count; + self->base.bits_per_sample = src_base->bits_per_sample; + self->base.samples_signed = src_base->samples_signed; + self->base.single_buffer = true; + + uint8_t bytes_per_frame = (src_base->bits_per_sample / 8) * src_base->channel_count; + self->output_buffer_length = OUTPUT_BUFFER_FRAMES * bytes_per_frame; + self->base.max_buffer_length = self->output_buffer_length; + + self->output_buffer = m_malloc_without_collect(self->output_buffer_length); + if (self->output_buffer == NULL) { + m_malloc_fail(self->output_buffer_length); + } +} + +void common_hal_audiotools_speedchanger_deinit(audiotools_speedchanger_obj_t *self) { + self->output_buffer = NULL; + self->source = MP_OBJ_NULL; + audiosample_mark_deinit(&self->base); +} + +void common_hal_audiotools_speedchanger_set_rate(audiotools_speedchanger_obj_t *self, uint32_t rate_fp) { + self->rate_fp = rate_fp; +} + +uint32_t common_hal_audiotools_speedchanger_get_rate(audiotools_speedchanger_obj_t *self) { + return self->rate_fp; +} + +// Fetch the next buffer from the source. Returns false if no data available. +static bool fetch_source_buffer(audiotools_speedchanger_obj_t *self) { + if (self->source_exhausted) { + return false; + } + uint8_t *buf = NULL; + uint32_t len = 0; + audioio_get_buffer_result_t result = audiosample_get_buffer(self->source, false, 0, &buf, &len); + if (result == GET_BUFFER_ERROR) { + self->source_exhausted = true; + return false; + } + if (len == 0) { + self->source_exhausted = true; + return false; + } + self->src_buffer = buf; + self->src_buffer_length = len; + uint8_t bytes_per_frame = (self->base.bits_per_sample / 8) * self->base.channel_count; + self->src_sample_count = len / bytes_per_frame; + self->source_done = (result == GET_BUFFER_DONE); + // Reset phase to index within this new buffer + self->phase = 0; + return true; +} + +void audiotools_speedchanger_reset_buffer(audiotools_speedchanger_obj_t *self, + bool single_channel_output, uint8_t channel) { + if (single_channel_output && channel == 1) { + return; + } + audiosample_reset_buffer(self->source, false, 0); + self->phase = 0; + self->src_buffer = NULL; + self->src_buffer_length = 0; + self->src_sample_count = 0; + self->source_done = false; + self->source_exhausted = false; +} + +audioio_get_buffer_result_t audiotools_speedchanger_get_buffer(audiotools_speedchanger_obj_t *self, + bool single_channel_output, uint8_t channel, + uint8_t **buffer, uint32_t *buffer_length) { + + // Ensure we have a source buffer + if (self->src_buffer == NULL) { + if (!fetch_source_buffer(self)) { + *buffer = NULL; + *buffer_length = 0; + return GET_BUFFER_DONE; + } + } + + uint8_t bytes_per_sample = self->base.bits_per_sample / 8; + uint8_t channels = self->base.channel_count; + uint8_t bytes_per_frame = bytes_per_sample * channels; + uint32_t out_frames = 0; + uint32_t max_out_frames = self->output_buffer_length / bytes_per_frame; + + if (bytes_per_sample == 1) { + // 8-bit samples + uint8_t *out = self->output_buffer; + while (out_frames < max_out_frames) { + uint32_t src_index = self->phase >> SPEED_SHIFT; + // Advance to next source buffer if needed + if (src_index >= self->src_sample_count) { + if (self->source_done) { + self->source_exhausted = true; + break; + } + if (!fetch_source_buffer(self)) { + break; + } + src_index = 0; // phase was reset by fetch + } + uint8_t *src = self->src_buffer + src_index * bytes_per_frame; + for (uint8_t c = 0; c < channels; c++) { + *out++ = src[c]; + } + out_frames++; + self->phase += self->rate_fp; + } + } else { + // 16-bit samples + int16_t *out = (int16_t *)self->output_buffer; + while (out_frames < max_out_frames) { + uint32_t src_index = self->phase >> SPEED_SHIFT; + if (src_index >= self->src_sample_count) { + if (self->source_done) { + self->source_exhausted = true; + break; + } + if (!fetch_source_buffer(self)) { + break; + } + src_index = 0; + } + int16_t *src = (int16_t *)(self->src_buffer + src_index * bytes_per_frame); + for (uint8_t c = 0; c < channels; c++) { + *out++ = src[c]; + } + out_frames++; + self->phase += self->rate_fp; + } + } + + *buffer = self->output_buffer; + *buffer_length = out_frames * bytes_per_frame; + + if (out_frames == 0) { + return GET_BUFFER_DONE; + } + return self->source_exhausted ? GET_BUFFER_DONE : GET_BUFFER_MORE_DATA; +} diff --git a/shared-module/audiotools/SpeedChanger.h b/shared-module/audiotools/SpeedChanger.h new file mode 100644 index 0000000000000..05cbec56fdea2 --- /dev/null +++ b/shared-module/audiotools/SpeedChanger.h @@ -0,0 +1,35 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#pragma once + +#include "py/obj.h" +#include "shared-module/audiocore/__init__.h" + +// Fixed-point 16.16 format +#define SPEED_SHIFT 16 + +typedef struct { + audiosample_base_t base; + mp_obj_t source; + uint8_t *output_buffer; + uint32_t output_buffer_length; // in bytes, allocated size + // Source buffer cache + uint8_t *src_buffer; + uint32_t src_buffer_length; // in bytes + uint32_t src_sample_count; // in frames + // Phase accumulator and rate in 16.16 fixed-point (units: source frames) + uint32_t phase; + uint32_t rate_fp; // 16.16 fixed-point rate + bool source_done; // source returned DONE on last get_buffer + bool source_exhausted; // source DONE and we consumed all of it +} audiotools_speedchanger_obj_t; + +void audiotools_speedchanger_reset_buffer(audiotools_speedchanger_obj_t *self, + bool single_channel_output, uint8_t channel); +audioio_get_buffer_result_t audiotools_speedchanger_get_buffer(audiotools_speedchanger_obj_t *self, + bool single_channel_output, uint8_t channel, + uint8_t **buffer, uint32_t *buffer_length); diff --git a/shared-module/audiotools/__init__.c b/shared-module/audiotools/__init__.c new file mode 100644 index 0000000000000..7c9b271a4b501 --- /dev/null +++ b/shared-module/audiotools/__init__.c @@ -0,0 +1,5 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT diff --git a/shared-module/audiotools/__init__.h b/shared-module/audiotools/__init__.h new file mode 100644 index 0000000000000..c4a52e5819d12 --- /dev/null +++ b/shared-module/audiotools/__init__.h @@ -0,0 +1,7 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#pragma once From 032c129d5188d9cd3eb90ee85a27ab68f73d012b Mon Sep 17 00:00:00 2001 From: Tod Kurt Date: Fri, 27 Mar 2026 16:40:56 -0700 Subject: [PATCH 2/4] update_board_info for zephyr --- .../adafruit/feather_nrf52840_zephyr/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml | 1 + .../zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml | 1 + .../zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml | 1 + .../boards/renesas/da14695_dk_usb/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml | 1 + .../zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml | 1 + .../zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml | 1 + ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml | 1 + .../zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml | 1 + 18 files changed, 18 insertions(+) diff --git a/ports/zephyr-cp/boards/adafruit/feather_nrf52840_zephyr/autogen_board_info.toml b/ports/zephyr-cp/boards/adafruit/feather_nrf52840_zephyr/autogen_board_info.toml index 2c717fc83c169..edfe80d53203f 100644 --- a/ports/zephyr-cp/boards/adafruit/feather_nrf52840_zephyr/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/adafruit/feather_nrf52840_zephyr/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml b/ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml index 1b82d3ba00e02..2074193d09bb3 100644 --- a/ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml b/ports/zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml index f995c03c2a26f..fcf372cfa6d3a 100644 --- a/ports/zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml b/ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml index 397d514a0dac5..a65c86ea27290 100644 --- a/ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml b/ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml index 69a657b8c98be..9a588fbd75a18 100644 --- a/ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml b/ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml index 378cbc07e9a2a..e3f3f4fe6d23d 100644 --- a/ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml b/ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml index 892b3dbbbd447..41dde878d074f 100644 --- a/ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml b/ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml index 718cd0bcfd353..80755cdf421e0 100644 --- a/ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml b/ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml index 10b0056c81dcc..a2d519ad6116b 100644 --- a/ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml b/ports/zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml index a3d6acdb79e71..d988846c0c319 100644 --- a/ports/zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/renesas/da14695_dk_usb/autogen_board_info.toml b/ports/zephyr-cp/boards/renesas/da14695_dk_usb/autogen_board_info.toml index 3d5fbb08c6543..5e5028e0ac2ee 100644 --- a/ports/zephyr-cp/boards/renesas/da14695_dk_usb/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/renesas/da14695_dk_usb/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml b/ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml index ec96d53072699..4a1186f39bd8e 100644 --- a/ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml b/ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml index 132899d424838..a22f8da260f84 100644 --- a/ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml b/ports/zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml index bc2a29aea088c..d2a53571d1098 100644 --- a/ports/zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml b/ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml index aacda400a305e..9a0c56a90238c 100644 --- a/ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml b/ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml index a8c03d5a4e8f5..99ad0b01f0a1f 100644 --- a/ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml b/ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml index b66682c59238b..77173e04378f6 100644 --- a/ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml b/ports/zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml index cadd8b5ade3a2..c80145f73b21b 100644 --- a/ports/zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml @@ -24,6 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false +audiotools = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio From 7038fe65bec80eeae15069578bc1e9cf58b247b0 Mon Sep 17 00:00:00 2001 From: Tod Kurt Date: Fri, 27 Mar 2026 17:16:11 -0700 Subject: [PATCH 3/4] fix doc build hopefully --- shared-bindings/audiotools/SpeedChanger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shared-bindings/audiotools/SpeedChanger.c b/shared-bindings/audiotools/SpeedChanger.c index ac46eb1dbc83e..ed7e8121d2dc9 100644 --- a/shared-bindings/audiotools/SpeedChanger.c +++ b/shared-bindings/audiotools/SpeedChanger.c @@ -31,7 +31,7 @@ static mp_obj_t fp_to_rate(uint32_t rate_fp) { //| Uses nearest-neighbor resampling with a fixed-point phase accumulator //| for CPU-efficient variable-speed playback.""" //| -//| def __init__(self, source: audiosample, rate: float = 1.0) -> None: +//| def __init__(self, source: circuitpython_typing.AudioSample, rate: float = 1.0) -> None: //| """Create a SpeedChanger that wraps ``source``. //| //| :param audiosample source: The audio source to resample. From 9ce0c5d6010feb3c869892065ffb65d1dee01095 Mon Sep 17 00:00:00 2001 From: Tod Kurt Date: Mon, 30 Mar 2026 16:48:19 -0700 Subject: [PATCH 4/4] rename audiotools to audiospeed --- ports/raspberrypi/mpconfigport.mk | 2 +- .../autogen_board_info.toml | 2 +- .../native/native_sim/autogen_board_info.toml | 2 +- .../nrf5340bsim/autogen_board_info.toml | 2 +- .../nordic/nrf5340dk/autogen_board_info.toml | 2 +- .../nordic/nrf54h20dk/autogen_board_info.toml | 2 +- .../nordic/nrf54l15dk/autogen_board_info.toml | 2 +- .../nordic/nrf7002dk/autogen_board_info.toml | 2 +- .../nxp/frdm_mcxn947/autogen_board_info.toml | 2 +- .../nxp/frdm_rw612/autogen_board_info.toml | 2 +- .../mimxrt1170_evk/autogen_board_info.toml | 2 +- .../da14695_dk_usb/autogen_board_info.toml | 2 +- .../renesas/ek_ra6m5/autogen_board_info.toml | 2 +- .../renesas/ek_ra8d1/autogen_board_info.toml | 2 +- .../nucleo_n657x0_q/autogen_board_info.toml | 2 +- .../nucleo_u575zi_q/autogen_board_info.toml | 2 +- .../st/stm32h750b_dk/autogen_board_info.toml | 2 +- .../st/stm32h7b3i_dk/autogen_board_info.toml | 2 +- .../stm32wba65i_dk1/autogen_board_info.toml | 2 +- py/circuitpy_defns.mk | 8 +-- .../{audiotools => audiospeed}/SpeedChanger.c | 66 +++++++++---------- shared-bindings/audiospeed/SpeedChanger.h | 17 +++++ shared-bindings/audiospeed/__init__.c | 28 ++++++++ .../{audiotools => audiospeed}/__init__.h | 0 shared-bindings/audiotools/SpeedChanger.h | 17 ----- shared-bindings/audiotools/__init__.c | 28 -------- .../{audiotools => audiospeed}/SpeedChanger.c | 16 ++--- .../{audiotools => audiospeed}/SpeedChanger.h | 6 +- .../{audiotools => audiospeed}/__init__.c | 0 .../{audiotools => audiospeed}/__init__.h | 0 30 files changed, 112 insertions(+), 112 deletions(-) rename shared-bindings/{audiotools => audiospeed}/SpeedChanger.c (62%) create mode 100644 shared-bindings/audiospeed/SpeedChanger.h create mode 100644 shared-bindings/audiospeed/__init__.c rename shared-bindings/{audiotools => audiospeed}/__init__.h (100%) delete mode 100644 shared-bindings/audiotools/SpeedChanger.h delete mode 100644 shared-bindings/audiotools/__init__.c rename shared-module/{audiotools => audiospeed}/SpeedChanger.c (90%) rename shared-module/{audiotools => audiospeed}/SpeedChanger.h (84%) rename shared-module/{audiotools => audiospeed}/__init__.c (100%) rename shared-module/{audiotools => audiospeed}/__init__.h (100%) diff --git a/ports/raspberrypi/mpconfigport.mk b/ports/raspberrypi/mpconfigport.mk index b8fc084322d5f..c670f5aa5dfc0 100644 --- a/ports/raspberrypi/mpconfigport.mk +++ b/ports/raspberrypi/mpconfigport.mk @@ -11,7 +11,7 @@ CIRCUITPY_FLOPPYIO ?= 1 CIRCUITPY_FRAMEBUFFERIO ?= $(CIRCUITPY_DISPLAYIO) CIRCUITPY_FULL_BUILD ?= 1 CIRCUITPY_AUDIOMP3 ?= 1 -CIRCUITPY_AUDIOTOOLS ?= 1 +CIRCUITPY_AUDIOSPEED ?= 1 CIRCUITPY_BITOPS ?= 1 CIRCUITPY_HASHLIB ?= 1 CIRCUITPY_HASHLIB_MBEDTLS ?= 1 diff --git a/ports/zephyr-cp/boards/adafruit/feather_nrf52840_zephyr/autogen_board_info.toml b/ports/zephyr-cp/boards/adafruit/feather_nrf52840_zephyr/autogen_board_info.toml index edfe80d53203f..df33d7a7eb2e5 100644 --- a/ports/zephyr-cp/boards/adafruit/feather_nrf52840_zephyr/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/adafruit/feather_nrf52840_zephyr/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml b/ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml index 2074193d09bb3..7b7295a90453c 100644 --- a/ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/native/native_sim/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml b/ports/zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml index fcf372cfa6d3a..75bfafe96d0ab 100644 --- a/ports/zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/native/nrf5340bsim/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml b/ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml index a65c86ea27290..a6d27f14eda39 100644 --- a/ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nordic/nrf5340dk/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml b/ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml index 9a588fbd75a18..ec76cd7c1abdb 100644 --- a/ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nordic/nrf54h20dk/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml b/ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml index e3f3f4fe6d23d..aca4d701cf785 100644 --- a/ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nordic/nrf54l15dk/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml b/ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml index 41dde878d074f..5366f53561262 100644 --- a/ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nordic/nrf7002dk/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml b/ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml index 80755cdf421e0..14aef6dfdf7cf 100644 --- a/ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nxp/frdm_mcxn947/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml b/ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml index a2d519ad6116b..a76ec250ec710 100644 --- a/ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nxp/frdm_rw612/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml b/ports/zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml index d988846c0c319..f8acb43678080 100644 --- a/ports/zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/nxp/mimxrt1170_evk/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/renesas/da14695_dk_usb/autogen_board_info.toml b/ports/zephyr-cp/boards/renesas/da14695_dk_usb/autogen_board_info.toml index 5e5028e0ac2ee..11a693117eccc 100644 --- a/ports/zephyr-cp/boards/renesas/da14695_dk_usb/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/renesas/da14695_dk_usb/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml b/ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml index 4a1186f39bd8e..00260356a8e9c 100644 --- a/ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/renesas/ek_ra6m5/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml b/ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml index a22f8da260f84..1742c507c3db8 100644 --- a/ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/renesas/ek_ra8d1/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml b/ports/zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml index d2a53571d1098..98ab65e270e59 100644 --- a/ports/zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/nucleo_n657x0_q/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml b/ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml index 9a0c56a90238c..a40eaac3b9d68 100644 --- a/ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/nucleo_u575zi_q/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml b/ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml index 99ad0b01f0a1f..596391b40ccf5 100644 --- a/ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/stm32h750b_dk/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml b/ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml index 77173e04378f6..adabe5cceecf9 100644 --- a/ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/stm32h7b3i_dk/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/ports/zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml b/ports/zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml index c80145f73b21b..07e9913a41a3a 100644 --- a/ports/zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml +++ b/ports/zephyr-cp/boards/st/stm32wba65i_dk1/autogen_board_info.toml @@ -24,7 +24,7 @@ audioio = false audiomixer = false audiomp3 = false audiopwmio = false -audiotools = false +audiospeed = false aurora_epaper = false bitbangio = false bitmapfilter = true # Zephyr board has busio diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 7e84d528c2613..f4245b01322bc 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -146,8 +146,8 @@ endif ifeq ($(CIRCUITPY_AUDIOMP3),1) SRC_PATTERNS += audiomp3/% endif -ifeq ($(CIRCUITPY_AUDIOTOOLS),1) -SRC_PATTERNS += audiotools/% +ifeq ($(CIRCUITPY_AUDIOSPEED),1) +SRC_PATTERNS += audiospeed/% endif ifeq ($(CIRCUITPY_AURORA_EPAPER),1) SRC_PATTERNS += aurora_epaper/% @@ -691,8 +691,8 @@ SRC_SHARED_MODULE_ALL = \ audiocore/RawSample.c \ audiocore/WaveFile.c \ audiocore/__init__.c \ - audiotools/SpeedChanger.c \ - audiotools/__init__.c \ + audiospeed/SpeedChanger.c \ + audiospeed/__init__.c \ audiodelays/Echo.c \ audiodelays/Chorus.c \ audiodelays/PitchShift.c \ diff --git a/shared-bindings/audiotools/SpeedChanger.c b/shared-bindings/audiospeed/SpeedChanger.c similarity index 62% rename from shared-bindings/audiotools/SpeedChanger.c rename to shared-bindings/audiospeed/SpeedChanger.c index ed7e8121d2dc9..34efa1516b035 100644 --- a/shared-bindings/audiotools/SpeedChanger.c +++ b/shared-bindings/audiospeed/SpeedChanger.c @@ -9,10 +9,10 @@ #include "shared/runtime/context_manager_helpers.h" #include "py/objproperty.h" #include "py/runtime.h" -#include "shared-bindings/audiotools/SpeedChanger.h" +#include "shared-bindings/audiospeed/SpeedChanger.h" #include "shared-bindings/audiocore/__init__.h" #include "shared-bindings/util.h" -#include "shared-module/audiotools/SpeedChanger.h" +#include "shared-module/audiospeed/SpeedChanger.h" // Convert a Python float to 16.16 fixed-point rate static uint32_t rate_to_fp(mp_obj_t rate_obj) { @@ -42,11 +42,11 @@ static mp_obj_t fp_to_rate(uint32_t rate_fp) { //| //| import board //| import audiocore -//| import audiotools +//| import audiospeed //| import audioio //| //| wav = audiocore.WaveFile("drum.wav") -//| fast = audiotools.SpeedChanger(wav, rate=1.5) +//| fast = audiospeed.SpeedChanger(wav, rate=1.5) //| audio = audioio.AudioOut(board.A0) //| audio.play(fast) //| @@ -56,7 +56,7 @@ static mp_obj_t fp_to_rate(uint32_t rate_fp) { //| """ //| ... //| -static mp_obj_t audiotools_speedchanger_make_new(const mp_obj_type_t *type, +static mp_obj_t audiospeed_speedchanger_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) { enum { ARG_source, ARG_rate }; static const mp_arg_t allowed_args[] = { @@ -75,8 +75,8 @@ static mp_obj_t audiotools_speedchanger_make_new(const mp_obj_type_t *type, rate_fp = rate_to_fp(args[ARG_rate].u_obj); } - audiotools_speedchanger_obj_t *self = mp_obj_malloc(audiotools_speedchanger_obj_t, &audiotools_speedchanger_type); - common_hal_audiotools_speedchanger_construct(self, source, rate_fp); + audiospeed_speedchanger_obj_t *self = mp_obj_malloc(audiospeed_speedchanger_obj_t, &audiospeed_speedchanger_type); + common_hal_audiospeed_speedchanger_construct(self, source, rate_fp); return MP_OBJ_FROM_PTR(self); } @@ -84,55 +84,55 @@ static mp_obj_t audiotools_speedchanger_make_new(const mp_obj_type_t *type, //| """Deinitialises the SpeedChanger and releases all memory resources for reuse.""" //| ... //| -static mp_obj_t audiotools_speedchanger_deinit(mp_obj_t self_in) { - audiotools_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_audiotools_speedchanger_deinit(self); +static mp_obj_t audiospeed_speedchanger_deinit(mp_obj_t self_in) { + audiospeed_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_audiospeed_speedchanger_deinit(self); return mp_const_none; } -static MP_DEFINE_CONST_FUN_OBJ_1(audiotools_speedchanger_deinit_obj, audiotools_speedchanger_deinit); +static MP_DEFINE_CONST_FUN_OBJ_1(audiospeed_speedchanger_deinit_obj, audiospeed_speedchanger_deinit); //| rate: float //| """Playback speed multiplier. Can be changed during playback.""" //| -static mp_obj_t audiotools_speedchanger_obj_get_rate(mp_obj_t self_in) { - audiotools_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); +static mp_obj_t audiospeed_speedchanger_obj_get_rate(mp_obj_t self_in) { + audiospeed_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); audiosample_check_for_deinit(&self->base); - return fp_to_rate(common_hal_audiotools_speedchanger_get_rate(self)); + return fp_to_rate(common_hal_audiospeed_speedchanger_get_rate(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(audiotools_speedchanger_get_rate_obj, audiotools_speedchanger_obj_get_rate); +MP_DEFINE_CONST_FUN_OBJ_1(audiospeed_speedchanger_get_rate_obj, audiospeed_speedchanger_obj_get_rate); -static mp_obj_t audiotools_speedchanger_obj_set_rate(mp_obj_t self_in, mp_obj_t rate_obj) { - audiotools_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); +static mp_obj_t audiospeed_speedchanger_obj_set_rate(mp_obj_t self_in, mp_obj_t rate_obj) { + audiospeed_speedchanger_obj_t *self = MP_OBJ_TO_PTR(self_in); audiosample_check_for_deinit(&self->base); - common_hal_audiotools_speedchanger_set_rate(self, rate_to_fp(rate_obj)); + common_hal_audiospeed_speedchanger_set_rate(self, rate_to_fp(rate_obj)); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_2(audiotools_speedchanger_set_rate_obj, audiotools_speedchanger_obj_set_rate); +MP_DEFINE_CONST_FUN_OBJ_2(audiospeed_speedchanger_set_rate_obj, audiospeed_speedchanger_obj_set_rate); -MP_PROPERTY_GETSET(audiotools_speedchanger_rate_obj, - (mp_obj_t)&audiotools_speedchanger_get_rate_obj, - (mp_obj_t)&audiotools_speedchanger_set_rate_obj); +MP_PROPERTY_GETSET(audiospeed_speedchanger_rate_obj, + (mp_obj_t)&audiospeed_speedchanger_get_rate_obj, + (mp_obj_t)&audiospeed_speedchanger_set_rate_obj); -static const mp_rom_map_elem_t audiotools_speedchanger_locals_dict_table[] = { - { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiotools_speedchanger_deinit_obj) }, +static const mp_rom_map_elem_t audiospeed_speedchanger_locals_dict_table[] = { + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiospeed_speedchanger_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) }, - { MP_ROM_QSTR(MP_QSTR_rate), MP_ROM_PTR(&audiotools_speedchanger_rate_obj) }, + { MP_ROM_QSTR(MP_QSTR_rate), MP_ROM_PTR(&audiospeed_speedchanger_rate_obj) }, AUDIOSAMPLE_FIELDS, }; -static MP_DEFINE_CONST_DICT(audiotools_speedchanger_locals_dict, audiotools_speedchanger_locals_dict_table); +static MP_DEFINE_CONST_DICT(audiospeed_speedchanger_locals_dict, audiospeed_speedchanger_locals_dict_table); -static const audiosample_p_t audiotools_speedchanger_proto = { +static const audiosample_p_t audiospeed_speedchanger_proto = { MP_PROTO_IMPLEMENT(MP_QSTR_protocol_audiosample) - .reset_buffer = (audiosample_reset_buffer_fun)audiotools_speedchanger_reset_buffer, - .get_buffer = (audiosample_get_buffer_fun)audiotools_speedchanger_get_buffer, + .reset_buffer = (audiosample_reset_buffer_fun)audiospeed_speedchanger_reset_buffer, + .get_buffer = (audiosample_get_buffer_fun)audiospeed_speedchanger_get_buffer, }; MP_DEFINE_CONST_OBJ_TYPE( - audiotools_speedchanger_type, + audiospeed_speedchanger_type, MP_QSTR_SpeedChanger, MP_TYPE_FLAG_HAS_SPECIAL_ACCESSORS, - make_new, audiotools_speedchanger_make_new, - locals_dict, &audiotools_speedchanger_locals_dict, - protocol, &audiotools_speedchanger_proto + make_new, audiospeed_speedchanger_make_new, + locals_dict, &audiospeed_speedchanger_locals_dict, + protocol, &audiospeed_speedchanger_proto ); diff --git a/shared-bindings/audiospeed/SpeedChanger.h b/shared-bindings/audiospeed/SpeedChanger.h new file mode 100644 index 0000000000000..64a126a7a61fb --- /dev/null +++ b/shared-bindings/audiospeed/SpeedChanger.h @@ -0,0 +1,17 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#pragma once + +#include "shared-module/audiospeed/SpeedChanger.h" + +extern const mp_obj_type_t audiospeed_speedchanger_type; + +void common_hal_audiospeed_speedchanger_construct(audiospeed_speedchanger_obj_t *self, + mp_obj_t source, uint32_t rate_fp); +void common_hal_audiospeed_speedchanger_deinit(audiospeed_speedchanger_obj_t *self); +void common_hal_audiospeed_speedchanger_set_rate(audiospeed_speedchanger_obj_t *self, uint32_t rate_fp); +uint32_t common_hal_audiospeed_speedchanger_get_rate(audiospeed_speedchanger_obj_t *self); diff --git a/shared-bindings/audiospeed/__init__.c b/shared-bindings/audiospeed/__init__.c new file mode 100644 index 0000000000000..b12e6db7e6bc7 --- /dev/null +++ b/shared-bindings/audiospeed/__init__.c @@ -0,0 +1,28 @@ +// This file is part of the CircuitPython project: https://circuitpython.org +// +// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt +// +// SPDX-License-Identifier: MIT + +#include + +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/audiospeed/SpeedChanger.h" + +//| """Audio processing tools""" + +static const mp_rom_map_elem_t audiospeed_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiospeed) }, + { MP_ROM_QSTR(MP_QSTR_SpeedChanger), MP_ROM_PTR(&audiospeed_speedchanger_type) }, +}; + +static MP_DEFINE_CONST_DICT(audiospeed_module_globals, audiospeed_module_globals_table); + +const mp_obj_module_t audiospeed_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t *)&audiospeed_module_globals, +}; + +MP_REGISTER_MODULE(MP_QSTR_audiospeed, audiospeed_module); diff --git a/shared-bindings/audiotools/__init__.h b/shared-bindings/audiospeed/__init__.h similarity index 100% rename from shared-bindings/audiotools/__init__.h rename to shared-bindings/audiospeed/__init__.h diff --git a/shared-bindings/audiotools/SpeedChanger.h b/shared-bindings/audiotools/SpeedChanger.h deleted file mode 100644 index d31ae6d6bdc9f..0000000000000 --- a/shared-bindings/audiotools/SpeedChanger.h +++ /dev/null @@ -1,17 +0,0 @@ -// This file is part of the CircuitPython project: https://circuitpython.org -// -// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt -// -// SPDX-License-Identifier: MIT - -#pragma once - -#include "shared-module/audiotools/SpeedChanger.h" - -extern const mp_obj_type_t audiotools_speedchanger_type; - -void common_hal_audiotools_speedchanger_construct(audiotools_speedchanger_obj_t *self, - mp_obj_t source, uint32_t rate_fp); -void common_hal_audiotools_speedchanger_deinit(audiotools_speedchanger_obj_t *self); -void common_hal_audiotools_speedchanger_set_rate(audiotools_speedchanger_obj_t *self, uint32_t rate_fp); -uint32_t common_hal_audiotools_speedchanger_get_rate(audiotools_speedchanger_obj_t *self); diff --git a/shared-bindings/audiotools/__init__.c b/shared-bindings/audiotools/__init__.c deleted file mode 100644 index 3d610aa1dbf88..0000000000000 --- a/shared-bindings/audiotools/__init__.c +++ /dev/null @@ -1,28 +0,0 @@ -// This file is part of the CircuitPython project: https://circuitpython.org -// -// SPDX-FileCopyrightText: Copyright (c) 2026 Tod Kurt -// -// SPDX-License-Identifier: MIT - -#include - -#include "py/obj.h" -#include "py/runtime.h" - -#include "shared-bindings/audiotools/SpeedChanger.h" - -//| """Audio processing tools""" - -static const mp_rom_map_elem_t audiotools_module_globals_table[] = { - { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiotools) }, - { MP_ROM_QSTR(MP_QSTR_SpeedChanger), MP_ROM_PTR(&audiotools_speedchanger_type) }, -}; - -static MP_DEFINE_CONST_DICT(audiotools_module_globals, audiotools_module_globals_table); - -const mp_obj_module_t audiotools_module = { - .base = { &mp_type_module }, - .globals = (mp_obj_dict_t *)&audiotools_module_globals, -}; - -MP_REGISTER_MODULE(MP_QSTR_audiotools, audiotools_module); diff --git a/shared-module/audiotools/SpeedChanger.c b/shared-module/audiospeed/SpeedChanger.c similarity index 90% rename from shared-module/audiotools/SpeedChanger.c rename to shared-module/audiospeed/SpeedChanger.c index 2bf03cf1aa919..e76bed1f17c39 100644 --- a/shared-module/audiotools/SpeedChanger.c +++ b/shared-module/audiospeed/SpeedChanger.c @@ -4,7 +4,7 @@ // // SPDX-License-Identifier: MIT -#include "shared-bindings/audiotools/SpeedChanger.h" +#include "shared-bindings/audiospeed/SpeedChanger.h" #include #include "py/runtime.h" @@ -15,7 +15,7 @@ #define OUTPUT_BUFFER_FRAMES 128 -void common_hal_audiotools_speedchanger_construct(audiotools_speedchanger_obj_t *self, +void common_hal_audiospeed_speedchanger_construct(audiospeed_speedchanger_obj_t *self, mp_obj_t source, uint32_t rate_fp) { audiosample_base_t *src_base = audiosample_check(source); @@ -45,22 +45,22 @@ void common_hal_audiotools_speedchanger_construct(audiotools_speedchanger_obj_t } } -void common_hal_audiotools_speedchanger_deinit(audiotools_speedchanger_obj_t *self) { +void common_hal_audiospeed_speedchanger_deinit(audiospeed_speedchanger_obj_t *self) { self->output_buffer = NULL; self->source = MP_OBJ_NULL; audiosample_mark_deinit(&self->base); } -void common_hal_audiotools_speedchanger_set_rate(audiotools_speedchanger_obj_t *self, uint32_t rate_fp) { +void common_hal_audiospeed_speedchanger_set_rate(audiospeed_speedchanger_obj_t *self, uint32_t rate_fp) { self->rate_fp = rate_fp; } -uint32_t common_hal_audiotools_speedchanger_get_rate(audiotools_speedchanger_obj_t *self) { +uint32_t common_hal_audiospeed_speedchanger_get_rate(audiospeed_speedchanger_obj_t *self) { return self->rate_fp; } // Fetch the next buffer from the source. Returns false if no data available. -static bool fetch_source_buffer(audiotools_speedchanger_obj_t *self) { +static bool fetch_source_buffer(audiospeed_speedchanger_obj_t *self) { if (self->source_exhausted) { return false; } @@ -85,7 +85,7 @@ static bool fetch_source_buffer(audiotools_speedchanger_obj_t *self) { return true; } -void audiotools_speedchanger_reset_buffer(audiotools_speedchanger_obj_t *self, +void audiospeed_speedchanger_reset_buffer(audiospeed_speedchanger_obj_t *self, bool single_channel_output, uint8_t channel) { if (single_channel_output && channel == 1) { return; @@ -99,7 +99,7 @@ void audiotools_speedchanger_reset_buffer(audiotools_speedchanger_obj_t *self, self->source_exhausted = false; } -audioio_get_buffer_result_t audiotools_speedchanger_get_buffer(audiotools_speedchanger_obj_t *self, +audioio_get_buffer_result_t audiospeed_speedchanger_get_buffer(audiospeed_speedchanger_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length) { diff --git a/shared-module/audiotools/SpeedChanger.h b/shared-module/audiospeed/SpeedChanger.h similarity index 84% rename from shared-module/audiotools/SpeedChanger.h rename to shared-module/audiospeed/SpeedChanger.h index 05cbec56fdea2..e920c72caf461 100644 --- a/shared-module/audiotools/SpeedChanger.h +++ b/shared-module/audiospeed/SpeedChanger.h @@ -26,10 +26,10 @@ typedef struct { uint32_t rate_fp; // 16.16 fixed-point rate bool source_done; // source returned DONE on last get_buffer bool source_exhausted; // source DONE and we consumed all of it -} audiotools_speedchanger_obj_t; +} audiospeed_speedchanger_obj_t; -void audiotools_speedchanger_reset_buffer(audiotools_speedchanger_obj_t *self, +void audiospeed_speedchanger_reset_buffer(audiospeed_speedchanger_obj_t *self, bool single_channel_output, uint8_t channel); -audioio_get_buffer_result_t audiotools_speedchanger_get_buffer(audiotools_speedchanger_obj_t *self, +audioio_get_buffer_result_t audiospeed_speedchanger_get_buffer(audiospeed_speedchanger_obj_t *self, bool single_channel_output, uint8_t channel, uint8_t **buffer, uint32_t *buffer_length); diff --git a/shared-module/audiotools/__init__.c b/shared-module/audiospeed/__init__.c similarity index 100% rename from shared-module/audiotools/__init__.c rename to shared-module/audiospeed/__init__.c diff --git a/shared-module/audiotools/__init__.h b/shared-module/audiospeed/__init__.h similarity index 100% rename from shared-module/audiotools/__init__.h rename to shared-module/audiospeed/__init__.h