Generative Music with GS?
Just wondering if you think it would be possibly AND plausable (performance-wise) to try and implement a generative method of music for my game. Essentially what I would want to do is this:
Have 4 actors placed on each corner of the screen each with a rule somehow implementing the game.time % = every 2 seconds > generate a random number between 1,50 and if = 1 > play sound1, if 2 play sound2, etc.
There would be different sound/random # bank on every actor and each would have a different time they play music at like every 5 seconds or every 10 seconds. Anyone mess around with this sort of thing yet? Also, if anyone knows what the equation would be for me to use game.time % x = every 2 second, every 5, 10, etc that would help also! Thanks.
Have 4 actors placed on each corner of the screen each with a rule somehow implementing the game.time % = every 2 seconds > generate a random number between 1,50 and if = 1 > play sound1, if 2 play sound2, etc.
There would be different sound/random # bank on every actor and each would have a different time they play music at like every 5 seconds or every 10 seconds. Anyone mess around with this sort of thing yet? Also, if anyone knows what the equation would be for me to use game.time % x = every 2 second, every 5, 10, etc that would help also! Thanks.
Comments
Yea I think as long as you're working with samples, it would be plausable. I've been interested in some audio apps as well with GS. I don't have any advise on the how too's though unfortunately. I'm not aware of GS having any kind of sine wave generators or other fundamental synthetic capabilities.. but it sounds like you're not too concerned with pure audio generation as much as accurate manipulations of samples triggered by various "game rules".
So yea about the sample triggering, it seems like audio is pretty responsive and I would imagine as long as you don't have too many sounds going off at once it will sound good. I only say "too many sounds" because it's not uncommon to find apps that don't account for excessive volume and end up distorting.
Good luck!
allowing the music seemlessly change without the user realizing that the soundtrack change, but instead it subconsciously influences his emotions while playing the game.
120 bpm offers two beats per second and is really easy to set up
fire the beat trigger (clock) from a single actor and have everything triggered off it. It avoids timing issues with repeated loops and any slippage.
There is no tone generator but a single complete waveform is enough to build from. You can loop it, change it's pitch (look up the pitch relationships for tones via google), and overlay harmonics as separate samples. It can also be enveloped.
cheers kipper
"Create an index/integer attribute called zero. Give it a value of 0.
When zero=floor( self.Time *20)%2
...do stuff
That will 'do stuff' every 0.1 seconds.
Adjust the '20' to change that. Without the '20' it will do stuff every 2 seconds."
@Mammoth...that's the concern I have: I think if I have a blank scene with not much going on it could be done, but running in the background of an actual game that already has a lot going on might destroy the FPS
Yeah as Kipper says picking the right tempo is key and 120 would be the easiest.
The way I found to best trigger the audio is to have a set of conditions with the above rule included. When the conditions are met have a 'play music' boolean that is triggered.
And a separate rule when play music is true, play sound (looped). Assuming you have loops that are at least a few bars in length.
So in your case:
when button is touched
and when zero = (game.time*2)%2 [to start the loop at intervals of 1 second]
change attribute play music to true
Unless you want to have very short loops, i.e drum hits etc. In that case just use the the above code and it will loop the sound every amount of time you specify.
That's what I used for Honey Tribe, but at a different tempo. It feels much nicer with all the sound fx and loops being in time.
----------
"Honey Tribe is not only a remarkably endearing little game, but it's also incredibly addictive." Pocket Gamer
"...a touch above the rest in the endless running genre" 148apps.com
Say hi on Twitter
Like us on Facebook
www.HoneyTribeStudios.com
If you want to save on overall pacakage size, use .ogg files.
If you want to save on RAM usage/loading times use .caf
(Someone did a test a posted the results somewhere around here)