Last active
January 16, 2021 04:12
-
-
Save Microncode/b2b60cf19f13b29d175da7846b5a0130 to your computer and use it in GitHub Desktop.
Here is a snap example of using the CSAudioPlayer in order to record sound of what you hear (WASAPI Loopback) to MP3 using C#
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//The mode of the recording process. This can be WasapiLoopbackCapture(default), | |
//WasapiCapture or LineIn | |
audioRecorder1.Mode = CSAudioRecorder.Mode.WasapiLoopbackCapture; | |
//The format of the destination file, this can be AAC, ACM(WAV), | |
//APE, MP2, MP3, OGG, WAV(PCM), and WMA. | |
audioRecorder1.Format = CSAudioRecorder.Format.MP3; | |
//Set the destination file | |
audioRecorder1.FileName = lblDestinationFile.Text; | |
//On progress event | |
audioRecorder1.RecordProgress += (s, e) => | |
{ | |
lblSizeIn.Text = audioRecorder1.TotalSizeIn; | |
// Or audioRecorder1.SizeSuffix(e.Bytes); | |
lblTimeIn.Text = audioRecorder1.TotalTimeIn; | |
// Or TimeSpan.FromSeconds(e.Seconds).ToString(); | |
}; | |
//When record has done | |
audioRecorder1.RecordDone += (s) => | |
{ | |
Console.WriteLine("\nDone."); | |
done = true; | |
}; | |
//Start to record | |
audioRecorder1.Start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment