some more fiddling
This commit is contained in:
parent
8a16bd166f
commit
c58b327c54
4 changed files with 39 additions and 9 deletions
18
ch32v-insert-coin/audio/sequences
Normal file
18
ch32v-insert-coin/audio/sequences
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
"wahwahwahwah" sound - let play a few times
|
||||||
|
note timing: 6hz
|
||||||
|
data: let freqs = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
||||||
|
|
||||||
|
"falling" sound
|
||||||
|
note timing: 6hz
|
||||||
|
[
|
||||||
|
1000,
|
||||||
|
990, 980, 970, 960, 950, 940, 930, 920, 910, 900,
|
||||||
|
890, 880, 870, 860, 850, 840, 830, 820, 810, 800,
|
||||||
|
790, 780, 770, 760, 750, 740, 730, 720, 710, 700,
|
||||||
|
690, 680, 670, 660, 650, 640, 630, 620, 610, 600,
|
||||||
|
590, 580, 570, 560, 550, 540, 530, 520, 510, 500,
|
||||||
|
490, 480, 470, 460, 450, 440, 430, 420, 410, 400,
|
||||||
|
390, 380, 370, 360, 350, 340, 330, 320, 310, 300,
|
||||||
|
290, 280, 270, 260, 250, 240, 230, 220, 210, 200,
|
||||||
|
190, 180, 170, 160, 150, 140, 130, 120, 110, 100,
|
||||||
|
]
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit aa57096e4b560ee4f65149ddf5ef6c4c8f82e4ce
|
Subproject commit e6ca9c7ed8b9af193333be793983df5e48cb961a
|
||||||
|
|
@ -253,7 +253,7 @@ fn SysTick() {
|
||||||
NOTE_TICK_FLAG = true;
|
NOTE_TICK_FLAG = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if SYSTICK_COUNT % 5000 == 0 {
|
if SYSTICK_COUNT % 50000 == 0 {
|
||||||
TICK_FLAG = true;
|
TICK_FLAG = true;
|
||||||
// if let Some(ref mut led) = LED {
|
// if let Some(ref mut led) = LED {
|
||||||
// let toggle = TOGGLE_COUNT;
|
// let toggle = TOGGLE_COUNT;
|
||||||
|
|
@ -317,7 +317,7 @@ fn debug_main(mut p: hal::Peripherals) -> ! {
|
||||||
riscv::asm::delay(20_000_000);
|
riscv::asm::delay(20_000_000);
|
||||||
println!("post2");
|
println!("post2");
|
||||||
|
|
||||||
let tick_rate_hz = 50000; // 50khz
|
let tick_rate_hz = 100000; // 50khz
|
||||||
|
|
||||||
// DAC output setup
|
// DAC output setup
|
||||||
let dac_pin = PwmPin::new_ch4::<0>(p.PC4);
|
let dac_pin = PwmPin::new_ch4::<0>(p.PC4);
|
||||||
|
|
@ -330,7 +330,7 @@ fn debug_main(mut p: hal::Peripherals) -> ! {
|
||||||
None,
|
None,
|
||||||
None,
|
None,
|
||||||
Some(dac_pin),
|
Some(dac_pin),
|
||||||
Hertz::khz(200),
|
Hertz::khz(500),
|
||||||
CountingMode::default(),
|
CountingMode::default(),
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -363,7 +363,16 @@ fn debug_main(mut p: hal::Peripherals) -> ! {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut index = 0;
|
let mut index = 0;
|
||||||
let freqs = [110, 440];
|
let freqs = [1567, 1396, 1318, 1174, 1046, 987, 880, 783, 698];
|
||||||
|
// let freqs = [100, 200, 300, 400, 500, 600, 700, 800, 900];
|
||||||
|
// let freqs = [
|
||||||
|
// 1000, 990, 980, 970, 960, 950, 940, 930, 920, 910, 900, 890, 880, 870, 860, 850, 840, 830,
|
||||||
|
// 820, 810, 800, 790, 780, 770, 760, 750, 740, 730, 720, 710, 700, 690, 680, 670, 660, 650,
|
||||||
|
// 640, 630, 620, 610, 600, 590, 580, 570, 560, 550, 540, 530, 520, 510, 500, 490, 480, 470,
|
||||||
|
// 460, 450, 440, 430, 420, 410, 400, 390, 380, 370, 360, 350, 340, 330, 320, 310, 300, 290,
|
||||||
|
// 280, 270, 260, 250, 240, 230, 220, 210, 200, 190, 180, 170, 160, 150, 140, 130, 120, 110,
|
||||||
|
// 100,
|
||||||
|
// ];
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
if flag() {
|
if flag() {
|
||||||
|
|
@ -377,6 +386,8 @@ fn debug_main(mut p: hal::Peripherals) -> ! {
|
||||||
if note_flag() {
|
if note_flag() {
|
||||||
clear_note_flag();
|
clear_note_flag();
|
||||||
synth.square.set_freq(freqs[index]);
|
synth.square.set_freq(freqs[index]);
|
||||||
|
// println!("{}", { freqs[index] });
|
||||||
|
// println!("{}", freqs[index]);
|
||||||
index += 1;
|
index += 1;
|
||||||
if index > freqs.len() - 1 {
|
if index > freqs.len() - 1 {
|
||||||
index = 0;
|
index = 0;
|
||||||
|
|
|
||||||
|
|
@ -3,10 +3,11 @@ use ch32_hal::println;
|
||||||
use ch32_hal::timer::GeneralInstance16bit;
|
use ch32_hal::timer::GeneralInstance16bit;
|
||||||
use wavetable_synth::{synthesizer::SimpleWavetableSynthesizer, wavetable::SimpleWavetable};
|
use wavetable_synth::{synthesizer::SimpleWavetableSynthesizer, wavetable::SimpleWavetable};
|
||||||
|
|
||||||
const SQUARE_WAVETABLE: [u8; 32] = [
|
const SQUARE_WAVETABLE: [u8; 2] = [0, 100];
|
||||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100,
|
// const SQUARE_WAVETABLE: [u8; 32] = [
|
||||||
100, 100, 100, 100, 100, 100, 100,
|
// 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 100, 100, 100, 100, 100, 100, 100, 100, 100,
|
||||||
];
|
// 100, 100, 100, 100, 100, 100, 100,
|
||||||
|
// ];
|
||||||
|
|
||||||
pub struct AppSynthesizers<'a, T: GeneralInstance16bit> {
|
pub struct AppSynthesizers<'a, T: GeneralInstance16bit> {
|
||||||
pub square: SimpleWavetableSynthesizer<SimpleWavetable<'static, u8>>,
|
pub square: SimpleWavetableSynthesizer<SimpleWavetable<'static, u8>>,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue