creating audio "on the fly"

BlitzMax Forums/BlitzMax Beginners Area/creating audio "on the fly"

lotonah(Posted 2006) [#1]
Hi there!

Can anyone help me find a tutorial or any useful information on how to create sounds in the game? Being able to load sound files is great, but not useful in my particular app...I'd like to generate music/sound effects on the fly.

Any help would be awesome!


Grisu(Posted 2006) [#2]
Welcome!

I doubt this is possible with the native bmx commands.

The FMod libary might be worth a look.
http://www.blitzbasic.com/Community/posts.php?topic=49584


Who was John Galt?(Posted 2006) [#3]
Yeah letonah I have done this - take a look at my posts in the thread Grisu's linking for a code example. If you're on Windows, take note of Tea's comment in the thread about declaring functions "Win32".


H&K(Posted 2006) [#4]
From the docs
' createaudiosample.bmx

Local sample:TAudioSample=CreateAudioSample( 32,11025,SF_MONO8 )

For Local k=0 Until 32
        sample.samples[k]=Sin(k*360/32)*127.5+127.5
Next

Local sound:TSound=LoadSound( sample,True )

PlaySound(sound)

Input



kfprimm(Posted 2006) [#5]
nvm


lotonah(Posted 2006) [#6]
H&K:

I think you've nailed it for me. That works on all 3 platforms I'm running, and it seems like a nice building-block to get to where I want to be. MANY THANKS!!

Now where did you find this in the docs? I hate the way they're laid out.

Platforms: OS X (PowerPC (G3 & G4)), WinXP Pro (Sempron 2500), Win98 SE (Athlon XP)


H&K(Posted 2006) [#7]
They are in the Audio samples bit af the modules dos, just below the audio mod.

I agree about the docs. There is a nice little searchable chm doc arround somewhere (cannot remember link), and that helps a bit


ImaginaryHuman(Posted 2006) [#8]
How would one go about constantly generating new sample data in realtime and also playing that sample data, so that there are no breaks in the playback?


H&K(Posted 2006) [#9]
One would write a good class wrapper. HAHAHAHA. (I dont know)


ImaginaryHuman(Posted 2006) [#10]
I guess you could make samples that fade in and out at the ends and then they can overlap a bit, if it were a sort of new-age kind of music or something. :-)

Or is there some way to do a constant audio stream from a looping writeable buffer?

Or is it possible to play a sample, and modify the sample itself, at the same time? Then you could loop the sample, and write new data to it like a circular buffer while it plays?


REDi(Posted 2006) [#11]
Or is there some way to do a constant audio stream from a looping writeable buffer?

Skidracers PortAudio module is what I use for maxmod, its on the modserver so you'll need to syncmods to get it, something like...

syncmods -u YourUserName -p YourPassword axe.portaudio

otherwise OpenAL


Who was John Galt?(Posted 2006) [#12]
or FMOD