summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--shared-bindings/audiocore/MixerVoice.c7
-rw-r--r--shared-bindings/audiocore/MixerVoice.h1
-rw-r--r--shared-module/audiocore/MixerVoice.c5
3 files changed, 10 insertions, 3 deletions
diff --git a/shared-bindings/audiocore/MixerVoice.c b/shared-bindings/audiocore/MixerVoice.c
index 2711be00f..36b3c35fc 100644
--- a/shared-bindings/audiocore/MixerVoice.c
+++ b/shared-bindings/audiocore/MixerVoice.c
@@ -50,10 +50,11 @@
//|
// TODO: support mono or stereo voices
STATIC mp_obj_t audioio_mixervoice_make_new(const mp_obj_type_t *type, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
- audioio_mixervoice_obj_t *self = m_new_obj(audioio_mixervoice_obj_t);
+ audioio_mixervoice_obj_t *self = m_new_obj(audioio_mixervoice_obj_t);
self->base.type = &audioio_mixervoice_type;
- self->sample = NULL;
- self->level = ((1 << 15)-1);
+
+ common_hal_audioio_mixervoice_construct(self);
+
return MP_OBJ_FROM_PTR(self);
}
diff --git a/shared-bindings/audiocore/MixerVoice.h b/shared-bindings/audiocore/MixerVoice.h
index b5e447058..5849ce252 100644
--- a/shared-bindings/audiocore/MixerVoice.h
+++ b/shared-bindings/audiocore/MixerVoice.h
@@ -35,6 +35,7 @@
extern const mp_obj_type_t audioio_mixer_type;
extern const mp_obj_type_t audioio_mixervoice_type;
+void common_hal_audioio_mixervoice_construct(audioio_mixervoice_obj_t *self);
void common_hal_audioio_mixervoice_set_parent(audioio_mixervoice_obj_t* self, audioio_mixer_obj_t *parent);
void common_hal_audioio_mixervoice_play(audioio_mixervoice_obj_t* self, mp_obj_t sample, bool loop);
void common_hal_audioio_mixervoice_stop(audioio_mixervoice_obj_t* self);
diff --git a/shared-module/audiocore/MixerVoice.c b/shared-module/audiocore/MixerVoice.c
index c16dfccb0..a9543a40d 100644
--- a/shared-module/audiocore/MixerVoice.c
+++ b/shared-module/audiocore/MixerVoice.c
@@ -32,6 +32,11 @@
#include "shared-module/audiocore/RawSample.h"
#include "shared-module/audiocore/MixerVoice.h"
+void common_hal_audioio_mixervoice_construct(audioio_mixervoice_obj_t *self) {
+ self->sample = NULL;
+ self->level = ((1 << 15) - 1);
+}
+
void common_hal_audioio_mixervoice_set_parent(audioio_mixervoice_obj_t* self, audioio_mixer_obj_t *parent) {
self->parent = parent;
}