From 54cde56ec5374f9b6c1aa9eb9dd6139b80df254a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 25 Jul 2019 17:55:57 -0500 Subject: [PATCH 01/13] audiopwmio: Add the shared files for this new module --- py/circuitpy_defns.mk | 6 + py/circuitpy_mpconfig.h | 8 + py/circuitpy_mpconfig.mk | 9 + shared-bindings/audiopwmio/AudioOut.c | 294 ++++++++++++++++++++++++++ shared-bindings/audiopwmio/AudioOut.h | 49 +++++ shared-bindings/audiopwmio/__init__.c | 71 +++++++ shared-bindings/audiopwmio/__init__.h | 34 +++ shared-module/audiopwmio/__init__.c | 0 shared-module/audiopwmio/__init__.h | 32 +++ 9 files changed, 503 insertions(+) create mode 100644 shared-bindings/audiopwmio/AudioOut.c create mode 100644 shared-bindings/audiopwmio/AudioOut.h create mode 100644 shared-bindings/audiopwmio/__init__.c create mode 100644 shared-bindings/audiopwmio/__init__.h create mode 100644 shared-module/audiopwmio/__init__.c create mode 100644 shared-module/audiopwmio/__init__.h diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index bdefc18cc0..28d560a735 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -108,6 +108,9 @@ endif ifeq ($(CIRCUITPY_AUDIOIO),1) SRC_PATTERNS += audioio/% endif +ifeq ($(CIRCUITPY_AUDIOPWMIO),1) +SRC_PATTERNS += audiopwmio/% +endif ifeq ($(CIRCUITPY_AUDIOCORE),1) SRC_PATTERNS += audiocore/% endif @@ -223,6 +226,8 @@ $(filter $(SRC_PATTERNS), \ audiobusio/__init__.c \ audiobusio/I2SOut.c \ audiobusio/PDMIn.c \ + audiopwmio/__init__.c \ + audiopwmio/AudioOut.c \ audioio/__init__.c \ audioio/AudioOut.c \ bleio/__init__.c \ @@ -303,6 +308,7 @@ $(filter $(SRC_PATTERNS), \ _stage/Layer.c \ _stage/Text.c \ _stage/__init__.c \ + audiopwmio/__init__.c \ audioio/__init__.c \ audiocore/__init__.c \ audiocore/Mixer.c \ diff --git a/py/circuitpy_mpconfig.h b/py/circuitpy_mpconfig.h index 3440eb052a..d88d6538e0 100644 --- a/py/circuitpy_mpconfig.h +++ b/py/circuitpy_mpconfig.h @@ -244,6 +244,13 @@ extern const struct _mp_obj_module_t audioio_module; #define AUDIOIO_MODULE #endif +#if CIRCUITPY_AUDIOPWMIO +#define AUDIOPWMIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_audiopwmio), (mp_obj_t)&audiopwmio_module }, +extern const struct _mp_obj_module_t audiopwmio_module; +#else +#define AUDIOPWMIO_MODULE +#endif + #if CIRCUITPY_BITBANGIO #define BITBANGIO_MODULE { MP_OBJ_NEW_QSTR(MP_QSTR_bitbangio), (mp_obj_t)&bitbangio_module }, extern const struct _mp_obj_module_t bitbangio_module; @@ -573,6 +580,7 @@ extern const struct _mp_obj_module_t ustack_module; AUDIOBUSIO_MODULE \ AUDIOCORE_MODULE \ AUDIOIO_MODULE \ + AUDIOPWMIO_MODULE \ BITBANGIO_MODULE \ BLEIO_MODULE \ BOARD_MODULE \ diff --git a/py/circuitpy_mpconfig.mk b/py/circuitpy_mpconfig.mk index 772a1c3e1f..a408cd7acc 100644 --- a/py/circuitpy_mpconfig.mk +++ b/py/circuitpy_mpconfig.mk @@ -74,9 +74,18 @@ CIRCUITPY_AUDIOIO = $(CIRCUITPY_FULL_BUILD) endif CFLAGS += -DCIRCUITPY_AUDIOIO=$(CIRCUITPY_AUDIOIO) +ifndef CIRCUITPY_AUDIOPWMIO +CIRCUITPY_AUDIOPWMIO = 0 +endif +CFLAGS += -DCIRCUITPY_AUDIOPWMIO=$(CIRCUITPY_AUDIOPWMIO) + ifndef CIRCUITPY_AUDIOCORE +ifeq ($(CIRCUITPY_AUDIOPWMIO),1) +CIRCUITPY_AUDIOCORE = $(CIRCUITPY_AUDIOPWMIO) +else CIRCUITPY_AUDIOCORE = $(CIRCUITPY_AUDIOIO) endif +endif CFLAGS += -DCIRCUITPY_AUDIOCORE=$(CIRCUITPY_AUDIOCORE) ifndef CIRCUITPY_BITBANGIO diff --git a/shared-bindings/audiopwmio/AudioOut.c b/shared-bindings/audiopwmio/AudioOut.c new file mode 100644 index 0000000000..37c845165b --- /dev/null +++ b/shared-bindings/audiopwmio/AudioOut.c @@ -0,0 +1,294 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "lib/utils/context_manager_helpers.h" +#include "py/binary.h" +#include "py/objproperty.h" +#include "py/runtime.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/audiopwmio/AudioOut.h" +#include "shared-bindings/audiocore/RawSample.h" +#include "shared-bindings/util.h" +#include "supervisor/shared/translate.h" + +//| .. currentmodule:: audiopwmio +//| +//| :class:`AudioOut` -- Output an analog audio signal +//| ======================================================== +//| +//| AudioOut can be used to output an analog audio signal on a given pin. +//| +//| .. class:: AudioOut(left_channel, *, right_channel=None, quiescent_value=0x8000) +//| +//| Create a AudioOut object associated with the given pin(s). This allows you to +//| play audio signals out on the given pin(s). In contrast to mod:`audioio`, +//| the pin(s) specified are digital pins, and are driven with a device-dependent PWM +//| signal. +//| +//| :param ~microcontroller.Pin left_channel: The pin to output the left channel to +//| :param ~microcontroller.Pin right_channel: The pin to output the right channel to +//| :param int quiescent_value: The output value when no signal is present. Samples should start +//| and end with this value to prevent audible popping. +//| +//| Simple 8ksps 440 Hz sin wave:: +//| +//| import audiocore +//| import audiopwmio +//| import board +//| import array +//| import time +//| import math +//| +//| # Generate one period of sine wav. +//| length = 8000 // 440 +//| sine_wave = array.array("H", [0] * length) +//| for i in range(length): +//| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) +//| +//| dac = audiopwmio.AudioOut(board.SPEAKER) +//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) +//| dac.play(sine_wave, loop=True) +//| time.sleep(1) +//| dac.stop() +//| +//| Playing a wave file from flash:: +//| +//| import board +//| import audiocore +//| import audiopwmio +//| import digitalio +//| +//| # Required for CircuitPlayground Express +//| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) +//| speaker_enable.switch_to_output(value=True) +//| +//| data = open("cplay-5.1-16bit-16khz.wav", "rb") +//| wav = audiocore.WaveFile(data) +//| a = audiopwmio.AudioOut(board.SPEAKER) +//| +//| print("playing") +//| a.play(wav) +//| while a.playing: +//| pass +//| print("stopped") +//| +STATIC mp_obj_t audiopwmio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_left_channel, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_right_channel, MP_ARG_OBJ | MP_ARG_KW_ONLY, {.u_rom_obj = mp_const_none} }, + { MP_QSTR_quiescent_value, MP_ARG_INT | MP_ARG_KW_ONLY, {.u_int = 0x8000} }, + }; + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_obj_t left_channel_obj = args[ARG_left_channel].u_obj; + assert_pin(left_channel_obj, false); + const mcu_pin_obj_t *left_channel_pin = MP_OBJ_TO_PTR(left_channel_obj); + + mp_obj_t right_channel_obj = args[ARG_right_channel].u_obj; + const mcu_pin_obj_t *right_channel_pin = NULL; + if (right_channel_obj != mp_const_none) { + assert_pin(right_channel_obj, false); + right_channel_pin = MP_OBJ_TO_PTR(right_channel_obj); + } + + // create AudioOut object from the given pin + audiopwmio_audioout_obj_t *self = m_new_obj(audiopwmio_audioout_obj_t); + self->base.type = &audiopwmio_audioout_type; + common_hal_audiopwmio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int); + + return MP_OBJ_FROM_PTR(self); +} + +//| .. method:: deinit() +//| +//| Deinitialises the AudioOut and releases any hardware resources for reuse. +//| +STATIC mp_obj_t audiopwmio_audioout_deinit(mp_obj_t self_in) { + audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_audiopwmio_audioout_deinit(self); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_deinit_obj, audiopwmio_audioout_deinit); + +STATIC void check_for_deinit(audiopwmio_audioout_obj_t *self) { + if (common_hal_audiopwmio_audioout_deinited(self)) { + raise_deinited_error(); + } +} +//| .. method:: __enter__() +//| +//| No-op used by Context Managers. +//| +// Provided by context manager helper. + +//| .. method:: __exit__() +//| +//| Automatically deinitializes the hardware when exiting a context. See +//| :ref:`lifetime-and-contextmanagers` for more info. +//| +STATIC mp_obj_t audiopwmio_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) { + (void)n_args; + common_hal_audiopwmio_audioout_deinit(args[0]); + return mp_const_none; +} +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_audioout___exit___obj, 4, 4, audiopwmio_audioout_obj___exit__); + + +//| .. method:: play(sample, *, loop=False) +//| +//| Plays the sample once when loop=False and continuously when loop=True. +//| Does not block. Use `playing` to block. +//| +//| Sample must be an `audiopwmio.WaveFile` or `audiopwmio.RawSample`. +//| +//| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output +//| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit +//| DAC that ignores the lowest 6 bits when playing 16 bit samples. +//| +STATIC mp_obj_t audiopwmio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { + enum { ARG_sample, ARG_loop }; + static const mp_arg_t allowed_args[] = { + { MP_QSTR_sample, MP_ARG_OBJ | MP_ARG_REQUIRED }, + { MP_QSTR_loop, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, + }; + audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + check_for_deinit(self); + mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; + mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); + + mp_obj_t sample = args[ARG_sample].u_obj; + common_hal_audiopwmio_audioout_play(self, sample, args[ARG_loop].u_bool); + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_KW(audiopwmio_audioout_play_obj, 1, audiopwmio_audioout_obj_play); + +//| .. method:: stop() +//| +//| Stops playback and resets to the start of the sample. +//| +STATIC mp_obj_t audiopwmio_audioout_obj_stop(mp_obj_t self_in) { + audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + common_hal_audiopwmio_audioout_stop(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_stop_obj, audiopwmio_audioout_obj_stop); + +//| .. attribute:: playing +//| +//| True when an audio sample is being output even if `paused`. (read-only) +//| +STATIC mp_obj_t audiopwmio_audioout_obj_get_playing(mp_obj_t self_in) { + audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return mp_obj_new_bool(common_hal_audiopwmio_audioout_get_playing(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_get_playing_obj, audiopwmio_audioout_obj_get_playing); + +const mp_obj_property_t audiopwmio_audioout_playing_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&audiopwmio_audioout_get_playing_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +//| .. method:: pause() +//| +//| Stops playback temporarily while remembering the position. Use `resume` to resume playback. +//| +STATIC mp_obj_t audiopwmio_audioout_obj_pause(mp_obj_t self_in) { + audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + + if (!common_hal_audiopwmio_audioout_get_playing(self)) { + mp_raise_RuntimeError(translate("Not playing")); + } + common_hal_audiopwmio_audioout_pause(self); + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_pause_obj, audiopwmio_audioout_obj_pause); + +//| .. method:: resume() +//| +//| Resumes sample playback after :py:func:`pause`. +//| +STATIC mp_obj_t audiopwmio_audioout_obj_resume(mp_obj_t self_in) { + audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + + if (common_hal_audiopwmio_audioout_get_paused(self)) { + common_hal_audiopwmio_audioout_resume(self); + } + + return mp_const_none; +} +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_resume_obj, audiopwmio_audioout_obj_resume); + +//| .. attribute:: paused +//| +//| True when playback is paused. (read-only) +//| +STATIC mp_obj_t audiopwmio_audioout_obj_get_paused(mp_obj_t self_in) { + audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); + check_for_deinit(self); + return mp_obj_new_bool(common_hal_audiopwmio_audioout_get_paused(self)); +} +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_get_paused_obj, audiopwmio_audioout_obj_get_paused); + +const mp_obj_property_t audiopwmio_audioout_paused_obj = { + .base.type = &mp_type_property, + .proxy = {(mp_obj_t)&audiopwmio_audioout_get_paused_obj, + (mp_obj_t)&mp_const_none_obj, + (mp_obj_t)&mp_const_none_obj}, +}; + +STATIC const mp_rom_map_elem_t audiopwmio_audioout_locals_dict_table[] = { + // Methods + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiopwmio_audioout_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiopwmio_audioout___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiopwmio_audioout_play_obj) }, + { MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiopwmio_audioout_stop_obj) }, + { MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&audiopwmio_audioout_pause_obj) }, + { MP_ROM_QSTR(MP_QSTR_resume), MP_ROM_PTR(&audiopwmio_audioout_resume_obj) }, + + // Properties + { MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiopwmio_audioout_playing_obj) }, + { MP_ROM_QSTR(MP_QSTR_paused), MP_ROM_PTR(&audiopwmio_audioout_paused_obj) }, +}; +STATIC MP_DEFINE_CONST_DICT(audiopwmio_audioout_locals_dict, audiopwmio_audioout_locals_dict_table); + +const mp_obj_type_t audiopwmio_audioout_type = { + { &mp_type_type }, + .name = MP_QSTR_PWMAudioOut, + .make_new = audiopwmio_audioout_make_new, + .locals_dict = (mp_obj_dict_t*)&audiopwmio_audioout_locals_dict, +}; diff --git a/shared-bindings/audiopwmio/AudioOut.h b/shared-bindings/audiopwmio/AudioOut.h new file mode 100644 index 0000000000..7fb0e0f331 --- /dev/null +++ b/shared-bindings/audiopwmio/AudioOut.h @@ -0,0 +1,49 @@ +/* + * This file is part of the Micro Python project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H +#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H + +#include "common-hal/audiopwmio/AudioOut.h" +#include "common-hal/microcontroller/Pin.h" +#include "shared-bindings/audiocore/RawSample.h" + +extern const mp_obj_type_t audiopwmio_audioout_type; + +// left_channel will always be non-NULL but right_channel may be for mono output. +void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self, + const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t default_value); + +void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self); +bool common_hal_audiopwmio_audioout_deinited(audiopwmio_audioout_obj_t* self); +void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj_t sample, bool loop); +void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self); +bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self); +void common_hal_audiopwmio_audioout_pause(audiopwmio_audioout_obj_t* self); +void common_hal_audiopwmio_audioout_resume(audiopwmio_audioout_obj_t* self); +bool common_hal_audiopwmio_audioout_get_paused(audiopwmio_audioout_obj_t* self); + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H diff --git a/shared-bindings/audiopwmio/__init__.c b/shared-bindings/audiopwmio/__init__.c new file mode 100644 index 0000000000..6253d1e8e7 --- /dev/null +++ b/shared-bindings/audiopwmio/__init__.c @@ -0,0 +1,71 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include + +#include "py/obj.h" +#include "py/runtime.h" + +#include "shared-bindings/microcontroller/Pin.h" +#include "shared-bindings/audiopwmio/__init__.h" +#include "shared-bindings/audiopwmio/AudioOut.h" + +//| :mod:`audiopwmio` --- Support for audio input and output +//| ======================================================== +//| +//| .. module:: audiopwmio +//| :synopsis: Support for audio output via digital PWM +//| :platform: NRF52 +//| +//| The `audiopwmio` module contains classes to provide access to audio IO. +//| +//| Libraries +//| +//| .. toctree:: +//| :maxdepth: 3 +//| +//| AudioOut +//| +//| All classes change hardware state and should be deinitialized when they +//| are no longer needed if the program continues after use. To do so, either +//| call :py:meth:`!deinit` or use a context manager. See +//| :ref:`lifetime-and-contextmanagers` for more info. +//| +//| Since CircuitPython 5, `Mixer`, `RawSample` and `WaveFile` are moved +//| to :mod:`audiocore`. +//| + +STATIC const mp_rom_map_elem_t audiopwmio_module_globals_table[] = { + { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiopwmio) }, + { MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audiopwmio_audioout_type) }, +}; + +STATIC MP_DEFINE_CONST_DICT(audiopwmio_module_globals, audiopwmio_module_globals_table); + +const mp_obj_module_t audiopwmio_module = { + .base = { &mp_type_module }, + .globals = (mp_obj_dict_t*)&audiopwmio_module_globals, +}; diff --git a/shared-bindings/audiopwmio/__init__.h b/shared-bindings/audiopwmio/__init__.h new file mode 100644 index 0000000000..e4b7067d11 --- /dev/null +++ b/shared-bindings/audiopwmio/__init__.h @@ -0,0 +1,34 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO___INIT___H +#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO___INIT___H + +#include "py/obj.h" + +// Nothing now. + +#endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOIO___INIT___H diff --git a/shared-module/audiopwmio/__init__.c b/shared-module/audiopwmio/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/shared-module/audiopwmio/__init__.h b/shared-module/audiopwmio/__init__.h new file mode 100644 index 0000000000..964e4aafe2 --- /dev/null +++ b/shared-module/audiopwmio/__init__.h @@ -0,0 +1,32 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2018 Dan Halbert for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_SHARED_MODULE_AUDIOPWMIO__INIT__H +#define MICROPY_INCLUDED_SHARED_MODULE_AUDIOPWMIO__INIT__H + +#include "shared-module/audiocore/__init__.h" + +#endif // MICROPY_INCLUDED_SHARED_MODULE_AUDIOPWMIO__INIT__H From 7b9d26cefe02d1a357b2594339db474b7c5cd88e Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 15 Jul 2019 19:56:21 -0500 Subject: [PATCH 02/13] WavFile.h: include vfs_fat.h for pyb_file_obj_t definition Without such a definition, this header is not self-contained, but requires whoever included it to also include vfs_fat.h --- shared-module/audiocore/WaveFile.h | 1 + 1 file changed, 1 insertion(+) diff --git a/shared-module/audiocore/WaveFile.h b/shared-module/audiocore/WaveFile.h index 97dd6a46f2..3eecbf15ce 100644 --- a/shared-module/audiocore/WaveFile.h +++ b/shared-module/audiocore/WaveFile.h @@ -27,6 +27,7 @@ #ifndef MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_WAVEFILE_H #define MICROPY_INCLUDED_SHARED_MODULE_AUDIOIO_WAVEFILE_H +#include "extmod/vfs_fat.h" #include "py/obj.h" #include "shared-module/audiocore/__init__.h" From 2bc704fe072f83772d0fe35803b4a462ee5a331a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 15 Jul 2019 19:56:21 -0500 Subject: [PATCH 03/13] ports/nrf: factor out routines for allocating, freeing pwm channels --- ports/nrf/common-hal/pulseio/PWMOut.c | 119 +++++++++++++++----------- ports/nrf/common-hal/pulseio/PWMOut.h | 3 + 2 files changed, 70 insertions(+), 52 deletions(-) diff --git a/ports/nrf/common-hal/pulseio/PWMOut.c b/ports/nrf/common-hal/pulseio/PWMOut.c index 5233c9adc6..b827470d3d 100644 --- a/ports/nrf/common-hal/pulseio/PWMOut.c +++ b/ports/nrf/common-hal/pulseio/PWMOut.c @@ -57,6 +57,12 @@ STATIC uint16_t pwm_seq[MP_ARRAY_SIZE(pwms)][CHANNELS_PER_PWM]; static uint8_t never_reset_pwm[MP_ARRAY_SIZE(pwms)]; +STATIC int pwm_idx(NRF_PWM_Type *pwm) { + for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) + if(pwms[i] == pwm) return i; + return -1; +} + void common_hal_pulseio_pwmout_never_reset(pulseio_pwmout_obj_t *self) { for(size_t i=0; i < MP_ARRAY_SIZE(pwms); i++) { NRF_PWM_Type* pwm = pwms[i]; @@ -133,6 +139,57 @@ bool convert_frequency(uint32_t frequency, uint16_t *countertop, nrf_pwm_clk_t * return false; } +NRF_PWM_Type *pwmout_allocate(uint16_t countertop, nrf_pwm_clk_t base_clock, + bool variable_frequency, int8_t *channel_out, bool *pwm_already_in_use_out) { + for (size_t pwm_index = 0; pwm_index < MP_ARRAY_SIZE(pwms); pwm_index++) { + NRF_PWM_Type *pwm = pwms[pwm_index]; + bool pwm_already_in_use = pwm->ENABLE & SPIM_ENABLE_ENABLE_Msk; + if (pwm_already_in_use) { + if (variable_frequency) { + // Variable frequency requires exclusive use of a PWM, so try the next one. + continue; + } + + // PWM is in use, but see if it's set to the same frequency we need. If so, + // look for a free channel. + if (pwm->COUNTERTOP == countertop && pwm->PRESCALER == base_clock) { + for (size_t chan = 0; chan < CHANNELS_PER_PWM; chan++) { + if (pwm->PSEL.OUT[chan] == 0xFFFFFFFF) { + // Channel is free. + if(channel_out) + *channel_out = chan; + if(pwm_already_in_use_out) + *pwm_already_in_use_out = pwm_already_in_use; + return pwm; + } + } + } + } else { + // PWM not yet in use, so we can start to use it. Use channel 0. + if(channel_out) + *channel_out = 0; + if(pwm_already_in_use_out) + *pwm_already_in_use_out = pwm_already_in_use; + return pwm; + } + } + return NULL; +} + +void pwmout_free_channel(NRF_PWM_Type *pwm, int8_t channel) { + // Disconnect pin from channel. + pwm->PSEL.OUT[channel] = 0xFFFFFFFF; + + for(int i=0; i < CHANNELS_PER_PWM; i++) { + if (pwm->PSEL.OUT[i] != 0xFFFFFFFF) { + // Some channel is still being used, so don't disable. + return; + } + } + + nrf_pwm_disable(pwm); +} + pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, const mcu_pin_obj_t* pin, uint16_t duty, @@ -148,48 +205,16 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, return PWMOUT_INVALID_FREQUENCY; } - self->pwm = NULL; - self->channel = CHANNELS_PER_PWM; // out-of-range value. + int8_t channel; bool pwm_already_in_use; - NRF_PWM_Type* pwm; - size_t pwm_index = 0; - for (; pwm_index < MP_ARRAY_SIZE(pwms); pwm_index++) { - pwm = pwms[pwm_index]; - pwm_already_in_use = pwm->ENABLE & SPIM_ENABLE_ENABLE_Msk; - if (pwm_already_in_use) { - if (variable_frequency) { - // Variable frequency requires exclusive use of a PWM, so try the next one. - continue; - } - - // PWM is in use, but see if it's set to the same frequency we need. If so, - // look for a free channel. - if (pwm->COUNTERTOP == countertop && pwm->PRESCALER == base_clock) { - for (size_t chan = 0; chan < CHANNELS_PER_PWM; chan++) { - if (pwm->PSEL.OUT[chan] == 0xFFFFFFFF) { - // Channel is free. - self->pwm = pwm; - self->channel = chan; - break; - } - } - // Did we find a channel? If not, loop and check the next pwm. - if (self->pwm != NULL) { - break; - } - } - } else { - // PWM not yet in use, so we can start to use it. Use channel 0. - self->pwm = pwm; - self->channel = 0; - break; - } - } + self->pwm = pwmout_allocate(countertop, base_clock, variable_frequency, + &channel, &pwm_already_in_use); if (self->pwm == NULL) { return PWMOUT_ALL_TIMERS_IN_USE; } + self->channel = channel; self->pin_number = pin->number; claim_pin(pin); @@ -200,17 +225,17 @@ pwmout_result_t common_hal_pulseio_pwmout_construct(pulseio_pwmout_obj_t* self, nrf_gpio_cfg_output(self->pin_number); // disable before mapping pin channel - nrf_pwm_disable(pwm); + nrf_pwm_disable(self->pwm); if (!pwm_already_in_use) { - reset_single_pwmout(pwm_index); - nrf_pwm_configure(pwm, base_clock, NRF_PWM_MODE_UP, countertop); + reset_single_pwmout(pwm_idx(self->pwm)); + nrf_pwm_configure(self->pwm, base_clock, NRF_PWM_MODE_UP, countertop); } // Connect channel to pin, without disturbing other channels. - pwm->PSEL.OUT[self->channel] = pin->number; + self->pwm->PSEL.OUT[self->channel] = pin->number; - nrf_pwm_enable(pwm); + nrf_pwm_enable(self->pwm); common_hal_pulseio_pwmout_set_duty_cycle(self, duty); return PWMOUT_OK; @@ -230,17 +255,7 @@ void common_hal_pulseio_pwmout_deinit(pulseio_pwmout_obj_t* self) { NRF_PWM_Type* pwm = self->pwm; self->pwm = NULL; - // Disconnect pin from channel. - pwm->PSEL.OUT[self->channel] = 0xFFFFFFFF; - - for(int i=0; i < CHANNELS_PER_PWM; i++) { - if (self->pwm->PSEL.OUT[i] != 0xFFFFFFFF) { - // Some channel is still being used, so don't disable. - return; - } - } - - nrf_pwm_disable(pwm); + pwmout_free_channel(pwm, self->channel); } void common_hal_pulseio_pwmout_set_duty_cycle(pulseio_pwmout_obj_t* self, uint16_t duty_cycle) { diff --git a/ports/nrf/common-hal/pulseio/PWMOut.h b/ports/nrf/common-hal/pulseio/PWMOut.h index a4e58dc1a5..b6798cb685 100644 --- a/ports/nrf/common-hal/pulseio/PWMOut.h +++ b/ports/nrf/common-hal/pulseio/PWMOut.h @@ -41,5 +41,8 @@ typedef struct { } pulseio_pwmout_obj_t; void pwmout_reset(void); +NRF_PWM_Type *pwmout_allocate(uint16_t countertop, nrf_pwm_clk_t base_clock, + bool variable_frequency, int8_t *channel_out, bool *pwm_already_in_use_out); +void pwmout_free_channel(NRF_PWM_Type *pwm, int8_t channel); #endif // MICROPY_INCLUDED_NRF_COMMON_HAL_PULSEIO_PWMOUT_H From a183425e001e3a7e61ae3bfa7cb5f8cee5922974 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 15 Jul 2019 19:56:21 -0500 Subject: [PATCH 04/13] ports/nrf: Implement audioio.AudioOut using PWM This implements AudioOut, with known caveats: * pause/resume are not yet implemented (this is just a bug) * at best, the sample fidelity is 8 bits (this is a hardware limitation) Testing performed: My test system is a Particle Xenon with a PAM8302 op-amp https://www.adafruit.com/product/2130 and 8-ohm speaker. There's no analog filtering between the Xenon's PWM pin and the "A+" input of the amplifier; the "A-" pin is disconnected. It is powered from VUSB. I used pin D4, which is *NOT* listed as a low-speed-only pin, but the code does NOT switch the pin to high drive. This is related to an open issue for general inability to set drive level for pins being used by a "special function" on nrf: https://github.com/adafruit/circuitpython/issues/1270 Nothing about the code I've written should limit the usable pins. All samples I played were 16-bit, generally monophonic at 11025Hz and 22050Hz from the Debian LibreOffice package. --- ports/nrf/background.c | 7 + ports/nrf/common-hal/audiopwmio/AudioOut.c | 318 +++++++++++++++++++++ ports/nrf/common-hal/audiopwmio/AudioOut.h | 59 ++++ ports/nrf/common-hal/audiopwmio/__init__.c | 0 ports/nrf/mpconfigport.mk | 4 +- ports/nrf/supervisor/port.c | 8 + 6 files changed, 395 insertions(+), 1 deletion(-) create mode 100644 ports/nrf/common-hal/audiopwmio/AudioOut.c create mode 100644 ports/nrf/common-hal/audiopwmio/AudioOut.h create mode 100644 ports/nrf/common-hal/audiopwmio/__init__.c diff --git a/ports/nrf/background.c b/ports/nrf/background.c index 9c4f3ab27e..91ec66b36a 100644 --- a/ports/nrf/background.c +++ b/ports/nrf/background.c @@ -33,6 +33,10 @@ #include "shared-module/displayio/__init__.h" #endif +#if CIRCUITPY_AUDIOPWMIO +#include "common-hal/audiopwmio/AudioOut.h" +#endif + static bool running_background_tasks = false; void background_tasks_reset(void) { @@ -47,6 +51,9 @@ void run_background_tasks(void) { running_background_tasks = true; filesystem_background(); usb_background(); +#if CIRCUITPY_AUDIOPWMIO + audiopwmout_background(); +#endif #if CIRCUITPY_DISPLAYIO displayio_refresh_displays(); diff --git a/ports/nrf/common-hal/audiopwmio/AudioOut.c b/ports/nrf/common-hal/audiopwmio/AudioOut.c new file mode 100644 index 0000000000..a3c56c76b0 --- /dev/null +++ b/ports/nrf/common-hal/audiopwmio/AudioOut.c @@ -0,0 +1,318 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#include +#include + +#include "extmod/vfs_fat.h" +#include "py/gc.h" +#include "py/mperrno.h" +#include "py/runtime.h" +#include "common-hal/audiopwmio/AudioOut.h" +#include "common-hal/pulseio/PWMOut.h" +#include "shared-bindings/audiopwmio/AudioOut.h" +#include "shared-bindings/microcontroller/__init__.h" +#include "shared-bindings/microcontroller/Pin.h" +#include "supervisor/shared/translate.h" + +// TODO: This should be the same size as PWMOut.c:pwms[], but there's no trivial way to accomplish that +STATIC audiopwmio_audioout_obj_t* active_audio[4]; + +#define F_TARGET (62500) +#define F_PWM (16000000) +// return the REFRESH value, store the TOP value in an out-parameter +// Tested for key values (worst relative error = 0.224% = 3.84 cents) +// 8000: top = 250 refresh = 7 [ 8000.0] +// 22050: top = 242 refresh = 2 [22038.5] +// 24000: top = 222 refresh = 2 [24024.0] +// 44100: top = 181 refresh = 1 [44198.8] +// 48000: top = 167 refresh = 1 [47904.1] +STATIC uint32_t calculate_pwm_parameters(uint32_t sample_rate, uint32_t *top_out) { + // the desired frequency is the closest integer multiple of sample_rate not less than F_TARGET + uint32_t desired_frequency = (F_TARGET + sample_rate - 1) / sample_rate * sample_rate; + // The top value is the PWM frequency divided by the desired frequency (round to nearest) + uint32_t top = (F_PWM + desired_frequency/2) / desired_frequency; + // The actual frequency is the PWM frequency divided by the top value (round to nearest) + uint32_t actual_frequency = (F_PWM + top/2) / top; + // The multiplier is the actual frequency divided by the sample rate (round to nearest) + uint32_t multiplier = (actual_frequency + sample_rate/2) / sample_rate; + *top_out = top; + return multiplier - 1; +} + +STATIC void activate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) { + for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) { + if(!active_audio[i]) { + active_audio[i] = self; + break; + } + } +} +STATIC void deactivate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) { + for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) { + if(active_audio[i] == self) + active_audio[i] = NULL; + } +} + +void audiopwmout_reset() { + for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) + active_audio[i] = NULL; +} + +STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) { + self->pwm->EVENTS_SEQSTARTED[1-buf] = 0; + uint16_t *dev_buffer = self->buffers[buf]; + uint8_t *buffer; + uint32_t buffer_length; + audioio_get_buffer_result_t get_buffer_result = + audiosample_get_buffer(self->sample, false, 0, + &buffer, &buffer_length); + if (get_buffer_result == GET_BUFFER_ERROR) { + common_hal_audiopwmio_audioout_stop(self); + return; + } + uint32_t num_samples = buffer_length / self->bytes_per_sample / self->spacing; + + if(self->bytes_per_sample == 1) { + uint8_t offset = self->signed_to_unsigned ? 0x80 : 0; + uint16_t scale = self->scale; + for(uint32_t i=0; ispacing; i++) { + uint8_t rawval = (*buffer++ + offset); + uint16_t val = (uint16_t)(((uint32_t)rawval * (uint32_t)scale) >> 8); + *dev_buffer++ = val; + if(self->spacing == 1) + *dev_buffer++ = val; + } + } else { + uint16_t offset = self->signed_to_unsigned ? 0x8000 : 0; + uint16_t scale = self->scale; + uint16_t *buffer16 = (uint16_t*)buffer; + for(uint32_t i=0; ispacing; i++) { + uint16_t rawval = (*buffer16++ + offset); + uint16_t val = (uint16_t)((rawval * (uint32_t)scale) >> 16); + *dev_buffer++ = val; + if(self->spacing == 1) + *dev_buffer++ = val; + } + } + self->pwm->SEQ[buf].PTR = (intptr_t)self->buffers[buf]; + self->pwm->SEQ[buf].CNT = num_samples*2; + + if (self->loop && get_buffer_result == GET_BUFFER_DONE) { + audiosample_reset_buffer(self->sample, false, 0); + } else if(get_buffer_result == GET_BUFFER_DONE) { + self->pwm->LOOP = 0; + self->stopping = true; + } else { + self->pwm->LOOP = 0xffff; + } +} + +STATIC void audiopwmout_background_obj(audiopwmio_audioout_obj_t *self) { + if(!common_hal_audiopwmio_audioout_get_playing(self)) + return; + if(self->loop && self->single_buffer) { + self->pwm->LOOP = 0xffff; + } else if(self->stopping) { + bool stopped = + (self->pwm->EVENTS_SEQEND[0] || !self->pwm->EVENTS_SEQSTARTED[0]) && + (self->pwm->EVENTS_SEQEND[1] || !self->pwm->EVENTS_SEQSTARTED[1]); + if(stopped) + self->pwm->TASKS_STOP = 1; + } else if(!self->single_buffer) { + if(self->pwm->EVENTS_SEQSTARTED[0]) fill_buffers(self, 1); + if(self->pwm->EVENTS_SEQSTARTED[1]) fill_buffers(self, 0); + } +} + +void audiopwmout_background() { + for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) { + if(!active_audio[i]) continue; + audiopwmout_background_obj(active_audio[i]); + } +} + +void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self, + const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t quiescent_value) { + assert_pin_free(left_channel); + assert_pin_free(right_channel); + self->pwm = pwmout_allocate(256, PWM_PRESCALER_PRESCALER_DIV_1, true, NULL, NULL); + if(!self->pwm) { + mp_raise_RuntimeError(translate("All timers in use")); + } + + self->pwm->PRESCALER = PWM_PRESCALER_PRESCALER_DIV_1; + // two uint16_t values per sample when Grouped + // n.b. SEQ[#].CNT "counts" are 2 per sample (left and right channels) + self->pwm->DECODER = PWM_DECODER_LOAD_Grouped; + + // we use channels 0 and 2 because these are GROUPED; it lets us save half + // the space for sample data (no additional optimization is possible for + // single channel) + self->pwm->PSEL.OUT[0] = self->left_channel_number = left_channel->number; + claim_pin(left_channel); + + if(right_channel) + { + self->pwm->PSEL.OUT[2] = self->right_channel_number = right_channel->number; + claim_pin(right_channel); + } + + self->quiescent_value = quiescent_value >> 8; + + self->pwm->ENABLE = 1; + // TODO: Ramp from 0 to quiescent value +} + +bool common_hal_audiopwmio_audioout_deinited(audiopwmio_audioout_obj_t* self) { + return !self->pwm; +} + +void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self) { + if (common_hal_audiopwmio_audioout_deinited(self)) { + return; + } + // TODO: ramp the pwm down from quiescent value to 0 + self->pwm->ENABLE = 0; + + if(self->left_channel_number) + reset_pin_number(self->left_channel_number); + if(self->right_channel_number) + reset_pin_number(self->right_channel_number); + + pwmout_free_channel(self->pwm, 0); + pwmout_free_channel(self->pwm, 2); + + self->pwm = NULL; + + m_free(self->buffers[0]); + self->buffers[0] = NULL; + + m_free(self->buffers[1]); + self->buffers[1] = NULL; +} + +void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj_t sample, bool loop) { + if (common_hal_audiopwmio_audioout_get_playing(self)) { + common_hal_audiopwmio_audioout_stop(self); + } + self->sample = sample; + self->loop = loop; + + uint32_t sample_rate = audiosample_sample_rate(sample); + uint32_t max_sample_rate = 62500; + if (sample_rate > max_sample_rate) { + mp_raise_ValueError_varg(translate("Sample rate too high. It must be less than %d"), max_sample_rate); + } + self->bytes_per_sample = audiosample_bits_per_sample(sample) / 8; + + uint32_t max_buffer_length; + audiosample_get_buffer_structure(sample, /* single channel */ false, + &self->single_buffer, &self->signed_to_unsigned, &max_buffer_length, + &self->spacing); + if(max_buffer_length > UINT16_MAX) { + mp_raise_ValueError_varg(translate("Buffer length %d too big. It must be less than %d"), max_buffer_length, UINT16_MAX); + } + self->buffer_length = (uint16_t)max_buffer_length; + self->buffers[0] = m_malloc(self->buffer_length * 2 * sizeof(uint16_t), false); + if(!self->single_buffer) + self->buffers[1] = m_malloc(self->buffer_length * 2 * sizeof(uint16_t), false); + + + uint32_t top; + self->pwm->SEQ[0].REFRESH = self->pwm->SEQ[1].REFRESH = calculate_pwm_parameters(sample_rate, &top); + self->scale = top-1; + self->pwm->COUNTERTOP = top; + + if(!self->single_buffer) + self->pwm->LOOP = 1; + else if(self->loop) + self->pwm->LOOP = 0xffff; + else + self->pwm->LOOP = 0; + audiosample_reset_buffer(self->sample, false, 0); + activate_audiopwmout_obj(self); + fill_buffers(self, 0); + self->pwm->SEQ[1].PTR = self->pwm->SEQ[0].PTR; + self->pwm->SEQ[1].CNT = self->pwm->SEQ[0].CNT; + self->pwm->EVENTS_SEQSTARTED[0] = 0; + self->pwm->EVENTS_SEQSTARTED[1] = 0; + self->pwm->TASKS_SEQSTART[0] = 1; + self->pwm->EVENTS_STOPPED = 0; + self->playing = true; + self->stopping = false; + self->paused = false; +} + +void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self) { + deactivate_audiopwmout_obj(self); + self->pwm->TASKS_STOP = 1; + self->stopping = false; + self->paused = false; + + m_free(self->buffers[0]); + self->buffers[0] = NULL; + + m_free(self->buffers[1]); + self->buffers[1] = NULL; +} + +bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self) { + if(self->pwm->EVENTS_STOPPED) { + self->playing = false; + self->pwm->EVENTS_STOPPED = 0; + } + return self->playing; +} + +/* pause/resume present difficulties for the NRF PWM audio module. + * + * A PWM sequence can be stopped in its tracks by sending a TASKS_STOP event, + * but there's no way to pick up the sequence where it was stopped; you could + * start at the start of one of the two sequences, but especially for "single buffer" + * sample, this seems undesirable. + * + * Or, you can stop at the end of a sequence so that you don't duplicate anything + * when restarting, but again this is unsatisfactory for a "single buffer" sample. + * + * For now, I've taken the coward's way and left these methods unimplemented. + * Perhaps the way forward is to divide even "single buffer" samples into tasks of + * only a few ms long, so that they can be stopped/restarted quickly enough that it + * feels instant. (This also saves on memory, for long in-memory "single buffer" + * samples!) + */ +void common_hal_audiopwmio_audioout_pause(audiopwmio_audioout_obj_t* self) { + self->paused = true; +} + +void common_hal_audiopwmio_audioout_resume(audiopwmio_audioout_obj_t* self) { + self->paused = false; +} + +bool common_hal_audiopwmio_audioout_get_paused(audiopwmio_audioout_obj_t* self) { + return self->paused; +} diff --git a/ports/nrf/common-hal/audiopwmio/AudioOut.h b/ports/nrf/common-hal/audiopwmio/AudioOut.h new file mode 100644 index 0000000000..9d2b823ad3 --- /dev/null +++ b/ports/nrf/common-hal/audiopwmio/AudioOut.h @@ -0,0 +1,59 @@ +/* + * This file is part of the MicroPython project, http://micropython.org/ + * + * The MIT License (MIT) + * + * Copyright (c) 2019 Jeff Epler for Adafruit Industries + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + +#ifndef MICROPY_INCLUDED_NRF_COMMON_HAL_AUDIOPWM_AUDIOOUT_H +#define MICROPY_INCLUDED_NRF_COMMON_HAL_AUDIOPWM_AUDIOOUT_H + +#include "common-hal/microcontroller/Pin.h" + +typedef struct { + mp_obj_base_t base; + mp_obj_t *sample; + NRF_PWM_Type *pwm; + uint16_t *buffers[2]; + + uint16_t buffer_length; + uint16_t quiescent_value; + uint16_t scale; + + uint8_t left_channel_number; + uint8_t right_channel_number; + uint8_t spacing; + uint8_t bytes_per_sample; + + bool playing; + bool stopping; + bool paused; + bool loop; + bool signed_to_unsigned; + bool single_buffer; +} audiopwmio_audioout_obj_t; + +void audiopwmout_reset(void); + +void audiopwmout_background(void); + +#endif diff --git a/ports/nrf/common-hal/audiopwmio/__init__.c b/ports/nrf/common-hal/audiopwmio/__init__.c new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ports/nrf/mpconfigport.mk b/ports/nrf/mpconfigport.mk index 83166708a6..57879bbaae 100644 --- a/ports/nrf/mpconfigport.mk +++ b/ports/nrf/mpconfigport.mk @@ -10,8 +10,10 @@ USB_SERIAL_NUMBER_LENGTH = 16 # All nRF ports have longints. LONGINT_IMPL = MPZ -# No DAC, so no regular audio. +# Audio via PWM +CIRCUITPY_AUDIOCORE = 1 CIRCUITPY_AUDIOIO = 0 +CIRCUITPY_AUDIOPWMIO = 1 # No I2S yet. CIRCUITPY_AUDIOBUSIO = 0 diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index 8fbf75498f..c98d5ab288 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -50,6 +50,10 @@ #include "shared-bindings/rtc/__init__.h" +#ifdef CIRCUITPY_AUDIOPWMIO +#include "common-hal/audiopwmio/AudioOut.h" +#endif + static void power_warning_handler(void) { reset_into_safe_mode(BROWNOUT); } @@ -94,6 +98,10 @@ void reset_port(void) { spi_reset(); uart_reset(); +#ifdef CIRCUITPY_AUDIOPWMIO + audiopwmout_reset(); +#endif + #if CIRCUITPY_PULSEIO pwmout_reset(); pulseout_reset(); From 324d31225c4fb46ae9f9c65c34710138851551b8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 25 Jul 2019 21:13:50 -0500 Subject: [PATCH 05/13] make translate --- locale/ID.po | 49 ++++++++++++++++++++++++---------------- locale/circuitpython.pot | 49 ++++++++++++++++++++++++---------------- locale/de_DE.po | 49 ++++++++++++++++++++++++---------------- locale/en_US.po | 49 ++++++++++++++++++++++++---------------- locale/en_x_pirate.po | 49 ++++++++++++++++++++++++---------------- locale/es.po | 49 ++++++++++++++++++++++++---------------- locale/fil.po | 49 ++++++++++++++++++++++++---------------- locale/fr.po | 49 ++++++++++++++++++++++++---------------- locale/it_IT.po | 49 ++++++++++++++++++++++++---------------- locale/pl.po | 49 ++++++++++++++++++++++++---------------- locale/pt_BR.po | 49 ++++++++++++++++++++++++---------------- locale/zh_Latn_pinyin.po | 49 ++++++++++++++++++++++++---------------- 12 files changed, 348 insertions(+), 240 deletions(-) diff --git a/locale/ID.po b/locale/ID.po index b211d53794..6c87b39c1f 100644 --- a/locale/ID.po +++ b/locale/ID.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -255,6 +255,7 @@ msgstr "Semua timer untuk pin ini sedang digunakan" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -329,6 +330,11 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "" +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -472,11 +478,11 @@ msgstr "" msgid "Could not initialize UART" msgstr "Tidak dapat menginisialisasi UART" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "" @@ -493,7 +499,7 @@ msgstr "DAC sudah digunakan" msgid "Data 0 pin must be byte aligned" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -768,7 +774,7 @@ msgstr "Ukuran buffer tidak valid" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "" @@ -776,11 +782,11 @@ msgstr "" msgid "Invalid direction." msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" @@ -822,11 +828,11 @@ msgstr "" msgid "Invalid run mode." msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "" @@ -947,6 +953,7 @@ msgid "Not connected" msgstr "Tidak dapat menyambungkan ke AP" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "" @@ -1071,11 +1078,12 @@ msgstr "" msgid "SDA or SCL needs a pull up" msgstr "SDA atau SCL membutuhkan pull up" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Nilai sampel terlalu tinggi. Nilai harus kurang dari %d" @@ -1143,19 +1151,19 @@ msgid "" "exit safe mode.\n" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "" @@ -1261,7 +1269,7 @@ msgstr "Baudrate tidak didukung" msgid "Unsupported display bus type" msgstr "Baudrate tidak didukung" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "" @@ -1277,7 +1285,7 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "" @@ -1404,7 +1412,7 @@ msgstr "" msgid "bits must be 8" msgstr "bits harus memilki nilai 8" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "" @@ -1417,7 +1425,7 @@ msgstr "" msgid "buf is too small. need %d bytes" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -1780,7 +1788,8 @@ msgstr "argumen keyword ekstra telah diberikan" msgid "extra positional arguments given" msgstr "argumen posisi ekstra telah diberikan" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -2325,7 +2334,7 @@ msgstr "" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/circuitpython.pot b/locale/circuitpython.pot index d91e2b3aca..df227ea2d9 100644 --- a/locale/circuitpython.pot +++ b/locale/circuitpython.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:13-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -253,6 +253,7 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -325,6 +326,11 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "" +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -462,11 +468,11 @@ msgstr "" msgid "Could not initialize UART" msgstr "" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "" @@ -483,7 +489,7 @@ msgstr "" msgid "Data 0 pin must be byte aligned" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -753,7 +759,7 @@ msgstr "" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "" @@ -761,11 +767,11 @@ msgstr "" msgid "Invalid direction." msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" @@ -807,11 +813,11 @@ msgstr "" msgid "Invalid run mode." msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "" @@ -931,6 +937,7 @@ msgid "Not connected" msgstr "" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "" @@ -1051,11 +1058,12 @@ msgstr "" msgid "SDA or SCL needs a pull up" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -1120,19 +1128,19 @@ msgid "" "exit safe mode.\n" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "" @@ -1237,7 +1245,7 @@ msgstr "" msgid "Unsupported display bus type" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "" @@ -1253,7 +1261,7 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "" @@ -1371,7 +1379,7 @@ msgstr "" msgid "bits must be 8" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "" @@ -1384,7 +1392,7 @@ msgstr "" msgid "buf is too small. need %d bytes" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -1746,7 +1754,8 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -2289,7 +2298,7 @@ msgstr "" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/de_DE.po b/locale/de_DE.po index 7488331476..bf9e5d2616 100644 --- a/locale/de_DE.po +++ b/locale/de_DE.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: Pascal Deneaux\n" "Language-Team: Sebastian Plamauer, Pascal Deneaux\n" @@ -255,6 +255,7 @@ msgstr "Alle timer für diesen Pin werden bereits benutzt" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -329,6 +330,11 @@ msgstr "Die Helligkeit ist nicht einstellbar" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Der Puffergröße ist inkorrekt. Sie sollte %d bytes haben." +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Der Puffer muss eine Mindestenslänge von 1 haben" @@ -466,11 +472,11 @@ msgstr "Konnte ble_uuid nicht decodieren. Status: 0x%04x" msgid "Could not initialize UART" msgstr "Konnte UART nicht initialisieren" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "Konnte first buffer nicht zuteilen" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "Konnte second buffer nicht zuteilen" @@ -487,7 +493,7 @@ msgstr "DAC wird schon benutzt" msgid "Data 0 pin must be byte aligned" msgstr "Data 0 pin muss am Byte ausgerichtet sein" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -759,7 +765,7 @@ msgstr "Ungültige Puffergröße" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "Ungültige Anzahl von Kanälen" @@ -767,11 +773,11 @@ msgstr "Ungültige Anzahl von Kanälen" msgid "Invalid direction." msgstr "Ungültige Richtung" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "Ungültige Datei" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Ungültige format chunk size" @@ -813,11 +819,11 @@ msgstr "Ungültige Polarität" msgid "Invalid run mode." msgstr "Ungültiger Ausführungsmodus" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "Ungültige Anzahl von Stimmen" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "Ungültige wave Datei" @@ -944,6 +950,7 @@ msgid "Not connected" msgstr "Nicht verbunden" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "Spielt nicht" @@ -1068,11 +1075,12 @@ msgstr "Sicherheitsmodus aktiv! Gespeicherter Code wird nicht ausgeführt\n" msgid "SDA or SCL needs a pull up" msgstr "SDA oder SCL brauchen pull up" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "Abtastrate muss positiv sein" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Abtastrate zu hoch. Wert muss unter %d liegen" @@ -1149,19 +1157,19 @@ msgstr "" "Die Reset-Taste wurde beim Booten von CircuitPython gedrückt. Drücke sie " "erneut um den abgesicherten Modus zu verlassen. \n" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "" @@ -1268,7 +1276,7 @@ msgstr "Baudrate wird nicht unterstützt" msgid "Unsupported display bus type" msgstr "Nicht unterstützter display bus type" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "Nicht unterstütztes Format" @@ -1284,7 +1292,7 @@ msgstr "Nicht unterstützter Pull-Wert" msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper-Funktionen unterstützen derzeit nicht mehr als 4 Argumente" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "Voice index zu hoch" @@ -1411,7 +1419,7 @@ msgstr "bits muss 7, 8 oder 9 sein" msgid "bits must be 8" msgstr "bits müssen 8 sein" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "Es müssen 8 oder 16 bits_per_sample sein" @@ -1424,7 +1432,7 @@ msgstr "Zweig ist außerhalb der Reichweite" msgid "buf is too small. need %d bytes" msgstr "buf ist zu klein. brauche %d Bytes" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "Puffer muss ein bytes-artiges Objekt sein" @@ -1786,7 +1794,8 @@ msgstr "Es wurden zusätzliche Keyword-Argumente angegeben" msgid "extra positional arguments given" msgstr "Es wurden zusätzliche Argumente ohne Keyword angegeben" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "Die Datei muss eine im Byte-Modus geöffnete Datei sein" @@ -2338,7 +2347,7 @@ msgstr "" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/en_US.po b/locale/en_US.po index 38074de988..7f4abc3c70 100644 --- a/locale/en_US.po +++ b/locale/en_US.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: \n" @@ -253,6 +253,7 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -325,6 +326,11 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "" +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -462,11 +468,11 @@ msgstr "" msgid "Could not initialize UART" msgstr "" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "" @@ -483,7 +489,7 @@ msgstr "" msgid "Data 0 pin must be byte aligned" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -753,7 +759,7 @@ msgstr "" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "" @@ -761,11 +767,11 @@ msgstr "" msgid "Invalid direction." msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" @@ -807,11 +813,11 @@ msgstr "" msgid "Invalid run mode." msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "" @@ -931,6 +937,7 @@ msgid "Not connected" msgstr "" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "" @@ -1051,11 +1058,12 @@ msgstr "" msgid "SDA or SCL needs a pull up" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -1120,19 +1128,19 @@ msgid "" "exit safe mode.\n" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "" @@ -1237,7 +1245,7 @@ msgstr "" msgid "Unsupported display bus type" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "" @@ -1253,7 +1261,7 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "" @@ -1371,7 +1379,7 @@ msgstr "" msgid "bits must be 8" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "" @@ -1384,7 +1392,7 @@ msgstr "" msgid "buf is too small. need %d bytes" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -1746,7 +1754,8 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -2289,7 +2298,7 @@ msgstr "" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/en_x_pirate.po b/locale/en_x_pirate.po index 9bee12d2a2..d412aabe9b 100644 --- a/locale/en_x_pirate.po +++ b/locale/en_x_pirate.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2018-07-27 11:55-0700\n" "Last-Translator: \n" "Language-Team: @sommersoft, @MrCertainly\n" @@ -255,6 +255,7 @@ msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -329,6 +330,11 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "" +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -466,11 +472,11 @@ msgstr "" msgid "Could not initialize UART" msgstr "" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "" @@ -487,7 +493,7 @@ msgstr "" msgid "Data 0 pin must be byte aligned" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -757,7 +763,7 @@ msgstr "" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "" @@ -765,11 +771,11 @@ msgstr "" msgid "Invalid direction." msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" @@ -811,11 +817,11 @@ msgstr "" msgid "Invalid run mode." msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "" @@ -935,6 +941,7 @@ msgid "Not connected" msgstr "" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "" @@ -1055,11 +1062,12 @@ msgstr "Runnin' in safe mode! Nay runnin' saved code.\n" msgid "SDA or SCL needs a pull up" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -1124,19 +1132,19 @@ msgid "" "exit safe mode.\n" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "" @@ -1241,7 +1249,7 @@ msgstr "" msgid "Unsupported display bus type" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "" @@ -1257,7 +1265,7 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "" @@ -1375,7 +1383,7 @@ msgstr "" msgid "bits must be 8" msgstr "pieces must be of 8" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "" @@ -1388,7 +1396,7 @@ msgstr "" msgid "buf is too small. need %d bytes" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -1750,7 +1758,8 @@ msgstr "" msgid "extra positional arguments given" msgstr "" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -2293,7 +2302,7 @@ msgstr "" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/es.po b/locale/es.po index 33cdfe348a..62677ae0d5 100644 --- a/locale/es.po +++ b/locale/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2018-08-24 22:56-0500\n" "Last-Translator: \n" "Language-Team: \n" @@ -257,6 +257,7 @@ msgstr "Todos los timers para este pin están siendo utilizados" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -333,6 +334,11 @@ msgstr "El brillo no se puede ajustar" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Tamaño de buffer incorrecto. Debe ser de %d bytes." +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer debe ser de longitud 1 como minimo" @@ -470,11 +476,11 @@ msgstr "No se puede descodificar ble_uuid, err 0x%04x" msgid "Could not initialize UART" msgstr "No se puede inicializar la UART" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "No se pudo asignar el primer buffer" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "No se pudo asignar el segundo buffer" @@ -491,7 +497,7 @@ msgstr "DAC ya está siendo utilizado" msgid "Data 0 pin must be byte aligned" msgstr "El pin Data 0 debe estar alineado a bytes" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Trozo de datos debe seguir fmt chunk" @@ -764,7 +770,7 @@ msgstr "Tamaño de buffer inválido" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Inválido periodo de captura. Rango válido: 1 - 500" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "Cuenta de canales inválida" @@ -772,11 +778,11 @@ msgstr "Cuenta de canales inválida" msgid "Invalid direction." msgstr "Dirección inválida." -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "Archivo inválido" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Formato de fragmento de formato no válido" @@ -818,11 +824,11 @@ msgstr "Polaridad inválida" msgid "Invalid run mode." msgstr "Modo de ejecución inválido." -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "Cuenta de voces inválida" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "Archivo wave inválido" @@ -946,6 +952,7 @@ msgid "Not connected" msgstr "No conectado" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "No reproduciendo" @@ -1079,11 +1086,12 @@ msgstr "Ejecutando en modo seguro! No se esta ejecutando el código guardado.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA o SCL necesitan una pull up" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "Sample rate debe ser positivo" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Frecuencia de muestreo demasiado alta. Debe ser menor a %d" @@ -1160,19 +1168,19 @@ msgstr "" "El botón reset fue presionado mientras arrancaba CircuitPython. Presiona " "otra vez para salir del modo seguro.\n" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "Los bits_per_sample del sample no igualan a los del mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "La cuenta de canales del sample no iguala a las del mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "El sample rate del sample no iguala al del mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "El signo del sample no iguala al del mixer" @@ -1278,7 +1286,7 @@ msgstr "Baudrate no soportado" msgid "Unsupported display bus type" msgstr "tipo de bitmap no soportado" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "Formato no soportado" @@ -1294,7 +1302,7 @@ msgstr "valor pull no soportado." msgid "Viper functions don't currently support more than 4 arguments" msgstr "funciones Viper actualmente no soportan más de 4 argumentos." -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "Index de voz demasiado alto" @@ -1420,7 +1428,7 @@ msgstr "bits deben ser 7, 8 ó 9" msgid "bits must be 8" msgstr "bits debe ser 8" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "bits_per_sample debe ser 8 ó 16" @@ -1433,7 +1441,7 @@ msgstr "El argumento de chr() no esta en el rango(256)" msgid "buf is too small. need %d bytes" msgstr "buf es demasiado pequeño. necesita %d bytes" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "buffer debe de ser un objeto bytes-like" @@ -1802,7 +1810,8 @@ msgstr "argumento(s) por palabra clave adicionales fueron dados" msgid "extra positional arguments given" msgstr "argumento posicional adicional dado" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "el archivo deberia ser una archivo abierto en modo byte" @@ -2353,7 +2362,7 @@ msgstr "retorno esperado '%q' pero se obtuvo '%q'" msgid "rsplit(None,n)" msgstr "rsplit(None,n)" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/fil.po b/locale/fil.po index 4f05812f79..c258fd6d12 100644 --- a/locale/fil.po +++ b/locale/fil.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2018-12-20 22:15-0800\n" "Last-Translator: Timothy \n" "Language-Team: fil\n" @@ -257,6 +257,7 @@ msgstr "Lahat ng timers para sa pin na ito ay ginagamit" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -331,6 +332,11 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Mali ang size ng buffer. Dapat %d bytes." +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Buffer dapat ay hindi baba sa 1 na haba" @@ -471,11 +477,11 @@ msgstr "" msgid "Could not initialize UART" msgstr "Hindi ma-initialize ang UART" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "Hindi ma-iallocate ang first buffer" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "Hindi ma-iallocate ang second buffer" @@ -493,7 +499,7 @@ msgstr "Ginagamit na ang DAC" msgid "Data 0 pin must be byte aligned" msgstr "graphic ay dapat 2048 bytes ang haba" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Dapat sunurin ng Data chunk ang fmt chunk" @@ -773,7 +779,7 @@ msgstr "Mali ang buffer size" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "Maling bilang ng channel" @@ -781,11 +787,11 @@ msgstr "Maling bilang ng channel" msgid "Invalid direction." msgstr "Mali ang direksyon." -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "Mali ang file" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Mali ang format ng chunk size" @@ -827,11 +833,11 @@ msgstr "Mali ang polarity" msgid "Invalid run mode." msgstr "Mali ang run mode." -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "Maling bilang ng voice" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "May hindi tama sa wave file" @@ -956,6 +962,7 @@ msgid "Not connected" msgstr "Hindi maka connect sa AP" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "Hindi playing" @@ -1084,11 +1091,12 @@ msgstr "Tumatakbo sa safe mode! Hindi tumatakbo ang nai-save na code.\n" msgid "SDA or SCL needs a pull up" msgstr "Kailangan ng pull up resistors ang SDA o SCL" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "Sample rate ay dapat positibo" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Sample rate ay masyadong mataas. Ito ay dapat hindi hiigit sa %d" @@ -1163,19 +1171,19 @@ msgstr "" "Ang reset button ay pinindot habang nag boot ang CircuitPython. Pindutin " "ulit para lumabas sa safe mode.\n" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "Ang bits_per_sample ng sample ay hindi tugma sa mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "Ang channel count ng sample ay hindi tugma sa mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "Ang sample rate ng sample ay hindi tugma sa mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "Ang signedness ng sample hindi tugma sa mixer" @@ -1282,7 +1290,7 @@ msgstr "Hindi supportadong baudrate" msgid "Unsupported display bus type" msgstr "Hindi supportadong tipo ng bitmap" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "Hindi supportadong format" @@ -1300,7 +1308,7 @@ msgstr "" "Ang mga function ng Viper ay kasalukuyang hindi sumusuporta sa higit sa 4 na " "argumento" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "Index ng Voice ay masyadong mataas" @@ -1424,7 +1432,7 @@ msgstr "bits ay dapat 7, 8 o 9" msgid "bits must be 8" msgstr "bits ay dapat walo (8)" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "bits_per_sample ay dapat 8 o 16" @@ -1437,7 +1445,7 @@ msgstr "branch wala sa range" msgid "buf is too small. need %d bytes" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "buffer ay dapat bytes-like object" @@ -1811,7 +1819,8 @@ msgstr "dagdag na keyword argument na ibinigay" msgid "extra positional arguments given" msgstr "dagdag na positional argument na ibinigay" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "file ay dapat buksan sa byte mode" @@ -2363,7 +2372,7 @@ msgstr "return umasa ng '%q' pero ang nakuha ay ‘%q’" msgid "rsplit(None,n)" msgstr "rsplit(None,n)" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/fr.po b/locale/fr.po index a948630ee1..77110d8b28 100644 --- a/locale/fr.po +++ b/locale/fr.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: 0.1\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2019-04-14 20:05+0100\n" "Last-Translator: Pierrick Couturier \n" "Language-Team: fr\n" @@ -260,6 +260,7 @@ msgstr "Tous les timers pour cette broche sont utilisés" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -336,6 +337,11 @@ msgstr "Luminosité non-ajustable" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Tampon de taille incorrect. Devrait être de %d octets." +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Le tampon doit être de longueur au moins 1" @@ -477,11 +483,11 @@ msgstr "Impossible de décoder le 'ble_uuid', err 0x%04x" msgid "Could not initialize UART" msgstr "L'UART n'a pu être initialisé" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "Impossible d'allouer le 1er tampon" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "Impossible d'allouer le 2e tampon" @@ -499,7 +505,7 @@ msgstr "DAC déjà utilisé" msgid "Data 0 pin must be byte aligned" msgstr "La broche 'Data 0' doit être aligné sur l'octet" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Un bloc de données doit suivre un bloc de format" @@ -780,7 +786,7 @@ msgstr "Longueur de tampon invalide" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Période de capture invalide. Gamme valide: 1 à 500" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "Invalid channel count" msgstr "Nombre de canaux invalide" @@ -789,11 +795,11 @@ msgstr "Nombre de canaux invalide" msgid "Invalid direction." msgstr "Direction invalide" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "Fichier invalide" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Taille de bloc de formatage invalide" @@ -835,12 +841,12 @@ msgstr "Polarité invalide" msgid "Invalid run mode." msgstr "Mode de lancement invalide." -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "Invalid voice count" msgstr "Nombre de voix invalide" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "Fichier WAVE invalide" @@ -965,6 +971,7 @@ msgid "Not connected" msgstr "Non connecté" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "Ne joue pas" @@ -1100,12 +1107,13 @@ msgstr "Mode sans-échec! Le code sauvegardé n'est pas éxecuté.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA ou SCL a besoin d'une résistance de tirage ('pull up')" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "Sample rate must be positive" msgstr "Le taux d'échantillonage doit être positif" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taux d'échantillonage trop élevé. Doit être inf. à %d" @@ -1183,20 +1191,20 @@ msgstr "" "Le bouton 'reset' a été appuyé pendant le démarrage de CircuitPython. " "Appuyer de nouveau pour quitter de le mode sans-échec.\n" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" "Le 'bits_per_sample' de l'échantillon ne correspond pas à celui du mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "Le canal de l'échantillon ne correspond pas à celui du mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "L'échantillonage de l'échantillon ne correspond pas à celui du mixer" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "Le signe de l'échantillon ne correspond pas à celui du mixer" @@ -1307,7 +1315,7 @@ msgstr "Débit non supporté" msgid "Unsupported display bus type" msgstr "Type de bus d'affichage non supporté" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "Format non supporté" @@ -1324,7 +1332,7 @@ msgid "Viper functions don't currently support more than 4 arguments" msgstr "" "les fonctions de Viper ne supportent pas plus de 4 arguments actuellement" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "Index de la voix trop grand" @@ -1449,7 +1457,7 @@ msgstr "bits doivent être 7, 8 ou 9" msgid "bits must be 8" msgstr "les bits doivent être 8" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "bits_per_sample must be 8 or 16" msgstr "'bits_per_sample' doivent être 8 ou 16" @@ -1464,7 +1472,7 @@ msgstr "branche hors-bornes" msgid "buf is too small. need %d bytes" msgstr "'buf' est trop petit. Besoin de %d octets" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "le tampon doit être un objet bytes-like" @@ -1845,7 +1853,8 @@ msgstr "argument(s) nommé(s) supplémentaire(s) donné(s)" msgid "extra positional arguments given" msgstr "argument(s) positionnel(s) supplémentaire(s) donné(s)" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "le fichier doit être un fichier ouvert en mode 'byte'" @@ -2404,7 +2413,7 @@ msgstr "return attendait '%q' mais a reçu '%q'" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/it_IT.po b/locale/it_IT.po index 40a685f759..1e844265f0 100644 --- a/locale/it_IT.po +++ b/locale/it_IT.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2018-10-02 16:27+0200\n" "Last-Translator: Enrico Paganin \n" "Language-Team: \n" @@ -256,6 +256,7 @@ msgstr "Tutti i timer per questo pin sono in uso" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -331,6 +332,11 @@ msgstr "Illiminazione non è regolabile" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Buffer di lunghezza non valida. Dovrebbe essere di %d bytes." +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Il buffer deve essere lungo almeno 1" @@ -472,11 +478,11 @@ msgstr "" msgid "Could not initialize UART" msgstr "Impossibile inizializzare l'UART" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "Impossibile allocare il primo buffer" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "Impossibile allocare il secondo buffer" @@ -494,7 +500,7 @@ msgstr "DAC già in uso" msgid "Data 0 pin must be byte aligned" msgstr "graphic deve essere lunga 2048 byte" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "" @@ -773,7 +779,7 @@ msgstr "lunghezza del buffer non valida" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "periodo di cattura invalido. Zona valida: 1 - 500" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "Invalid channel count" msgstr "Argomento non valido" @@ -782,11 +788,11 @@ msgstr "Argomento non valido" msgid "Invalid direction." msgstr "Direzione non valida." -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "File non valido" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "" @@ -828,12 +834,12 @@ msgstr "Polarità non valida" msgid "Invalid run mode." msgstr "Modalità di esecuzione non valida." -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "Invalid voice count" msgstr "Tipo di servizio non valido" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "File wave non valido" @@ -955,6 +961,7 @@ msgid "Not connected" msgstr "Impossible connettersi all'AP" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "In pausa" @@ -1088,12 +1095,13 @@ msgstr "Modalità sicura in esecuzione! Codice salvato non in esecuzione.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA o SCL necessitano un pull-up" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "Sample rate must be positive" msgstr "STA deve essere attiva" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "" @@ -1162,19 +1170,19 @@ msgid "" "exit safe mode.\n" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "" @@ -1281,7 +1289,7 @@ msgstr "baudrate non supportato" msgid "Unsupported display bus type" msgstr "tipo di bitmap non supportato" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "Formato non supportato" @@ -1297,7 +1305,7 @@ msgstr "Valore di pull non supportato." msgid "Viper functions don't currently support more than 4 arguments" msgstr "Le funzioni Viper non supportano più di 4 argomenti al momento" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "" @@ -1418,7 +1426,7 @@ msgstr "i bit devono essere 7, 8 o 9" msgid "bits must be 8" msgstr "i bit devono essere 8" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "bits_per_sample must be 8 or 16" msgstr "i bit devono essere 7, 8 o 9" @@ -1433,7 +1441,7 @@ msgstr "argomento di chr() non è in range(256)" msgid "buf is too small. need %d bytes" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -1803,7 +1811,8 @@ msgstr "argomento nominato aggiuntivo fornito" msgid "extra positional arguments given" msgstr "argomenti posizonali extra dati" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -2361,7 +2370,7 @@ msgstr "return aspettava '%q' ma ha ottenuto '%q'" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/pl.po b/locale/pl.po index 8967851269..8be7652bba 100644 --- a/locale/pl.po +++ b/locale/pl.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2019-03-19 18:37-0700\n" "Last-Translator: Radomir Dopieralski \n" "Language-Team: pl\n" @@ -254,6 +254,7 @@ msgstr "Wszystkie timery tej nóżki w użyciu" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -328,6 +329,11 @@ msgstr "Jasność nie jest regulowana" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Zła wielkość bufora. Powinno być %d bajtów." +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Bufor musi mieć długość 1 lub więcej" @@ -465,11 +471,11 @@ msgstr "Nie można zdekodować ble_uuid, błąd 0x%04x" msgid "Could not initialize UART" msgstr "Ustawienie UART nie powiodło się" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "Nie udała się alokacja pierwszego bufora" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "Nie udała się alokacja drugiego bufora" @@ -486,7 +492,7 @@ msgstr "DAC w użyciu" msgid "Data 0 pin must be byte aligned" msgstr "Nóżka data 0 musi być wyrównana do bajtu" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Fragment danych musi następować po fragmencie fmt" @@ -758,7 +764,7 @@ msgstr "Zła wielkość bufora" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Zły okres. Poprawny zakres to: 1 - 500" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "Zła liczba kanałów" @@ -766,11 +772,11 @@ msgstr "Zła liczba kanałów" msgid "Invalid direction." msgstr "Zły tryb" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "Zły plik" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Zła wielkość fragmentu formatu" @@ -812,11 +818,11 @@ msgstr "Zła polaryzacja" msgid "Invalid run mode." msgstr "Zły tryb uruchomienia" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "Zła liczba głosów" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "Zły plik wave" @@ -941,6 +947,7 @@ msgid "Not connected" msgstr "Nie podłączono" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "Nic nie jest odtwarzane" @@ -1061,11 +1068,12 @@ msgstr "Uruchomiony tryb bezpieczeństwa! Zapisany kod nie jest uruchamiany.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA lub SCL wymagają podciągnięcia" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "Częstotliwość próbkowania musi być dodatnia" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Zbyt wysoka częstotliwość próbkowania. Musi być mniejsza niż %d" @@ -1140,19 +1148,19 @@ msgstr "" "Przycisk reset został wciśnięty podczas startu CircuitPythona. Wciśnij go " "ponownie aby wyjść z trybu bezpieczeństwa.\n" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "Wartość bits_per_sample nie pasuje do miksera" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "Liczba kanałów nie pasuje do miksera " -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "Sample rate nie pasuje do miksera" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "Znak nie pasuje do miksera" @@ -1257,7 +1265,7 @@ msgstr "Zła szybkość transmisji" msgid "Unsupported display bus type" msgstr "Zły typ magistrali wyświetlaczy" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "Zły format" @@ -1273,7 +1281,7 @@ msgstr "Zła wartość podciągnięcia." msgid "Viper functions don't currently support more than 4 arguments" msgstr "Funkcje Viper nie obsługują obecnie więcej niż 4 argumentów" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "Zbyt wysoki indeks głosu" @@ -1395,7 +1403,7 @@ msgstr "bits musi być 7, 8 lub 9" msgid "bits must be 8" msgstr "bits musi być 8" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "bits_per_sample musi być 8 lub 16" @@ -1408,7 +1416,7 @@ msgstr "skok poza zakres" msgid "buf is too small. need %d bytes" msgstr "buf zbyt mały. Wymagane %d bajtów" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "bufor mysi być typu bytes" @@ -1771,7 +1779,8 @@ msgstr "nadmiarowe argumenty nazwane" msgid "extra positional arguments given" msgstr "nadmiarowe argumenty pozycyjne" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "file musi być otwarte w trybie bajtowym" @@ -2315,7 +2324,7 @@ msgstr "return oczekiwał '%q', a jest '%q'" msgid "rsplit(None,n)" msgstr "rsplit(None,n)" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/pt_BR.po b/locale/pt_BR.po index 7e052bfb71..7ad1504b68 100644 --- a/locale/pt_BR.po +++ b/locale/pt_BR.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2018-10-02 21:14-0000\n" "Last-Translator: \n" "Language-Team: \n" @@ -256,6 +256,7 @@ msgstr "Todos os temporizadores para este pino estão em uso" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -328,6 +329,11 @@ msgstr "" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Buffer de tamanho incorreto. Deve ser %d bytes." +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "" @@ -468,11 +474,11 @@ msgstr "" msgid "Could not initialize UART" msgstr "Não foi possível inicializar o UART" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "Não pôde alocar primeiro buffer" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "Não pôde alocar segundo buffer" @@ -489,7 +495,7 @@ msgstr "DAC em uso" msgid "Data 0 pin must be byte aligned" msgstr "" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Pedaço de dados deve seguir o pedaço de cortes" @@ -766,7 +772,7 @@ msgstr "Arquivo inválido" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "Invalid channel count" msgstr "certificado inválido" @@ -775,11 +781,11 @@ msgstr "certificado inválido" msgid "Invalid direction." msgstr "Direção inválida" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "Arquivo inválido" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Tamanho do pedaço de formato inválido" @@ -821,12 +827,12 @@ msgstr "" msgid "Invalid run mode." msgstr "" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "Invalid voice count" msgstr "certificado inválido" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "Aqruivo de ondas inválido" @@ -947,6 +953,7 @@ msgid "Not connected" msgstr "Não é possível conectar-se ao AP" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "" @@ -1071,11 +1078,12 @@ msgstr "Rodando em modo seguro! Não está executando o código salvo.\n" msgid "SDA or SCL needs a pull up" msgstr "SDA ou SCL precisa de um pull up" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Taxa de amostragem muito alta. Deve ser menor que %d" @@ -1140,19 +1148,19 @@ msgid "" "exit safe mode.\n" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "" @@ -1258,7 +1266,7 @@ msgstr "Taxa de transmissão não suportada" msgid "Unsupported display bus type" msgstr "Taxa de transmissão não suportada" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "Formato não suportado" @@ -1274,7 +1282,7 @@ msgstr "" msgid "Viper functions don't currently support more than 4 arguments" msgstr "" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "" @@ -1392,7 +1400,7 @@ msgstr "" msgid "bits must be 8" msgstr "bits devem ser 8" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c #, fuzzy msgid "bits_per_sample must be 8 or 16" msgstr "bits devem ser 8" @@ -1407,7 +1415,7 @@ msgstr "Calibração está fora do intervalo" msgid "buf is too small. need %d bytes" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "" @@ -1771,7 +1779,8 @@ msgstr "argumentos extras de palavras-chave passados" msgid "extra positional arguments given" msgstr "argumentos extra posicionais passados" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "" @@ -2316,7 +2325,7 @@ msgstr "" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" diff --git a/locale/zh_Latn_pinyin.po b/locale/zh_Latn_pinyin.po index 258a4d3df8..6272592729 100644 --- a/locale/zh_Latn_pinyin.po +++ b/locale/zh_Latn_pinyin.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: circuitpython-cn\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2019-07-19 16:10-0700\n" +"POT-Creation-Date: 2019-07-25 21:12-0500\n" "PO-Revision-Date: 2019-04-13 10:10-0700\n" "Last-Translator: hexthat\n" "Language-Team: Chinese Hanyu Pinyin\n" @@ -255,6 +255,7 @@ msgstr "Cǐ yǐn jiǎo de suǒyǒu jìshí qì zhèngzài shǐyòng" #: ports/atmel-samd/common-hal/audioio/AudioOut.c #: ports/atmel-samd/common-hal/frequencyio/FrequencyIn.c #: ports/atmel-samd/common-hal/pulseio/PulseOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #: ports/nrf/common-hal/pulseio/PulseOut.c shared-bindings/pulseio/PWMOut.c #: shared-module/_pew/PewPew.c msgid "All timers in use" @@ -329,6 +330,11 @@ msgstr "Liàngdù wúfǎ tiáozhěng" msgid "Buffer incorrect size. Should be %d bytes." msgstr "Huǎnchōng qū dàxiǎo bù zhèngquè. Yīnggāi shì %d zì jié." +#: ports/nrf/common-hal/audiopwmio/AudioOut.c +#, c-format +msgid "Buffer length %d too big. It must be less than %d" +msgstr "" + #: shared-bindings/bitbangio/I2C.c shared-bindings/busio/I2C.c msgid "Buffer must be at least length 1" msgstr "Huǎnchōng qū bìxū zhìshǎo chángdù 1" @@ -466,11 +472,11 @@ msgstr "Wúfǎ jiěmǎ kě dú_uuid, err 0x%04x" msgid "Could not initialize UART" msgstr "Wúfǎ chūshǐhuà UART" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate first buffer" msgstr "Wúfǎ fēnpèi dì yī gè huǎnchōng qū" -#: shared-module/audioio/Mixer.c shared-module/audioio/WaveFile.c +#: shared-module/audiocore/Mixer.c shared-module/audiocore/WaveFile.c msgid "Couldn't allocate second buffer" msgstr "Wúfǎ fēnpèi dì èr gè huǎnchōng qū" @@ -487,7 +493,7 @@ msgstr "Fā yuán huì yǐjīng shǐyòng" msgid "Data 0 pin must be byte aligned" msgstr "Shùjù 0 de yǐn jiǎo bìxū shì zì jié duìqí" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Data chunk must follow fmt chunk" msgstr "Shùjù kuài bìxū zūnxún fmt qū kuài" @@ -759,7 +765,7 @@ msgstr "Wúxiào de huǎnchōng qū dàxiǎo" msgid "Invalid capture period. Valid range: 1 - 500" msgstr "Wúxiào de bǔhuò zhōuqí. Yǒuxiào fànwéi: 1-500" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid channel count" msgstr "Wúxiào de tōngdào jìshù" @@ -767,11 +773,11 @@ msgstr "Wúxiào de tōngdào jìshù" msgid "Invalid direction." msgstr "Wúxiào de fāngxiàng." -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid file" msgstr "Wúxiào de wénjiàn" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid format chunk size" msgstr "Géshì kuài dàxiǎo wúxiào" @@ -813,11 +819,11 @@ msgstr "Wúxiào liǎng jí zhí" msgid "Invalid run mode." msgstr "Wúxiào de yùnxíng móshì." -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Invalid voice count" msgstr "Wúxiào de yǔyīn jìshù" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Invalid wave file" msgstr "Wúxiào de làng làngcháo wénjiàn" @@ -941,6 +947,7 @@ msgid "Not connected" msgstr "Wèi liánjiē" #: shared-bindings/audiobusio/I2SOut.c shared-bindings/audioio/AudioOut.c +#: shared-bindings/audiopwmio/AudioOut.c msgid "Not playing" msgstr "Wèi bòfàng" @@ -1066,11 +1073,12 @@ msgstr "Zài ānquán móshì xià yùnxíng! Bù yùnxíng yǐ bǎocún de dài msgid "SDA or SCL needs a pull up" msgstr "SDA huò SCL xūyào lādòng" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "Sample rate must be positive" msgstr "Cǎiyàng lǜ bìxū wèi zhèng shù" #: ports/atmel-samd/common-hal/audioio/AudioOut.c +#: ports/nrf/common-hal/audiopwmio/AudioOut.c #, c-format msgid "Sample rate too high. It must be less than %d" msgstr "Cǎiyàng lǜ tài gāo. Tā bìxū xiǎoyú %d" @@ -1145,19 +1153,19 @@ msgstr "" "Qǐdòng CircuitPython shí, chóng zhì ànniǔ bèi àn xià. Zàicì àn xià yǐ tuìchū " "ānquán móshì\n" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's bits_per_sample does not match the mixer's" msgstr "Yàngběn de bits_per_sample yǔ hǔn yīn qì bù pǐpèi" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's channel count does not match the mixer's" msgstr "Yàngběn de píndào jìshù yǔ hǔn yīn qì bù xiāngfú" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's sample rate does not match the mixer's" msgstr "Yàngběn de yàngběn sùdù yǔ hǔn yīn qì de xiāngchà bù pǐpèi" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "The sample's signedness does not match the mixer's" msgstr "Yàngběn de qiānmíng yǔ hǔn yīn qì de qiānmíng bù pǐpèi" @@ -1262,7 +1270,7 @@ msgstr "Bù zhīchí de baudrate" msgid "Unsupported display bus type" msgstr "Bù zhīchí de gōnggòng qìchē lèixíng" -#: shared-module/audioio/WaveFile.c +#: shared-module/audiocore/WaveFile.c msgid "Unsupported format" msgstr "Bù zhīchí de géshì" @@ -1278,7 +1286,7 @@ msgstr "Bù zhīchí de lādòng zhí." msgid "Viper functions don't currently support more than 4 arguments" msgstr "Viper hánshù mùqián bù zhīchí chāoguò 4 gè cānshù" -#: shared-module/audioio/Mixer.c +#: shared-module/audiocore/Mixer.c msgid "Voice index too high" msgstr "Yǔyīn suǒyǐn tài gāo" @@ -1403,7 +1411,7 @@ msgstr "bǐtè bìxū shì 7,8 huò 9" msgid "bits must be 8" msgstr "bǐtè bìxū shì 8" -#: shared-bindings/audioio/Mixer.c +#: shared-bindings/audiocore/Mixer.c msgid "bits_per_sample must be 8 or 16" msgstr "měi jiàn yàngběn bìxū wèi 8 huò 16" @@ -1416,7 +1424,7 @@ msgstr "fēnzhī bùzài fànwéi nèi" msgid "buf is too small. need %d bytes" msgstr "huǎnchōng tài xiǎo. Xūyào%d zì jié" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "buffer must be a bytes-like object" msgstr "huǎnchōng qū bìxū shì zì jié lèi duìxiàng" @@ -1781,7 +1789,8 @@ msgstr "éwài de guānjiàn cí cānshù" msgid "extra positional arguments given" msgstr "gěi chūle éwài de wèizhì cānshù" -#: shared-bindings/audioio/WaveFile.c shared-bindings/displayio/OnDiskBitmap.c +#: shared-bindings/audiocore/WaveFile.c +#: shared-bindings/displayio/OnDiskBitmap.c msgid "file must be a file opened in byte mode" msgstr "wénjiàn bìxū shì zài zì jié móshì xià dǎkāi de wénjiàn" @@ -2326,7 +2335,7 @@ msgstr "fǎnhuí yùqí de '%q' dàn huòdéle '%q'" msgid "rsplit(None,n)" msgstr "" -#: shared-bindings/audioio/RawSample.c +#: shared-bindings/audiocore/RawSample.c msgid "" "sample_source buffer must be a bytearray or array of type 'h', 'H', 'b' or " "'B'" From a53720810b6925d6023a0022bca3c18783756ad6 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 25 Jul 2019 21:35:07 -0500 Subject: [PATCH 06/13] docs: corrections that stem from the "audiocore" rename --- shared-bindings/audiobusio/I2SOut.c | 7 ++++--- shared-bindings/audiocore/Mixer.c | 9 +++++---- shared-bindings/audiocore/RawSample.c | 5 +++-- shared-bindings/audiocore/WaveFile.c | 5 +++-- shared-bindings/audioio/AudioOut.c | 5 +++-- 5 files changed, 18 insertions(+), 13 deletions(-) diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index 980f113929..bee835d12c 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -56,7 +56,7 @@ //| using `UDA1334 Breakout `_:: //| //| import audiobusio -//| import audioio +//| import audiocore //| import board //| import array //| import time @@ -68,7 +68,7 @@ //| for i in range(length): //| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| sine_wave = audiobusio.RawSample(sine_wave, sample_rate=8000) +//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) //| i2s = audiobusio.I2SOut(board.D1, board.D0, board.D9) //| i2s.play(sine_wave, loop=True) //| time.sleep(1) @@ -78,12 +78,13 @@ //| //| import board //| import audioio +//| import audiocore //| import audiobusio //| import digitalio //| //| //| f = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audioio.WaveFile(f) +//| wav = audiocore.WaveFile(f) //| //| a = audiobusio.I2SOut(board.D1, board.D0, board.D9) //| diff --git a/shared-bindings/audiocore/Mixer.c b/shared-bindings/audiocore/Mixer.c index b2f0a3fdac..c25b936f08 100644 --- a/shared-bindings/audiocore/Mixer.c +++ b/shared-bindings/audiocore/Mixer.c @@ -36,7 +36,7 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audioio +//| .. currentmodule:: audiocore //| //| :class:`Mixer` -- Mixes one or more audio samples together //| =========================================================== @@ -54,15 +54,16 @@ //| //| import board //| import audioio +//| import audiocore //| import digitalio //| //| # Required for CircuitPlayground Express //| speaker_enable = digitalio.DigitalInOut(board.SPEAKER_ENABLE) //| speaker_enable.switch_to_output(value=True) //| -//| music = audioio.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) -//| drum = audioio.WaveFile(open("drum.wav", "rb")) -//| mixer = audioio.Mixer(voice_count=2, sample_rate=16000, channel_count=1, bits_per_sample=16, samples_signed=True) +//| music = audiocore.WaveFile(open("cplay-5.1-16bit-16khz.wav", "rb")) +//| drum = audiocore.WaveFile(open("drum.wav", "rb")) +//| mixer = audiocore.Mixer(voice_count=2, sample_rate=16000, channel_count=1, bits_per_sample=16, samples_signed=True) //| a = audioio.AudioOut(board.A0) //| //| print("playing") diff --git a/shared-bindings/audiocore/RawSample.c b/shared-bindings/audiocore/RawSample.c index 912b48bfbb..07f8c683f2 100644 --- a/shared-bindings/audiocore/RawSample.c +++ b/shared-bindings/audiocore/RawSample.c @@ -35,7 +35,7 @@ #include "shared-bindings/audiocore/RawSample.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audioio +//| .. currentmodule:: audiocore //| //| :class:`RawSample` -- A raw audio sample buffer //| ======================================================== @@ -55,6 +55,7 @@ //| //| Simple 8ksps 440 Hz sin wave:: //| +//| import audiocore //| import audioio //| import board //| import array @@ -68,7 +69,7 @@ //| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15)) //| //| dac = audioio.AudioOut(board.SPEAKER) -//| sine_wave = audioio.RawSample(sine_wave) +//| sine_wave = audiocore.RawSample(sine_wave) //| dac.play(sine_wave, loop=True) //| time.sleep(1) //| dac.stop() diff --git a/shared-bindings/audiocore/WaveFile.c b/shared-bindings/audiocore/WaveFile.c index 4c1993b7c4..edb190d3ab 100644 --- a/shared-bindings/audiocore/WaveFile.c +++ b/shared-bindings/audiocore/WaveFile.c @@ -33,7 +33,7 @@ #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" -//| .. currentmodule:: audioio +//| .. currentmodule:: audiocore //| //| :class:`WaveFile` -- Load a wave file for audio playback //| ======================================================== @@ -50,6 +50,7 @@ //| Playing a wave file from flash:: //| //| import board +//| import audiocore //| import audioio //| import digitalio //| @@ -58,7 +59,7 @@ //| speaker_enable.switch_to_output(value=True) //| //| data = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audioio.WaveFile(data) +//| wav = audiocore.WaveFile(data) //| a = audioio.AudioOut(board.A0) //| //| print("playing") diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 79df66f7dd..3247033534 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -55,6 +55,7 @@ //| //| Simple 8ksps 440 Hz sin wave:: //| +//| import audiocore //| import audioio //| import board //| import array @@ -68,7 +69,7 @@ //| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| //| dac = audioio.AudioOut(board.SPEAKER) -//| sine_wave = audioio.RawSample(sine_wave, sample_rate=8000) +//| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) //| dac.play(sine_wave, loop=True) //| time.sleep(1) //| dac.stop() @@ -84,7 +85,7 @@ //| speaker_enable.switch_to_output(value=True) //| //| data = open("cplay-5.1-16bit-16khz.wav", "rb") -//| wav = audioio.WaveFile(data) +//| wav = audiocore.WaveFile(data) //| a = audioio.AudioOut(board.A0) //| //| print("playing") From 91b7ba7dccb0233516998a1601f467015c80633b Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 25 Jul 2019 21:35:27 -0500 Subject: [PATCH 07/13] docs: An `audiocore.Mixer` suffices where another audio source would --- shared-bindings/audiobusio/I2SOut.c | 2 +- shared-bindings/audiocore/Mixer.c | 2 +- shared-bindings/audioio/AudioOut.c | 2 +- shared-bindings/audiopwmio/AudioOut.c | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/shared-bindings/audiobusio/I2SOut.c b/shared-bindings/audiobusio/I2SOut.c index bee835d12c..9bce9c7609 100644 --- a/shared-bindings/audiobusio/I2SOut.c +++ b/shared-bindings/audiobusio/I2SOut.c @@ -164,7 +164,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiobusio_i2sout___exit___obj, 4, 4, //| Plays the sample once when loop=False and continuously when loop=True. //| Does not block. Use `playing` to block. //| -//| Sample must be an `audioio.WaveFile` or `audioio.RawSample`. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiocore.Mixer`. //| //| The sample itself should consist of 8 bit or 16 bit samples. //| diff --git a/shared-bindings/audiocore/Mixer.c b/shared-bindings/audiocore/Mixer.c index c25b936f08..9ab720434b 100644 --- a/shared-bindings/audiocore/Mixer.c +++ b/shared-bindings/audiocore/Mixer.c @@ -152,7 +152,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_mixer___exit___obj, 4, 4, aud //| Plays the sample once when loop=False and continuously when loop=True. //| Does not block. Use `playing` to block. //| -//| Sample must be an `audioio.WaveFile`, `audioio.Mixer` or `audioio.RawSample`. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiocore.Mixer`. //| //| The sample must match the Mixer's encoding settings given in the constructor. //| diff --git a/shared-bindings/audioio/AudioOut.c b/shared-bindings/audioio/AudioOut.c index 3247033534..af2fce48e3 100644 --- a/shared-bindings/audioio/AudioOut.c +++ b/shared-bindings/audioio/AudioOut.c @@ -163,7 +163,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audioio_audioout___exit___obj, 4, 4, //| Plays the sample once when loop=False and continuously when loop=True. //| Does not block. Use `playing` to block. //| -//| Sample must be an `audioio.WaveFile` or `audioio.RawSample`. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiocore.Mixer`. //| //| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output //| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit diff --git a/shared-bindings/audiopwmio/AudioOut.c b/shared-bindings/audiopwmio/AudioOut.c index 37c845165b..79f83da891 100644 --- a/shared-bindings/audiopwmio/AudioOut.c +++ b/shared-bindings/audiopwmio/AudioOut.c @@ -166,7 +166,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_audioout___exit___obj, 4, //| Plays the sample once when loop=False and continuously when loop=True. //| Does not block. Use `playing` to block. //| -//| Sample must be an `audiopwmio.WaveFile` or `audiopwmio.RawSample`. +//| Sample must be an `audiocore.WaveFile`, `audiocore.RawSample`, or `audiocore.Mixer`. //| //| The sample itself should consist of 16 bit samples. Microcontrollers with a lower output //| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit From aa1398e696b46efe0a8fb7c069f0c732ef6f99b8 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Thu, 25 Jul 2019 21:56:22 -0500 Subject: [PATCH 08/13] support matrix: add audiopwmio, update audiocore, sort --- shared-bindings/index.rst | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shared-bindings/index.rst b/shared-bindings/index.rst index b7690d292a..7152f506e5 100644 --- a/shared-bindings/index.rst +++ b/shared-bindings/index.rst @@ -35,8 +35,9 @@ Module Supported Ports ================= ============================== `analogio` **All Supported** `audiobusio` **SAMD/SAMD Express** +`audiocore` **All with audioio, audiobusio or audiopwmio** `audioio` **SAMD Express** -`audiocore` **All with audioio** +`audiopwmio` **nRF** `binascii` **ESP8266** `bitbangio` **SAMD Express, ESP8266** `board` **All Supported** From b72352949ba50d4cece043f65e037de7e3ae3a1a Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Mon, 29 Jul 2019 18:39:00 -0400 Subject: [PATCH 09/13] PWM audio: Rename AudioOut -> PWMAudioOut, _audioio_ -> _audiopwmio_ --- ports/nrf/background.c | 2 +- .../audiopwmio/{AudioOut.c => PWMAudioOut.c} | 42 +++---- .../audiopwmio/{AudioOut.h => PWMAudioOut.h} | 2 +- ports/nrf/supervisor/port.c | 2 +- py/circuitpy_defns.mk | 2 +- .../audiopwmio/{AudioOut.c => PWMAudioOut.c} | 114 +++++++++--------- .../audiopwmio/{AudioOut.h => PWMAudioOut.h} | 22 ++-- shared-bindings/audiopwmio/__init__.c | 4 +- 8 files changed, 95 insertions(+), 95 deletions(-) rename ports/nrf/common-hal/audiopwmio/{AudioOut.c => PWMAudioOut.c} (87%) rename ports/nrf/common-hal/audiopwmio/{AudioOut.h => PWMAudioOut.h} (98%) rename shared-bindings/audiopwmio/{AudioOut.c => PWMAudioOut.c} (63%) rename shared-bindings/audiopwmio/{AudioOut.h => PWMAudioOut.h} (67%) diff --git a/ports/nrf/background.c b/ports/nrf/background.c index 91ec66b36a..453bc96dfb 100644 --- a/ports/nrf/background.c +++ b/ports/nrf/background.c @@ -34,7 +34,7 @@ #endif #if CIRCUITPY_AUDIOPWMIO -#include "common-hal/audiopwmio/AudioOut.h" +#include "common-hal/audiopwmio/PWMAudioOut.h" #endif static bool running_background_tasks = false; diff --git a/ports/nrf/common-hal/audiopwmio/AudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c similarity index 87% rename from ports/nrf/common-hal/audiopwmio/AudioOut.c rename to ports/nrf/common-hal/audiopwmio/PWMAudioOut.c index a3c56c76b0..b4c409bb67 100644 --- a/ports/nrf/common-hal/audiopwmio/AudioOut.c +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c @@ -31,15 +31,15 @@ #include "py/gc.h" #include "py/mperrno.h" #include "py/runtime.h" -#include "common-hal/audiopwmio/AudioOut.h" +#include "common-hal/audiopwmio/PWMAudioOut.h" #include "common-hal/pulseio/PWMOut.h" -#include "shared-bindings/audiopwmio/AudioOut.h" +#include "shared-bindings/audiopwmio/PWMAudioOut.h" #include "shared-bindings/microcontroller/__init__.h" #include "shared-bindings/microcontroller/Pin.h" #include "supervisor/shared/translate.h" // TODO: This should be the same size as PWMOut.c:pwms[], but there's no trivial way to accomplish that -STATIC audiopwmio_audioout_obj_t* active_audio[4]; +STATIC audiopwmio_pwmaudioout_obj_t* active_audio[4]; #define F_TARGET (62500) #define F_PWM (16000000) @@ -63,7 +63,7 @@ STATIC uint32_t calculate_pwm_parameters(uint32_t sample_rate, uint32_t *top_out return multiplier - 1; } -STATIC void activate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) { +STATIC void activate_audiopwmout_obj(audiopwmio_pwmaudioout_obj_t *self) { for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) { if(!active_audio[i]) { active_audio[i] = self; @@ -71,7 +71,7 @@ STATIC void activate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) { } } } -STATIC void deactivate_audiopwmout_obj(audiopwmio_audioout_obj_t *self) { +STATIC void deactivate_audiopwmout_obj(audiopwmio_pwmaudioout_obj_t *self) { for(size_t i=0; i < MP_ARRAY_SIZE(active_audio); i++) { if(active_audio[i] == self) active_audio[i] = NULL; @@ -83,7 +83,7 @@ void audiopwmout_reset() { active_audio[i] = NULL; } -STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) { +STATIC void fill_buffers(audiopwmio_pwmaudioout_obj_t *self, int buf) { self->pwm->EVENTS_SEQSTARTED[1-buf] = 0; uint16_t *dev_buffer = self->buffers[buf]; uint8_t *buffer; @@ -92,7 +92,7 @@ STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) { audiosample_get_buffer(self->sample, false, 0, &buffer, &buffer_length); if (get_buffer_result == GET_BUFFER_ERROR) { - common_hal_audiopwmio_audioout_stop(self); + common_hal_audiopwmio_pwmaudioout_stop(self); return; } uint32_t num_samples = buffer_length / self->bytes_per_sample / self->spacing; @@ -132,8 +132,8 @@ STATIC void fill_buffers(audiopwmio_audioout_obj_t *self, int buf) { } } -STATIC void audiopwmout_background_obj(audiopwmio_audioout_obj_t *self) { - if(!common_hal_audiopwmio_audioout_get_playing(self)) +STATIC void audiopwmout_background_obj(audiopwmio_pwmaudioout_obj_t *self) { + if(!common_hal_audiopwmio_pwmaudioout_get_playing(self)) return; if(self->loop && self->single_buffer) { self->pwm->LOOP = 0xffff; @@ -156,7 +156,7 @@ void audiopwmout_background() { } } -void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self, +void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t* self, const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t quiescent_value) { assert_pin_free(left_channel); assert_pin_free(right_channel); @@ -188,12 +188,12 @@ void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self, // TODO: Ramp from 0 to quiescent value } -bool common_hal_audiopwmio_audioout_deinited(audiopwmio_audioout_obj_t* self) { +bool common_hal_audiopwmio_pwmaudioout_deinited(audiopwmio_pwmaudioout_obj_t* self) { return !self->pwm; } -void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self) { - if (common_hal_audiopwmio_audioout_deinited(self)) { +void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t* self) { + if (common_hal_audiopwmio_pwmaudioout_deinited(self)) { return; } // TODO: ramp the pwm down from quiescent value to 0 @@ -216,9 +216,9 @@ void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self) { self->buffers[1] = NULL; } -void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj_t sample, bool loop) { - if (common_hal_audiopwmio_audioout_get_playing(self)) { - common_hal_audiopwmio_audioout_stop(self); +void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, mp_obj_t sample, bool loop) { + if (common_hal_audiopwmio_pwmaudioout_get_playing(self)) { + common_hal_audiopwmio_pwmaudioout_stop(self); } self->sample = sample; self->loop = loop; @@ -268,7 +268,7 @@ void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj self->paused = false; } -void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self) { +void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t* self) { deactivate_audiopwmout_obj(self); self->pwm->TASKS_STOP = 1; self->stopping = false; @@ -281,7 +281,7 @@ void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self) { self->buffers[1] = NULL; } -bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self) { +bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* self) { if(self->pwm->EVENTS_STOPPED) { self->playing = false; self->pwm->EVENTS_STOPPED = 0; @@ -305,14 +305,14 @@ bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self) * feels instant. (This also saves on memory, for long in-memory "single buffer" * samples!) */ -void common_hal_audiopwmio_audioout_pause(audiopwmio_audioout_obj_t* self) { +void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t* self) { self->paused = true; } -void common_hal_audiopwmio_audioout_resume(audiopwmio_audioout_obj_t* self) { +void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t* self) { self->paused = false; } -bool common_hal_audiopwmio_audioout_get_paused(audiopwmio_audioout_obj_t* self) { +bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t* self) { return self->paused; } diff --git a/ports/nrf/common-hal/audiopwmio/AudioOut.h b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h similarity index 98% rename from ports/nrf/common-hal/audiopwmio/AudioOut.h rename to ports/nrf/common-hal/audiopwmio/PWMAudioOut.h index 9d2b823ad3..8deff5d340 100644 --- a/ports/nrf/common-hal/audiopwmio/AudioOut.h +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.h @@ -50,7 +50,7 @@ typedef struct { bool loop; bool signed_to_unsigned; bool single_buffer; -} audiopwmio_audioout_obj_t; +} audiopwmio_pwmaudioout_obj_t; void audiopwmout_reset(void); diff --git a/ports/nrf/supervisor/port.c b/ports/nrf/supervisor/port.c index c98d5ab288..03f7876247 100644 --- a/ports/nrf/supervisor/port.c +++ b/ports/nrf/supervisor/port.c @@ -51,7 +51,7 @@ #include "shared-bindings/rtc/__init__.h" #ifdef CIRCUITPY_AUDIOPWMIO -#include "common-hal/audiopwmio/AudioOut.h" +#include "common-hal/audiopwmio/PWMAudioOut.h" #endif static void power_warning_handler(void) { diff --git a/py/circuitpy_defns.mk b/py/circuitpy_defns.mk index 28d560a735..a6dde61dac 100644 --- a/py/circuitpy_defns.mk +++ b/py/circuitpy_defns.mk @@ -227,7 +227,7 @@ $(filter $(SRC_PATTERNS), \ audiobusio/I2SOut.c \ audiobusio/PDMIn.c \ audiopwmio/__init__.c \ - audiopwmio/AudioOut.c \ + audiopwmio/PWMAudioOut.c \ audioio/__init__.c \ audioio/AudioOut.c \ bleio/__init__.c \ diff --git a/shared-bindings/audiopwmio/AudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c similarity index 63% rename from shared-bindings/audiopwmio/AudioOut.c rename to shared-bindings/audiopwmio/PWMAudioOut.c index 79f83da891..042da270db 100644 --- a/shared-bindings/audiopwmio/AudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -31,7 +31,7 @@ #include "py/objproperty.h" #include "py/runtime.h" #include "shared-bindings/microcontroller/Pin.h" -#include "shared-bindings/audiopwmio/AudioOut.h" +#include "shared-bindings/audiopwmio/PWMAudioOut.h" #include "shared-bindings/audiocore/RawSample.h" #include "shared-bindings/util.h" #include "supervisor/shared/translate.h" @@ -97,7 +97,7 @@ //| pass //| print("stopped") //| -STATIC mp_obj_t audiopwmio_audioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_left_channel, ARG_right_channel, ARG_quiescent_value }; static const mp_arg_t allowed_args[] = { { MP_QSTR_left_channel, MP_ARG_OBJ | MP_ARG_REQUIRED }, @@ -119,9 +119,9 @@ STATIC mp_obj_t audiopwmio_audioout_make_new(const mp_obj_type_t *type, size_t n } // create AudioOut object from the given pin - audiopwmio_audioout_obj_t *self = m_new_obj(audiopwmio_audioout_obj_t); - self->base.type = &audiopwmio_audioout_type; - common_hal_audiopwmio_audioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int); + audiopwmio_pwmaudioout_obj_t *self = m_new_obj(audiopwmio_pwmaudioout_obj_t); + self->base.type = &audiopwmio_pwmaudioout_type; + common_hal_audiopwmio_pwmaudioout_construct(self, left_channel_pin, right_channel_pin, args[ARG_quiescent_value].u_int); return MP_OBJ_FROM_PTR(self); } @@ -130,15 +130,15 @@ STATIC mp_obj_t audiopwmio_audioout_make_new(const mp_obj_type_t *type, size_t n //| //| Deinitialises the AudioOut and releases any hardware resources for reuse. //| -STATIC mp_obj_t audiopwmio_audioout_deinit(mp_obj_t self_in) { - audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); - common_hal_audiopwmio_audioout_deinit(self); +STATIC mp_obj_t audiopwmio_pwmaudioout_deinit(mp_obj_t self_in) { + audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); + common_hal_audiopwmio_pwmaudioout_deinit(self); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_deinit_obj, audiopwmio_audioout_deinit); +STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_deinit_obj, audiopwmio_pwmaudioout_deinit); -STATIC void check_for_deinit(audiopwmio_audioout_obj_t *self) { - if (common_hal_audiopwmio_audioout_deinited(self)) { +STATIC void check_for_deinit(audiopwmio_pwmaudioout_obj_t *self) { + if (common_hal_audiopwmio_pwmaudioout_deinited(self)) { raise_deinited_error(); } } @@ -153,12 +153,12 @@ STATIC void check_for_deinit(audiopwmio_audioout_obj_t *self) { //| Automatically deinitializes the hardware when exiting a context. See //| :ref:`lifetime-and-contextmanagers` for more info. //| -STATIC mp_obj_t audiopwmio_audioout_obj___exit__(size_t n_args, const mp_obj_t *args) { +STATIC mp_obj_t audiopwmio_pwmaudioout_obj___exit__(size_t n_args, const mp_obj_t *args) { (void)n_args; - common_hal_audiopwmio_audioout_deinit(args[0]); + common_hal_audiopwmio_pwmaudioout_deinit(args[0]); return mp_const_none; } -STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_audioout___exit___obj, 4, 4, audiopwmio_audioout_obj___exit__); +STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_pwmaudioout___exit___obj, 4, 4, audiopwmio_pwmaudioout_obj___exit__); //| .. method:: play(sample, *, loop=False) @@ -172,50 +172,50 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(audiopwmio_audioout___exit___obj, 4, //| resolution will use the highest order bits to output. For example, the SAMD21 has a 10 bit //| DAC that ignores the lowest 6 bits when playing 16 bit samples. //| -STATIC mp_obj_t audiopwmio_audioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { +STATIC mp_obj_t audiopwmio_pwmaudioout_obj_play(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { enum { ARG_sample, ARG_loop }; static const mp_arg_t allowed_args[] = { { MP_QSTR_sample, MP_ARG_OBJ | MP_ARG_REQUIRED }, { MP_QSTR_loop, MP_ARG_BOOL | MP_ARG_KW_ONLY, {.u_bool = false} }, }; - audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); + audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(pos_args[0]); check_for_deinit(self); mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)]; mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args); mp_obj_t sample = args[ARG_sample].u_obj; - common_hal_audiopwmio_audioout_play(self, sample, args[ARG_loop].u_bool); + common_hal_audiopwmio_pwmaudioout_play(self, sample, args[ARG_loop].u_bool); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_KW(audiopwmio_audioout_play_obj, 1, audiopwmio_audioout_obj_play); +MP_DEFINE_CONST_FUN_OBJ_KW(audiopwmio_pwmaudioout_play_obj, 1, audiopwmio_pwmaudioout_obj_play); //| .. method:: stop() //| //| Stops playback and resets to the start of the sample. //| -STATIC mp_obj_t audiopwmio_audioout_obj_stop(mp_obj_t self_in) { - audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t audiopwmio_pwmaudioout_obj_stop(mp_obj_t self_in) { + audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); - common_hal_audiopwmio_audioout_stop(self); + common_hal_audiopwmio_pwmaudioout_stop(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_stop_obj, audiopwmio_audioout_obj_stop); +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_stop_obj, audiopwmio_pwmaudioout_obj_stop); //| .. attribute:: playing //| //| True when an audio sample is being output even if `paused`. (read-only) //| -STATIC mp_obj_t audiopwmio_audioout_obj_get_playing(mp_obj_t self_in) { - audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_playing(mp_obj_t self_in) { + audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); - return mp_obj_new_bool(common_hal_audiopwmio_audioout_get_playing(self)); + return mp_obj_new_bool(common_hal_audiopwmio_pwmaudioout_get_playing(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_get_playing_obj, audiopwmio_audioout_obj_get_playing); +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_get_playing_obj, audiopwmio_pwmaudioout_obj_get_playing); -const mp_obj_property_t audiopwmio_audioout_playing_obj = { +const mp_obj_property_t audiopwmio_pwmaudioout_playing_obj = { .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiopwmio_audioout_get_playing_obj, + .proxy = {(mp_obj_t)&audiopwmio_pwmaudioout_get_playing_obj, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj}, }; @@ -224,71 +224,71 @@ const mp_obj_property_t audiopwmio_audioout_playing_obj = { //| //| Stops playback temporarily while remembering the position. Use `resume` to resume playback. //| -STATIC mp_obj_t audiopwmio_audioout_obj_pause(mp_obj_t self_in) { - audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t audiopwmio_pwmaudioout_obj_pause(mp_obj_t self_in) { + audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); - if (!common_hal_audiopwmio_audioout_get_playing(self)) { + if (!common_hal_audiopwmio_pwmaudioout_get_playing(self)) { mp_raise_RuntimeError(translate("Not playing")); } - common_hal_audiopwmio_audioout_pause(self); + common_hal_audiopwmio_pwmaudioout_pause(self); return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_pause_obj, audiopwmio_audioout_obj_pause); +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_pause_obj, audiopwmio_pwmaudioout_obj_pause); //| .. method:: resume() //| //| Resumes sample playback after :py:func:`pause`. //| -STATIC mp_obj_t audiopwmio_audioout_obj_resume(mp_obj_t self_in) { - audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t audiopwmio_pwmaudioout_obj_resume(mp_obj_t self_in) { + audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); - if (common_hal_audiopwmio_audioout_get_paused(self)) { - common_hal_audiopwmio_audioout_resume(self); + if (common_hal_audiopwmio_pwmaudioout_get_paused(self)) { + common_hal_audiopwmio_pwmaudioout_resume(self); } return mp_const_none; } -MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_resume_obj, audiopwmio_audioout_obj_resume); +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_resume_obj, audiopwmio_pwmaudioout_obj_resume); //| .. attribute:: paused //| //| True when playback is paused. (read-only) //| -STATIC mp_obj_t audiopwmio_audioout_obj_get_paused(mp_obj_t self_in) { - audiopwmio_audioout_obj_t *self = MP_OBJ_TO_PTR(self_in); +STATIC mp_obj_t audiopwmio_pwmaudioout_obj_get_paused(mp_obj_t self_in) { + audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); check_for_deinit(self); - return mp_obj_new_bool(common_hal_audiopwmio_audioout_get_paused(self)); + return mp_obj_new_bool(common_hal_audiopwmio_pwmaudioout_get_paused(self)); } -MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_audioout_get_paused_obj, audiopwmio_audioout_obj_get_paused); +MP_DEFINE_CONST_FUN_OBJ_1(audiopwmio_pwmaudioout_get_paused_obj, audiopwmio_pwmaudioout_obj_get_paused); -const mp_obj_property_t audiopwmio_audioout_paused_obj = { +const mp_obj_property_t audiopwmio_pwmaudioout_paused_obj = { .base.type = &mp_type_property, - .proxy = {(mp_obj_t)&audiopwmio_audioout_get_paused_obj, + .proxy = {(mp_obj_t)&audiopwmio_pwmaudioout_get_paused_obj, (mp_obj_t)&mp_const_none_obj, (mp_obj_t)&mp_const_none_obj}, }; -STATIC const mp_rom_map_elem_t audiopwmio_audioout_locals_dict_table[] = { +STATIC const mp_rom_map_elem_t audiopwmio_pwmaudioout_locals_dict_table[] = { // Methods - { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiopwmio_audioout_deinit_obj) }, + { MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&audiopwmio_pwmaudioout_deinit_obj) }, { MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) }, - { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiopwmio_audioout___exit___obj) }, - { MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiopwmio_audioout_play_obj) }, - { MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiopwmio_audioout_stop_obj) }, - { MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&audiopwmio_audioout_pause_obj) }, - { MP_ROM_QSTR(MP_QSTR_resume), MP_ROM_PTR(&audiopwmio_audioout_resume_obj) }, + { MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&audiopwmio_pwmaudioout___exit___obj) }, + { MP_ROM_QSTR(MP_QSTR_play), MP_ROM_PTR(&audiopwmio_pwmaudioout_play_obj) }, + { MP_ROM_QSTR(MP_QSTR_stop), MP_ROM_PTR(&audiopwmio_pwmaudioout_stop_obj) }, + { MP_ROM_QSTR(MP_QSTR_pause), MP_ROM_PTR(&audiopwmio_pwmaudioout_pause_obj) }, + { MP_ROM_QSTR(MP_QSTR_resume), MP_ROM_PTR(&audiopwmio_pwmaudioout_resume_obj) }, // Properties - { MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiopwmio_audioout_playing_obj) }, - { MP_ROM_QSTR(MP_QSTR_paused), MP_ROM_PTR(&audiopwmio_audioout_paused_obj) }, + { MP_ROM_QSTR(MP_QSTR_playing), MP_ROM_PTR(&audiopwmio_pwmaudioout_playing_obj) }, + { MP_ROM_QSTR(MP_QSTR_paused), MP_ROM_PTR(&audiopwmio_pwmaudioout_paused_obj) }, }; -STATIC MP_DEFINE_CONST_DICT(audiopwmio_audioout_locals_dict, audiopwmio_audioout_locals_dict_table); +STATIC MP_DEFINE_CONST_DICT(audiopwmio_pwmaudioout_locals_dict, audiopwmio_pwmaudioout_locals_dict_table); -const mp_obj_type_t audiopwmio_audioout_type = { +const mp_obj_type_t audiopwmio_pwmaudioout_type = { { &mp_type_type }, .name = MP_QSTR_PWMAudioOut, - .make_new = audiopwmio_audioout_make_new, - .locals_dict = (mp_obj_dict_t*)&audiopwmio_audioout_locals_dict, + .make_new = audiopwmio_pwmaudioout_make_new, + .locals_dict = (mp_obj_dict_t*)&audiopwmio_pwmaudioout_locals_dict, }; diff --git a/shared-bindings/audiopwmio/AudioOut.h b/shared-bindings/audiopwmio/PWMAudioOut.h similarity index 67% rename from shared-bindings/audiopwmio/AudioOut.h rename to shared-bindings/audiopwmio/PWMAudioOut.h index 7fb0e0f331..22afc70d38 100644 --- a/shared-bindings/audiopwmio/AudioOut.h +++ b/shared-bindings/audiopwmio/PWMAudioOut.h @@ -27,23 +27,23 @@ #ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H #define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H -#include "common-hal/audiopwmio/AudioOut.h" +#include "common-hal/audiopwmio/PWMAudioOut.h" #include "common-hal/microcontroller/Pin.h" #include "shared-bindings/audiocore/RawSample.h" -extern const mp_obj_type_t audiopwmio_audioout_type; +extern const mp_obj_type_t audiopwmio_pwmaudioout_type; // left_channel will always be non-NULL but right_channel may be for mono output. -void common_hal_audiopwmio_audioout_construct(audiopwmio_audioout_obj_t* self, +void common_hal_audiopwmio_pwmaudioout_construct(audiopwmio_pwmaudioout_obj_t* self, const mcu_pin_obj_t* left_channel, const mcu_pin_obj_t* right_channel, uint16_t default_value); -void common_hal_audiopwmio_audioout_deinit(audiopwmio_audioout_obj_t* self); -bool common_hal_audiopwmio_audioout_deinited(audiopwmio_audioout_obj_t* self); -void common_hal_audiopwmio_audioout_play(audiopwmio_audioout_obj_t* self, mp_obj_t sample, bool loop); -void common_hal_audiopwmio_audioout_stop(audiopwmio_audioout_obj_t* self); -bool common_hal_audiopwmio_audioout_get_playing(audiopwmio_audioout_obj_t* self); -void common_hal_audiopwmio_audioout_pause(audiopwmio_audioout_obj_t* self); -void common_hal_audiopwmio_audioout_resume(audiopwmio_audioout_obj_t* self); -bool common_hal_audiopwmio_audioout_get_paused(audiopwmio_audioout_obj_t* self); +void common_hal_audiopwmio_pwmaudioout_deinit(audiopwmio_pwmaudioout_obj_t* self); +bool common_hal_audiopwmio_pwmaudioout_deinited(audiopwmio_pwmaudioout_obj_t* self); +void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, mp_obj_t sample, bool loop); +void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t* self); +bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* self); +void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t* self); +void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t* self); +bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t* self); #endif // MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOPWMIO_AUDIOOUT_H diff --git a/shared-bindings/audiopwmio/__init__.c b/shared-bindings/audiopwmio/__init__.c index 6253d1e8e7..aa41b0d4bb 100644 --- a/shared-bindings/audiopwmio/__init__.c +++ b/shared-bindings/audiopwmio/__init__.c @@ -31,7 +31,7 @@ #include "shared-bindings/microcontroller/Pin.h" #include "shared-bindings/audiopwmio/__init__.h" -#include "shared-bindings/audiopwmio/AudioOut.h" +#include "shared-bindings/audiopwmio/PWMAudioOut.h" //| :mod:`audiopwmio` --- Support for audio input and output //| ======================================================== @@ -60,7 +60,7 @@ STATIC const mp_rom_map_elem_t audiopwmio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiopwmio) }, - { MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audiopwmio_audioout_type) }, + { MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audiopwmio_pwmaudioout_type) }, }; STATIC MP_DEFINE_CONST_DICT(audiopwmio_module_globals, audiopwmio_module_globals_table); From 3961014a9e3d9b3698a686838c3fc1b5530a148b Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 29 Jul 2019 17:43:22 -0700 Subject: [PATCH 10/13] Update doc comments for PWMAudioOut --- shared-bindings/audiopwmio/PWMAudioOut.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/shared-bindings/audiopwmio/PWMAudioOut.c b/shared-bindings/audiopwmio/PWMAudioOut.c index 042da270db..92543d1128 100644 --- a/shared-bindings/audiopwmio/PWMAudioOut.c +++ b/shared-bindings/audiopwmio/PWMAudioOut.c @@ -38,14 +38,14 @@ //| .. currentmodule:: audiopwmio //| -//| :class:`AudioOut` -- Output an analog audio signal +//| :class:`PWMAudioOut` -- Output an analog audio signal //| ======================================================== //| //| AudioOut can be used to output an analog audio signal on a given pin. //| -//| .. class:: AudioOut(left_channel, *, right_channel=None, quiescent_value=0x8000) +//| .. class:: PWMAudioOut(left_channel, *, right_channel=None, quiescent_value=0x8000) //| -//| Create a AudioOut object associated with the given pin(s). This allows you to +//| Create a PWMAudioOut object associated with the given pin(s). This allows you to //| play audio signals out on the given pin(s). In contrast to mod:`audioio`, //| the pin(s) specified are digital pins, and are driven with a device-dependent PWM //| signal. @@ -70,7 +70,7 @@ //| for i in range(length): //| sine_wave[i] = int(math.sin(math.pi * 2 * i / 18) * (2 ** 15) + 2 ** 15) //| -//| dac = audiopwmio.AudioOut(board.SPEAKER) +//| dac = audiopwmio.PWMAudioOut(board.SPEAKER) //| sine_wave = audiocore.RawSample(sine_wave, sample_rate=8000) //| dac.play(sine_wave, loop=True) //| time.sleep(1) @@ -89,7 +89,7 @@ //| //| data = open("cplay-5.1-16bit-16khz.wav", "rb") //| wav = audiocore.WaveFile(data) -//| a = audiopwmio.AudioOut(board.SPEAKER) +//| a = audiopwmio.PWMAudioOut(board.SPEAKER) //| //| print("playing") //| a.play(wav) @@ -128,7 +128,7 @@ STATIC mp_obj_t audiopwmio_pwmaudioout_make_new(const mp_obj_type_t *type, size_ //| .. method:: deinit() //| -//| Deinitialises the AudioOut and releases any hardware resources for reuse. +//| Deinitialises the PWMAudioOut and releases any hardware resources for reuse. //| STATIC mp_obj_t audiopwmio_pwmaudioout_deinit(mp_obj_t self_in) { audiopwmio_pwmaudioout_obj_t *self = MP_OBJ_TO_PTR(self_in); From 3b3a7bbd064c5722946f09d5a7bfa90d7eee9b52 Mon Sep 17 00:00:00 2001 From: Scott Shawcroft Date: Mon, 29 Jul 2019 17:45:06 -0700 Subject: [PATCH 11/13] Update pwmaudioio module for PWMAudioOut --- shared-bindings/audiopwmio/__init__.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shared-bindings/audiopwmio/__init__.c b/shared-bindings/audiopwmio/__init__.c index aa41b0d4bb..8a2b202b36 100644 --- a/shared-bindings/audiopwmio/__init__.c +++ b/shared-bindings/audiopwmio/__init__.c @@ -47,7 +47,7 @@ //| .. toctree:: //| :maxdepth: 3 //| -//| AudioOut +//| PWMAudioOut //| //| All classes change hardware state and should be deinitialized when they //| are no longer needed if the program continues after use. To do so, either @@ -60,7 +60,7 @@ STATIC const mp_rom_map_elem_t audiopwmio_module_globals_table[] = { { MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiopwmio) }, - { MP_ROM_QSTR(MP_QSTR_AudioOut), MP_ROM_PTR(&audiopwmio_pwmaudioout_type) }, + { MP_ROM_QSTR(MP_QSTR_PWMAudioOut), MP_ROM_PTR(&audiopwmio_pwmaudioout_type) }, }; STATIC MP_DEFINE_CONST_DICT(audiopwmio_module_globals, audiopwmio_module_globals_table); From 76f65ac6949cae1123c581d7cfed1209c5e9d3cf Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Wed, 31 Jul 2019 20:02:56 -0500 Subject: [PATCH 12/13] Implement play/pause .. and also incidentally fix a problem where a RawSample could only be looped 131070 times. --- ports/nrf/common-hal/audiopwmio/PWMAudioOut.c | 27 +++++++++---------- 1 file changed, 12 insertions(+), 15 deletions(-) diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c index b4c409bb67..6e22df7c32 100644 --- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c @@ -125,25 +125,21 @@ STATIC void fill_buffers(audiopwmio_pwmaudioout_obj_t *self, int buf) { if (self->loop && get_buffer_result == GET_BUFFER_DONE) { audiosample_reset_buffer(self->sample, false, 0); } else if(get_buffer_result == GET_BUFFER_DONE) { - self->pwm->LOOP = 0; + self->pwm->SHORTS = NRF_PWM_SHORT_SEQEND0_STOP_MASK | NRF_PWM_SHORT_SEQEND1_STOP_MASK; self->stopping = true; - } else { - self->pwm->LOOP = 0xffff; } } STATIC void audiopwmout_background_obj(audiopwmio_pwmaudioout_obj_t *self) { if(!common_hal_audiopwmio_pwmaudioout_get_playing(self)) return; - if(self->loop && self->single_buffer) { - self->pwm->LOOP = 0xffff; - } else if(self->stopping) { + if(self->stopping) { bool stopped = (self->pwm->EVENTS_SEQEND[0] || !self->pwm->EVENTS_SEQSTARTED[0]) && (self->pwm->EVENTS_SEQEND[1] || !self->pwm->EVENTS_SEQSTARTED[1]); if(stopped) self->pwm->TASKS_STOP = 1; - } else if(!self->single_buffer) { + } else if(!self->paused && !self->single_buffer) { if(self->pwm->EVENTS_SEQSTARTED[0]) fill_buffers(self, 1); if(self->pwm->EVENTS_SEQSTARTED[1]) fill_buffers(self, 0); } @@ -248,12 +244,7 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, self->scale = top-1; self->pwm->COUNTERTOP = top; - if(!self->single_buffer) - self->pwm->LOOP = 1; - else if(self->loop) - self->pwm->LOOP = 0xffff; - else - self->pwm->LOOP = 0; + self->pwm->LOOP = 1; audiosample_reset_buffer(self->sample, false, 0); activate_audiopwmout_obj(self); fill_buffers(self, 0); @@ -261,8 +252,9 @@ void common_hal_audiopwmio_pwmaudioout_play(audiopwmio_pwmaudioout_obj_t* self, self->pwm->SEQ[1].CNT = self->pwm->SEQ[0].CNT; self->pwm->EVENTS_SEQSTARTED[0] = 0; self->pwm->EVENTS_SEQSTARTED[1] = 0; - self->pwm->TASKS_SEQSTART[0] = 1; self->pwm->EVENTS_STOPPED = 0; + self->pwm->SHORTS = NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK; + self->pwm->TASKS_SEQSTART[0] = 1; self->playing = true; self->stopping = false; self->paused = false; @@ -282,7 +274,7 @@ void common_hal_audiopwmio_pwmaudioout_stop(audiopwmio_pwmaudioout_obj_t* self) } bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* self) { - if(self->pwm->EVENTS_STOPPED) { + if(!self->paused && self->pwm->EVENTS_STOPPED) { self->playing = false; self->pwm->EVENTS_STOPPED = 0; } @@ -307,10 +299,15 @@ bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* */ void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t* self) { self->paused = true; + self->pwm->SHORTS = NRF_PWM_SHORT_SEQEND1_STOP_MASK; + while(!self->pwm->EVENTS_STOPPED) { /* NOTHING */ } } void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t* self) { self->paused = false; + self->pwm->SHORTS = NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK; + self->pwm->EVENTS_STOPPED = 0; + self->pwm->TASKS_SEQSTART[0] = 1; } bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t* self) { From 77bc1ba03e75bb772d6fb0ce7096d870d95f1ad0 Mon Sep 17 00:00:00 2001 From: Jeff Epler Date: Sat, 3 Aug 2019 08:19:25 -0500 Subject: [PATCH 13/13] nrf: PWMAudioOut: Remove the need to wait in "pause" The original formulation was because I saw the need to avoid a transition from playing to stopped exactly when a resume was taking place. However, @tannewt was concerned about this pause causing trouble, because it could be relatively lengthy (several ms even in a typical case). After reflection, I've convinced myself that updating the registers in this order in resume avoids a window where a "stopped" event can be missed as long as the shortcut is updated first. Testing re-performed: pause/resume testing of looped RawSample and WaveFile audio sources. --- ports/nrf/common-hal/audiopwmio/PWMAudioOut.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c index 6e22df7c32..0321b751ca 100644 --- a/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c +++ b/ports/nrf/common-hal/audiopwmio/PWMAudioOut.c @@ -295,19 +295,20 @@ bool common_hal_audiopwmio_pwmaudioout_get_playing(audiopwmio_pwmaudioout_obj_t* * Perhaps the way forward is to divide even "single buffer" samples into tasks of * only a few ms long, so that they can be stopped/restarted quickly enough that it * feels instant. (This also saves on memory, for long in-memory "single buffer" - * samples!) + * samples, since we have to locally take a resampled copy!) */ void common_hal_audiopwmio_pwmaudioout_pause(audiopwmio_pwmaudioout_obj_t* self) { self->paused = true; self->pwm->SHORTS = NRF_PWM_SHORT_SEQEND1_STOP_MASK; - while(!self->pwm->EVENTS_STOPPED) { /* NOTHING */ } } void common_hal_audiopwmio_pwmaudioout_resume(audiopwmio_pwmaudioout_obj_t* self) { self->paused = false; self->pwm->SHORTS = NRF_PWM_SHORT_LOOPSDONE_SEQSTART0_MASK; - self->pwm->EVENTS_STOPPED = 0; - self->pwm->TASKS_SEQSTART[0] = 1; + if (self->pwm->EVENTS_STOPPED) { + self->pwm->EVENTS_STOPPED = 0; + self->pwm->TASKS_SEQSTART[0] = 1; + } } bool common_hal_audiopwmio_pwmaudioout_get_paused(audiopwmio_pwmaudioout_obj_t* self) {