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.
then I play the file using
The console does not generate any errors.
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.
About the author
#3
08/12/2013 (4:36 am)
Thanks Mike & Richard.
#4
Using alxPlay("ToyAssets:test_sound");
<AudioAsset
AssetName="test_sound"
AssetAutoUnload="0"
AudioFile="test_sound.wav" />
and the sound clip does not play.
Downloaded the AudioBasicsToy and alxPlay does work for that, but I haven't found any differences between my project and the AudioBasicsToy that seem relevant to this.
Is there something that needs to be added to play sounds?
08/13/2013 (3:33 am)
Not sure if my question is the same in regards to 'streaming'. I just want to play a sound.Using alxPlay("ToyAssets:test_sound");
<AudioAsset
AssetName="test_sound"
AssetAutoUnload="0"
AudioFile="test_sound.wav" />
and the sound clip does not play.
Downloaded the AudioBasicsToy and alxPlay does work for that, but I haven't found any differences between my project and the AudioBasicsToy that seem relevant to this.
Is there something that needs to be added to play sounds?
#5
One common mistake is to use audio files that are not 16 bits 44.1khz, make sure your audio is in that format.
08/13/2013 (9:49 am)
It should work without additional hassles.One common mistake is to use audio files that are not 16 bits 44.1khz, make sure your audio is in that format.
#6
Actually brought all of audioBasicsToy code into my project and all it's sound files and it still doesn't play any sounds. Is there another way besides alxPlay to play a sound?
08/13/2013 (2:18 pm)
The audio files tested work on the audioBasicsToy in the sandbox.Actually brought all of audioBasicsToy code into my project and all it's sound files and it still doesn't play any sounds. Is there another way besides alxPlay to play a sound?
#7
08/13/2013 (2:38 pm)
Not that I am aware of. Did you properly rename the audio assets? Everything in the toy simply points to the files in the ToyAssets module.
#8
That engine fix listed above wouldn't effect this would it?
08/13/2013 (2:43 pm)
Yeah, as far as I can tell everything's been renamed properly.That engine fix listed above wouldn't effect this would it?
#9
I would suggest looking at the console, if that doesn't yield clues, in your topmost main.cs (Or wherever, really), set the following to true
This will list every asset and module that's loaded, unloaded as well as any error which might occur from this. Just search the console.log file after you've run the game with the name of your asset to see where it comes up.
08/13/2013 (2:52 pm)
I've just tested the audioBasicstoy using the branch which contains the fix and everything works as expected.I would suggest looking at the console, if that doesn't yield clues, in your topmost main.cs (Or wherever, really), set the following to true
ModuleDatabase.EchoInfo = false; // Set asset database information echo. AssetDatabase.EchoInfo = false;
This will list every asset and module that's loaded, unloaded as well as any error which might occur from this. Just search the console.log file after you've run the game with the name of your asset to see where it comes up.
#10
Are you getting any errors in the console? Did you turn on EchoInfo for the module and asset systems? Are you taking any debugging steps to see if the function where the alxPlay is located is even being called?
Edit: bah, Simon beat me to it!
08/13/2013 (2:55 pm)
No, that is only to fix streaming. None of the ToyAsset sound files are set up to stream by default.Are you getting any errors in the console? Did you turn on EchoInfo for the module and asset systems? Are you taking any debugging steps to see if the function where the alxPlay is located is even being called?
Edit: bah, Simon beat me to it!
#11
This is what happens when I use alxPlay("ToyAssets:winMusic");
Asset Manager: Started releasing Asset Id 'ToyAssets:winMusic'...
Asset Manager: > Reference count now '0'.
Asset Manager: > Finished releasing Asset Id 'ToyAssets:winMusic'.
08/13/2013 (3:05 pm)
Turning those to to true shows all the sound assets being loaded (previous times I would get a console error if I didn't load one or mistyped it).This is what happens when I use alxPlay("ToyAssets:winMusic");
Asset Manager: Started releasing Asset Id 'ToyAssets:winMusic'...
Asset Manager: > Reference count now '0'.
Asset Manager: > Finished releasing Asset Id 'ToyAssets:winMusic'.
#12
Copied that to original project and now it works.
Thanks for trying to help with it though, much appreciated.
Edit: Image to accompany story explanation
08/13/2013 (10:13 pm)
Kinda feel like that scene from Gladiator - "Victory, and the crowd cheers". Started rebuilding/merging project into the sandbox since that sound works, and noticed this little harmless 'OpenAL32.dll' that was just sitting there all innocent, watching me work, just giggling in the corner waiting to be noticed.Copied that to original project and now it works.
Thanks for trying to help with it though, much appreciated.
Edit: Image to accompany story explanation
#13
Next time someone faces a similar issue, you can be sure we'll think of the OpenAL dll before anything else!
08/13/2013 (11:05 pm)
hahaha no worries, we've all spent a day or two completely stumped on really 'obvious' (once you know the problem anyways) things.Next time someone faces a similar issue, you can be sure we'll think of the OpenAL dll before anything else!
#14
My program has background music playing and a bunch of sound effects that go off, all using alxPlay(). Want to make sure having a bunch of overlapping sounds playing is fine.
Is there a way to have background music quieter than sound effects? There are some $channels and a $master_volume, can you choose which channel your using for each sound or choose if something is music vs. sfx?
$pref::Audio::sfxVolume = 1.0;
$pref::Audio::musicVolume = 1.0;
Also when sounds are being played and you exit the program, it gives an error "Torque 2D MIT has stopped working", is there a way to prevent that upon exiting?
08/17/2013 (12:43 am)
Are there any 'best practices' when it comes to sound?My program has background music playing and a bunch of sound effects that go off, all using alxPlay(). Want to make sure having a bunch of overlapping sounds playing is fine.
Is there a way to have background music quieter than sound effects? There are some $channels and a $master_volume, can you choose which channel your using for each sound or choose if something is music vs. sfx?
$pref::Audio::sfxVolume = 1.0;
$pref::Audio::musicVolume = 1.0;
Also when sounds are being played and you exit the program, it gives an error "Torque 2D MIT has stopped working", is there a way to prevent that upon exiting?
#15
Regarding sound volumes: first define 2 channels like so
Whenever you want to change the volume of background music just change the volume of $musicAudioChannel using alxSetChannelVolume().
08/17/2013 (2:45 am)
@Christian, regarding the program error, find the solution here.Regarding sound volumes: first define 2 channels like so
$musicAudioChannel = 1; $effectsAudioChannel = 2;then define the volumes of those two channels
alxSetChannelVolume($musicAudioChannel, 0.5); // music volume is 0.5 alxSetChannelVolume($effectsAudioChannel, 1); // sfx volume is 1Assign a volume channel in all your audio asset files
<AudioAsset
AssetName=arrowDrawSound
AudioFile=arrowDraw.wav
VolumeChannel = 2
Looping= false
/>using VolumeChannel = 2 means this audio asset will be getting its volume from $effectsAudioChannel's volume which in this case is 1.Whenever you want to change the volume of background music just change the volume of $musicAudioChannel using alxSetChannelVolume().
#16
To avoid others having to look through several posts, here's the short answer : Just call alxStopAll() when the module is destroyed
As for the audio channels, you have a maximum of 32 you can use.
08/17/2013 (2:56 am)
Amjad wins!To avoid others having to look through several posts, here's the short answer : Just call alxStopAll() when the module is destroyed
As for the audio channels, you have a maximum of 32 you can use.
#17
08/17/2013 (3:00 am)
Perfect, thanks.
#18
08/17/2013 (5:31 am)
:-)
#19
myModule.destroy(); does it, but gives another error.
08/17/2013 (5:34 am)
After alxStopAll() how do you close the window to exit the program through code?myModule.destroy(); does it, but gives another error.
#20
In your module's "main.cs",
08/17/2013 (6:17 am)
No, don't use myModule.destroy(); in fact, don't add anything but alxStopAll() in your module's destroy() functionIn your module's "main.cs",
function yourModuleName::destroy( %this )
{
// destroy scene window
alxStopAll();
destroySceneWindow();
}
Torque Owner Richard Ranft
Roostertail Games