IrrKlang Again
BlitzMax Forums/Brucey's Modules/IrrKlang Again
| ||
Is there a way, if using the IrrKlangaudio, of accessing the other exposed features of IrrKlang ? i.e. StopAllSounds(), RemoveSoundSourceSource() etc ? |
| ||
The driver (engine) is not currently exposed, but you should be able to access the other objects by casting. For example, cast your TSound to TISoundSourceSound, gains you access to the _sound field, which is a TISoundSource object. so : Local sound:TSound = LoadSound(....) Local mySoundSource:TSoundSoure = TISoundSourceSound(sound)._sound Print mySoundSource.GetPlayLength() And for TChannel, cast to TTISoundChannel, which gets you the _channel field, which is a TISound object. eg: Local channel:TChannel = CueSound(sound) Local myISound:TISound = TTISoundChannel(channel)._channel myISound.SetPan(0.5) Local sfx:TISoundEffectControl = myISound.GetSoundEffectControl() sfx.EnableEchoSoundEffect() etc. I'll look into exposing the "engine" too. |
| ||
Ive started to look IrrKlang.mod - rather than casting etc. First snag _engine.AddSoundSourceFromMemory(IncbinPtr("media/getout.ogg"), IncbinLen("media/getout.ogg"), "aa") ' play the sound we added to memory Global snd:TISound = _engine.Play2D("aa") snd.setMinDistance(5.0) ' <<<<< error NULL Its my understanding that Play2D returns a TISound ? In my example its retuning NULL but the sample plays ? |
| ||
It should indeed. Try giving the name of the sound something like "aa.ogg" and see if that makes any difference. I raised a an issue with the developer of irrKlang in which a memory sound source wouldn't work properly if the file-extension wasn't included in the "name" part. If it's not that, then I guess there's something else going on. |
| ||
Does the same with or without the extension. It plays the sound just doesnt return the pointer to it. Same happens when you do _engine.Play3D |
| ||
Method Play2D:TISound(soundfileName:String, playLooped:Int = False, startPaused:Int = False, .. track:Int = False, streamMode:Int = ESM_AUTO_DETECT, enableSoundEffects:Int = False) Local s:Byte Ptr = soundfileName.ToCString() Local sound:Byte Ptr = bmx_soundengine_play2d(refPtr, s, playLooped, startPaused, track, streamMode, enableSoundEffects) ' ' Seems "sound" is not being set here ' MemFree(s) Return TISound._create(sound) End Method .... . . Type TISound Field soundPtr:Byte Ptr Function _create:TISound(soundPtr:Byte Ptr) If soundPtr Then '<<<< this is always NULL Local this:TISound = New TISound this.soundPtr = soundPtr Return this End If End Function Seems that the passed "sound" is always null ? |
| ||
I just checked the irrKlang API docs... Only returns a pointer to an ISound if the parameters 'track', 'startPaused' or 'enableSoundEffects' have been set to true. Just tested that, and it indeed does appear to be the case. Yes, I'll need to add some more detail to the docs for that. |
| ||
Thanks a million. I shall preserve with it or drop it in favor of BASS :S 1 other little thing :S Local snd:TISoundSource = _engine.AddSoundSourceFromFile("media/getout.ogg", 0, True) Local Channel:tisound = _engine.Play2DSource(snd,True,True) channel.setpaused(False) Now works and the sample plays fine. If I issue a channel.STOP() how the heck do you restart it without dropping that channel and creating a new one ? |
| ||
Now a problem with freeing channels :S - Im sure its not your wrapper and more todo with IrrKlang......... I have a need to load and unload samples, this is a stress test for it. This loads in 1 sample, allocates it to 20 channels (all paused) then unloads them. SuperStrict Framework BaH.irrKlang Import BRL.StandardIO Import BRL.GLMax2D ' start the sound engine with default parameters Local _engine:TISoundEngine = CreateIrrKlangDevice() If Not _engine Then Print "Could not startup engine" End End If Graphics 640,480,0 Local snd:TISoundSource = _engine.AddSoundSourceFromFile("media/getout.ogg", 0, True) Local Channel:tisound[20] While Not KeyDown(KEY_Q) Cls DrawText "Press 1 to load/unload channels - q to quit.", 50, 20 Flip Local key:Int = WaitKey() If key = key_1 Then For Local t:Int = 0 To 19 channel[t] = _engine.Play2DSource(snd,True,True) Next DebugLog("ALL ASSIGNED") For Local t:Int = 0 To 19 channel[t].stop() channel[t].drop() channel[t] = Null Next DebugLog("ALL UN-ASSIGNED") EndIf Wend _engine.RemoveSoundSourceSource(snd) _engine.RemoveAllSoundSources() _engine.Drop() End Run and press "1" a fair few times (24 times to be exact), it then crashes on "channel[t] = _engine.Play2DSource(snd,True,True)" |
| ||
From the docs : AddSoundSourceFromFile returns: The added sound source or Null if not sucessful because for example a sound already existed with that name. If not successful, the reason will be printed into the log. Note: Don't call Drop() to this pointer, it will be managed by irrKlang and exist as long as you don't delete irrKlang or call RemoveSoundSource(). However, you are free to call Grab() if you want and Drop() it then later of course. I think maybe you should call engine.RemoveSoundSource() instead of Drop()? |
| ||
I thought DROP() was only dropping the tisound object and not the sample ? I wish to re-use the TiSound (channel) and to keep the sample in tact. I might go back to BASS :) |
| ||
can't you just stop it and start playing something else? (without dropping it) |
| ||
Thats what I originally thought, if you take out the .drop(), the memory usage just keep growing.... |