1 private void showWAVForm(string filepath) //此函数只能用于读取16bit量化单声道的WAV文件
2 {
3 FileStream fs = new FileStream(filepath,FileMode.Open);
4 fs.Read(new byte[42],0,42);
5 byte[] datasize = new byte[4];
6 fs.Read(datasize,0,4);
7 int dtsize = byteArray2Int(datasize); //数据块部分数据的字节数
8 for (int i = 0; i < dtsize/2; i++)
9 {
10 byte[] byt = new byte[2];
11 fs.Read(byt, 0, 2);
12 short dt = (short)(byt[0] | (((int)byt[1]) << 8));
13 Console.WriteLine(dt);
14 }
15 fs.Close();
16 }
17
18 private int byteArray2Int(byte[] hex)
19 {
20 return hex[0] | (hex[1] << 8) | (hex[2] << 16) | (hex[3] << 24);
21 }