Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WaveInEvent does not record audio in .Net 5 #791

Closed
Hromon opened this issue Jun 12, 2021 · 6 comments
Closed

WaveInEvent does not record audio in .Net 5 #791

Hromon opened this issue Jun 12, 2021 · 6 comments

Comments

@Hromon
Copy link

Hromon commented Jun 12, 2021

o/
I wrote the following code:
image
This code works on the .Net Framework, but does not work on .Net 5. WaveInEvent does not write (its buffers are empty) and does not generate an event about data availability for reading, respectively. :C

@Zintom
Copy link

Zintom commented Jun 12, 2021

Why are you clearing the BufferedWaveProvider each time there is data available? From your example you appear to be wanting to play back audio that has been recorded by the Default Input Device, BufferedWaveProvider is a circular buffer so all you need to do is make its buffer big enough to fit a few seconds of audio in it and so long as you are consuming from the buffer as quickly as you are putting data in, it will never fill up.

As for why you're not getting any data, are you sure the default input device is setup correctly? i.e is the default set to your microphone. Alternatively you can manually select the audio device using the MMDeviceEnumerator.EnumerateAudioEndPoints(..) API.

@Hromon
Copy link
Author

Hromon commented Jun 13, 2021

Why are you clearing the BufferedWaveProvider each time there is data available? From your example you appear to be wanting to play back audio that has been recorded by the Default Input Device, BufferedWaveProvider is a circular buffer so all you need to do is make its buffer big enough to fit a few seconds of audio in it and so long as you are consuming from the buffer as quickly as you are putting data in, it will never fill up.

As for why you're not getting any data, are you sure the default input device is setup correctly? i.e is the default set to your microphone. Alternatively you can manually select the audio device using the MMDeviceEnumerator.EnumerateAudioEndPoints(..) API.

Yes, I'm sure, because if you put a breakpoint, then I will never come to WaveIn_DataAvailable.

As for the default input device - this code was written in .Net 5 and .Net framework in one solution and was run sequentially. The result is that the framework works, Core 5 does not.

@Zintom
Copy link

Zintom commented Jun 13, 2021

Hmm, very possibly related to #789 or some unknown bug caused by the 5.0.7 patch.

One other thing to try is to enlarge BufferMilliseconds to something a bit bigger, maybe the buffer isn't large enough to store the data recorded (honestly that's just a total guess but may be worth checking).

@Hromon
Copy link
Author

Hromon commented Jun 14, 2021

Hmm, very possibly related to #789 or some unknown bug caused by the 5.0.7 patch.

One other thing to try is to enlarge BufferMilliseconds to something a bit bigger, maybe the buffer isn't large enough to store the data recorded (honestly that's just a total guess but may be worth checking).

I tryid, but it not work

@Zintom
Copy link

Zintom commented Jun 20, 2021

Would you mind trying with the new 2.0.1 (NuGet) patch please.

@Hromon
Copy link
Author

Hromon commented Jun 21, 2021

Would you mind trying with the new 2.0.1 (NuGet) patch please.

Work, thanks.

@Hromon Hromon closed this as completed Jun 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants