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 / Pause Music Loop Music Glitch?

Author
Message
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 6th Dec 2008 23:18


Why does that work (Press space bar to pause music) and when you replace the second loop music with resume music, it does not? Attached is the code with .mid file...

Attachments

Login to view attachments
Kira Vakaan
16
Years of Service
User Offline
Joined: 1st Dec 2008
Location: MI, United States
Posted: 7th Dec 2008 00:17
That's interesting. I have no idea why resume music has no effect. At first I thought that maybe it had something to do with the fact that the music was looping, and not just playing through once, but it doesn't seem to have any effect at all. I mean, not even something as simple as this works:



I also noticed something a little strange about resuming the music like you show in your code example. Although the music continues, some of the instruments are replaced with a grand piano, which I know to be the first MIDI instrument. I don't understand why. Maybe that's just something specific to my own system...
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Dec 2008 02:02
Firstly, don`t use midi music, because they suck. Use Xm or mp3 or wma, just not midi.

Secondly, you are not using the variable "press". If the spacebar is pressed, it equals 1, else 0, but you don`t use it anywhere.

You should use:

Quote: "Load music "BGLOOP2.MID", 1
Loop Music 1

Do
If SpaceKey()=0 and Press=1
Press=0
Endif
If SpaceKey()=1 and pause=0 and press=0
If Press=0
Pause=1
Press=1
Pause Music 1
Endif
Endif
If SpaceKey()=1 and pause=1 and press=0
If Press=0
Pause=0
Press=1
Loop Music 1
Endif
Endif
Loop


end"


This is a glitch that can`t be solved. The only way to fix it, is to not use midi!

TheComet

Peachy, and the Chaos of the Gems

Irojo
17
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 7th Dec 2008 03:07
Speaking of glitches, am I the only one who sees this thread has 1 more post then it actually has on the main page, however has the accurate messages on this page?


I download memory.
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 7th Dec 2008 06:39 Edited at: 7th Dec 2008 06:40
@ Comet

The Press variable is so that the space bar option does not repeat none-stop as it is held. If the space bar is pressed, press is set to 1, so that it will not go back to that condition. When you let go, it goes back to 0, then press again to resume.

I only used Midi as an experiment.

@ Irojo

I think that is just you, it shows correctly for me. (Post amount)

TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Dec 2008 13:53
Quote: "The Press variable is so that the space bar option does not repeat none-stop as it is held. If the space bar is pressed, press is set to 1, so that it will not go back to that condition. When you let go, it goes back to 0, then press again to resume."


Yeah, that is what it does, you`re right, but you don`t check it anywhere. That`s why I say you`re not using it.

Does it work with mp3?

TheComet

Peachy, and the Chaos of the Gems

Latch
18
Years of Service
User Offline
Joined: 23rd Jul 2006
Location:
Posted: 7th Dec 2008 15:34 Edited at: 7th Dec 2008 15:38
Quote: "...midi music, because they suck"

I disagree that midi s.... As sound cards improve and samples are used in wavetables, midi files are not only small and portable across multiple hardware (including computers and electronic instruments), but the sound qaulity (based on the sound card or software drivers) can be exceptional. And because midi events - including notes - are consistant finite numbers, they can be used to trigger ANYTHING in hardware or software. Let me climb down from my soapbox now...

@Maindric
The problem today is most computers aren't set up properly to deal with midi - so in using DarkBASIC, I would agree it's probably better to avoid using midi if you plan on distributing your app unless you handle it outside of using the DarkBASIC commands. Memory and size limits aren't the same when midi was very popular for video games; so using mp3's, trackers, even wav files is passable. Though, with old DOS games, there was always a setup program to test compatibility and setup the sound card...

Anyway, in answer to your original question,

Quote: "Why does that work (Press space bar to pause music) and when you replace the second loop music with resume music, it does not?"

On my computer it works both ways so I couldn't "break" it to observe the problem but, I think DBC uses MCI string commands (those are media commands from the win32 api) to play midi files. There is a problem with an MCI midi sequence driver called mciseq that may or may not recognize the MCI string "resume" . So, if the problem is with the driver, it may do unpredictable things (like not play with resume or reset the midi instruments).

@Kira Vakaan
Quote: "I also noticed something a little strange about resuming the music like you show in your code example. Although the music continues, some of the instruments are replaced with a grand piano, which I know to be the first MIDI instrument. I don't understand why. Maybe that's just something specific to my own system..."


Only some of the instruments are replaced, or all of them? An explanation can get complicated but it's probably a driver on your system. A midi file is based on a series of events - play a note, change an instrument, add reverb, hold pedal... etc. An instrument change may be indicated at the beginning of the file and never again throughout the file. The general default if no instrument change is indicated is instrument 1 and Channel 1 to play all of the notes in the file. If the software or maybe even the hardware doesn't maintain the channels or the instrument settings when the midi is paused or stopped, then continues playing the file from the halted point, it may revert to the defaults.

Enjoy your day.
TheComet
17
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 7th Dec 2008 18:26
Quote: "Are we looking at the same piece of code? He does check it even twice."


*Bash my head on my bed*

Sorry, you`re right. I didn`t see the "if press=0"

Sorry!

TheComet

Peachy, and the Chaos of the Gems

Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 7th Dec 2008 19:11
@Irojo

Ok, your explanation makes sense. Thanks for clarifying.


@TheComet

I know enough about programming that I would not add a useless variable like that.


@WindowsKiller

Thanks for pointing that out.

Irojo
17
Years of Service
User Offline
Joined: 21st May 2008
Location: Eating toast.
Posted: 7th Dec 2008 19:14
Bizarre glitch.

My macintosh is showing the right amount of posts on the same page. :S

Quote: "Ok, your explanation makes sense. Thanks for clarifying."


I didn't clarify it after the first post. Am I missing something, or did you put the wrong name there?


I download memory.
chunks chunks
18
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 7th Dec 2008 20:26 Edited at: 7th Dec 2008 20:27
try my mp3 plugin you should be able to use it with load dll/call i think.
http://forum.thegamecreators.com/?m=forum_view&t=139418&b=18

although it does not play midi`s , ive got some c++ code for midi`s i could knock a quick dll up if it`s needed it might not produce a glitch ..


chunks

nvidia geforce 8600gt + amd athlon 64
windows xp pro.
Not_Maindric
17
Years of Service
User Offline
Joined: 10th Jul 2007
Location: Omaha, NE
Posted: 7th Dec 2008 20:31
@ Irojo

Thanks for informing me. That batter?


@Chunks

Thanks for that, I will check it out and test it. I have been looking for something to let me know where in the song you are. =D

chunks chunks
18
Years of Service
User Offline
Joined: 2nd Jan 2007
Location: ackworth uk
Posted: 7th Dec 2008 20:49 Edited at: 7th Dec 2008 20:50
just a quick piece of code on the useage in dark basic classic .



you will have to open the dll in notepad or dll viewer to get the correct function names ...

chunks

nvidia geforce 8600gt + amd athlon 64
windows xp pro.

Login to post a reply

Server time is: 2025-06-07 17:14:46
Your offset time is: 2025-06-07 17:14:46