Just realised it would sometimes be handy if you could choose instead of simply using StopMusic to use StopMusicFX or something like that to fadein or fadeout the music.
Naturally I can make a piece of code to handle that, but it is quite a lot of lines and would need to be took into consideration that it doesnt collide with something else.
Especially if you take into consideration the possiblity that pressimg mouse button once would start fading the music, and second press (for impatient ones) woudl completely stop the music, it would be much simpler if Hollywood woudl itself be hadnligh that fading in / fading out part instead of having to program it myself.
PlayMusic / StopMusic with fadein/fadeout
- airsoftsoftwair
- Posts: 5443
- Joined: Fri Feb 12, 2010 2:33 pm
- Location: Germany
- Contact:
Re: PlayMusic / StopMusic with fadein/fadeout
That's quite some work and the sound driver is complex stuff and highly system dependent so it's rather unlikely because the gain is not that great in comparison to the amount of work this would require.
Re: PlayMusic / StopMusic with fadein/fadeout
Hi Bugala, this is just an idea, quick & dirty & untested but it should work since this idea has been used in GEMZ, you can expand the concept and implement easily crossfades between musics, you should also check if the music is playing or not, it may contain errors since I have no way to test it right now :
Code: Select all
OpenMusic(1, "mysong.mp3")
Global musicVolume = 64
Global musicFadeID = -1
Function FadeMusic(fadeIn, speed)
; Check if a fade is already running
If GetType(musicFadeID) <> #NUMBER
; Fade in progress, stop it
ClearInterval(musicFadeID)
EndIf
; Start a fade FX
musicFadeID = SetInterval(Nil, handleFadeFX, speed, { fadeInFX = fadeIn } )
EndFunction
Function handleFadeFX(userdata)
If userdata.fadeInFX
; Handle a fade in fx
musicVolume = musicVolume + 1
If musicVolume > 64
ClearInterval(musicFadeID)
MusicFadeID = -1
musicVolume = 64
EndIf
Else
; Handle a fade out fx
musicVolume = musicVolume - 1
If musicVolume < 0
ClearInterval(musicFadeID)
MusicFadeID = -1
musicVolume = 0
EndIf
EndIf
SetMusicVolume(1, musicVolume)
EndFunction
PlayMusic(1, { volume = 64 })
; starts a fadeout decreasing one volume unit every 100ms
FadeMusic(False, 100)
Repeat
WaitEvent()
Forever
----------------------------
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
[Allanon] Fabio Falcucci | GitHub for recent works | Support me on Patreon for Hollywood libraries | ☆★ All my links ★☆
Re: PlayMusic / StopMusic with fadein/fadeout
Thanks, I might put it in use.