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.

DarkBASIC Discussion / Help with getting simultaneous playing of music tracks

Author
Message
muckers
18
Years of Service
User Offline
Joined: 18th Jun 2006
Location:
Posted: 18th Jun 2006 12:57
Ok, a minor thing I know, but everything else in my game is working fine and I just want to fine tune things like this.

Rather than having a single track looping over and over again, I wanted to load 2 or 3 music tracks, and have them play one after the other.

However, I can't get this to work. Here's an example of what I tried most recently:



So, what I *thought* I'd coded was an if statement telling DB that if the value of music 2 playing was zero (ie. the music isn't playing) then play music 3.

I assumed that once music 2 had stopped playing, it's playing value would be zero and it would start the third music track.

Instead, what happens is the track stops playing but music 3 doesn't start playing.

I then tried assigning manual changing of the music to two random keys (just to test the conecpt)



And here, nothing happened when I pressed those keys.

So I'm wondering if anyone can help, not necessarily with the manual chaing by a key press, but an automatic playing of one music file once another has finished playing.

Thanks in advance.
muckers
18
Years of Service
User Offline
Joined: 18th Jun 2006
Location:
Posted: 18th Jun 2006 13:57
Ok, a minor thing I know, but everything else in my game is working fine and I just want to fine tune things like this.

Rather than having a single track looping over and over again, I wanted to load 2 or 3 music tracks, and have them play one after the other.

However, I can\'t get this to work. Here\'s an example of what I tried most recently:

Quote: "rem Load music
LOAD MUSIC \"musicgame_01_electric_hellfire.mp3\",2

LOAD MUSIC \"musicgame_02_Bite_the_Bullet.mp3\", 3

rem play EH-BLS
PLAY MUSIC 2

rem play other music
if music playing(2)=0

PLAY MUSIC 3

endif"


So, what I *thought* I\'d coded was an if statement telling DB that if the value of music 2 playing was zero (ie. the music isn\'t playing) then play music 3.

I assumed that once music 2 had stopped playing, it\'s playing value would be zero and it would start the third music track.

Instead, what happens is the track stops playing but music 3 doesn\'t start playing.

I then tried assigning manual changing of the music to two random keys (just to test the conecpt)

Quote: "
If inkey$()=\"m\"
STOP MUSIC 2
PLAY MUSIC 3
endif

If inkey$()=\"n\"
STOP MUSIC 3
PLAY MUSIC 2
endif
"


And here, nothing happened when I pressed those keys.

So I\'m wondering if anyone can help, not necessarily with the manual chaing by a key press, but an automatic playing of one music file once another has finished playing.

Thanks in advance.
Sven B
20
Years of Service
User Offline
Joined: 5th Jan 2005
Location: Belgium
Posted: 18th Jun 2006 14:05 Edited at: 18th Jun 2006 14:06
well, I'll explain

You tell your program to start to play the music.

2milliseconds after that, it tests if one of those keys are pressed, or in the first code, tests if the music is playing , 2ms after you started it (which is always true ofcourse).

Since no person can press a key 2ms after the program started (unless maybe you keep it down before it even starts), the music will not be played.

THE solution is kind of what DBC is all about: loops.
if you type instead of



Then it would work.
the loop will repeat itself endlessly until the music is not playing. If so, it skips the loop and starts with the next command: play music 3.

There are different sorts of loops, so its the job of the programmer to see which one fits its program.

It's the programmer's life:
Have a problem, solve the problem, and have a new problem to solve.
muckers
18
Years of Service
User Offline
Joined: 18th Jun 2006
Location:
Posted: 18th Jun 2006 14:08
Ah of course. Always a simple solution. ^_^

Thanks, I'll try that now.

Login to post a reply

Server time is: 2025-05-25 02:10:19
Your offset time is: 2025-05-25 02:10:19