Game Development Community

Audio asset "Streaming = true" is not working [solved]

by Amjad Yahya · in Torque 2D Beginner · 08/11/2013 (6:59 am) · 35 replies

I use "Streaming = true" when declaring an audio asset but it never plays using alxPlay(), on the other hand when using "Streaming = false" it does play.

the Audio file is 11 MB .wav file.
<AudioAsset
	AssetName="splashScreenMusicSound"
	AudioFile="splashScreen.wav"
	Looping = true
	Streaming = true
	Volume = "1" />

then I play the file using
alxPlay("Game:splashScreenMusicSound");

The console does not generate any errors.
Page«First 1 2 Next»
#21
08/17/2013 (6:37 am)
Are you using that function to close the game though? What line of code do you use to exit the program?
#23
08/17/2013 (7:15 am)
Ah, thanks.
#24
08/17/2013 (9:49 am)
When you quit a game, the engine first destroys the modules then exits the game, I tried both scenarios when the module is destroyed and when the game exits
function onExit()
{
    // Unload the AppCore module.
	alxStopAll();
    ModuleDatabase.unloadExplicit( "AppCore" );
}
both work fine, and note that when you call quit() or exit using alt+F4 the engine always calls all modules' destroy() functions as well as onExit() in "main.cs" that is located in your game's root folder.

So, you are free to call alxStopAll() whenever you want as long as it gets called before quiting the game.
#25
08/17/2013 (3:29 pm)
Ok cool, thanks. I got this one a little off-topic, but it was worth it.
#26
08/21/2013 (12:38 am)
Hey guys, this won't fix the issue when switching modules in the sandbox but it does fix the issue when quitting the game when audio is still playing
Pull request 111

Simply had to add Audio:OpenALShutdown to the termination sequence.
No need to call alxStopall manually anymore in onExit()
#27
08/21/2013 (2:31 am)
Thanks Simon, you rock..
#28
08/26/2013 (6:52 am)
What is a music handle?

When trying to pause the music I've tried a couple routes:

$music_handle = "Toyassets:music_squence;
$music_handle = alxPlay(%battle_music[%rand]);

and with both alxPause doesn't work

alxPause($music_handle);


#29
08/26/2013 (7:11 am)
An audio handle is similar to an object id but for audio sources. alxPause and alxUnpause are currently broken which is why you can't get it to work properly - a fix will be available at some point "soon" though. Audio is Simon's baby so I'll let him announce what he is working on when he is ready.
#30
08/26/2013 (8:43 pm)
Ok, who broke them? I spent hours getting them to work in the first place and one of youze clownz broke 'em?!?

And another thing - OpenAL support is weird and may or may not work correctly on all sound cards. Especially pausing, though that was supposed to have been fixed with the latest (but still quite old) version of the libraries....
#31
08/26/2013 (9:08 pm)
FYI, Pausing worked but the flag AL_PAUSE was never enabled, thus, when the next update loop ran 125ms later, the audio code simply deleted the buffer without telling anyone.

I've fixed that in a personal branch + added audio emitters console object which can be positioned in the scene as well as make the listener follow the camera.


@Christian : you use the handle to apply modifications to the sound after it has been created.

For instance, the following code pitches down your original sound

alxSourcef(%handle,"AL_PITCH", 0.5);

Check out the OpenAL manual for more tricks.
#32
08/26/2013 (9:27 pm)
@Richard - well, you did provide a fix too, but that pull request got rejected. :)

And yeah, OpenAL is funny. Sounds were just a garbled mess on my windows machine, probably due to poor mb onboard sound drivers, but on the Mac everything is fine. With Android needing OpenSL ES, hopefully we will get the beginnings of a SFX like system where other platform audio layers can be supported. Perhaps looking at stuff like PortAudio for guidance.
#33
08/26/2013 (9:43 pm)
@Richard: !Never saw that pull request, must have been a few days before my time.

In any case, it looks much more comprehensive and sleeker than what I've done and it was rejected just because the fixes were all bunched up as one big fix.

I'll review it over the course of the week and I'll make sure we discuss how to handle this next committee meeting.
#34
08/27/2013 (4:04 am)
!Update!

@Richard : Clean work, man! I kinda feel bad for not noticing this pull request before.

@Mike : Most modern on-board sound chips default to 48 000 hertz sampling rates, which T2D can't handle just yet; it still plays the files but they sound like digital banshees. It defaults to 44100 Hz 16 bits and the only way to change it is by editing the source.

I guess next up should be a bunch of Consolefunctions to allow users to set the desired sampling rate and bits.

Richard's original pull request

My own work branch

Went over the changes thoroughly, even though my initial modifications worked with my own hardware, Richard's way is much more thorough and clean.

Tested, functional, doesn't change anything for the end user either.

As an added bonus, we get AL_SAMPLE_OFFSET, AL_SEC_OFFSET and AL_BYTE_OFFSET so that we interested parties may really harness the audio engine's capabilities.

Thanks Richard!
#35
08/27/2013 (6:28 am)
@Simon - yeah, my git/pull/wtf skills are not great. That fix is almost verbatim what I put into 3 Step Studio and I was never certain how it didn't get pushed out with the MIT release. I can only surmise that it wasn't merged across because those fixes were rather late in the MIT branch prep cycle. I spent around two weeks total researching and implementing that and it was a little frustrating; there is mention of "known bugs" dealing with OpenAL and pausing but it's hard to find details on work-arounds. I also added a nicer sound error reporting function that should spit out more meaningful messages when there is a problem.

<edit> Oh, man - I just looked at that pull request and it is a mess. Though there is the VS2012 project generation stuff in there too....

And a note - If you set looping to true it may make your audio handle into a negative integer value. I say may because it's setting a bit in the value and in theory it might not actually flip the sign....
Page«First 1 2 Next»