首页 > Windows开发 > 详细

C#读取wav文件

时间:2016-10-14 22:41:02      阅读:323      评论:0      收藏:0      [点我收藏+]
 1      private void showWAVForm(string filepath)
 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 = hex2Int(datasize); //数据块部分数据的字节数
 8             for (int i = 0; i < dtsize/2; i++)
 9                 {
10                   byte[] byt = new byte[2];
11                   fs.Read(byt, 0, 2);
12                   int dt = (byt[0] & 255) | (((int)byt[1]) << 8);
13                   Console.WriteLine(dt);
14                 }
15                 fs.Close();
16         }
17 
18     private int hex2Int(byte[] hex)
19        {
20           return hex[0] | (hex[1] << 8) | (hex[2] << 16) | (hex[3] << 24);//十六进制转为十进制
21        }

 

C#读取wav文件

原文:http://www.cnblogs.com/144823836yj/p/5961967.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!