01-17-2011 05:52 PM
Has anyone attempted to or succeeded at using the microphone (flash.media.Microphone) under the latest simulator?
I see that Microphone.isSupported is returning true, and I can get ActivityEvent and SampleDataEvents, but it doesn't seem to be picking up actual sound.
I haven't tried analyzing what the data actually looks like yet, but the activity level mostly sits down near 0. I get sporadic activity events (true/false transitions) that don't seem have any relationship to the sound in the room, and the levels only just barely touch 10 then drop again instantly.
Running the same test program via ADL (on my host machine) and saying "testing" in a normal voice gives me levels up around 50 and normal-looking activity transitions.
Just curious whether anyone else has tried and got any real results. Thanks.
Solved! Go to Solution.
01-18-2011 10:47 AM
I am afraid this is not yet supported peter.
API known issues The following APIs are currently not implemented: Camera Microphone CameraUI CameraRoll Geolocation (80891)
01-18-2011 10:51 AM
Thanks for the link, zezke! I had read that page but didn't remember all the details, I guess.
(Anyone else find that the alternating background colours in that list makes it pretty hard to read?)
01-18-2011 11:22 AM
01-18-2011 12:39 PM
@shaider2000, please don't ask new questions in existing threads. For one thing, very few people will see your post, as it won't show up in the Forum Message List.
Go to that link and click on New Message to start a new topic. And the answer, by the way, is you can use only free command line tools or third-party IDEs and such (I do). Ask again in a new thread and you'll get lots of responses. Also considering searching the forum first, as this isn't the first time it's been asked.
01-18-2011 01:01 PM
@zezke, I'm happy to say I'll have to retract my acceptance of your post as a solution.
Turns out that the API is certainly supported and the simulator supports it, but there appear to be issues in the simulator (who could have guessed?). ;-)
Basically the SampleDataEvents are arriving much more slowly than they should be. It appears very sluggish, and after only a few seconds (e.g. 7.7 in the above image) the data is already lagging behind by many seconds. Running in ADL the lag stays around 0.2s constant, and the calculated rate approaches 8kHz over time, as it should (averaging out various inaccuracies).
But it does record the correct data! The image shows the middle of the word "PlayBook".
So the answer to my original question is yes, the Microphone does work in the simulator, but only about as well as many of the other new simulator features. ;-)
The actual sample rate, by the way, appears to be correct (in spite of my "rate" value shown in the app). It's just that the sample buffers get backlogged for some reason, and are not delivered to the code as quickly as they arrive. If I let it run for a long time, I'd probably see gradual memory loss since it must be storing these all somewhere. For proof that the data is actually correct, just delayed, below is a comparison of the simulator versus my host machine, recording the same sound (me whistling at a constant pitch, probably around 2kHz). Yes, there's all kinds of aliasing going on, but they wouldn't look that similar if the simulator sampling rate was wrong.
01-18-2011 09:59 PM
Interesting... I had the idea of changing the Microphone.rate setting to see what effect it would have. I just assumed it would make things much worse, with significantly greater lag.
As it turns out, although rate settings of 5, 8, and 11 (these rate values approximately the sampling rate in kHz) all show some of this lag, when I set it to 22 or 44 it keeps up and works perfectly!
So I'll make this the answer: flash.media.Microphone is basically supported, though with some issues. Using Microphone.rate of 22 would be advisable to avoid the sample lag issue, and 44 seems to work fine as well though with this flaky simulator version I'm a bit worried about overloading it and getting The Freeze.