summaryrefslogtreecommitdiff
path: root/shared-module
diff options
context:
space:
mode:
authordean <deanm1278@gmail.com>2018-11-15 14:11:45 -0500
committerdean <deanm1278@gmail.com>2018-11-15 14:11:45 -0500
commitdd05aafb9bcbfeae77ce8b21b425b26e67891082 (patch)
tree48dc29c5b18c984f7e3656e341641a58d687df77 /shared-module
parent59c6ed34fdb7312de4747110d6a40f67a8787f13 (diff)
DM: adding mixer voice API
Diffstat (limited to 'shared-module')
-rw-r--r--shared-module/audioio/Mixer.c9
-rw-r--r--shared-module/audioio/Mixer.h12
-rw-r--r--shared-module/audioio/MixerVoice.c18
-rw-r--r--shared-module/audioio/MixerVoice.h12
4 files changed, 34 insertions, 17 deletions
diff --git a/shared-module/audioio/Mixer.c b/shared-module/audioio/Mixer.c
index 5125574ef..4797f4adc 100644
--- a/shared-module/audioio/Mixer.c
+++ b/shared-module/audioio/Mixer.c
@@ -100,7 +100,7 @@ void common_hal_audioio_mixer_play(audioio_mixer_obj_t* self, mp_obj_t sample, u
if (samples_signed != self->samples_signed) {
mp_raise_ValueError(translate("The sample's signedness does not match the mixer's"));
}
- audioio_mixer_voice_obj_t* voice = &self->voice[v];
+ audioio_mixervoice_obj_t* voice = &self->voice[v];
voice->sample = sample;
voice->loop = loop;
@@ -132,11 +132,6 @@ void audioio_mixer_reset_buffer(audioio_mixer_obj_t* self,
}
}
-void common_hal_audioio_mixer_set_gain(audioio_mixer_obj_t* self, uint8_t voice, float gain) {
- audioio_mixer_voice_obj_t* v = &self->voice[voice];
- v->gain = gain * ((1 << 15)-1);
-}
-
uint32_t add8signed(uint32_t a, uint32_t b) {
#if (defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1))
return __QADD8(a, b);
@@ -311,7 +306,7 @@ audioio_get_buffer_result_t audioio_mixer_get_buffer(audioio_mixer_obj_t* self,
self->use_first_buffer = !self->use_first_buffer;
bool voices_active = false;
for (int32_t v = 0; v < self->voice_count; v++) {
- audioio_mixer_voice_obj_t* voice = &self->voice[v];
+ audioio_mixervoice_obj_t* voice = &self->voice[v];
uint32_t j = 0;
bool voice_done = voice->sample == NULL;
diff --git a/shared-module/audioio/Mixer.h b/shared-module/audioio/Mixer.h
index 3451aa25d..40b6df2fe 100644
--- a/shared-module/audioio/Mixer.h
+++ b/shared-module/audioio/Mixer.h
@@ -30,15 +30,7 @@
#include "py/obj.h"
#include "shared-module/audioio/__init__.h"
-
-typedef struct {
- mp_obj_t sample;
- bool loop;
- bool more_data;
- uint32_t* remaining_buffer;
- uint32_t buffer_length;
- int16_t gain;
-} audioio_mixer_voice_obj_t;
+#include "shared-bindings/audioio/MixerVoice.h"
typedef struct {
mp_obj_base_t base;
@@ -56,7 +48,7 @@ typedef struct {
uint32_t right_read_count;
uint8_t voice_count;
- audioio_mixer_voice_obj_t voice[];
+ mp_obj_t voice[];
} audioio_mixer_obj_t;
diff --git a/shared-module/audioio/MixerVoice.c b/shared-module/audioio/MixerVoice.c
new file mode 100644
index 000000000..ff40da34c
--- /dev/null
+++ b/shared-module/audioio/MixerVoice.c
@@ -0,0 +1,18 @@
+/*
+ * MixerVoice.c
+ *
+ * Created on: Nov 15, 2018
+ * Author: dean
+ */
+
+#include "shared-bindings/audioio/Mixer.h"
+
+#include <stdint.h>
+
+#include "py/runtime.h"
+#include "shared-module/audioio/__init__.h"
+#include "shared-module/audioio/RawSample.h"
+
+void common_hal_audioio_mixervoice_set_gain(audioio_mixer_obj_t* self, float gain) {
+ self->gain = gain * ((1 << 15)-1);
+}
diff --git a/shared-module/audioio/MixerVoice.h b/shared-module/audioio/MixerVoice.h
new file mode 100644
index 000000000..c04e8ef24
--- /dev/null
+++ b/shared-module/audioio/MixerVoice.h
@@ -0,0 +1,12 @@
+/*
+ * MixerVoice.h
+ *
+ * Created on: Nov 15, 2018
+ * Author: dean
+ */
+
+#ifndef SHARED_MODULE_AUDIOIO_MIXERVOICE_H_
+#define SHARED_MODULE_AUDIOIO_MIXERVOICE_H_
+
+
+#endif /* SHARED_MODULE_AUDIOIO_MIXERVOICE_H_ */