Sound looping, but not from start?

BlitzMax Forums/BlitzMax Programming/Sound looping, but not from start?

BlitzProg(Posted 2011) [#1]
Usually when you ask for a sound to loop, it will simply repeatedly play itself from the start to the end.

This is unlike some background sounds that plays but do not restart from the beginning in some game, which allow for some kind of "music introduction" to be played before the main music loop starts.

Is there a simple way to do this with a sound?

thanks :)


ziggy(Posted 2011) [#2]
As far as I know, wav files do support a loop start and loop end mark, I'm not sure if BlitzMax sound engine supports it.


BlitzProg(Posted 2011) [#3]
It's not a big deal, i'm just looking forward having simpler ways to do it rather than having to load two different sounds and check whenever the first one is finished to play the second one. >.<

But thanks for the quick answer.

Edit:

I play all games with sound&music on, sometimes I like to download the musics and listen to them again. And just like how the game play them, I only wish to hear the introduction once. That's what i'm wanting to do, if there is a way.

Last edited 2011


SLotman(Posted 2011) [#4]
Should be possible. Code below (just wrote it) can play a music with directsound, starting from a given point:



I had to suspend the GC, otherwise it crashes, probably releasing the sound buffer or something.

Every driver *should* have something like "setPosition" - this would allow to at least loop manually inside the same sample (like the code above), instead of having several ones loaded into memory...

Last edited 2011


SLotman(Posted 2011) [#5]
Better yet: this new code doesn't need to suspend the garbage collector:




SLotman(Posted 2011) [#6]
Best of all solutions: searching the forum I found this post, which made everything so much easier! I honestly didn't know about TAudioSample interface, which helps a lot!



Last edited 2011


Czar Flavius(Posted 2011) [#7]
I just made a global flag which is set when the first sound is finished and kicks off the second. Not pretty, but it works and doesn't require messing around.

Last edited 2011