Ye
This commit is contained in:
parent
0daca6f46b
commit
09b1a6707a
14
main.c
14
main.c
@ -3,7 +3,6 @@
|
||||
#include <sys/types.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
|
||||
#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) {}
|
||||
}
|
||||
|
||||
|
||||
3
pwm.c
3
pwm.c
@ -1,5 +1,6 @@
|
||||
#include <hardware/pwm.h>
|
||||
#include <pico/types.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#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);
|
||||
|
||||
6
synth.cc
6
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;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user