From c316bc9b6351884ec433d2282a63ea247b23d02f Mon Sep 17 00:00:00 2001 From: Chris Needham Date: Fri, 19 Jan 2024 01:46:15 +0000 Subject: [PATCH] Simplified code --- src/waveform-generator.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/waveform-generator.js b/src/waveform-generator.js index 8fe0cac..5f5fa16 100644 --- a/src/waveform-generator.js +++ b/src/waveform-generator.js @@ -34,8 +34,7 @@ function generateWaveformData(options) { return new Float32Array(channel); }); var output_channels = split_channels ? channels.length : 1; - var version = output_channels === 1 ? 1 : 2; - var header_size = version === 1 ? 20 : 24; + var header_size = 24; var data_length = calculateWaveformDataLength(length, scale); var bytes_per_sample = options.bits === 8 ? 1 : 2; var total_size = header_size + data_length * 2 * bytes_per_sample * output_channels; @@ -57,15 +56,12 @@ function generateWaveformData(options) { var range_min = options.bits === 8 ? INT8_MIN : INT16_MIN; var range_max = options.bits === 8 ? INT8_MAX : INT16_MAX; - data_view.setInt32(0, version, true); // Version + data_view.setInt32(0, 2, true); // Version data_view.setUint32(4, options.bits === 8, true); // Is 8 bit? data_view.setInt32(8, sample_rate, true); // Sample rate data_view.setInt32(12, scale, true); // Scale data_view.setInt32(16, data_length, true); // Length - - if (version === 2) { - data_view.setInt32(20, output_channels, true); - } + data_view.setInt32(20, output_channels, true); for (i = 0; i < length; i++) { var sample = 0;