performance problems with bah fmod/irrklang?

BlitzMax Forums/Brucey's Modules/performance problems with bah fmod/irrklang?

dmaz(Posted 2009) [#1]
I switched to bah.irrklang a few weeks ago for a game I'm doing. a week ago I started some performance testing on an older computer and notice a problem. I added some profiling code and started to fix anything that I could. problem was, the slow down turned out to be playing a sound using bah.irrKlang. so I tried bah.fmod... same slow down... no slow down though when using other drivers.

on my older computer with a Creative SB Audigy, Play2d(irrklang) and PlaySound (fmod) take ~7ms and sometimes as high as 16ms to play *one* sound. while the same test takes 0ms for blitzmax's built in drivers or the older fmod mod (from the forums)

here is a basic test between bmax sound and bah.irrklang

numPlayed is to show the diff on faster computers... again, bah.fmod shows the same problem.


dmaz(Posted 2009) [#2]
bah.bass seems to have the same problem...


Retimer(Posted 2009) [#3]
Same problems here. Bass appears to be the slowest comparing to irrklang and fmod =(

Loading the sounds into memory pre-play doesn't appear to help much either.


Brucey(Posted 2009) [#4]
How does this compare ?
Function irrKlang2()
	Local SFXENGINE:TISoundEngine = CreateIrrKlangDevice()
	Local source:TISoundSource = SFXENGINE.AddSoundSourceFromFile("media/bell.wav",,True)
	
	While Not KeyDown(KEY_ESCAPE)
	
		Cls
		DrawText "Press any SPACE to play sound", 50, 20
		Flip 1
	
	
		If KeyDown(KEY_SPACE)
			Local time:Int = MilliSecs()
			For Local i:Int = 0 Until numPlayed
				SFXENGINE.Play2DSource(source)
			Next
			time = MilliSecs() - time
			Print time
		End If
		
	Wend
End Function



Retimer(Posted 2009) [#5]
That's exactly how I tested mine, thinking it was a preload difference, but that yields absolutely no difference in performance for me.

Maybe these sound libraries are just...bloated from all the extra features.


Brucey(Posted 2009) [#6]
Dunno... I even stripped it down to the raw call to the library (skipping the Type wrapping, and it seems to perform the same for me regardless.
Upping the count for the bmax test doesn't seem to make it any slower, but I'm not sure if it is really mixing 100 channels or not...
There may be a small advantage to having the bmax mixer compiled into the code... while the others are shared libraries - but I don't know how much difference that would really make.

Generally, I don't think it is much of a problem. Well, I've never noticed any issues with anything I've been using them for.
Maybe using the above method for a slower PC might make more of a difference - 16ms is certainly quite a delay.


dmaz(Posted 2009) [#7]
that example performs the same for me... I also tested it without using your class and just externed the functions myself... no difference. I've since noticed that bmx's "DirectSound" driver has the same issue... which is too bad since it's the one included in bmx which performs the nicest on vista.

I've compiled a test app that allows testing most of the sound drivers/libraries for bmx, I can set up a link if anybody it interested.

ut I'm not sure if it is really mixing 100 channels or not.
I wonder about that too... but you can generally tell by the sound difference between 1 or more 10 or even the diff when holding space to launch more. some of them definitely have max number to mix... the old fmod I think defaults to 8 or 16 if I remember correctly.

with the bass example I was using 65,535 for the max playback since that was an example I saw. I tried lowering it and using setting a flag like BASS_SAMPLE_OVER_VOL but all I get is a memory exception when that many have played... funny because it's not that many playing simultaneously but how many have played.... do I have to free something in BASS after I play a sound?

the bass example
Function Bass()
	TBass.Init(-1,44100,0,Null,Null)
	Local snd:TBassSample = New TBassSample.FileLoad("media/bell.wav",0,0,50,BASS_SAMPLE_OVER_VOL)
	While Not KeyDown(KEY_ESCAPE)
	
		If KeyDown(KEY_SPACE)
			Local time:Int = MilliSecs()
			For Local i:Int = 0 Until numPlayed
				snd.GetChannel(True).Play False
			Next
			time = MilliSecs() - time
			APlot time
		End If
		
	Wend
End Function


the 3.74 fmod wrap on the forums work nice but I couldn't get the library to compile for insertion into the app folder...