From 0164c347750734e51a1509792bcef6a583a4fc79 Mon Sep 17 00:00:00 2001 From: ferrari <maxence.ferrari@gmail.com> Date: Fri, 6 May 2022 11:07:54 +0200 Subject: [PATCH] Fix bit_depth option --- src/filewriter.cpp | 2 +- src/main.cpp | 2 +- src/recorder.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/filewriter.cpp b/src/filewriter.cpp index dbb2ed1..6ec9057 100644 --- a/src/filewriter.cpp +++ b/src/filewriter.cpp @@ -92,7 +92,7 @@ WavFileWriter::WavFileWriter(std::string &filename_template, size_t num_channels // write header store_little_endian(header.fmt_channels, num_channels); store_little_endian(header.fmt_sample_rate, sample_rate); - store_little_endian(header.fmt_bits_per_sample, 1<<(2+depth)); + store_little_endian(header.fmt_bits_per_sample, 8 * depth); store_little_endian(header.fmt_byte_rate, num_channels * sample_rate * depth); store_little_endian(header.fmt_frame_size, num_channels * depth); if (expected_num_samples) { diff --git a/src/main.cpp b/src/main.cpp index 7b69b06..da1c594 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -69,7 +69,7 @@ int record(size_t channels, size_t rate, size_t depth, size_t filter, std::stri size_t sample_size = channels * depth; std::vector<std::uint8_t> samples; try { - std::cout << "Setting recording format to " << channels << " channels at " << rate << " Hz " << (1<<(2+depth)) << " bits" << std::endl; + std::cout << "Setting recording format to " << channels << " channels at " << rate << " Hz " << (8 * depth) << " bits" << std::endl; recorder.start_recording(channels, rate, depth, filter); // we will record until we have enough (or forever, if totallen == 0) while ((total_samples_wanted == 0) || (total_samples_read < total_samples_wanted)) { diff --git a/src/recorder.cpp b/src/recorder.cpp index b16869b..823bd69 100644 --- a/src/recorder.cpp +++ b/src/recorder.cpp @@ -122,7 +122,7 @@ void JasonRecorder::start_recording(std::uint8_t num_channels,size_t sample_rat (std::uint8_t) ((sample_rate >> 8) & 0xFF), (std::uint8_t) (sample_rate & 0xFF), num_channels, - (std::uint8_t) ((1 << (2 + depth))), + (std::uint8_t) (8 * depth), num_filter}; send_message(START_ID, payload1); this->num_channels = num_channels; @@ -141,7 +141,7 @@ void JasonRecorder::stop_recording() { (std::uint8_t) ((this->sample_rate >> 8) & 0xFF), (std::uint8_t) (this->sample_rate & 0xFF), this->num_channels, - (std::uint8_t) ((1 << (2 + this->depth))), + (std::uint8_t) (8 * this->depth), this->num_filter}; send_message(START_ID, payload1); recording = false; -- GitLab