Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jack Sensing in C#

I am writing an application that will record audio from microphone. My problem is I need to know when the user plug in the jack and remove the jack out.

I looked into Win32_SoundDevice WMI class and seems to me there is no such a property that I can check the status of the Jack.

Then I found RegisterEndpointNotificationCallback in IMMDeviceEnumerator which seems to do what I need but I have no clue how to do this in C#. Does anyone know how to use MMDeviceEnumerator methods to check for audio port status ? Any help highly appreciated.

like image 405
kakopappa Avatar asked Mar 06 '12 09:03

kakopappa


1 Answers

You might want to take a look at then open source NAudio project.

I've browsed their code and it appears they have a .Net wrapper for your IMMDeviceEnumerator interface.

As this project is under Microsoft Public License, it'll probably be usable in your project.

like image 67
ken2k Avatar answered Oct 19 '22 17:10

ken2k