Open AL inconsistent on SB Audigy2

BlitzMax Forums/BlitzMax Programming/Open AL inconsistent on SB Audigy2

Grey Alien(Posted 2007) [#1]
Hmm, I know that OpenAL is made by creative labs, and I also have a DB Audigy 2 card but it is giving me inconsistent results when triggering samples rapidly.

Basically I have the same sound and I am playing it once every 100ms like a sort of machine gun. With FreeAudio and DirectSound it's totally fine, very regular. However, with OpenAL it's not regular! You can actually hear that the gaps are not consistent OR maybe actually it's triggering the sample not always at the start, sometimes slightly in.

I actually encountered this problem ago with a tracker program I was using. When I hit the key rapidly I didn't get a consistent sample sound each time and worked out that it was missing off some of the start sometimes. I thought it was either a bug in the app or they were craply trying to simulate some kind of human "touch" (except I couldn't find anywhere to turn it off!).

So I'm wondering if anyone else has seen this with OpenAL or if it's just my system? Maybe I should make a test app?

[edit]
***TEST APP***
http://www.greyaliengames.com/misc/sounddrivertest.zip

It plays a tick noise every 100MS (or thereabouts because I'm using Flip so it could be as much as 16MS out.) but anyway it sounds consistent with FreeAudio and DirectSound.

However for me when I use OpenAL the tick noise is like half as frequent, it's totally rubbish. Does anyone else get this or is it just me?


Volker(Posted 2007) [#2]
Same here.Pr
Soundblaster Live!


GfK(Posted 2007) [#3]
Same - 6yr old Toshiba Satellite laptop, onboard ALi audio

Looks like its an issue with OpenAL itself rather than being hardware specific.

[edit] ALi is Acer Labs inc - nothing to do with OpenAL!

[edit again] Can you post the code you used for this test?


Grey Alien(Posted 2007) [#4]
Wow, so it's an OpenAL problem. How crap is that!?

Strict

Global CurrentDriver$
Global Channel:TChannel
Global TestSound:TSound

SetDriver("FreeAudio")
'SetDriver("DirectSound")
'SetDriver("OpenAL")

Graphics 400,300,0

Local LastTime = MilliSecs()
While Not KeyHit(KEY_ESCAPE)
	Local now = MilliSecs()
	'Play a sound?
	If now > LastTime+100 Then
		LastTime = now 'reset
		CueSound(TestSound,Channel)
		ResumeChannel(Channel)
	EndIf

	'Change driver?
	If KeyHit(Key_Space) Then
		Select CurrentDriver
			Case "FreeAudio"
				SetDriver("DirectSound")
			Case "DirectSound"
				SetDriver("OpenAL")
			Case "OpenAL"
				SetDriver("FreeAudio")
		End Select
	EndIf
		
	Cls
	DrawText "Current Driver="+CurrentDriver,10,10
	DrawText "Press <escape> to exit",10,30
	DrawText "Press <space> to change driver",10,50
	Flip	
Wend

Function SetDriver(Driver$)
	CurrentDriver = Driver
	SetAudioDriver(Driver)
	SetupSound()
End Function

Function SetupSound()
	Channel =  AllocChannel()
	TestSound = LoadSound("rapid.wav")	
End Function

End


If you want to rule out the up to 16ms (or so) variation due to Flip, then comment Flip out. OpenAL plays the samples slower than the other two drivers, explain that!


Grey Alien(Posted 2007) [#5]
So if OpenAL is used in Vista, you won't get horrible lags like FreeAudio, you'll just get this other weird crap instead. Sigh.


GfK(Posted 2007) [#6]
I guess... but I'm not playing the same sound over and over every 100ms so it hasn't really been an issue.

Actually, wouldn't it be easier just to loop the sound anyway?


xlsior(Posted 2007) [#7]
Something else weird:

I have an on-board RealTek High-Definition audio adapter on my motherboard.

The sample plays very steadily with all three drivers on my computer (under XP), however there's two big inconsistencies:

1) Under OpenAL, the delay between the ticks is probably about twice as long. Much more ticks per second under DirectSound and FreeAudio than under OpenAL, although the OpenAL version remains very steady, no change at all in the delays... just spaced out further.

2) I have a 5.1 surround sound speaker setup. In your sample, FreeAudio and DirectSound play the sound through the front left & right speakers. Front center and rear left+right remain silent.
With openAL, all the front & center channels are silent but the ticks are coming through the rear left + right speakers instead.

(Which is not a good thing, unless you specifically intended to do so... The sound ought to come from the front for a typical 2D game, not from behind you)


Grey Alien(Posted 2007) [#8]
Actually, wouldn't it be easier just to loop the sound anyway?
No not really it conincides with a visual event. Basically it's bugged and I don't like it.

xlsior: Yeah I get a greater delay between ticks too. Actually with flip I get this weird consistent rhythem, and with flip off I get the greater delay. As for the speaker problem, that's weird too but maybe it's due to settings on on your sound card because OpenAL is by Creative Labs and I bet they're trying to be clever.


Grey Alien(Posted 2007) [#9]
Aha, I've found something out. If I use this code before CueSound:

		StopChannel(Channel)
		Channel = AllocChannel()

Then OpenAL sounds like the others.

This means that you have to use StopChannel with OpenAL, you can't reuse the channel as it seems to want to let the sample finish or something. Weird.

Should I report this as a bug because the behaviour is inconsistent with the other audio drivers?


GfK(Posted 2007) [#10]
Dunno... are you saying its a problem with Blitzmax, or with OpenAL?


Grey Alien(Posted 2007) [#11]
well I guess OpenGL, but it could be a problem in the module which accesses it. Maybe a workaround could be made? I've posted in the bug forum.


xlsior(Posted 2007) [#12]
xlsior: Yeah I get a greater delay between ticks too. Actually with flip I get this weird consistent rhythem, and with flip off I get the greater delay. As for the speaker problem, that's weird too but maybe it's due to settings on on your sound card because OpenAL is by Creative Labs and I bet they're trying to be clever.


I don't see any setting in my sound card config that allow me to specify preferred speakers or something... I don't have a creative labs soundcard.


Grey Alien(Posted 2007) [#13]
ok then, yep it's definitely weird.


Grey Alien(Posted 2007) [#14]
The main issue has been fixed, yay! Syncmods to get it.