Archive for January, 2009

Microphone activityLevel in Flash

January 14th, 2009 admin 11 comments

I wanted to analyse the frequencies of the microphone input in Flash, but guess what? You can’t!

With streaming sound it’s no problem, as this tutorial shows. But surprise: the microphone input is not accessible so you can’t respond to specific frequencies in you live sound input. Crap.

Anyway, after discovering this I set out to simply use the volume of the input, which is represented in the activityLevel property of the Microphone class. When activity is registered (you can set a threshold volume above which it does so), the ActivityEvent.ACTIVITY is dispatched, so you can respond to that.

Get ready for my next surprise: I only see the event being dispatched when my security settings panel is open, and then only when the microphone tab is active! Wtf is going on here?!

After battling with this, and trying out different possible solutions, it turns out that to make it work, you need to have set the loopback setting to true (microphone.setLoopBack(true)). This means that the microphone input will be played back over your speakers.

Needless to say you won’t always want this to happen. In fact, you probably nĂ©ver want this to happen (think of the feedback!), but apparently you have to in order to be able to read the input volume at all.

Luckily the solution is fairly straightforward: set the soundTransform property of the microphone to a SoundTransform instance with volume zero and presto: no mic sound playing back through your speakers, but an ActivityEvent.ACTIVITY event triggering nonetheless.

Categories: programming Tags: