How to display the frequency in Hz with the audio Analyser

Get help using Construct 2

Post » Fri Jul 03, 2015 8:50 am

Hello,

I'm a music teacher, and I'd like to create a game with the audio input.

So I'm starting with the Audio analyser example.
I'm able for now to create a sprite and use the peak/frequency meter to move it .

I'd like to display in a text box the frequency of the input microphone (Audio.AnalyserFreqBinAt("mic", 0, FrequencyBin.binNumber) but I need the real frequency in Hz not a multiple

here is an example : if I Sing in the microphone input if frequency is below 440 (should be A3) I compare X
If it is above 440, I compare another X

If I understand the principle, I should be able to create a music staff game with some kind of pitch recognition, pitch move practice (up and down)

Can someone help me , please ?

thanks
B
4
Posts: 17
Reputation: 228

Post » Fri Jul 03, 2015 3:01 pm

in fact I'm not sure I should use (Audio.AnalyserFreqBinAt("mic", 0, FrequencyBin.binNumber)

Can someone tell me what to write to see the frequency (from the effect audio analyser) please ?

Thank you
B
4
Posts: 17
Reputation: 228

Post » Fri Jul 03, 2015 9:26 pm

You can't. Well, you probably can but it may well be a bit slow. Audio.AnalyserFreqBinAt() returns a value of a frequency bin, which is a sound sample at some rate (you can get this from the AudioContext I think but it isn't accessible directly).

You should be able to analyse this for frequency using the usual approaches - zero crossing being the simplest. This is what event 8 is doing - for each frequency vertical bar it gets the value there and sets the bar height accordingly).

Having worked with SALT the problem with zero crossing is it can be a bit inaccurate. It's okay for high versus low, but it probably needs a more complex algorithm for accurate pitch recognition - probably looking for matching sections in the sample. A PC can do this in realtime in javascript but it is probably beyond Construct 2.

There doesn't seem to be any code for measuring frequency in the Audio plugin.
My tutorial through development blog is at http://myconstruct2dev.blogspot.co.uk/
B
12
S
3
Posts: 221
Reputation: 1,328

Post » Sat Jul 04, 2015 6:53 am

Hello paulscottrobson,
thank you for clarifying that.
Loud soft works, but that's a boring gameplay... :/

If I use a javascript tuner in an iFrame, is there a way to use this iframe as an input for a game ?
B
4
Posts: 17
Reputation: 228


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, JackTYGA, worm1 and 29 guests