New audio stuff

BlitzMax Forums/BlitzMax Module Tweaks/New audio stuff

marksibly(Posted 2007) [#1]
Hi,

Ok, there's some new audio stuff available via syncmods (Windows only for now).

There's a new OpenAL driver, and FreeSound now optionally uses DirectSound.

You need to install the OpenAL runtime separately - it's not included in the module. However, if it's not installed your app wont crap out - the driver just wont be available.

New commands in BRL.Audio:

Function AudioDrivers$[]() - returns an array of audio drivers. This will typically include:

FreeAudio Default
FreeAudio DirectSound
OpenAL Default
OpenAL Generic Hardware
OpenAL Generic Software
Null

I'd be interested to see what other people get too...
For Local t$=EachIn AudioDrivers()
   Print t
Next


Function SetAudioDriver( name$ ) - set current audio driver. Returns 1 if successful, else 0.

If you don't set an audio driver, then the system will try and pick one for you - see: Function Driver() in audio.mod/audio.bmx.

Post results/impressions here!


H&K(Posted 2007) [#2]
FreeAudio DirectSound
FreeAudio Default
Null



REDi(Posted 2007) [#3]
Great work Mr Sibly!

H&K, you can get OpenAL here... http://developer.creative.com/landing.asp?cat=1&sbcat=31&top=38


impixi(Posted 2007) [#4]
Thanks Mark.

* OpenAL Default
* OpenAL SB Audigy Audio [A000]
* FreeAudio DirectSound
* FreeAudio Default
* Null

OS: Windows XP Pro fully patched.
Soundcard: Audigy 1 (driver 5.12.1.443 (23/02/2004))

I'm experiencing variable results.

When using the FreeAudio DirectSound driver there's a noticeable delay every so often and I suspect there's also a delay with FreeAudio Default driver, though barely noticeable.

When using the OpenAL drivers there doesn’t seem to be any delays, though the sound quality is different (worse?).

Test code:

SuperStrict

Graphics 800, 600

Local drivers:String[] = AudioDrivers()
Local current_driver:Int = 0
SetAudioDriver(drivers[current_driver])

Local sound_url:String = "\Program Files\BlitzMax\Samples\hitoro\sounds\shot.ogg"

Local sound:TSound = LoadSound(sound_url)

Local timer:TTimer = CreateTimer(10)

While Not KeyHit(KEY_ESCAPE)

	If KeyHit(KEY_TAB)
		current_driver :+ 1
		If current_driver >= drivers.length Then current_driver = 0
		SetAudioDriver(drivers[current_driver])
		sound = LoadSound(sound_url)
	EndIf		

	Cls
	DrawText "Press [TAB] to use next driver.", 5, 5
	DrawText "Current driver: " + current_driver + " - " + drivers[current_driver], 5, 25
	Flip
		
	WaitTimer timer
	PlaySound sound

Wend

End


EDIT:

Results from my Acer Aspire 1601 notebook:

* OpenAL Default
* OpenAL Generic Software
* OpenAL Generic Hardware
* FreeAudio DirectSound
* FreeAudio Default
* Null

Same issues as mentioned above. Probably the sound quality issue is best described as "stronger, more vibrant" sound from the FreeAudio driver. That or my ears are playing tricks on me...


hub(Posted 2007) [#5]
OpenAL Default
OpenAL Generic Software
OpenAL Generic Hardware
FreeAudio DirectSound
FreeAudio Default
Null


hub(Posted 2007) [#6]
@Redi
MaxMod not work since my last syncmod to test the new audio test.

C:/Program Files/BlitzMax/mod/redi.mod/maxmod.mod/maxmod.debug.win32.x86.a(maxmod.bmx.debug.win32.x86.o.b)(code+0x16755): undefined reference to `brl_audio_audio_driver'
C:/Program Files/BlitzMax/mod/redi.mod/maxmod.mod/maxmod.debug.win32.x86.a(maxmod.bmx.debug.win32.x86.o.b)(code+0x16769): undefined reference to `brl_audio_audio_driver'


REDi(Posted 2007) [#7]
ok thanks hub, fix is coming mate.


popcade(Posted 2007) [#8]
Streaming or Mod support will be nice, hope maxmod can be corss-platform too (via these new additions).


REDi(Posted 2007) [#9]
the new version of maxmod is up now. rush it a bit, and sidplay will need updating, but it works. (and includes some new additions/bug fixes ect)

BUG REPORT: I'm getting some cracking with the dsound driver, when the cpu usage is quite high, might need to make that buffer a little bigger?


degac(Posted 2007) [#10]
OpenAL Default
OpenAL NVIDIA(R) nForce(TM) Audio
FreeAudio DirectSound
FreeAudio Default
Null


Edit:

after playing with some code...
Sometimes BlitzMax popups and Unhandled Memory Exception BUT the the sound plays in background; sometimes I have only the error, and sometimes I have no sound.
This happens only when I try to use SetAudioDriver("") with ones reported by AudioDrivers().
If I don't use SetAudioDriver() the program works perfectly...
'test sound
Include "lib_sound.bmx"
Graphics 640,480
tsnd.InitSound(10)
Print "Audio driver:"
For Local t$=EachIn AudioDrivers()
   Print t
Next
SetAudioDriver("FreeAudio DirectSound")

Global suono1:TSound = LoadSound("music/o_t1.ogg")
Global suono2:TSound = LoadSound("music/o_applause.ogg")

tsnd.SetVolume(1)
Print tsnd.EmittSound(suono1,0)
tsnd.EmittSound(suono2)
'tsnd.FadeIn(1 , 400)',0)

While Not AppTerminate() 
	tSnd.UpdateSound()
	If MouseDown(1)
		tsnd.PauseSound()
	End If
	If MouseDown(2)
		tsnd.ResumeSound()
	End If
	Delay 1
Wend
tsnd.FreeSound()
End

And this is my lib for handling music channels
Global channel:tsnd[10]


Type tsnd
	Field channel:TChannel
	Field volume:Float
	Field delta:Float
	Field status:Int
	Field depth:Float
	Field pan:Float
	Field rate:Float	


Function InitSound(numchan:Int=10)
		Print "Init sound channel - start"
		channel=Null
		channel=New tsnd[numchan]
		
		For Local i:Int=0 To channel.length-1
			channel[i]=New tsnd
			channel[i].channel=AllocChannel()
			channel[i].volume=1
			channel[i].delta=0
		Next
		Print "Init sound channel - finish - "+channel.length
End Function

Function StopSound(chan:Int=-1)
		If chan=-1
			For Local i:Int=0 To channel.length-1
				StopChannel channel[i].channel
		
			Next
		Else
				StopChannel channel[chan].channel
		End If

End Function 

Function PauseSound(chan:Int = - 1)
	If chan = - 1
		For Local i:Int=0 To channel.length-1
			PauseChannel channel[i].channel
		Next
	Else
		PauseChannel channel[chan].channel
	End If
End Function 

Function ResumeSound(chan:Int = - 1)
	If chan = - 1
		For Local i:Int=0 To channel.length-1
			ResumeChannel channel[i].channel
		Next
	Else
		ResumeChannel channel[chan].channel
	End If
End Function 

Function DepthSound(chan:Int = - 1,dep:Float=0)
	If chan = - 1
		For Local i:Int=0 To channel.length-1
			SetChannelDepth channel[i].channel , dep
			channel[i].depth=depth
		Next
	Else
		SetChannelDepth channel[chan].channel , dep
		channel[chan].depth=depth

	End If

End Function 

Function PanSound(chan:Int = - 1,pan:Float=0)
	If chan = - 1
		For Local i:Int=0 To channel.length-1
			SetChannelPan channel[i].channel , pan
			channel[i].pan=pan
		Next
	Else
		SetChannelPan channel[chan].channel , pan
		channel[chan].pan=pan

	End If

End Function 

Function RateSound(chan:Int = - 1,rate:Float=0)
	If chan = - 1
		For Local i:Int=0 To channel.length-1
			SetChannelRate channel[i].channel , rate
			channel[i].rate=rate
		Next
	Else
		SetChannelRate channel[chan].channel , rata
		channel[chan].rate=rate

	End If

End Function 
	
	
	

Function FreeSound()
		Print "Free sound channel"
		For Local i:Int=0 To channel.length-1
			channel[i].channel=Null
		Next
		channel=Null
End Function

Function EmittSound:Int(sound:TSound,chan:Int=-1)
'possibilità: chan=-1 trova il primo canale libero


If chan=-1
		For Local i:Int=0 To channel.length-1
		
			If channel[i].channel.playing()=False
			PlaySound sound,channel[i].channel
			Return i
			End If
		Next
Else
If chan < channel.length
			If channel[chan].channel.playing()=False
				PlaySound sound,channel[chan].channel
				Return chan
			End If
			Else
				Return -1
			End If

End If
End Function

Function SetVolume(vol:Float,chan:Int=-1)
		'''print "Set Vol "+vol
		If chan=-1
			For Local i:Int=0 To channel.length-1
				SetChannelVolume channel[i].channel,vol
				channel[i].volume = vol
			Next
		Else
			SetChannelVolume channel[chan].channel,vol
			channel[chan].volume=vol
		
		End If
End Function

Function FadeOut(vol:Float , time:Int = 1000 , chan:Int = - 1)

	If chan=-1
		For Local i:Int = 0 To channel.length - 1
			channel[i].volume=vol
			channel[i].delta =- Float((channel[i].volume-0.05) / Time)
		
		Next
	Else
			channel[chan].volume=vol
			channel[chan].delta=-Float((channel[chan].volume-0.05)/Time)

	End If

End Function

Function FadeIn(vol:Float,time:Int=1000,chan:Int=-1)
	If chan=-1
		For Local i:Int=0 To channel.length-1
			channel[i].delta=Float(1.05-channel[i].volume)/Time
		Next
	Else
			channel[chan].delta=(1.05-channel[chan].volume)/Time

	End If
End Function

Function UpdateSound(chan:Int=-1)
	If chan=-1
		For Local i:Int=0 To channel.length-1
			channel[i].volume:+ channel[i].delta
			If channel[i].volume < 0 channel[i].volume = 0
			If channel[i].volume > 1 channel[i].volume = 1
			SetChannelVolume channel[i].channel , channel[i].volume
		Next
	Else
			channel[chan].volume:+channel[chan].delta
			SetChannelVolume channel[chan].channel,channel[chan].volume
	End If
End Function 
End Type


*** Maybe it is only due to my bad programming!!!


Grisu(Posted 2007) [#11]
I have installed the windows oa runtime, but the app still crashes.

Picture:


Btw: Does oa support streaming as well?


GfK(Posted 2007) [#12]
REDi - where's the new version of MaxMod? I daren't syncmods yet as I'm using MaxMod and my game is hours away from finished. I don't want it to break! ;)


REDi(Posted 2007) [#13]
on the website mate, just click the link in my sig ;)


GfK(Posted 2007) [#14]
Oh, I went there but it said the last post was October 2006!

Anyhoo, I've just installed 1.16 and now I've got a problem.

My game won't run. Its telling me that it doesn't know what 'music.stop' is (music being a tMusic object).

I've synced modules, rebuilt modules, documented modules, turned quickbuild off.

Ideas? :/


REDi(Posted 2007) [#15]
So we dont hijack Marks thread any more, check here... http://www.blitzmax.com/Community/posts.php?topic=67464


GfK(Posted 2007) [#16]
Just got my program running again. All my sound is now crackling like merry hell. :(

[edit] SetAudioDriver("FreeAudio Default") sorted it. My only other option is "FreeAudio DirectSound" - I guess its choosing this if I don't specify a driver myself.

In summary, looks like DirectSound might be a bit broken.


Mark Tiffany(Posted 2007) [#17]
I get these on my Windows PC:

OpenAL Default
OpenAL NVIDIA(R) nForce(TM) Audio
FreeAudio DirectSound
FreeAudio Default
Null


JazzieB(Posted 2007) [#18]
This is what I get on my setup.

OpenAL Default
OpenAL Generic Software
OpenAL Generic Hardware
OpenAL SB X-Fi Audio [A000]
FreeAudio DirectSound
FreeAudio Default
Null

Just tried it with my game and I still get a bit of crackle with whichever it picks by default. although I don't know which one this is. Is there any way of returning which driver is currently in use?

I'll go through them all one by one later today and report back my findings.


GfK(Posted 2007) [#19]
Just tried it with my game and I still get a bit of crackle with whichever it picks by default. although I don't know which one this is. Is there any way of returning which driver is currently in use?
Same problem here - I'm sure (see post above for explanation) its 'FreeAudio DirectSound' thats... whats the word.... 'munted'? ;)


JazzieB(Posted 2007) [#20]
About 50% of the time I get an unhandled memory exception error. I get this with both just the FreeAudio mod and with the OpenAL mod as well. The IDE highlights the following line in freeaudio.bmx

Function fa_Init( deviceid )
	Local device
?Win32
	If deviceid
		device=OpenDirectSoundDevice()
	Else
		device=OpenMultiMediaDevice()
	EndIf
?Linux
	device=OpenSystemAudio()
?MacOS
	device=OpenSystemAudio()
?
	Local res=-1
	If device res=fa_Reset(device)  ' <<<<<<<<<<<
	Return res
End Function


I am using the following code to compile a list of working drivers in preparation of a user selectable option later in the program.
Local drivers:String[]=AudioDrivers()
Global soundDrivers:String[drivers.Length]
Global currentAudioDriver:String="FreeAudio DirectSound",currentAudioIndex:Int
Global maxAudioDriver:Int=-1

For Local i:Int=0 Until drivers.Length
	If SetAudioDriver(drivers[i]) Then
		maxAudioDriver:+1
		soundDrivers[maxAudioDriver]=drivers[i]
		If drivers[i]=currentAudioDriver Then
			currentAudioIndex=maxAudioDriver
		ElseIf drivers[i]="Null" Then
			soundDrivers[maxAudioDriver]="No Sound"
		EndIf
	EndIf
Next

SetAudioDriver currentAudioDriver

Also, the program continues to run with the music still playing and I am able to play the game with all its sound effects also playing with no problem. However, I've also noticed that when the error occurs memory consumption continues to rise rapidly.

EDIT...

I've now checked all the drivers and can report the following...

FreeAudio DirectSound gives me the crackle I previously reported. FreeAudio Default gives me the 1 second delay.

OpenAL Default and OpenAL Soundcard Specific works, but plays my music (an OGG) on the rear channels only, while the sound effects play just fine! OpenAL Software and Hardware work just fine with no issues.

The only differences between the quality of the sound (other than the crackle) between FreeAudio and OpenAL that I can observe is that OpenAL seems to play the audio a little quieter.


Gabriel(Posted 2007) [#21]
Initially :

FreeAudio DirectSound
FreeAudio Default
Null


After installing OpenAL

OpenAL Default
OpenAL Generic Software
OpenAL Generic Hardware
FreeAudio DirectSound
FreeAudio Default
Null


Sounds play pretty much exactly the same on each driver. No crackling or anything.

By the way, does this mean we're going to get streaming audio and 3d sound?


Difference(Posted 2007) [#22]
Running Marks exact program:
For Local t$=EachIn AudioDrivers()
   Print t
Next

Brings up a black screen that I can't [ALT]+[TAB] or [CTRL]+[ALT]+[DELETE] away form. I Have to hard reset my PC.
What gives?


Panno(Posted 2007) [#23]
* OpenAL Default
* OpenAL Generic Software
* OpenAL Generic Hardware
* FreeAudio DirectSound
* FreeAudio Default
* Null


sounds crackling


marksibly(Posted 2007) [#24]

I have installed the windows oa runtime, but the app still crashes.


Can you try deleting OpenAL32.dll from C:\windows\system32? (Back it up first!)

If that fixes it, can you email me your OpenAL32.dll? blitzman at blitzbasic dot com...

If it's crashing within the DLL, I guess I'll have to add a 'UseOpenALAudio' or something ugly...



I am using the following code to compile a list of working drivers in preparation of a user selectable option later in the program.


Perhaps try not repeatedly using SetAudioDriver - just use it once after the user has selected a device. Theoretically, everything in the driver list should work anyway.


Running Marks exact program:
Brings up a black screen that I can't [ALT]+[TAB] or [CTRL]+[ALT]+[DELETE] away form. I Have to hard reset my PC.


Very weird! Can you run anything at all?!? Anyone else?

Check out the source in audio.mod/audio.bmx - it isn't do anything weird - can you try single stepping through?


Just got my program running again. All my sound is now crackling like merry hell.


Can you try changing the #define DSOUNDFRAG 2048 in freeaudio.mod/dsounddevice.cpp to 4096 and building modules?

What I might do is change the default device back to FreeAudio Default. Although this is giving problems on Vista, at least it's a known quantity for everyone else...


bradford6(Posted 2007) [#25]
OpenAL Default
OpenAL Generic Software
OpenAL Generic Hardware
OpenAL SB Audigy 2 ZS Audio [8800]
FreeAudio DirectSound
FreeAudio Default
Null


GfK(Posted 2007) [#26]
Is sound dodgy in all apps under vista, or just Blitzmax? If its everything then surely thats a driver issue?

I'll try fiddling with dsounddevice.cpp tomorrow, as rebuilding modules takes ages on this PC and its after midnight now.


bradford6(Posted 2007) [#27]
For Local t$=EachIn AudioDrivers()
   Local result:Int = SetAudioDriver(t$)
	If result = 1 Then Print "Set "+t$+" OK!"
	If result = 0 Then Print "Failed to Set "+t$
Next



Set OpenAL Default OK!
Set OpenAL Generic Software OK!
Set OpenAL Generic Hardware OK!
Set OpenAL SB Audigy 2 ZS Audio [8800] OK!
Set FreeAudio DirectSound OK!
Set FreeAudio Default OK!
Set Null OK!




when I play a .wav file using "OpenAL SB Audigy 2 ZS Audio [8800]" driver if clicks and cracks


xlsior(Posted 2007) [#28]
OpenAL Default
OpenAL Generic Software
OpenAL Generic Hardware
FreeAudio DirectSound
FreeAudio Default
Null


But... Running Bradford6's code snippet does result in an error for me:

Set OpenAL Default OK!
Set OpenAL Generic Software OK!
Set OpenAL Generic Hardware OK!
Set FreeAudio DirectSound OK!
Unhandled Memory Exception Error
Process complete


Some additional test showed that SetAudioDriver("FreeAudio DirectSound") is what's causing the problem -- about 1 out of 4 runs it completes successfully, the other three times I get the Unhandled Memory Exception Error

This is using directX 9.0c. for what it's worth: I do have two sound cards in my machine -- a basic onboard adapter, and well as a PCI CMI8738 C-Wave Media Device. the onboard one doesn't have drivers installed.
DXDIag only lists the c-wave adapter, as does the sound configuration tool in the control panel.

dxdiag has no problems playing and sounds, and I've never had any problems in games either.


skidracer(Posted 2007) [#29]
I'm having some serious issues where it seems the order global variables are initialized are completely wrong, the correct order I assume is based on import dependencies, if it isn't then the way the default drivers and openal libs are initialized are completely out of order when I step through, or the latest mingw is just evil.


The r0nin(Posted 2007) [#30]
Whenever I compile with OpenAL in the Framework, I get the following error:

Unhandled Exception:Unhandled Memory Exception Error.

In this portion of the openalaudio.bmx:
If OpenALInstalled()
	
		For Local devname$=EachIn EnumOpenALDevices()
		TOpenALAudioDriver.Create( "OpenAL "+devname,devname )
		Next
	TOpenALAudioDriver.Create "OpenAL Default",String.FromCString( alcGetString( 0,ALC_DEFAULT_DEVICE_SPECIFIER ) )
EndIf


This is the line that's highlighted:

		For Local devname$=EachIn EnumOpenALDevices()

Help (I can't compile even simple programs without this occurring...)!!!!


popcade(Posted 2007) [#31]
http://bugdie.org/_tmp/oal32_dll.zip

These 2 DLLs seems to be the main OpenAL32 components, tyr to put it along with your game/testapp and see if the drivers are correctly shown.


popcade(Posted 2007) [#32]
BTW...

Set OpenAL Default OK!
Set OpenAL Generic Software OK!
Set OpenAL Generic Hardware OK!
Set FreeAudio DirectSound OK!
Unhandled Memory Exception Error
Process complete 


I also got this message when running brad's code.


Difference(Posted 2007) [#33]

Very weird! Can you run anything at all?!? Anyone else?

Check out the source in audio.mod/audio.bmx - it isn't do anything weird - can you try single stepping through?

My problem seems to be related to "Print" not to the audio code.

It is very cumbersome to track down, since I have to hard-reset every time, so bare with me while I track it down.


Tachyon(Posted 2007) [#34]
I reluctantly syncmod'd last night to try out the new audio stuff. My driver list includes:

OpenAL Default
OpenAL Generic Software
OpenAL Generic Hardware
OpenAL SB X-Fi Audio [DF00]
FreeAudio DirectSound
FreeAudio Default
Null

I tried all the drivers one by one on my 'big project'...each one worked fine for me. A very slight crackling was heard on a couple of the OpenAL drivers, and on those drivers I noticed the sound overall was a bit muffled (not as bright). The FreeAudio DirectSound driver worked well also. There was just one or two odd delays that seemed to go away as I played for a bit.

My development rig:
AMD64, 4 GB RAM, Windows XP, Sound Blaster X-Fi Platinum
All drivers and software kept cleanly up-to-date and patched.

Oh, and thanks Mark for investigating other audio solutions.


Tom Darby(Posted 2007) [#35]
OK, I get odd behavior running brad's code. I haven't installed OpenAL yet. When I run the following code,

SuperStrict

For Local t$=EachIn AudioDrivers()
   Local result:Int = SetAudioDriver(t$)
	If result = 1 Then Print "Set "+t$+" OK!"
	If result = 0 Then Print "Failed to Set "+t$
Next



I generally get this:

Set FreeAudio DirectSound OK!
Unhandled Memory Exception Error
Process complete


Other times, such as when I build in debug mode or immediately after I get it to run successfully, I get this:

Set FreeAudio DirectSound OK!
Set FreeAudio Default OK!
Set Null OK!



Now, when I run the following code,


SuperStrict

Print
Print " *** "
Print
For Local t$=EachIn AudioDrivers()
   Print t
Next

Print
Print " *** "
Print
For Local t$=EachIn AudioDrivers()
   Local result:Int = SetAudioDriver(t$)
	If result = 1 Then Print "Set "+t$+" OK!"
	If result = 0 Then Print "Failed to Set "+t$
Next



It always works, regardless of release/debug mode, and I get this:


 *** 

FreeAudio DirectSound
FreeAudio Default
Null

 *** 

Set FreeAudio DirectSound OK!
Set FreeAudio Default OK!
Set Null OK!



popcade(Posted 2007) [#36]
The new mod make the sound crackling as hell...


bradford6(Posted 2007) [#37]
Here is a little Test program for you to try:

You get the added bonus of listening to my amazing guitar skilz. (once you get sick of my abysmal playing, just replace the URL with a localfile path.

Edit: fixed bug that shows 'false' at program start. Please Use Mark's version below.



marksibly(Posted 2007) [#38]
Skid, you're using an old version - I changed Initialize to StartUp, added a Shutdown and moved atexit_ to Audio.


xlsior(Posted 2007) [#39]
Bradford6: Weird. when I run that sample, it fails at first: "OpenAL Default FALSE", and nothing is audible.

Then after I cycle through the various sound drivers (all of which work) it wraps around again to the beginning... But now it says "OpenAL Default True" instead, which does work.

Weird, weird, weird.


skidracer(Posted 2007) [#40]
It's a bug in his code, until you hit space it will print FALSE and no music is played.

Mark: Thanks!


marksibly(Posted 2007) [#41]

Bradford6: Weird. when I run that sample, it fails at first: "OpenAL Default FALSE", and nothing is audible.


Nothing starts until you hit space. Interesting test though - here's a smaller version:
Strict

Local URL:String="http::www.bmaxbook.com/guitar.ogg"
Global SoundBank:TBank=LoadBank(URL)

Local devs$[]=AudioDrivers(),i=-1,channel:TChannel,okay$

Graphics 640,480

While Not KeyHit( KEY_ESCAPE )

	If KeyHit( KEY_SPACE ) Or i<0
		i:+1
		If i=devs.length i=0
		If channel StopChannel channel
		okay="False"
		channel=Null
		If SetAudioDriver( devs[i] )
			channel=AllocChannel()
			Local sound:TSound = LoadSound(SoundBank)
			PlaySound sound,channel
			okay="True"
		EndIf
	EndIf

	Cls
	DrawText "hit space to switch driver",20,20
	DrawText "Current Driver: "+devs[i]+" (Okay="+okay+")",20,40
	Flip

Wend



skidracer(Posted 2007) [#42]
Mark, commited latest-

pub.freeaudio 1.20
brl.freeaudioaudio 1.08

will fire up the mac and do some testing


Barbapapa(Posted 2007) [#43]
Not sure where this belongs, but let me explain and you will understand why I post it here.

I made a sync a few minutes ago, when skid told me about the updated axe.lua v1.22. And now the testing scripts don't work anymore, I get an Unhandled Memory Exception Error when compiling AND BMax jumps to openalaudio.bmx in line 236. I must add that I don't have OpenAl installed, nor did I do a total module rebuild yet. Waiting for any ideas first.

Here's the little script, nothing fany...

SuperStrict

Import Axe.Lua

Function luaPrint:Int( l:Byte Ptr )
    For Local i:Int = 1 To lua_gettop( l ) ' The lua stack goes from 1 to lua_gettop( l ) -- it does not start at zero
        Select lua_type( l, i )                                     ' gets the type of the variable
            Case LUA_TBOOLEAN
                Print lua_toboolean( l, i )                         ' true/false
            Case LUA_TNUMBER
                Print lua_tonumber( l, i )                          ' double
            Case LUA_TSTRING
                Print String.FromCString( lua_tostring( l, i ) )    ' print a string - lua_tostring is an auxiliary function
                                                                    ' you should use lua_tolstring in your own code for safety
            Default
                ' other types exist, but for the sake of not writing too much code, they're excluded
        End Select
    Next
    Return 0        ' zero arguments are returned -- if you pushed anything on the stack, you'd specify the
                    ' amount of values you wanted to return
End Function

Local state:Byte Ptr = luaL_newstate( )         ' Create the state

lua_register( state, "print", luaPrint )    ' Register the function

lua_dofile( state, "test1.lua" )          ' Execute a script

lua_close( state )                          ' Close the state


or even this little baby
SuperStrict

Import axe.luascript

Global lua:TLuaScriptEngine=New TLuaScriptEngine

lua.reset()

lua.RunScriptFile("test1.lua")

lua.ShutDown() 


The test1.lua is nothing interesting, only a few calculations and print statements. And it worked all well, before the sync. I don't believe it's because of the axe.lua mod but what do I know...


skidracer(Posted 2007) [#44]
Could very well be axe.lua, i shouldn't be adding to syncmods at the moment as I'm testing with newer compiler tools, so I advise touching the lua.bmx file then doing build modules to rule it out.


Tachyon(Posted 2007) [#45]
[EDIT...reposted this message in Mark's 2nd audio thread]

Just sync'd again and it downloaded a bunch of new audio updates...and now my game just plain crashes with "Unhandled Memory Exception Error". I have no other information to give you because it doesn't tell me anymore than that. I am not setting an audio driver so it should be using the default driver.

...um, it looks like the debugger is highlighting a "flip" command, as if it is crashing there. ??


Grisu(Posted 2007) [#46]
After latest syncmods:

FreeAudio DirectSound
FreeAudio Default
Null

=AC97 on-board sound chip / NF4


Barbapapa(Posted 2007) [#47]
ok, I did a resync this morning with the new audio files and lua works again, cool.


GfK(Posted 2007) [#48]
Can you try changing the #define DSOUNDFRAG 2048 in freeaudio.mod/dsounddevice.cpp to 4096 and building modules?
Oops sorry, totally forgot to do that until just now!

I changed it to 4096 and it still crackles but to a lesser extent. I continued increasing it until the problem went away completely (which was at 16384), but then I get a 0.5s lag when playing sounds.

[edit]Um, best post this in the other thread in case this one gets locked.