Streaming sound with bass.dll?

BlitzMax Forums/BlitzMax Programming/Streaming sound with bass.dll?

Who was John Galt?(Posted 2008) [#1]
[EDIT] The title is a bit misleading. I'm trying to synthesize sound on the fly with the cpu, not stream from the net[/EDIT]

This is possible I believe. Anyone got a relevant code example they can post?


Abrexxes(Posted 2008) [#2]
"Generate" sounds and load them with bass ?

Here my function from BBS (Signature). You can translate it to bmax.

Function BASS_CreateBeep%(art% = 1 ,hz% = 900,time% = 100 ,freq# = 44100 , chans% = 1, max% = 1, flags% = 0, onlynew% = 0)
	
	Local q%, y%, yy% , stemp%, length%, tbank%, hfinal%, hchannel%
		length = (((freq*chans)*time) / 1000)*2
			stemp = BASS_SampleCreate(length,freq,chans,max,flags)
				tbank = CreateBank (length*2)
				For q = 0 To (length-1)
						;this 4 are for 44100/mono/16bit (default values)
						If art=1 y=Sin(q/freq*360*hz)*32767
						If art=2 yy=yy+Rand(hz/8,hz*3):y=Sin(yy/freq*360)*16384
						If art=3 yy=yy+Rand(1000.0*hz/(q+1),1000.0*hz/(q+1)*10):y=Sin(yy/freq*360)*16384
						If art=4 y=y+hz*1.45:If y>32767 y=-32767
					
						;feel free to add your own stuff. :)
				PokeShort tbank, q*2, y
				Next
				BASS_RtlMoveMemory2(stemp, tbank, length)
			FreeBank tbank
		hfinal = BASS_SampleCreateDone()
	hchannel = BASS_SampleGetChannel (hfinal, onlynew)
Return hchannel

End Function    


A demo for this (b3d/b+) is included in BBS.

cu


Who was John Galt?(Posted 2008) [#3]
Hi Abrexxes, I'm talking about continuous generation whilst the sample is playing, i.e: the ability to generate a continuously varying sound that plays indefinitely. I think this is slightly different to what you're doing, but thanks for the response. Do you know if what I'm after is possible with Bass?


Abrexxes(Posted 2008) [#4]
You can only modify the playback attributes in realtime with the plugins. A sound lib is not a synthi and buffers are protected inside of bass (or fmod). That means that you can only create a soundbuffer like the code above and manipulate the channel attributes during the playback.

What you need is another way to deal with buffers and pointer routines like VSTi can do it. So, not a "soundlib" but a "waveform generator". Search this site for more informations: http://www.musicdsp.org/

In this case the "soundlib" is only used to "play" your sound (device).

cu


Who was John Galt?(Posted 2008) [#5]
Thanks for the link. I know real-time streaming sound is in fact possible with fmod, but it seems to have a problem with BM's garbage collector, which is why I'm looking for alternatives.