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.

Newcomers DBPro Corner / Loop command doesn't seem to work on mp3 music

Author
Message
aldoro101
5
Years of Service
User Offline
Joined: 27th Apr 2014
Location:
Posted: 17th May 2014 19:38
I'm working on a bit of a project right now, and I want to loop mp3 tracks in my code. I use the Loop Music command and the mp3 track I want. When it plays the loop, it only loops once. I have no stop commands set in place to end a music loop. I checked through my code extensively and I can't find anything that would be in conflict with the music loop. Can somebody help me out?

Man everybody got aids n' $h1t.
nonZero
8
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 21st May 2014 00:20
I dunno how good my memory is but I vaguely recall that LOOP MUSIC needs to be called inside a loop. If it isn't a syntax problem, it may be a buffering problem so perhaps leaving it running a minute or so. Also make sure the mp3 is correctly clipped etc. Try other formats too.

"Oh nonZero, let me tell you, I love you." -- Dark Java Dude 64, Vice-Kapitan of nASA(nonZero's Awesomeness-Spreading Association)
TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st May 2014 00:24
In the worst of cases, you can try removing your "loop music" command, and place this in your main loop:



Your mod has been erased by a signature
nonZero
8
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 21st May 2014 13:02 Edited at: 21st May 2014 13:06
I solved the problem. There is a bug is the LOOP MUSIC command. After going over the src for a game I made, I noticed I was using LOOP SOUND instead.
The command is more robust:
* Lets you specify a start, end and initial position for the music.
* Lets you use 3D sound and position/rotate the listener.
* Comes with all standard features like volume control, pause, resume, etc.
* Works just like the MUSIC commands.
* Only downside is it seems to be .wav only
I know wav-format is disk consuming but it is higher-quality than even 320kbit mp3 (when converting from source, obviously mp3 -> wav won't increase the quality). If the size is a problem, you can easily just compress (zip) your sound/music folder in your release and have your games uncompress what you need at each level load, then delete it at each level end.

Side-note: Maybe try making my next side project an assets-on-demand compressor for these situations, IF one doesn't exist (I'm sure it does). Or maybe I make a better music plugin, lol.

"Oh nonZero, let me tell you, I love you." -- Dark Java Dude 64, Vice-Kapitan of nASA(nonZero's Awesomeness-Spreading Association)
TheComet
12
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 21st May 2014 14:06
Just a few notes on load sound:

* Works with .mp3 files as well as .wav files
* BEWARE: "load sound" will dump the entire sound file into memory, and takes a lot longer to load! "load music" only streams the music from disk, and loads very quickly.

Your mod has been erased by a signature
nonZero
8
Years of Service
User Offline
Joined: 10th Jul 2011
Location: Dark Empire HQ, Otherworld, Silent Hill
Posted: 22nd May 2014 11:29
Quote: "Works with .mp3 files as well as .wav files"

It does? It didn't work for me, got the "Could not load sound at line *" error years back and had to waste time converting stuff to wav. I just tried it now since I upgraded to 7.5 a while back but still no luck. What version are you running? I'm on 7.5 now and it still fails. Maybe I've been messing up somewhere? I had it down to DBP being DBP. Unless it's a VBR thing since most of my mp3s are VBR.

Quote: ""load sound" will dump the entire sound file into memory"

Aside from the initial load (load sound = ~200ms for a 51 second wav vs load music = ~150ms for the same length mp3), isn't that a good thing? I mean a 2 minute song at a decent sampling rate costs you ~19MB memory but you're guaranteed way less latency and your CPU won't take a hit buffering x seconds ahead constantly (assuming it buffers about 5 to 10 seconds with loop music, I have no clue what DBP does with media) since the whole thing is buffered in one go (or am I way off base? I'm still only just getting the hang of optimization).
Of course if OP wants a 5 minute song, that'd be around 49MB memory, much like loading five 1 minute songs so I see where you're going in the long run and you do have a very good point which I'll bear in mind myself

"Oh nonZero, let me tell you, I love you." -- Dark Java Dude 64, Vice-Kapitan of nASA(nonZero's Awesomeness-Spreading Association)
The Tall Man
6
Years of Service
User Offline
Joined: 16th Nov 2013
Location: Earth
Posted: 26th May 2014 10:31 Edited at: 26th May 2014 10:37
I ran into the same thing in DarkGDK a while back (they share the same source-code). Yeah it's a bug in the command's implementation (for PlayMusic as well). Here's the work-around I found.

In your main loop, check if the music is still playing. If it is not, then call the Stop command (even though it's already stopped). This provides some cleanup that the source-code developers forgot to include. Then call the Loop Music command again. I've had to do this for PlayMusic (for repeated plays) and LoopMusic (for continuous loops).

Not really a difference between Play Music and Loop Music here, but give it a shot.

Here's my DarkGDK post about it:
http://forum.thegamecreators.com/?m=forum_view&t=208800&b=22

Judging what we see is the greatest blinder and self-limiter in the universe.

What we perceive is never reality. It is only a story we tell ourselves based on our current perspective, which has far more to do with our beliefs about ourselves than with anything else.

Login to post a reply

Server time is: 2020-01-23 01:23:06
Your offset time is: 2020-01-23 01:23:06