views:

67

answers:

2

Hello,

I want to see if there is a microphone active using Python.

How can I do it?

Thanks in advance!

+3  A: 

Microphones are analog devices, most api's probably couldn't even tell you if there is a microphone plugged in, your computer just reads data from one of your soundcards input channels.

What you probably want to know is if the input channels are turned on or off. Determining that is highly platform specific.

mikerobi
How does your laptop switch from its internal speakers to your headphones when you plug them in?
Aviral Dasgupta
@aviraldg, well mine has separate ports, but in other cases, I would guess that the driver or firmware uses DSP to infer what is plugged in based on the electrical signal.
mikerobi
@mikerobi how it does that, is an interesting thing, but you ain't getting that in Python. So you're correct in a way. +1.
Aviral Dasgupta
A: 

This is what I wanted:

import ctypes
from ctypes import *

winmm= windll.winmm
print 'waveInGetNumDevs=',winmm.waveInGetNumDevs()
aF