How to display the frequency in Hz with the audio Analyser

0 favourites
  • 4 posts
From the Asset Store
100+ Musical High Quality Sound Effects for your game!
  • 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

  • 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

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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 ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)