|
Hello, I got this script from this thread I started. How can I use it to detect a sudden increase in volume, (like a drum beat) and then tie it to another function (like increasing the velocity of a particle emitter or spawning an enemy)?
(comments are locked)
|
|
I havent tried it, but perhaps you could sum all the samples within a RMS and check if it makes an abnormally large jump in the sum? The RMS function seems to be summing your samples already? so the "vol" variable, isnt that the thing you should be watching? perhaps if you store the value from each update in a "previousVol" somewhere globally and then compare the previous to the new vol. If the difference is... lets say 30 then you have a spike. Then you call your "volumeter trigger"? Wouldnt that do the trick? How would I do that?
Dec 18 '10 at 01:48 AM
Tyler 2
How would you do what?
Dec 18 '10 at 02:19 AM
BerggreenDK
"sum all the samples within a RMS and check if it makes an abnormally large jump in the sum?"
Dec 18 '10 at 02:29 AM
Tyler 2
I believe the RMS function already does it for you. Do you understand what the script does or how much practice do you have? Not to be rude, but I am trying to understand your question.
Dec 18 '10 at 02:44 AM
BerggreenDK
You're not being rude.I think the script I posted takes the volume of of the audio in the scene every interval? I am not very good at scripting. I dont know how I would "store the value from each update in a "previousVol" somewhere globally and then compare the previous to the new vol."
Dec 18 '10 at 06:18 AM
Tyler 2
(comments are locked)
|
|
If you want to detect a sudden peak just check the absolute value of the samples:
This is simplified, better analysis would require more complex code. You would probably have to develop some heuristics to distinguish beats from other sounds in the music. Thanks. I added that to the script I posted above, and even though I am getting no error, I cannot get anything to happen when the audio increases (even if I set the threshold to .1). Tyler 0 secs ago
Dec 18 '10 at 05:50 PM
Tyler 2
This is a function that you call like the RMS funcion. something like: if (ExceedsVolumeThreshold(window))
Dec 18 '10 at 10:49 PM
_Petroz
Thank you. Is there a way to analyze audio BEFORE it plays? I know that is odd, but in music generated games like audio surf and rhythm zone, that is done (I presume it would help performance)?
Dec 19 '10 at 06:46 AM
Tyler 2
Also, this is going to need some fine tunning, do you have any idea on how I could accuratly test to see if it is detecting beats (I want to eventualy make something like this http://youtube.com/watch?v=xH20F6Q3trY or this http://www.youtube.com/watch?v=cInI1DDpVjM&feature=related if that helps put it into context)
Dec 19 '10 at 07:29 AM
Tyler 2
(comments are locked)
|
