我正在实施这个音频发生器程序,效果很好:
我无法弄清楚,为什么以下两行代码:
BW.Write(Sample)
BW.Write(Sample)
一个“写”是有意义的,但为什么第二个“写”?
答案 0 :(得分:1)
该示例有点神秘,但波形文件配置为2个通道,因此两个写入只是将相同的音频数据发送到两个通道。
波头是这个硬编码的位:
Dim Hdr() As Integer = {&H46464952, 36 + Bytes, &H45564157, _
&H20746D66, 16, &H20001, 44100, _
176400, &H100004, &H61746164, Bytes}
哪个解码意味着:
H46464952 = 'RIFF' (little endian) 36+Bytes = Length of header + length of data H45564157 = 'WAVE' (little endian) H20746D66 = 'fmt ' (little endian) 16 = length of fmt chunk (always 16) H20001 = 0x0001: PCM, 0x0002: 2 channels 44100 = sampleRate 176400 = sampleRate*numChannels*bytesPerSample = 44100*2*2 H100004 = 0x0004: numChannels*bytesPerSample, 0x0010: bitsPerSample (16) H61746164 = 'data' Bytes = size of data chunk