Dark Bit Factory & Gravity

PROGRAMMING => Freebasic => Topic started by: Shockwave on March 14, 2011

Title: Sound Samples + Song
Post by: Shockwave on March 14, 2011
Does anyone know any good ways of playing .wavs while minifmod is playing?

Cheers and apologies for the dumb question..
Title: Re: Sound Samples + Song
Post by: va!n on March 14, 2011
What about Win32 API PlaySound or DX routines to play wave?
Title: Re: Sound Samples + Song
Post by: Shockwave on March 15, 2011
Hmm, yes I can use the API but I was hoping that there was a way to do it with minifmod :)
Title: Re: Sound Samples + Song
Post by: Shockwave on March 15, 2011
Here's an implimentation of Va!ns idea;

Code: [Select]

    #INCLUDE "windows.bi"       
    #INCLUDE ONCE "win\mmsystem.bi"
    #INCLUDE "explode.bas"

    DIM SHARED PPP AS UBYTE PTR

    PPP=@explode.wav(0)   
    PlaySound(PPP,NULL,SND_MEMORY OR SND_ASYNC)


Explode.bas is just a wav that's been converted with bin2bas, PPP points at the first element of the array in than resource.

It works but it's ugly, occasionally it causes the screen to glitch in tinyptc and you cannot specify a sound channel (as far as I know so if you try and play more than one sample, the other gets cut off).

I am looking for a better solution..

Any ideas?
Title: Re: Sound Samples + Song
Post by: va!n on March 15, 2011
Another idea, that could work but you need to figure out some minifmod things. So what about to add to your module some more (empty/unused) channels? So there are unused channels you can use to play your own samples (waves) when ever you want. Maybe there are two ways from now to realise it: You can add your own samples to the module too or you need to point to your own samples (includes or like your own generated waves). I am sure this would be the best way and you have all sound output by DX ;)

Since i never used minifmod i dont know its API nor SDK and if there are any easy ways available to realize. At least this would be much better and cleaner instead using DX and API for playing wave sounds; but it more work.



[Edit - Added:]
Another thing could be waveOutOpen() and all the API for this, mixing channels by yourself.
Title: Re: Sound Samples + Song
Post by: hellfire on March 15, 2011
Does anyone know any good ways of playing .wavs while minifmod is playing?
I was hoping that there was a way to do it with minifmod :)
The minifmod "api" doesn't offer what you're looking for - in contrast to fmod (http://www.fmod.org/) it's just a black-boxish xm-player and not an actual sound system.
If you want to dig into it, it's relatively easy to include such functionality since everything you're asking for is already in there.
As far as I remember the channel allocation was pretty much hard-wired, though, and probably requires some conceptual changes...

If the samples you want to play are already in your xm-file and it's not occupying all 32 channels I could figure out something quick & dirty.
Title: Re: Sound Samples + Song
Post by: Shockwave on March 15, 2011
As far as I remember the channel allocation was pretty much hard-wired, though, and probably requires some conceptual changes...

For what I want to do, the juice isn't worth the squeeze, I don't even know what song I am going to be using so I think that I'll take your advice and look into Fmod instead, if I run out of time I'll just put up with Playsound.

Looking to the future it would be a really cool extension to tinyptc++ to have sound sample playback included though (I think ufmod is in there already?).


As always, thanks for your help :)