How to get sound data sample value in c#

心已入冬 提交于 2019-11-29 15:41:59

NAudio can do this for you, it's in the library (I think it's the WaveStream or WaveReader class, or something similar). I can recommend it's use, if it's not too much overhead.

If you want to roll-your-own, and want to deal with arbitrary wave files, you'll have to read up on the WAV file format, and analyze the header yourself.

Although in general a WAV file contains 16bit samples, it doesn't have to, and depending on the exact format, they might be stored in little endian or big endian.

The header contains information about sample rate, number of channels, bits per sample, bytes per sample and such like, which allow you to do the actual math to get exactly one sample.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!