Make synthio debuggable in unix coverage port
This commit is contained in:
parent
db1e01c462
commit
13e17e6dcd
|
@ -30,15 +30,23 @@ SRC_BITMAP := \
|
|||
displayio_min.c \
|
||||
shared-bindings/aesio/aes.c \
|
||||
shared-bindings/aesio/__init__.c \
|
||||
shared-bindings/audiocore/__init__.c \
|
||||
shared-bindings/audiocore/RawSample.c \
|
||||
shared-bindings/audiocore/WaveFile.c \
|
||||
shared-bindings/bitmaptools/__init__.c \
|
||||
shared-bindings/displayio/Bitmap.c \
|
||||
shared-bindings/rainbowio/__init__.c \
|
||||
shared-bindings/struct/__init__.c \
|
||||
shared-bindings/synthio/__init__.c \
|
||||
shared-bindings/synthio/MidiTrack.c \
|
||||
shared-bindings/traceback/__init__.c \
|
||||
shared-bindings/util.c \
|
||||
shared-bindings/zlib/__init__.c \
|
||||
shared-module/aesio/aes.c \
|
||||
shared-module/aesio/__init__.c \
|
||||
shared-module/audiocore/__init__.c \
|
||||
shared-module/audiocore/RawSample.c \
|
||||
shared-module/audiocore/WaveFile.c \
|
||||
shared-module/bitmaptools/__init__.c \
|
||||
shared-module/displayio/area.c \
|
||||
shared-module/displayio/Bitmap.c \
|
||||
|
@ -47,6 +55,8 @@ SRC_BITMAP := \
|
|||
shared-module/os/getenv.c \
|
||||
shared-module/rainbowio/__init__.c \
|
||||
shared-module/struct/__init__.c \
|
||||
shared-module/synthio/__init__.c \
|
||||
shared-module/synthio/MidiTrack.c \
|
||||
shared-module/traceback/__init__.c \
|
||||
shared-module/zlib/__init__.c \
|
||||
|
||||
|
@ -54,12 +64,16 @@ SRC_C += $(SRC_BITMAP)
|
|||
|
||||
CFLAGS += \
|
||||
-DCIRCUITPY_AESIO=1 \
|
||||
-DCIRCUITPY_AUDIOCORE=1 \
|
||||
-DCIRCUITPY_AUDIOCORE_DEBUG=1 \
|
||||
-DCIRCUITPY_BITMAPTOOLS=1 \
|
||||
-DCIRCUITPY_DISPLAYIO_UNIX=1 \
|
||||
-DCIRCUITPY_OS_GETENV=1 \
|
||||
-DCIRCUITPY_GIFIO=1 \
|
||||
-DCIRCUITPY_OS_GETENV=1 \
|
||||
-DCIRCUITPY_RAINBOWIO=1 \
|
||||
-DCIRCUITPY_STRUCT=1 \
|
||||
-DCIRCUITPY_SYNTHIO=1 \
|
||||
-DCIRCUITPY_SYNTHIO_MAX_CHANNELS=14 \
|
||||
-DCIRCUITPY_TRACEBACK=1 \
|
||||
-DCIRCUITPY_ZLIB=1
|
||||
|
||||
|
|
|
@ -107,6 +107,11 @@ CFLAGS += -DCIRCUITPY_AUDIOCORE=$(CIRCUITPY_AUDIOCORE)
|
|||
CIRCUITPY_AUDIOMIXER ?= $(CIRCUITPY_AUDIOIO)
|
||||
CFLAGS += -DCIRCUITPY_AUDIOMIXER=$(CIRCUITPY_AUDIOMIXER)
|
||||
|
||||
ifndef CIRCUITPY_AUDIOCORE_DEBUG
|
||||
CIRCUITPY_AUDIOCORE_DEBUG ?= 0
|
||||
endif
|
||||
CFLAGS += -DCIRCUITPY_AUDIOCORE_DEBUG=$(CIRCUITPY_AUDIOCORE_DEBUG)
|
||||
|
||||
ifndef CIRCUITPY_AUDIOMP3
|
||||
ifeq ($(CIRCUITPY_FULL_BUILD),1)
|
||||
CIRCUITPY_AUDIOMP3 = $(CIRCUITPY_AUDIOCORE)
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include "shared-bindings/audiocore/WaveFile.h"
|
||||
#include "shared-bindings/util.h"
|
||||
#include "supervisor/shared/translate/translate.h"
|
||||
#include "extmod/vfs_posix.h"
|
||||
|
||||
//| class WaveFile:
|
||||
//| """Load a wave file for audio playback
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
|
||||
#include "shared-bindings/microcontroller/Pin.h"
|
||||
#include "shared-bindings/audiocore/__init__.h"
|
||||
#include "shared-bindings/audiocore/RawSample.h"
|
||||
#include "shared-bindings/audiocore/WaveFile.h"
|
||||
|
@ -37,10 +36,57 @@
|
|||
|
||||
//| """Support for audio samples"""
|
||||
|
||||
#if CIRCUITPY_AUDIOCORE_DEBUG
|
||||
// (no docstrings so that the debug functions are not shown on docs.circuitpython.org)
|
||||
STATIC mp_obj_t audiocore_get_buffer(mp_obj_t sample_in) {
|
||||
uint8_t *buffer = NULL;
|
||||
uint32_t buffer_length = 0;
|
||||
audioio_get_buffer_result_t gbr = audiosample_get_buffer(sample_in, false, 0, &buffer, &buffer_length);
|
||||
|
||||
mp_obj_t result[2] = {mp_obj_new_int_from_uint(gbr), mp_const_none};
|
||||
|
||||
if (gbr != GET_BUFFER_ERROR) {
|
||||
// copies the data because the gc semantics of get_buffer are unclear
|
||||
result[1] = mp_obj_new_bytes(buffer, buffer_length);
|
||||
}
|
||||
|
||||
return mp_obj_new_tuple(2, result);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiocore_get_buffer_obj, audiocore_get_buffer);
|
||||
|
||||
STATIC mp_obj_t audiocore_get_structure(mp_obj_t sample_in) {
|
||||
bool single_buffer, samples_signed;
|
||||
uint32_t max_buffer_length;
|
||||
uint8_t spacing;
|
||||
|
||||
audiosample_get_buffer_structure(sample_in, false, &single_buffer, &samples_signed, &max_buffer_length, &spacing);
|
||||
mp_obj_t result[4] = {
|
||||
mp_obj_new_int_from_uint(single_buffer),
|
||||
mp_obj_new_int_from_uint(samples_signed),
|
||||
mp_obj_new_int_from_uint(max_buffer_length),
|
||||
mp_obj_new_int_from_uint(spacing),
|
||||
};
|
||||
return mp_obj_new_tuple(4, result);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiocore_get_structure_obj, audiocore_get_structure);
|
||||
|
||||
STATIC mp_obj_t audiocore_reset_buffer(mp_obj_t sample_in) {
|
||||
audiosample_reset_buffer(sample_in, false, 0);
|
||||
return mp_const_none;
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(audiocore_reset_buffer_obj, audiocore_reset_buffer);
|
||||
|
||||
#endif
|
||||
|
||||
STATIC const mp_rom_map_elem_t audiocore_module_globals_table[] = {
|
||||
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_audiocore) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_RawSample), MP_ROM_PTR(&audioio_rawsample_type) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_WaveFile), MP_ROM_PTR(&audioio_wavefile_type) },
|
||||
#if CIRCUITPY_AUDIOCORE_DEBUG
|
||||
{ MP_ROM_QSTR(MP_QSTR_get_buffer), MP_ROM_PTR(&audiocore_get_buffer_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_reset_buffer), MP_ROM_PTR(&audiocore_reset_buffer_obj) },
|
||||
{ MP_ROM_QSTR(MP_QSTR_get_structure), MP_ROM_PTR(&audiocore_get_structure_obj) },
|
||||
#endif
|
||||
};
|
||||
|
||||
STATIC MP_DEFINE_CONST_DICT(audiocore_module_globals, audiocore_module_globals_table);
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
#ifndef MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMIXER_MIXER_H
|
||||
#define MICROPY_INCLUDED_SHARED_BINDINGS_AUDIOMIXER_MIXER_H
|
||||
|
||||
#include "common-hal/microcontroller/Pin.h"
|
||||
#include "shared-module/audiomixer/Mixer.h"
|
||||
#include "shared-bindings/audiocore/RawSample.h"
|
||||
|
||||
|
|
|
@ -30,6 +30,7 @@
|
|||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "extmod/vfs_fat.h"
|
||||
#include "extmod/vfs_posix.h"
|
||||
|
||||
#include "shared-bindings/synthio/__init__.h"
|
||||
#include "shared-bindings/synthio/MidiTrack.h"
|
||||
|
@ -115,7 +116,11 @@ STATIC mp_obj_t synthio_from_file(size_t n_args, const mp_obj_t *pos_args, mp_ma
|
|||
common_hal_synthio_miditrack_construct(result, buffer, track_size,
|
||||
tempo, args[ARG_sample_rate].u_int);
|
||||
|
||||
#if MICROPY_MALLOC_USES_ALLOCATED_SIZE
|
||||
m_free(buffer, track_size);
|
||||
#else
|
||||
m_free(buffer);
|
||||
#endif
|
||||
|
||||
return MP_OBJ_FROM_PTR(result);
|
||||
}
|
||||
|
|
|
@ -57,8 +57,7 @@ STATIC void terminate_span(synthio_miditrack_obj_t *self, uint16_t *dur) {
|
|||
}
|
||||
|
||||
STATIC void add_span(synthio_miditrack_obj_t *self, const synthio_midi_span_t *span) {
|
||||
self->track = m_realloc(self->track,
|
||||
(self->total_spans + 1) * sizeof(synthio_midi_span_t));
|
||||
self->track = m_renew(synthio_midi_span_t, self->track, self->total_spans, self->total_spans + 1);
|
||||
self->track[self->total_spans++] = *span;
|
||||
}
|
||||
|
||||
|
@ -151,9 +150,9 @@ void common_hal_synthio_miditrack_construct(synthio_miditrack_obj_t *self,
|
|||
}
|
||||
|
||||
void common_hal_synthio_miditrack_deinit(synthio_miditrack_obj_t *self) {
|
||||
m_free(self->buffer);
|
||||
m_del(uint8_t, self->buffer, self->buffer_length);
|
||||
self->buffer = NULL;
|
||||
m_free(self->track);
|
||||
m_del(synthio_midi_span_t, self->track, self->total_spans + 1);
|
||||
self->track = NULL;
|
||||
}
|
||||
bool common_hal_synthio_miditrack_deinited(synthio_miditrack_obj_t *self) {
|
||||
|
|
Loading…
Reference in New Issue