Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Get Spectrum Data from a mute AudioSource

Discussion in 'Audio & Video' started by Novu, Feb 21, 2017.

  1. Novu

    Novu

    Joined:
    Feb 21, 2017
    Posts:
    2
    Hey guys,
    at the moment Iam working on a rythm game in VR which uses a beat detection algorithm. If a beat is found the player should hit the drums. At the moment that's really hard, so I'm trying to implement as system as in e.g. Guitar Hero, where spheres lerp in 5 seconds to the drums and you kind of see that there is a beat incoming.
    My idea was to play the song muted and process it with the algorithm to spawn the cubes. 5 seconds later the same song starts to play in another audio source, which means the spheres should arrive at the exact time you here the beat.
    At the moment Iam using

    float[] spectrum = AudioListener.GetSpectrumData (SIZE, 0, FFTWindow.Hamming);

    to get the needed Spectrum Data.
    Unfortunately I can only get the data of the AudioListener meaning all loud Sources in my scene. I need it the ther way round, get the data of my muted source and ignore the playing song. Is there a way?
     
  2. Novu

    Novu

    Joined:
    Feb 21, 2017
    Posts:
    2
    If others run into that problem aswell: A solution is to get the Spectrum Data from the AudioSource. Through that you are able to implement an Audio Mixer that basically mutes the Source before the AudioListener "listens" to it.
     
    sonofbryce likes this.
  3. Rhiknow

    Rhiknow

    Joined:
    Jul 6, 2015
    Posts:
    1
    Thank you!
     
  4. TSantosFigueira

    TSantosFigueira

    Joined:
    Oct 6, 2016
    Posts:
    1