WAV 格式通常以 44 字节标头开始,然后是每秒 44,100 次(采样率)采集的音频样本,其中每个样本是 16 位有符号整数小端(位深度)......比特率是通过将这两个基本因素相乘来计算的: (采样率)*(位深度)......这是单声道,所以如果立体声这些样本是交错的
查看您引用的 API,首先探测属性:vbr(可变比特率)如果它是真的,您想要的计算将是无法实现的。对于 WAV,它应该始终保持恒定的比特率(即错误)。然后检索属性:比特率
比特率 = (sample_rate) * (bit_depth) * (number_of_channels) === 比特每秒
For argument sake lets say your ...
sample_rate = 44100; // 44.1 kHz which is typical
bit_depth = 16; // also typical
number_of_channels = 2; // mono --> 1 stereo --> 2
look_ahead_milli_sec = 1500; // you are given this in milliseconds
bit_rate = sample_rate * bit_depth * number_of_channels;
bit_rate = 44100 * 16 * 2;
bitrate = 1411200; // based on above calculation
bytes_per_second = bitrate / 8; // bits to bytes per sec
bytes_per_second = 1411200 / 8; // bits to bytes per sec
bytes_per_second = 176400; // bytes per sec
look_ahead_in_bytes = (bytes_per_second / 1000) * look_ahead_milli_sec;
look_ahead_in_bytes = (176400 / 1000) * 1500;
look_ahead_in_bytes = 264600;