From: Kostya Shishkov Date: Fri, 6 Mar 2020 18:14:40 +0000 (+0100) Subject: update WAV writer for interleaved audio support X-Git-Url: https://git.nihav.org/?p=nihav-tool.git;a=commitdiff_plain;h=bcaa61dbe363c0fef533285d02789c2b4994425e update WAV writer for interleaved audio support --- 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)?; } }