No audio?

BlitzMax Forums/BlitzMax Programming/No audio?

EOF(Posted 2010) [#1]
I don't think this is a bug but for some reason I am getting no audio from a game which worked fine on WinXP

My current device is a Win7, EeePC 1201T laptop

The game is framework'ed and importing only the base stuff:
Import BRL.FreeAudioAudio
Import BRL.WAVLoader

blah:TSound=LoadSound("more blah.wav")
PlaySound blah


From this small test
Local adlist$[]=AudioDrivers()
For Local a$=EachIn adlist
	DebugLog a
Next
I get
DebugLog:FreeAudio
DebugLog:FreeAudio Multimedia
DebugLog:FreeAudio DirectSound
DebugLog:Null


I have tried SetAudioDriver "FreeAudio" but still no joy
Also, tried importing BRL.DirectSoundAudio and switching the driver via SetAudioDriver "DirectSound"

The problem is I have lost track of all the changes happening in the sound department
Where do I start?


EOF(Posted 2010) [#2]
Fixed

I was loading sound like this (which used to work):

Type Sfx
	Global PlayerShoot:TSound = LoadSound("sfx/playershoot.wav")
End Type

PlaySound Sfx.PlayerShoot


I had to put all sound loading into a Method New() enclosure which now solves the sound problem
Type Sfx
	Global PlayerShoot:TSound
	Method New()
		 PlayerShoot = LoadSound("sfx/playershoot.wav")
	End Method
End Type

New Sfx

PlaySound Sfx.PlayerShoot



Jesse(Posted 2010) [#3]
interesting, I guess I am going to have to remember that in case I try to run some old code that is set up as such.


Czar Flavius(Posted 2010) [#4]
That's not a very elegant solution, the Sfx object is wasted!

For each type, I usually have a Load function that loads all those things. Then I have a SuperLoad function that has a long list of Load function calls for each type. And then I call this before my main game loop. It's ugly and C-headerish, I know, but it works and it's reliable, if you just remember to add new Type Loads to the SuperLoad when you write them.

The problem is, when Blitz decides to initialize global variables inside types can be a bit hard to guess. (It's NOT instant)


EOF(Posted 2010) [#5]
That's not a very elegant solution, the Sfx object is wasted
How so?
I actually stick all my sounds into the Sfx Type. It's a handy way of grouping everything together

Type Sfx
	Global PlayerShoot:TSound , AlienShoot:TSound
	Global AlienShunt:TSound , PlayerDie:TSound
	Global UfoAppear:TSound , UfoDie:TSound
	Method New()
		PlayerShoot 	= LoadSound("sfx/playershoot.wav")
		AlienShoot 	= LoadSound("sfx/alienshoot.wav")
		AlienShunt 	= LoadSound("sfx/shuntdown.wav")
		PlayerDie	 = LoadSound("sfx/killplayer.wav")
		UfoAppear 	= LoadSound("sfx/ufo.wav")
		UfoDie 		= LoadSound("sfx/killufo.wav")
	End Method
End Type

I do the same for Graphics via a Gfx Type
It means I can avoid 'same name' issues too:

DrawImage Gfx.alien1
PlaySound Sfx.alien1


Jesse(Posted 2010) [#6]
I believe what he means is that sense "New Sfx" is not being assigned to a variable that it is just being collected by the garbage collector. I wonder if anything is really collected by the garbage collector maybe the instantiated address and some useless information for its use/purpose.
I have been using that same method of organization and I got the idea from you Jim. and I really like it.


Czar Flavius(Posted 2010) [#7]
Type Sfx
	Global PlayerShoot:TSound , AlienShoot:TSound
	Global AlienShunt:TSound , PlayerDie:TSound
	Global UfoAppear:TSound , UfoDie:TSound

	Function Load()
		PlayerShoot 	= LoadSound("sfx/playershoot.wav")
		AlienShoot 	= LoadSound("sfx/alienshoot.wav")
		AlienShunt 	= LoadSound("sfx/shuntdown.wav")
		PlayerDie	 = LoadSound("sfx/killplayer.wav")
		UfoAppear 	= LoadSound("sfx/ufo.wav")
		UfoDie 		= LoadSound("sfx/killufo.wav")
	End Function
End Type

Sfx.Load()
Main game loop


What's wrong with that?


EOF(Posted 2010) [#8]
Ahh, I am with you now. Good thinking