显示使用C#中的音频波形 [英] Display a audio waveform using C#

查看:538
本文介绍了显示使用C#中的音频波形的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在搜索和#1谷歌,但没有发现什么我寻找。结果
到目前为止,我得到了音频原始数据(WAV文件),我想对其进行可视化。

I've already searched at Stackoverflow and google, but haven't found what I'm looking for.
So far I got the audio raw data(WAV File) and I want to visualize it.

        private void Form1_Load(object sender, EventArgs e)
    {
        FileStream fs = new FileStream("D:\\tada.wav", FileMode.Open);
        BinaryReader reader = new BinaryReader(fs);
        char[] data = new char[4];
        long fsize;
        long wfxSize;
        long dataSize;
        WaveFormatEx wfx;

        //RIFF
        reader.Read(data, 0, 4);

        fsize = reader.ReadInt32();

        //WAVE
        reader.Read(data, 0, 4);

        //FMT
        reader.Read(data, 0, 4);
        wfxSize = reader.ReadInt32();

        byte[] wfxBuffer = new byte[wfxSize];
        reader.Read(wfxBuffer, 0, (int)wfxSize);
        wfx = new WaveFormatEx(wfxBuffer);

        //DATA
        reader.Read(data, 0, 4);
        dataSize = reader.ReadInt32();
        byte[] dataBuff = new byte[dataSize];
        reader.Read(dataBuff, 0, (int)dataSize);
        reader.Close();

        //Visualize the data...
    }

我知道我需要将原始数据转换成样本,然后检查每个样品的峰和画线,但我真的不知道该怎么做(除了图)。

I know I need to convert the raw data into samples and then check for the peak for each sample and draw lines, but I really don't know how to do it(except for the drawing).

推荐答案

可视化数据。。哇!你应该看看这里的 WAV文件规范和< A HREF =htt​​ps://ccrma​​.stanford.edu/courses/422/projects/WaveFor​​mat/相对=nofollow>也许这里然后重新思考这是否是你真正想解决的东西。 (第二个链接实际上是一个更好的,更精简的概述。看看数据部分,看它是否是你要使用的东西。)

Visualize the data... Wow! You should check out the WAV file spec here and perhaps here and then re-think whether this is something you actually want to tackle. (The second link is actually a better, more streamlined overview. Take a look at the data section to see if it's something you want to work with.)

不要误会我的意思。也许这正是你想要做什么,它可能会很有趣。你应该知道你要成什么样!

Don't get me wrong. Maybe this is exactly what you want to do, and it might be fun. You should just know what you're getting into!

此外,这里有一个 code项目组件你可以直接使用或看看的想法。

Also, here's a Code Project component that you could use outright or look at for ideas.

这篇关于显示使用C#中的音频波形的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆