By placing certain fields in a fixed location in all sample types, code can be reduced & reused. For instance, the same property object can be used for every sample type's `sample_rate` property. The sample proto functions like `sample_rate` become superfluous since once an object is verified to support the audiosample protocol, direct access to the fields in the base object is possible.
29 lines
857 B
C
29 lines
857 B
C
// This file is part of the CircuitPython project: https://circuitpython.org
|
|
//
|
|
// SPDX-FileCopyrightText: Copyright (c) 2021 Artyom Skrobov
|
|
// SPDX-FileCopyrightText: Copyright (c) 2023 Jeff Epler for Adafruit Industries
|
|
//
|
|
// SPDX-License-Identifier: MIT
|
|
|
|
#pragma once
|
|
|
|
#include "py/obj.h"
|
|
|
|
#include "shared-module/synthio/__init__.h"
|
|
|
|
typedef struct {
|
|
synthio_synth_t synth;
|
|
mp_obj_t blocks;
|
|
} synthio_synthesizer_obj_t;
|
|
|
|
|
|
// These are not available from Python because it may be called in an interrupt.
|
|
void synthio_synthesizer_reset_buffer(synthio_synthesizer_obj_t *self,
|
|
bool single_channel_output,
|
|
uint8_t channel);
|
|
|
|
audioio_get_buffer_result_t synthio_synthesizer_get_buffer(synthio_synthesizer_obj_t *self,
|
|
bool single_channel_output,
|
|
uint8_t channel,
|
|
uint8_t **buffer,
|
|
uint32_t *buffer_length); // length in bytes
|