Hi, hope someone can explain this in more human language then it’s written in manual.
Here’s how I’ve understood it, but it looks almost wrong to me…
(the calculations are made for 44,1KHz)
Once you call SoundMixer.computeSpectrum() you get 2048 bytes, 256 x 4 for left channel and 256 x 4 for right channel. The question is what time it describes? Meaning… it can’t be 44100 * 2048 (90 316 800) bytes per second! Just because it is nearly 100 times more than average WAVE file would need for the double sample rate…
It’s only giving you back the volume of the 8 frequencies (8 for left, 8 for right) for the exact moment you call computeSpectrum()
If you were doing a visualization for music, you’d call computeSpectrum() every frame (or on a timer) and then adjust your visuals based on the frequencies’ amplitudes.
Huh… than, correct me if I’m wrong… to fully reproduce the sound that plays at 44KHz for 1 second you’d need a file of some 80-90Mb (no way…)? Where does it get this info from? It can not be in the loaded file…
And, it’s not the case… meaning, I don’t need to make a visualisation for sound, I’m trying to write and than save the played sounds. So… if this means that the bytearray it returns describes 1/44100 sec duration, than, it’s impossible to do…
[quote=wvxvw;2344370]Huh… than, correct me if I’m wrong… to fully reproduce the sound that plays at 44KHz for 1 second you’d need a file of some 80-90Mb (no way…)? Where does it get this info from? It can not be in the loaded file…
And, it’s not the case… meaning, I don’t need to make a visualisation for sound, I’m trying to write and than save the played sounds. So… if this means that the bytearray it returns describes 1/44100 sec duration, than, it’s impossible to do…[/quote]
computeSpectrum() wasn’t set up with the intention of copying/saving sound files. It just analyzes any and all audio that is audible in the player when you call it, for that moment.
Seems like I strart understanding it… (a bit late though =) computeSpectrum() gives you some data not really related to the sound you’re playing, it’s sort of Bitmap.draw() which will not reproduce what you had in the original file… Yes, I realize saving audio files wasn’t the purpose of it… but, there’s no other way you can get any data of sounds you play in your app… (which is even worse than AS2…) And, what is really even more weird… there’re tools like Zinc, that let you do it with no effort at all… (meaning, it can be done, and there’re API for it…)
Anyway… thank you for explanation.