intermediate

This commit is contained in:
Asaril 2025-03-19 02:12:20 +01:00
parent 29e525ae35
commit 601afd1560

View file

@ -398,24 +398,24 @@ fn main() -> anyhow::Result<()> {
mic_drv.rx_enable()?;
loop {
// let buffer: &mut [u8; AUDIO_SAMPLES_PER_BUF*4] = cast_slice_mut(&mut audio[next_audio_buf]);
// let buffer = bytes_of_mut(&mut audio[next_audio_buf]);
let mut buffer:[u8;AUDIO_SAMPLES_PER_BUF*4] = [0;AUDIO_SAMPLES_PER_BUF*4];
let buffer = bytes_of_mut(&mut audio[next_audio_buf]);
// let mut buffer:[u8;AUDIO_SAMPLES_PER_BUF*4] = [0;AUDIO_SAMPLES_PER_BUF*4];
let num_bytes_read = mic_drv.read(buffer.as_mut_slice(), TickType_t::MAX)?;
if num_bytes_read != AUDIO_SAMPLES_PER_BUF * 4 {
log::error!("buffer underflow");
}
for i in 0..AUDIO_SAMPLES_PER_BUF {
let sample:&[u8;4] = &buffer[i*4..i*4+4].try_into().expect("bla");
audio[next_audio_buf][i] = i32::from_be_bytes(*sample);
}
// for i in 0..AUDIO_SAMPLES_PER_BUF {
// let sample:&[u8;4] = &buffer[i*4..i*4+4].try_into().expect("bla");
// audio[next_audio_buf][i] = i32::from_le_bytes(*sample);
// }
// log::info!("a: {:08x}", audio[next_audio_buf][0]);
let current_fft_buf = processor.process(&audio[next_audio_buf]);
effect.render(&processor, current_fft_buf, &leds.leds);
effect.render(&processor, current_fft_buf, &(leds.leds));
let output_buffer = bytes_of(&leds);
led_drv.write(output_buffer)?;