22 lines
445 B
C
22 lines
445 B
C
#include <hardware/pwm.h>
|
|
#include <pico/types.h>
|
|
|
|
#include "const.h"
|
|
#include "synth.h"
|
|
|
|
#include "pwm.h"
|
|
|
|
void pwm_isr(void) {
|
|
static uint slice = -1, chan = -1;
|
|
if (slice == -1) slice = pwm_gpio_to_slice_num(AUDIO_OUT);
|
|
if (chan == -1) chan = pwm_gpio_to_channel(AUDIO_OUT);
|
|
|
|
pwm_clear_irq(slice);
|
|
|
|
float sample = get_sample();
|
|
|
|
uint16_t level = (uint16_t)((sample + 1.0f) * 0.5f * 3400.0f);
|
|
pwm_set_chan_level(slice, chan, level);
|
|
}
|
|
|