Wintermute Engine > Scripts, plugins, utilities, goodies

How to crossfade two music files

<< < (2/3) > >>

Mnemonic:
odnorf: But note that Jerrot's code only manipulates the volume when crossfading. You'd have to catch the user modyfing music volume (e.g. in a settings window) and then change the volume of our music1 and music2 entities.

odnorf:
Hmmm... that's true. The modified Jerrot's code works well if we don't change the GlobalMusicVolume while it crossfades. But if we change the volume then it will work only when we change the scene. I'll think a better way when I got the time (and I'll got a lot of free time in 2-3 days).

Jerrot:

--- Quote from: Mnemonic on June 07, 2003, 08:56:44 AM ---May I have a small suggestion? If you put the entity loading code into this function, you won't have to modify game.script at all:

--- End quote ---

Oh, right, that'd be better - I will update my post tomorrow. (too tired today)


--- Quote ---It's "SOUND_PANNING". It shoudn't crash, though...

--- End quote ---

Ah! Works! :) Actually I just guessed - the entity attribute by scripting is "SoundPanning", the ".entity" file format is not documented yet and I just tried it like "active", "scalable", etc. !

BTW it does not crash, but the "Loading..." appears and stays.

Jerrot:

--- Quote from: odnorf on June 07, 2003, 07:05:11 PM ---Hmmm... that's true. The modified Jerrot's code works well if we don't change the GlobalMusicVolume while it crossfades.

--- End quote ---

Yep, that's what I told you by MSN, the for-next could get in trouble. Maybe one should check this in the loop - and if the volume was altered while proceeding the function, it should just exit the crossfading and set the new volume. Guess that's easy. Although I'm not sure yet, if the whole thing wouldn't be better replaced by some built-in function doing this stuff here.


--- Quote from: odnorf on June 07, 2003, 07:05:11 PM ---But if we change the volume then it will work only when we change the scene. I'll think a better way when I got the time (and I'll got a lot of free time in 2-3 days).

--- End quote ---

I did not get the last one - if you change the volume by some settings screen, you can set the SoundVolumes of both music entities and your code should work.

odnorf:

--- Quote from: Jerrot on June 10, 2003, 09:22:15 AM ---
--- Quote from: odnorf on June 07, 2003, 07:05:11 PM ---Hmmm... that's true. The modified Jerrot's code works well if we don't change the GlobalMusicVolume while it crossfades.

--- End quote ---

Yep, that's what I told you by MSN, the for-next could get in trouble. Maybe one should check this in the loop - and if the volume was altered while proceeding the function, it should just exit the crossfading and set the new volume. Guess that's easy. Although I'm not sure yet, if the whole thing wouldn't be better replaced by some built-in function doing this stuff here.

--- End quote ---

But if we change the volumes in the for-next loop some nasty things might happen. For example, the volumes can go to a negative number (I just tested it). Ofcourse it can be solved by using a few if() but the code gets agly and the volume-changes while crossfading sounds bad. It seems that I am too lazy right now to do more tests... And I have to agry again with you that a built-in function is a much better idea.
Like Crossfade(MusicX, SpeedValue)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version