标题:C#中使用SoundRecord()录音,如何实时显示录音的波形
只看楼主
kongjibo
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2013-8-20
 问题点数:0 回复次数:0 
C#中使用SoundRecord()录音,如何实时显示录音的波形
小弟新手,正在研究怎么用C#做个进行录音软件,通过第三方调用DirectX的SoungRecord()已经实现录音功能,但是如何才能够像XP自带的录音机似的能够实时显示录音的数据波形呢?应该用什么控件来做啊?望各位大侠指教,指点一二,或者给个思路也行啊!










程序代码:
private void CreateSoundFile()
        {
            // Open up the wave file for writing.
            mWaveFile = new FileStream(mFileName, FileMode.Create);
            mWriter = new BinaryWriter(mWaveFile);

            // Set up file with RIFF chunk info.
            char[] ChunkRiff = {'R','I','F','F'};
            char[] ChunkType = {'W','A','V','E'};
            char[] ChunkFmt = {'f','m','t',' '};
            char[] ChunkData = {'d','a','t','a'};
         
            short shPad = 1;                // File padding
            int nFormatChunkLength = 0x10;  // Format chunk length.
            int nLength = 0;                // File length, minus first 8 bytes of RIFF description. This will be filled in later.
            short shBytesPerSample = 0;     // Bytes per sample.



            // 一个样本点的字节数目
            if (8 == mWavFormat.BitsPerSample && 1 == mWavFormat.Channels)
                shBytesPerSample = 1;

            else if ((8 == mWavFormat.BitsPerSample && 2 == mWavFormat.Channels) || (16 == mWavFormat.BitsPerSample && 1 == mWavFormat.Channels))
                shBytesPerSample = 2;

            else if (16 == mWavFormat.BitsPerSample && 2 == mWavFormat.Channels)
                shBytesPerSample = 4;

            // RIFF 块
            mWriter.Write(ChunkRiff);
            mWriter.Write(nLength);
            mWriter.Write(ChunkType);

            // WAVE块
            mWriter.Write(ChunkFmt);
            mWriter.Write(nFormatChunkLength);
            mWriter.Write(shPad);
            mWriter.Write(mWavFormat.Channels);
            mWriter.Write(mWavFormat.SamplesPerSecond);
            mWriter.Write(mWavFormat.AverageBytesPerSecond);
            mWriter.Write(shBytesPerSample);
            mWriter.Write(mWavFormat.BitsPerSample);
        
            // 数据块
            mWriter.Write(ChunkData);
            mWriter.Write((int)0);   // The sample length will be written in later.
        }////
搜索更多相关主题的帖子: DirectX private 录音软件 第三方 录音机 
2013-08-20 17:34



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-419422-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.406082 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved