基本上,我认为计算pcm文件大小的公式如下:
fileSize(in bits) = samples_per_sec x seconds x number_of_channels
它对我来说工作得很好,因为我专门处理8位深度的pcm文件。当我开始处理16位深度文件时,这个公式并不能产生准确的结果。通过谷歌搜索,我发现我之前提到的公式是错误的,实际上你必须坚持这个:
fileSize(in bits) = samples_per_sec x seconds x number_of_channel x bit_depth/8
它解释了为什么我用错误的公式得到了正确的结果,因为,你知道,8/8 = 1。
我不明白的是:为什么要把位深度除以8 ?
为了在你的计算中得到位,你必须把它们放在公式的右边:
bits = samples/seconds x seconds x num_of_channels(dimensionless) x bits/sample = bits
很好。所以不除以8也可以。但事实并非如此。我哪里错了?
在你的注释风格:
-
samples_per_sec x seconds x number_of_channels
is总采样数 -
samples_per_sec x seconds x number_of_channel x bit_depth
is总比特数 -
samples_per_sec x seconds x number_of_channel x bit_depth / 8
is字节总数 -
samples/seconds x seconds x num_of_channels(dimensionless) x bits/sample
为sample_rate x duration_in_seconds x num_of_channels x bit_depth
,也是总比特数
主要的混淆可能来自位和字节。音频样本大小通常用位深度来描述。notbytedepth. 文件大小/内存通常用字节来描述。要从位到字节,只需除以8。