Sounds on the fly
BlitzMax Forums/BlitzMax Programming/Sounds on the fly
| ||
I was wondering, is it possible to create sounds from within BlitzMax, without using a sound file? I talking about in the same way we used to create sounds on the 8-bit computer. |
| ||
Ah, I think I have just answered my own question. Am I right in thinking the CreateAudioSample command does this? |
| ||
I found this somewhere which does it:Const freq:Int=44100 Const updatespeed:Int=10 Const buffersize:Int=freq/updatespeed Local buffer:TAudioSample[2] buffer[0]=CreateAudioSample(buffersize,freq,SF_STEREO16BE) buffer[1]=CreateAudioSample(buffersize,freq,SF_STEREO16BE) Global sound:TSound[2] sound[0]=LoadSound(buffer[0]) sound[1]=LoadSound(buffer[1]) Playsound sound[0] |
| ||
Just give a look to the help of BlitzMax, from the example' 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 of course you need to 'fill' in the proper way the Audio Sample... |
| ||
I wrote this a while back: (BMX) Synthesize a simple sound sample |