Those could be good assumptions, but I'd like them born out in practice. Care to provide exact main.rs and cargo.toml contents?
That question might be difficult to have the answer for because I keep changing the code like every couple of hours and I don't remember what I did with each version. But I remember exiting out (by pressing enter) many times (in many versions) after just the first generations. Here's a list of results I have gotten:
- No output file whatsoever
- The output file is half the size it should be
- The output file is just 1 second long
- The output file is completely blank (zero seconds)
So believe me when I say I haven't seen a winning code that delivers quickly what should be delivered quickly.
These aren't assumptions.
You can check the writing with writer.write_sample(sample)?; just by removing all code that changes the signal. Just read the file and write it to another - if you get a copy of the original it's working.
For the "... far too big for f32" -> for every batch you keep the highest sample value und print it after the loop. Set your BATCH_SIZE down to 160, run it and watch. Something like this: (didn't run it - might contain typos etc.)
for _ in 0..BATCH_SIZE {
let shift_samples = (0.001 * SAMPLE_RATE as f32) as usize; // 1 ms shift
let mut shifted_samples = samples.clone();
shifted_samples.rotate_right(shift_samples);
let mut max_sample = 0.0 // INSERT THIS
for (sample, shifted) in samples.iter_mut().zip(shifted_samples.iter()) {
*sample += *shifted;
if *sample > max_sample { max_sample = *sample } // INSERT THIS
}
println!("max sample: {max_sample}"); // INSERT THIS
}
I can only compile and run complete main.rs and cargo.toml files. I know how to examine code and run it. But my hands are shaky when it comes to putting code together.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.