use a MixerVoice constructor

This commit is contained in:
sommersoft 2019-08-24 07:56:12 -05:00
parent 1ec4faee55
commit 2c55b40a53
3 changed files with 10 additions and 3 deletions

View File

@ -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);
}

View File

@ -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);

View File

@ -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;
}