[iOS/Android] MicroPhone Decibel and Frequency values

mdotedot

  • Posts: 1569
Blocks:
* Initialize
* Start Recording
* getDecibel
* getFrequency
* Stop Recording

MicroPhone Extension + Demo download


The decibel values are calculated with the same formulas on both iOS and Android.
This is where the best game mechanics can be obtained.

Frequency values are obtained by using Fast Fourier Transform calculations. But the implementation differ on both platforms and values aren't the same.
Need far more testing when implemented.
Also, the range detection for your particular sound/noice detection should be evaluated.

Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

Max Finch

  • *
  • Posts: 2187
Appreciate this extension Mdot!

GuyCockcroft

  • Posts: 177
Great stuff! I've managed to get this working, and it does seem to be picking up some signal from the mic. The decibel level seems to be working, however, the frequency numbers are pretty erratic! Is there a (fairly) easy way of filtering the input so that it's only analysing sound over a given frequency? I noticed there is mention of a low pass filter in the code, but a high-pass would be very useful too - to eliminate the effects of low rumbly sounds. (Maybe this is why the numbers are erratic?)

Also, I spotted that the output sound levels on iOS are very much reduced once the mic has been activated - even when the recording has stopped. This doesn't seem to affect the Android version though.

thanks!

« Last Edit: May 17, 2019, 05:23:12 am by GuyCockcroft »

mdotedot

  • Posts: 1569
Thanks for the feedback.

I'm working with Max on the volume reduction .

Frequency numbers are very erratic indeed. As mentioned you need a lot of trial and error to do something with it. I never got it working perfectly.  I've found a lot of posts on the issue and the surrounding sounds in every location and every device are different. But I was hoping for a range of frequencies to be using in a game. Like whisseling/blowing or 'A' versus 'O' which should have totally different frequencies. I couldn't get it to work but maybe in the far future.....
Hanging out in the Chat:  http://www.stencyl.com/chat/

Proud member of the League of Idiotic Stencylers! Doing things in Stencyl that probably shouldn't be done.

GuyCockcroft

  • Posts: 177
Yep - fair enough. I think that somehow shaping/filtering the signal a bit before the FFT analysis is probably the way to go - to get around the limitations of the mic input, and any background noise going on. Good luck with it!

Max Finch

  • *
  • Posts: 2187
In regards to decibel, you could easily manage the erratic rate by placing the decibel block in a timer function which updates less frequently. Say placing the block in an event which updates every .2 seconds or I believe half the step size of the game engine.

I'm working on a game which has a Microphone game difficulty, it's pretty neat!

GuyCockcroft

  • Posts: 177
Yep, good point. I’d be interested to see what you come up with!