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 Professional Discussion / music playing() not returning correct value if used after sync command

Author
Message
JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 31st May 2011 21:22




gosub _initMusic
print "numberOfSongs =" +str$(numberOfSongs)
for h = 1 to numberOfSongs
print song$(h)
next
gosub _playMusic

print "thisSong"+str$(thisSong)

sync on : sync rate 0
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 1st Jun 2011 00:03
My experience with those functions (music playing(), music looping(), sound playing() and sound looping()) is generally bad; most of the time they constantly return false for me (and have done so for several years).
It might be that they are only applicable to certain sound files (ie. midi and 8 bit pcm wave or something). You can always try posting this to the bug reports forum and see what happens though


"Why do programmers get Halloween and Christmas mixed up?"
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 1st Jun 2011 01:59
I had a similar problem, and posted a working and not working snippet in a post on the Newcomers forum. >link<

Can u see if my code helps? and if not, perhaps we should see if this has already been reported as a bug?

JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 1st Jun 2011 08:48
For some reason (my ignorance I'm sure) My original message didn't come out as planned.

I am wanting to allow the user to play their own mp3 files in a game I am writing. I have found the exact cause of my problems, but I've searched the boards and haven't found very much.

If I run all of my code (which isn't practical) before the sync statement, it all runs fine. But if any portion of the code resides after the sync statement, it returns a 1 for music playing() even after it has stopped.

I've also tried to use music exist() which works in a test for me, without the sync statement but has the same problem as music playing()

I am trying, again, to include the real code example, without erasing all of my text, like I did last time.

If, I keep the "while music playing()" set of code above the sync it works, below the sync, it fails to load the second song.



here (hopefully) is the code:

=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 1st Jun 2011 10:49
I'd prolly need to see the rest of your code to help you further.

I don't see a play music command, nor a sync in the snippet u provided.

Did you try both my snippets from the other board linked above, did either of them work for you?

>Edit<

I notice in the code you have provided, that you are making a loop by using the goto command, it would be better to use something like a do/loop.

Secondly, in this loop, you have the line



being called over and over again as it loops, this is not needed. This line should only be called once, and be positioned at the top of your code outside of the loop.

baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Jun 2011 12:14
There have been some problems with these commands but I believe they have been fixed in the latest update of DBP.

Try downloading it here:
http://forum.thegamecreators.com/?m=forum_view&b=1&t=180294&p=0

Quote: "Sound
-----
Fixed issue with OGG sounds not detecting end of loop or end of sound (sound playing()=0)
When pausing and then unpausing a looped sound, the sound would stop playing at the end - this has been corrected
Further tweaked OGG file end detection to handle more OGG types

Music
-----
Major reorganisation of the Music plug-in - separation of the 3 different music player types into classes"


Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 1st Jun 2011 12:31
Also, the main loop might need a sync command to update the playing functions, i.e. instead of



use



Not sure off-hand whether that applies to sound or music or both (or even neither ) but I'm sure at least one of them needed the sync at some stage.
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 1st Jun 2011 19:57
@Baxslash:
I'm pretty sure I had this issue running one of the later 7.7 rc's.

JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 1st Jun 2011 22:23
Thanks everyone for your input. Nothing that was suggested seemed to solve the issue, until I downloaded the update suggested by Baxslash

Problem Solved!

Thanks!
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Jun 2011 23:37
Quote: "I'm pretty sure I had this issue running one of the later 7.7 rc's."

Really? That's a shame, I thought they'd finally sorted it out...

I guess there are workarounds though. Just a bit of a pain.

DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 2nd Jun 2011 13:29
I'm still on 1.075 and have no issues with sound here. I have had them in the past however. Was thinking of updating but will hold fire for now by the sounds.

http://s6.bitefight.org/c.php?uid=103081
JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 3rd Jun 2011 07:59
I'm baaaaaaaaaack. It didn't fix the problem. I thought it did because the test code I was using ran twice instead only once as usual.

I have done a work around by making a standalone, mini MP3 player that is kicked off with execute executable. I can kill it when the game is over.

As soon as the application that I am writing encounters the sync on command, it no longer keeps up with the pointer for music playing().

Also, if anyone knows of a dll that will allow me to record and choose the recording specs, (at least 44.1 khz mono) and could give me some basic instructions on how to implement, I would greatly appreciate it. I have looked all over the boards (including the dll board) and have only found one entry that basically was old and didn't provide any code that would (I could) compile.

I have lots of different outboard recording hardware and would like to be able to select the hardware and set the recording specs, AND it needs to be able to play and record at the same time.

DBPro will play and record at the same time, but will only record at 11 khz mono on any of my systems, whether playing or not.

Thanks for everyone's input. I tried all of the suggestions (desperate) with no results.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 5th Jun 2011 00:54
Quote: "It didn't fix the problem."


Could you post the code you are using? The snippets you posted before aren't complete.

And why are you only testing the first music file in your loop?
JRNTexas
15
Years of Service
User Offline
Joined: 24th May 2011
Location: Austin, Texas
Posted: 16th Jun 2011 02:28
I found the problem.

I was using fastsync.

The help lists the command: FASTSYNC Non Display Update Flag

You can use this command to squeeze a few extra clock cycles out of your main loop and make your applications faster. If you require this command to perform non display updates similar to SYNC command, pass in an optional parameter of one.

If you do not put a 1 in the non display update flag, it does not update sound playing()

I did not have the 1 in place and consequently, it would set the flag to 1 when the sound started playing but it would not set it back to 0 when it stopped.

Problem solved!
LailaSmith01
15
Years of Service
User Offline
Joined: 15th Jun 2011
Location:
Posted: 16th Jun 2011 03:37
I was also looking for some solution on this over the net. Thanks for all your replies. It helped me too!

<a href="http://www.petstreetmall.com/Pet-Exercise-Play-Pens/492.html">Dog Pens</a> - 30% Off & FREE Shipping on Dog Exercise Pens, Dog Pens - Lowest Price

Login to post a reply

Server time is: 2026-07-10 20:05:40
Your offset time is: 2026-07-10 20:05:40