chore: stabilize current head before Phase 10a QC

This commit is contained in:
2026-05-10 23:00:25 +01:00
parent c95a5da077
commit b463c32f17
24 changed files with 238 additions and 89 deletions

View File

@@ -42,8 +42,9 @@ impl WavWriter {
};
let file = std::fs::File::create(path).map_err(MagnotiaError::Io)?;
let buffered = BufWriter::new(file);
let inner = hound::WavWriter::new(buffered, spec)
.map_err(|e| MagnotiaError::Io(std::io::Error::other(format!("WAV create failed: {e}"))))?;
let inner = hound::WavWriter::new(buffered, spec).map_err(|e| {
MagnotiaError::Io(std::io::Error::other(format!("WAV create failed: {e}")))
})?;
Ok(Self {
inner,
samples_since_flush: 0,
@@ -76,9 +77,9 @@ impl WavWriter {
/// `Self::DEFAULT_FLUSH_EVERY_SAMPLES` — but may do so at natural
/// boundaries (end-of-utterance, UI events) for tighter recovery.
pub fn flush(&mut self) -> Result<()> {
self.inner
.flush()
.map_err(|e| MagnotiaError::Io(std::io::Error::other(format!("WAV flush failed: {e}"))))?;
self.inner.flush().map_err(|e| {
MagnotiaError::Io(std::io::Error::other(format!("WAV flush failed: {e}")))
})?;
self.samples_since_flush = 0;
Ok(())
}
@@ -110,14 +111,14 @@ pub fn write_wav(path: &Path, audio: &AudioSamples) -> Result<()> {
for &sample in audio.samples() {
let clamped = sample.clamp(-1.0, 1.0);
let int_sample = (clamped * i16::MAX as f32) as i16;
writer
.write_sample(int_sample)
.map_err(|e| MagnotiaError::Io(std::io::Error::other(format!("WAV write failed: {e}"))))?;
writer.write_sample(int_sample).map_err(|e| {
MagnotiaError::Io(std::io::Error::other(format!("WAV write failed: {e}")))
})?;
}
writer
.finalize()
.map_err(|e| MagnotiaError::Io(std::io::Error::other(format!("WAV finalize failed: {e}"))))?;
writer.finalize().map_err(|e| {
MagnotiaError::Io(std::io::Error::other(format!("WAV finalize failed: {e}")))
})?;
Ok(())
}