Page 1 of 1

"layered" music

PostPosted: Sun Jan 30, 2011 5:27 pm
by Toasterman
In some games I've noticed a cool effect with their music that I wondered if you could do in GE
Sometimes there will be one music track playing, and another one with the same tune, maybe with some drums etc, will overlay onto it

Like in Super Mario World on the super nes, the main tune will be playing, but when you get on Yoshi, the same tune will play but with drums
However, the track doesn't start again or anything, it just adds to what is already there based on some context in the game
Could an effect like this work in GE (I suspect they have special programs to do stuff like this)

I don't know any way to change music without restarting the track.
You can only have one music play at a time, but is there a way to have more and just change the volume on one to off and on at certain points?

I can explain better if this is unclear

Re: "layered" music

PostPosted: Sun Jan 30, 2011 6:03 pm
by sonicfire
thats what you could do, yes! start two sounds at the same time and let them loop forever. start the second with volume of zero.
only enable (volume=1) the second sound that should be the additional layer (like drums or something) when you need it.

Re: "layered" music

PostPosted: Sun Jan 30, 2011 6:15 pm
by Toasterman
Heh, for some reason, I thought you couldn't change the volume of sound :oops:
-a self answered question, is that a new dimension of fail or what? :lol:

On a side note, how can you know what channel a sound is on?
Most of my sound and music is generated in game, so is there a way to return somethings channel instead of just guessing?
(I've not really used the stopSound() function much)

Re: "layered" music

PostPosted: Sun Jan 30, 2011 6:21 pm
by Game A Gogo
if I'm not mistaking, playsound2 returns an int, which is the channel the sound is played on. You should check the documentation for further information

Re: "layered" music

PostPosted: Sun Jan 30, 2011 9:21 pm
by sonicfire
Game A Gogo wrote:if I'm not mistaking, playsound2 returns an int, which is the channel the sound is played on. You should check the documentation for further information


Exactly! :)

Use something like:

Code: Select all
musicAvol = 1;
musicBvol = 0;

musicAch = 0;
musicBch = 0;

(...)

musicAch = PlayMusic("musicA.wav", musicAvol, 999);
musicBch = PlayMusic("musicB.wav", musicBvol, 999);


And whenever you want to "play" music B:

Code: Select all
musicBvol = 1;


and for completely stopping any music either stopSound(musicAch); or stopSound(musicBch);


not sure if this also works with playmusic or playmusic2, but it should.
(i still dont know the real differences between playsound and playmusic, i always use playsound :) )

hope that helps :)

Re: "layered" music

PostPosted: Sun Jan 30, 2011 9:42 pm
by Game A Gogo
playmusic always plays the music in the first channel

Re: "layered" music

PostPosted: Sun Jan 30, 2011 9:52 pm
by Toasterman
Thanks :)
That ought to work

The reason I was interested- I thought it would be cool for the music to change dynamically in the level depending on whats happening
Like if the character goes underwater the music turns all muffled or different instruments play, or something
Or in a town or large building, the music looses some of the instruments when you enter a house or move up a level
Maybe it could get more complex the deeper you go into a dungeon or level
Something like that

Re: "layered" music

PostPosted: Sun Jan 30, 2011 11:24 pm
by sonicfire
Game A Gogo wrote:playmusic always plays the music in the first channel


Thanks so much! DidnĀ“t know that :)

Re: "layered" music

PostPosted: Sun Feb 13, 2011 2:30 pm
by BloodRedDragon
I tried this with a guitar hero style game, where the music beats were synced with a grid actor at a constant velocity. The one problem is that if your computer's sound card isnt that great, and the audio quality is higher than 22050 hz, then the music may skip spontaneously every now and then, causing one track to go out of time with another.

One other idea:

Super Mario Galaxy (both games) have homeworld tracks that add more instrumental parts depending on how far you get in the game, meaning there is about five different tracks for the homeworld that change every time you return after defeating a boss (maybe?) This way, you wouldnt have to worry about audio sync. :)