- Home /
Stereo Mix as Input?
So. I was wondering if it was possible to use the Stereo Mix as an AudioSource. I'm experimenting with stuff, and right now I'm making audio visualizers. Is there any way of using the Stereo Mix or the entire system audio output as my AudioSource for visualizing instead of just loading an AudioClip resource from within Unity?
External links and noob tutorials will be highly appreciated. :)
Also, sorry if this is a duplicate, since I'm really really bad at searching.
Answer by gregzo · Aug 05, 2013 at 07:23 AM
Check out OnAudioFilterRead, it gives you access to post spatialisation audio data. It needs to be implemented on an object which has either an AudioSource, or an AudioListener, in which case you'll get the total mix from the listener's pov.
It is not well documented, so here are a few tips :
OnAudioFilterRead on a mono AudioSource will give you stereo data ( if your audio settings are set to stereo, of course ). But... it will give you spatialized data - meaning that gain and pan will vary depending on the AudioListener's position relative to the AudioSource.
Note that data you access is pre AudioReverbZone transformation.
Pipeline Summary : Mono 3D AudioClip ( read/write access through GetData / SetData ) -> AudioSource processes the clip's data to spatialize it -> OnAudioFilterRead access -> AudioReverbZone processes last
Last, OnAudioFilterRead is on a seperate (faster) thread. Special care is required, and you cannot call UnityEngine methods from it.
Hope it helps!
I was asking if it was possible to visualize ALL system sounds. For example, if I play music with iTunes or any other player, my Unity build could read audio from these sources.
Anyway, this helped me a lot in some other aspect. I could probably just stick with this since I'm just experimenting stuff. Thanks :) (yes, any random information is useful for me since I'm still on my way to learning Unity)
But I'm still waiting for an answer for my real issue. :-bd
Sorry for the misunderstanding. You need a plugin to capture system sound. I don't think there are any in the asset store, but surely some C# code can be found on the web somewhere. You'll then need Unity Pro - Plugins are not supported in Free.
Also, the code you'll find will most probably be system specific.
Your answer
Follow this Question
Related Questions
Can not play a disabled audio source 2 Answers
Multi Channel Audio 4 Answers
Specifying OnAudioFilterRead()'s audiosource 1 Answer
Glitched Music 0 Answers
Change music during chase 1 Answer