From 09b1a6707acd53c886ce00b088dc7c64ab4c9d3e Mon Sep 17 00:00:00 2001 From: Tom-on64 Date: Sat, 25 Apr 2026 03:05:25 +0200 Subject: [PATCH] Ye --- main.c | 14 +++++++++----- pwm.c | 3 ++- synth.cc | 6 ++++-- synth.h | 1 + 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/main.c b/main.c index 1324cf7..9ca271c 100644 --- a/main.c +++ b/main.c @@ -3,7 +3,6 @@ #include #include #include -#include #include "hardware/gpio.h" #include "hardware/pwm.h" @@ -23,6 +22,9 @@ state_t state; void init_all() { stdio_init_all(); + + sleep_ms(2000); + puts("Starting PIN initialization"); const uint8_t out_gpio[] = {MUX_S0,MUX_S1,MUX_S2, STATUS_LED}; const uint8_t in_gpio[] = {VCO_BUTTON,QUANT_BUTTON,AMEN_BUTTON}; @@ -43,6 +45,9 @@ void init_all() { adc_select_input(i); } + // Synth + synth_init(); + // PWM bullshit gpio_set_function(AUDIO_OUT, GPIO_FUNC_PWM); @@ -55,6 +60,7 @@ void init_all() { pwm_set_irq_enabled(slice, true); irq_set_exclusive_handler(PWM_IRQ_WRAP, pwm_isr); irq_set_enabled(PWM_IRQ_WRAP, true); + } __attribute__((noreturn)) @@ -62,8 +68,8 @@ void core1_main(void) { while (1) { update_buttons(); update_inputs(); - printf("vco_mode: %d, quant_enabled: %d amen_enabled: %d\n", state.vco_mode,state.quant_enabled,state.amen_enabled); - printf("clock_bpm: %f\n",state.clock_bpm); + //printf("vco_mode: %d, quant_enabled: %d amen_enabled: %d\n", state.vco_mode,state.quant_enabled,state.amen_enabled); + //printf("clock_bpm: %f\n",state.clock_bpm); sleep_ms(1); } } @@ -71,9 +77,7 @@ void core1_main(void) { __attribute__((noreturn)) int main() { init_all(); - multicore_launch_core1(core1_main); - while (1) {} } diff --git a/pwm.c b/pwm.c index 23d7e3c..a2d2b30 100644 --- a/pwm.c +++ b/pwm.c @@ -1,5 +1,6 @@ #include #include +#include #include "const.h" #include "synth.h" @@ -13,8 +14,8 @@ void pwm_isr(void) { pwm_clear_irq(slice); - // TODO: float sample = get_sample(); + printf("sample: %f\n", sample); uint16_t level = (uint16_t)((sample + 1.0f) * 0.5f * 3400.0f); pwm_set_chan_level(slice, chan, level); diff --git a/synth.cc b/synth.cc index a60c5cc..4c25262 100644 --- a/synth.cc +++ b/synth.cc @@ -72,6 +72,10 @@ void synth_init(void) { } float get_sample(void) { + return osc.Process(); +} + +float _get_sample(void) { float bps = state.clock_bpm / 60.0f; float clock_inc = bps / SAMPLE_RATE; clock_phase += clock_inc; @@ -118,7 +122,5 @@ float get_sample(void) { mix = fclamp(mix, -1.0f, 1.0f); return mix; - - return 0; } diff --git a/synth.h b/synth.h index e3f2fa0..f6f1096 100644 --- a/synth.h +++ b/synth.h @@ -4,6 +4,7 @@ extern "C" { #endif +void synth_init(void); float get_sample(void); #ifdef __cplusplus