├── README.md ├── Microphone Module.csproj ├── Program.cs └── Microphone Module.sln /README.md: -------------------------------------------------------------------------------- 1 | # CSharp-Microphone-Recorder 2 | This is a simple commandline voice recorder written in c#. 3 | 4 | # Usage: 5 | 6 | Records voice for 15 seconds into test.wav. 7 | 8 | ```recorder.exe 15 test.wav``` 9 | -------------------------------------------------------------------------------- /Microphone Module.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net5.0 6 | Microphone_Module 7 | 8 | 9 | 10 | -------------------------------------------------------------------------------- /Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Threading; 3 | using System.Runtime.InteropServices; 4 | 5 | 6 | namespace Microphone_Module 7 | { 8 | public class Program 9 | { 10 | [DllImport("winmm.dll")] 11 | 12 | public static extern long mciSendString( 13 | 14 | string strCommand, 15 | 16 | string strReturn, 17 | 18 | int iReturnLength, 19 | 20 | IntPtr oCallback, 21 | 22 | int lpszDeviceID 23 | ); 24 | static void Main(string[] args) 25 | { 26 | int sleep = (int.Parse(args[0])*1000); 27 | mciSendString("open new Type waveaudio Alias recsound", "", 0, IntPtr.Zero, 1); 28 | mciSendString("record recsound", null, 0, IntPtr.Zero, 1); 29 | Thread.Sleep(sleep); 30 | mciSendString("save recsound " + args[1], "", 0, IntPtr.Zero ,1); 31 | mciSendString("close recsound ", null, 0, IntPtr.Zero, 1); 32 | } 33 | } 34 | } -------------------------------------------------------------------------------- /Microphone Module.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.0.32112.339 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Microphone Module", "Microphone Module.csproj", "{A0319825-BE5D-49C2-BF44-4932C557A8F0}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {A0319825-BE5D-49C2-BF44-4932C557A8F0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {A0319825-BE5D-49C2-BF44-4932C557A8F0}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {A0319825-BE5D-49C2-BF44-4932C557A8F0}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {A0319825-BE5D-49C2-BF44-4932C557A8F0}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {8081D343-FE68-4383-B7CF-79426F99B3F6} 24 | EndGlobalSection 25 | EndGlobal 26 | --------------------------------------------------------------------------------