From 3a5da13910ec0eccf439d8b3a9f6728d127dc1b8 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Wed, 21 Feb 2018 11:50:28 +0100 Subject: Correct wav header write --- src/wavfile.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/wavfile.cpp') diff --git a/src/wavfile.cpp b/src/wavfile.cpp index 7de4ffc..4bd4bd6 100644 --- a/src/wavfile.cpp +++ b/src/wavfile.cpp @@ -219,7 +219,7 @@ WavWriter::WavWriter(const char *filename) } } -void WavWriter::initialise_header(int rate) +void WavWriter::initialise_header(int rate, int channels) { struct wavfile_header header; @@ -234,10 +234,10 @@ void WavWriter::initialise_header(int rate) header.riff_length = 0; header.fmt_length = 16; header.audio_format = 1; - header.num_channels = 2; + header.num_channels = channels; header.sample_rate = samples_per_second; - header.byte_rate = samples_per_second*(bits_per_sample/8); - header.block_align = bits_per_sample/8; + header.byte_rate = samples_per_second*(bits_per_sample/8)*channels; + header.block_align = channels*bits_per_sample/8; header.bits_per_sample = bits_per_sample; header.data_length = 0; -- cgit v1.2.3