From bcaa61dbe363c0fef533285d02789c2b4994425e Mon Sep 17 00:00:00 2001 From: Kostya Shishkov Date: Fri, 6 Mar 2020 19:14:40 +0100 Subject: [PATCH] update WAV writer for interleaved audio support --- src/wavwriter.rs | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/wavwriter.rs b/src/wavwriter.rs index d72b82a..fbf825d 100644 --- a/src/wavwriter.rs +++ b/src/wavwriter.rs @@ -37,11 +37,19 @@ macro_rules! write_data { let nch = ainfo.get_channels() as usize; let mut offs: Vec = Vec::with_capacity(nch); for ch in 0..nch { offs.push($buf.get_offset(ch)); } + let is_planar = $buf.get_step() == 1; let data = $buf.get_data(); - for i in 0..len { - for ch in 0..nch { - let sample = data[offs[ch] + i]; + if is_planar { + for i in 0..len { + for ch in 0..nch { + let sample = data[offs[ch] + i]; + $write($wr, sample)?; + } + } + } else { + for i in 0..len*nch { + let sample = data[i]; $write($wr, sample)?; } } -- 2.39.5