2023-05-01 10:41:05 -04:00
|
|
|
/*
|
|
|
|
* This file is part of the MicroPython project, http://micropython.org/
|
|
|
|
*
|
|
|
|
* The MIT License (MIT)
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Jeff Epler for Adafruit Industries
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
* of this software and associated documentation files (the "Software"), to deal
|
|
|
|
* in the Software without restriction, including without limitation the rights
|
|
|
|
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
* copies of the Software, and to permit persons to whom the Software is
|
|
|
|
* furnished to do so, subject to the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be included in
|
|
|
|
* all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
* THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "shared-module/synthio/__init__.h"
|
2023-05-29 11:53:48 -04:00
|
|
|
#include "shared-module/synthio/Biquad.h"
|
2023-05-15 11:49:42 -04:00
|
|
|
#include "shared-module/synthio/LFO.h"
|
2023-05-10 09:40:09 -04:00
|
|
|
#include "shared-bindings/synthio/__init__.h"
|
2023-05-01 10:41:05 -04:00
|
|
|
|
|
|
|
typedef struct synthio_note_obj {
|
|
|
|
mp_obj_base_t base;
|
|
|
|
|
2023-05-17 16:05:34 -04:00
|
|
|
synthio_block_slot_t panning, bend, amplitude, ring_bend;
|
2023-05-15 11:49:42 -04:00
|
|
|
|
2023-05-10 13:07:01 -04:00
|
|
|
mp_float_t frequency, ring_frequency;
|
|
|
|
mp_obj_t waveform_obj, envelope_obj, ring_waveform_obj;
|
2023-05-29 11:53:48 -04:00
|
|
|
mp_obj_t filter_obj;
|
|
|
|
|
|
|
|
biquad_filter_state filter_state;
|
2023-05-01 10:41:05 -04:00
|
|
|
|
|
|
|
int32_t sample_rate;
|
|
|
|
|
|
|
|
int32_t frequency_scaled;
|
2023-05-15 11:49:42 -04:00
|
|
|
int32_t ring_frequency_scaled, ring_frequency_bent;
|
2023-05-01 10:41:05 -04:00
|
|
|
|
|
|
|
mp_buffer_info_t waveform_buf;
|
2023-05-10 13:07:01 -04:00
|
|
|
mp_buffer_info_t ring_waveform_buf;
|
2023-05-01 10:41:05 -04:00
|
|
|
synthio_envelope_definition_t envelope_def;
|
|
|
|
} synthio_note_obj_t;
|
|
|
|
|
|
|
|
void synthio_note_recalculate(synthio_note_obj_t *self, int32_t sample_rate);
|
2023-05-10 12:16:22 -04:00
|
|
|
uint32_t synthio_note_step(synthio_note_obj_t *self, int32_t sample_rate, int16_t dur, uint16_t loudness[2]);
|
2023-05-01 10:41:05 -04:00
|
|
|
void synthio_note_start(synthio_note_obj_t *self, int32_t sample_rate);
|
|
|
|
bool synthio_note_playing(synthio_note_obj_t *self);
|