Enable audiomixer on unix port, for testing

This commit is contained in:
Jeff Epler 2023-04-05 08:51:55 -05:00
parent b011468251
commit b9dea05dbf
No known key found for this signature in database
GPG Key ID: D5BF15AB975AB4DE
8 changed files with 19 additions and 17 deletions

View File

@ -33,6 +33,9 @@ SRC_BITMAP := \
shared-bindings/audiocore/__init__.c \
shared-bindings/audiocore/RawSample.c \
shared-bindings/audiocore/WaveFile.c \
shared-bindings/audiomixer/__init__.c \
shared-bindings/audiomixer/Mixer.c \
shared-bindings/audiomixer/MixerVoice.c \
shared-bindings/bitmaptools/__init__.c \
shared-bindings/displayio/Bitmap.c \
shared-bindings/rainbowio/__init__.c \
@ -48,6 +51,9 @@ SRC_BITMAP := \
shared-module/audiocore/__init__.c \
shared-module/audiocore/RawSample.c \
shared-module/audiocore/WaveFile.c \
shared-module/audiomixer/__init__.c \
shared-module/audiomixer/Mixer.c \
shared-module/audiomixer/MixerVoice.c \
shared-module/bitmaptools/__init__.c \
shared-module/displayio/area.c \
shared-module/displayio/Bitmap.c \
@ -67,6 +73,7 @@ SRC_C += $(SRC_BITMAP)
CFLAGS += \
-DCIRCUITPY_AESIO=1 \
-DCIRCUITPY_AUDIOCORE=1 \
-DCIRCUITPY_AUDIOMIXER=1 \
-DCIRCUITPY_AUDIOCORE_DEBUG=1 \
-DCIRCUITPY_BITMAPTOOLS=1 \
-DCIRCUITPY_DISPLAYIO_UNIX=1 \

View File

@ -33,8 +33,6 @@
#include "py/binary.h"
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate/translate.h"

View File

@ -28,7 +28,6 @@
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMIXER_MIXER_H
#include "shared-module/audiomixer/Mixer.h"
#include "shared-bindings/audiocore/RawSample.h"
extern const mp_obj_type_t audiomixer_mixer_type;
extern const mp_obj_type_t audiomixer_mixervoice_type;

View File

@ -32,8 +32,6 @@
#include "py/binary.h"
#include "py/objproperty.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audiocore/RawSample.h"
#include "shared-bindings/util.h"
#include "supervisor/shared/translate/translate.h"
@ -115,7 +113,7 @@ STATIC mp_obj_t audiomixer_mixervoice_obj_set_level(size_t n_args, const mp_obj_
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);
float level = mp_obj_get_float(args[ARG_level].u_obj);
mp_float_t level = mp_obj_get_float(args[ARG_level].u_obj);
if (level > 1 || level < 0) {
mp_raise_ValueError(translate("level must be between 0 and 1"));

View File

@ -26,9 +26,6 @@
#ifndef SHARED_BINDINGS_AUDIOMIXER_MIXERVOICE_H_
#define SHARED_BINDINGS_AUDIOMIXER_MIXERVOICE_H_
#include "common-hal/microcontroller/Pin.h"
#include "shared-bindings/audiocore/RawSample.h"
#include "shared-module/audiomixer/MixerVoice.h"
#include "shared-module/audiomixer/Mixer.h"
@ -39,8 +36,8 @@ void common_hal_audiomixer_mixervoice_construct(audiomixer_mixervoice_obj_t *sel
void common_hal_audiomixer_mixervoice_set_parent(audiomixer_mixervoice_obj_t *self, audiomixer_mixer_obj_t *parent);
void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp_obj_t sample, bool loop);
void common_hal_audiomixer_mixervoice_stop(audiomixer_mixervoice_obj_t *self);
float common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self);
void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, float gain);
mp_float_t common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self);
void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, mp_float_t gain);
bool common_hal_audiomixer_mixervoice_get_playing(audiomixer_mixervoice_obj_t *self);

View File

@ -29,7 +29,6 @@
#include "py/obj.h"
#include "py/runtime.h"
#include "shared-bindings/microcontroller/Pin.h"
#include "shared-bindings/audiomixer/Mixer.h"
//| """Support for audio mixing"""

View File

@ -35,6 +35,10 @@
#include "shared-module/audiocore/__init__.h"
#include "shared-module/audiocore/RawSample.h"
#if (defined(__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1))
#include "periph.h"
#endif
void common_hal_audiomixer_mixer_construct(audiomixer_mixer_obj_t *self,
uint8_t voice_count,
uint32_t buffer_size,
@ -140,7 +144,7 @@ static inline uint32_t mult16signed(uint32_t val, int32_t mul) {
float mod_mul = (float)mul / (float)((1 << 15) - 1);
for (int8_t i = 0; i < 2; i++) {
int16_t ai = (val >> (sizeof(uint16_t) * 8 * i));
int32_t intermediate = ai * mod_mul;
int32_t intermediate = (int32_t)(ai * mod_mul);
if (intermediate > SHRT_MAX) {
intermediate = SHRT_MAX;
} else if (intermediate < SHRT_MIN) {

View File

@ -42,12 +42,12 @@ void common_hal_audiomixer_mixervoice_set_parent(audiomixer_mixervoice_obj_t *se
self->parent = parent;
}
float common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self) {
return (float)self->level / (1 << 15);
mp_float_t common_hal_audiomixer_mixervoice_get_level(audiomixer_mixervoice_obj_t *self) {
return (mp_float_t)self->level / (1 << 15);
}
void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, float level) {
self->level = level * (1 << 15);
void common_hal_audiomixer_mixervoice_set_level(audiomixer_mixervoice_obj_t *self, mp_float_t level) {
self->level = (uint16_t)(level * (1 << 15));
}
void common_hal_audiomixer_mixervoice_play(audiomixer_mixervoice_obj_t *self, mp_obj_t sample, bool loop) {