Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Code Snippets / Music Volume Control

Author
Message
XpMe
20
Years of Service
User Offline
Joined: 8th Jul 2004
Location: Dallas Texas
Posted: 22nd Jul 2004 03:56
I found out when I first got DBpro that when you load music that the
volume will jump to a different setting and be too loud or too low
when it starts up(the musics internal vol. settings ?).
When I use the below commands just after loading then the volume stays correct because it is reset too fast to notice a low or high setting.
I haven't ever tried it on music that starts up playing real loud.
If you mouse click on a volume control(including mute buttons also)
the volume never is correct unless you do something like this.
It just has to be called several times like in this loop.
While you press down on the mouse then before you lift your
finger the SetMusicVolume() command will have been called
a few times and force a change of volume.
Anyway this is how I do it and it works for me.
Does it work for you ?

Dirpath$= "D:\"
FiName$ = "HotMp3Music.mp3" ` whatever you choose
Fi$ = Dirpath$ + FiName$
Mvol = 50 ` music volume 0-200
Mnum = 1 ` music number
if file exist(Fi$) = 1
if music exist(Mnum) = 1 then delete music Mnum
load music Fi$ , Mnum
play music Mnum
SetMusicVolume(Mnum , Mvol)
ink rgb(250,235,99),0 : print " Now Playing " + Fi$
endif
wait key
if music exist(Mnum) = 1 then delete music Mnum
end
`called on the next line after play music command
function SetMusicVolume( musicNumber , musicVolume )
if MUSIC EXIST( musicNumber ) = 0 then exitfunction ` no music loaded
for t = 0 to musicVolume
SET MUSIC VOLUME musicNumber , t
next t
endfunction

Login to post a reply

Server time is: 2024-11-23 20:04:01
Your offset time is: 2024-11-23 20:04:01