No audio?
BlitzMax Forums/BlitzMax Programming/No audio?
| ||
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 NextI 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? |
| ||
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 |
| ||
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. |
| ||
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) |
| ||
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 |
| ||
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. |
| ||
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? |
| ||
Ahh, I am with you now. Good thinking |