- Home /
What does the numSamples parameter in GetOutputData actually mean?
Unfortunately, the documentation for AudioSource.GetOutputData()
is a bit sparse so, what does the numSamples
parameter mean? And what does the function exactly return (yes, an array but of what exactly)?
Answer by skovacs1 · Oct 14, 2010 at 02:42 PM
The documentation on this is indeed lacking.
If you google define: audio samples, you'll get a fairly clear answer as to what audio samples are, but the simplest explanation is that all digital audio is actually a series of quantized energy levels (samples).
GetOutputData
"returns a block of the currently playing source's output data." numSamples
would be the number of such samples to return and therefore the size of the returned array. The array returned is an array of float
values, representing the quantized value of each sample.
The real question is what "block" is it returning? Is it from the point in the output data where it is currently playing at the moment the function goes through (it reads like this may the case, but doesn't really say) or is it from the beginning of the output data or somewhere else?
As far as I tried the function out, it actually returns the value of where the audio is currently playing.
Your answer
Follow this Question
Related Questions
Unity Unable to Reassign Audio Clip 1 Answer
Too many AudioSources? 1 Answer
GameObject reacts to audio source 1 Answer
Adding Audio clip in scripting 1 Answer
Music works but not when accessed by another script in JavaScript 1 Answer