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. }////