用c#写的录音程序源码

时间:2016-01-09 04:46:37
【文件属性】:

文件名称:用c#写的录音程序源码

文件大小:576KB

文件格式:RAR

更新时间:2016-01-09 04:46:37

c# record 录音 源码

一款很不错的录音程序,附带源代码,自行编译: 如遇到内存不能读写错误(103行),请把编译 CPU Type 从“Any CPU”改为“x86”即可。 部分代码: public const string WaveAudio = "waveaudio"; public const uint MM_MCINOTIFY = 0x3B9; public const uint MCI_NOTIFY_SUCCESSFUL = 0x0001; public const uint MCI_NOTIFY_SUPERSEDED = 0x0002; public const uint MCI_NOTIFY_ABORTED = 0x0004; public const uint MCI_NOTIFY_FAILURE = 0x0008; public const uint MCI_OPEN = 0x0803; public const uint MCI_CLOSE = 0x0804; public const uint MCI_PLAY = 0x0806; public const uint MCI_SEEK = 0x0807; public const uint MCI_STOP = 0x0808; public const uint MCI_PAUSE = 0x0809; public const uint MCI_RECORD = 0x080F; public const uint MCI_RESUME = 0x0855; public const uint MCI_SAVE = 0x0813; public const uint MCI_LOAD = 0x0850; public const uint MCI_STATUS = 0x0814; public const uint MCI_SAVE_FILE = 0x00000100; public const uint MCI_OPEN_ELEMENT = 0x00000200; public const uint MCI_OPEN_TYPE = 0x00002000; public const uint MCI_LOAD_FILE = 0x00000100; public const uint MCI_STATUS_POSITION = 0x00000002; public const uint MCI_STATUS_LENGTH = 0x00000001; public const uint MCI_STATUS_ITEM = 0x00000100; public const uint MCI_NOTIFY = 0x00000001; public const uint MCI_WAIT = 0x00000002; public const uint MCI_FROM = 0x00000004; public const uint MCI_TO = 0x00000008; // Structures [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MCI_OPEN_PARMS { public IntPtr dwCallback; public uint wDeviceID; public IntPtr lpstrDeviceType; public IntPtr lpstrElementName; public IntPtr lpstrAlias; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MCI_RECORD_PARMS { public IntPtr dwCallback; public uint dwFrom; public uint dwTo; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MCI_PLAY_PARMS { public IntPtr dwCallback; public uint dwFrom; public uint dwTo; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MCI_GENERIC_PARMS { public IntPtr dwCallback; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MCI_SEEK_PARMS { public IntPtr dwCallback; public uint dwTo; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MCI_SAVE_PARMS { public IntPtr dwCallback; public IntPtr lpfilename; } [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi)] public struct MCI_STATUS_PARMS { public IntPtr dwCallback; public uint dwReturn; public uint dwItem; public uint dwTrack; } ; // Functions [DllImport("winmm.dll", CharSet = CharSet.Ansi, BestFitMapping = true, ThrowOnUnmappableChar = true)] [return: MarshalAs(UnmanagedType.U4)] public static extern uint mciSendCommand( uint mciId, uint uMsg, uint dwParam1, IntPtr dwParam2); [DllImport("winmm.dll", CharSet = CharSet.Ansi, BestFitMapping = true, ThrowOnUnmappableChar = true)] [return: MarshalAs(UnmanagedType.Bool)] public static extern bool mciGetErrorString( uint mcierr, [MarshalAs(UnmanagedType.LPStr)] System.Text.StringBuilder pszText, uint cchText); } }


网友评论

  • 参考参考还是可以的。只是这功能现在用的少了。
  • 还行吧,不是太完善的代码
  • 可以参考一下!
  • 可以运行,需要做录音方面的东西,参考下,谢谢
  • 为什么用不了
  • 代码需要再优化一
  • 该demo使用了winmm.dll进行录音和播放的,是在C#中调用winmm.dll中的api进行操作的。录音和播放都很正常,美中不足的是,录音没录到byte[]里面,限制了使用范围。
  • 非常好的程序,解决了我的问题
  • 还行吧,不是太完善的代码
  • 很不错,以满足我的要求了
  • 可以用 不错。。赞一个
  • 可用,不知道录音质量怎么样
  • 代码需要再优化一下
  • 跟楼上的一样,录音挺好
  • 垃圾 不好用
  • 简单好用~ 功能有点弱
  • 杂音比较大,
  • 杂音比较大,没有实现暂停录制
  • 资源使用还可以,比较有用
  • 写的挺不错 没有用插件 值得学习,杂音效果应该处理一下
  • 代码需要再优化一下,录音质量不太好。
  • 学习了,希望注释多点
  • 非常不错,代码注释多一点更好
  • 跟楼上的一样,录音挺好,就是音质不太好
  • 代码需要再优化一下,录音质量不太好。
  • 挺好的代码
  • 可用,只是杂音大点
  • 真的可以用耶
  • 还行吧,要自信调试
  • 很好用,学习MCI的好资料,值得推荐!