[Bug 1.1 Beta] Audio Music (non 3D) not working - LOGGED
by elvince · in Torque 3D Professional · 02/24/2010 (9:47 am) · 14 replies
Hi,
When I try to load & play a file my game crash.
after few test, I did make this work by using description AudioDefaultLoop3D. It's seem a non 3D description crash.
Thanks,
When I try to load & play a file my game crash.
datablock SFXProfile(Test)
{
filename = "art/sound/environment/amb";
description = AudioMusicLoop2D;
preload = true;
};
sfxPlayOnce( Test);after few test, I did make this work by using description AudioDefaultLoop3D. It's seem a non 3D description crash.
Thanks,
About the author
Recent Threads
#2
But your definition of sound 3D seems to be the opposite of the official t3d docs.
3D sound are uses to spread sound in space managed by cones. Depanding of the player position thé sound Will not be the same.
For background music I should use 2D music this where it fails in current beta!
In fact playonce do not constraint the music to play once as it depands of your description. I found that confuising but that the current state.
GG could please clarify whether or not I understood properly how it should works?
Thanks!
02/24/2010 (1:13 pm)
Thanks for this Answer. But your definition of sound 3D seems to be the opposite of the official t3d docs.
3D sound are uses to spread sound in space managed by cones. Depanding of the player position thé sound Will not be the same.
For background music I should use 2D music this where it fails in current beta!
In fact playonce do not constraint the music to play once as it depands of your description. I found that confuising but that the current state.
GG could please clarify whether or not I understood properly how it should works?
Thanks!
#3
3D needs a mono audio file
2D needs a stereo audio file
sigh ... silly me ...
Are you doing this 2D sound in-mission or in (main) menu?
02/24/2010 (2:01 pm)
DOH! Yes you're right I got the descriptions mixed up!3D needs a mono audio file
2D needs a stereo audio file
sigh ... silly me ...
Are you doing this 2D sound in-mission or in (main) menu?
#4
Doesn't happen with Fmod - but the audio sounds awful when it does play.
02/24/2010 (2:33 pm)
Okay, I can replicate this crash.Doesn't happen with Fmod - but the audio sounds awful when it does play.
#5
after a bit of messing around --- using OpenAL
Actually that doesn't seem to matter, it really loves crashing on AudioMusicLoop2/3D.
Works okay in AudioMusic2/3D.
Crashes in AudioStreamLoop2D.
Works in AudioLoop2D.
But I have got rid of the awful distortion on other music sounds<-RESOLVED, needs SFXsource(sfxdescription_name);
In-game these things seem easier done through a SoundEmitter and turn stuff on/off with triggers.
EDIT:
Okay, after more testing.
You can have looping or streaming music but not both ... even if the audio is not preloaded (isn't that streaming?).
more edits:
is3D seems good with either.
So, comment out "isStreaming" on all looping in game/core/scripts/client/AudioDescriptions.cs
Note: Fmod doesn't have these crashes.
02/24/2010 (3:07 pm)
elvince, did you create an sfxsource to play through first?after a bit of messing around --- using OpenAL
Actually that doesn't seem to matter, it really loves crashing on AudioMusicLoop2/3D.
Works okay in AudioMusic2/3D.
Crashes in AudioStreamLoop2D.
Works in AudioLoop2D.
But I have got rid of the awful distortion on other music sounds<-RESOLVED, needs SFXsource(sfxdescription_name);
In-game these things seem easier done through a SoundEmitter and turn stuff on/off with triggers.
EDIT:
Okay, after more testing.
You can have looping or streaming music but not both ... even if the audio is not preloaded (isn't that streaming?).
more edits:
is3D seems good with either.
So, comment out "isStreaming" on all looping in game/core/scripts/client/AudioDescriptions.cs
singleton SFXDescription( AudioStreamLoop2D : AudioEffect )//don't use - crashes with both
{
isLooping = true;
isStreaming = true;
};
//-----------------------------------------------------------------------------
// Music
//-----------------------------------------------------------------------------
singleton SFXDescription( AudioMusic2D : AudioMusic )
{
isStreaming = true;
};
singleton SFXDescription( AudioMusicLoop2D : AudioMusic )
{
isLooping = true;
// isStreaming = true;//yorks causes crash with both
};
singleton SFXDescription( AudioMusic3D : AudioMusic )
{
isStreaming = true;
is3D = true;
};
singleton SFXDescription( AudioMusicLoop3D : AudioMusic )
{
// isStreaming = true;//yorks causes crash with both
is3D = true;//this is okay though
isLooping = true;
};Note: Fmod doesn't have these crashes.
#6
Thanks for the answer.
I do not create a SFX source, just a profile. The playonce handle to create it automatically for me.
And for the moment, I'm not in game, I was just testing a music for the main menu. So no way to use emitters.
And you're right IsStreaming should be the opposite of preload as per the off. docs.
When you preload, you put in it memory. Streaming you read it live.
I didn't test fMod for the moment, I was just with OpenAL. I might have say that from the start :D
Thanks for the workaround, now it's time for GG to look in the C++ code to fix that ^^
02/24/2010 (11:34 pm)
Hi,Thanks for the answer.
I do not create a SFX source, just a profile. The playonce handle to create it automatically for me.
And for the moment, I'm not in game, I was just testing a music for the main menu. So no way to use emitters.
And you're right IsStreaming should be the opposite of preload as per the off. docs.
When you preload, you put in it memory. Streaming you read it live.
I didn't test fMod for the moment, I was just with OpenAL. I might have say that from the start :D
Thanks for the workaround, now it's time for GG to look in the C++ code to fix that ^^
#7
Though to be honest I'm not certain that those if(statements) are getting called correctly after putting them elsewhere ... though the above does work.
02/25/2010 (7:57 am)
I had a little play around (lol, so much for my plans of an early night, last night!) and found getting audio to play on the main menu took a little messing but went like this okay:function MainMenuGui::onWake(%this)
{
if (isFunction("getWebDeployment") &&
getWebDeployment() &&
isObject(%this-->ExitButton))
%this-->ExitButton.setVisible(false);
//yorks
// sfxPlayOnce(AudioMusicLoop2D, "./art/sound/music/timeogg.ogg");
$MainTheme = sfxCreateSource(AudioMusicLoop2D, "./art/sound/music/timeogg.ogg");
echo("MainMenu Theme Music is currently " @ $maintheme.getstatus());
if($maintheme.getstatus() $=stopped)
{
$maintheme.play();
echo("MainMenu Theme is restarting");
}
else
{
echo("MAINMENU MUSIC is already going, do nothing");
}
//yorks end
}
function MainMenuGui::onSleep(%this)
{
//yorks
echo("MainMenu Theme Music is currently " @ $maintheme.getstatus());
if($maintheme.getstatus() $=playing)
{
$maintheme.stop(0);
echo("MainMenu Theme is Stopping");
}
//yorks end
}Though to be honest I'm not certain that those if(statements) are getting called correctly after putting them elsewhere ... though the above does work.
#8
To keep things short; make sure that every client side only sound (such as the music that plays, usually most or all of the 2D sounds) is defined with new or singleton, while networked sounds (such as a footstep, gun shot, etc.. - whatever is defined as a 3D sound usually, and whatever you want other clients to overhear) are defined with datablock (which ensures their networked nature).
Local sounds must be defined only on the client, while networked sounds should be defined on both the client and the server.
The problem you are seeing is that you have audio defined as a networked sound - yet probably only defined on the client. When the server loads its definitions, the client cleans out all its networked sounds to make place for the sounds that the server instructs it to load. The audio buffer for this sound will be cleared, and that's why you see the crash.
Rene did some fixes so that it goes down with grace. The fix should be available in the next beta. Until then, try changing that definition to use a singleton or a new and see if that solves the problem.
02/26/2010 (2:06 am)
We had a long debugging session a few days ago with Rene Damm about a very similar issue.To keep things short; make sure that every client side only sound (such as the music that plays, usually most or all of the 2D sounds) is defined with new or singleton, while networked sounds (such as a footstep, gun shot, etc.. - whatever is defined as a 3D sound usually, and whatever you want other clients to overhear) are defined with datablock (which ensures their networked nature).
Local sounds must be defined only on the client, while networked sounds should be defined on both the client and the server.
The problem you are seeing is that you have audio defined as a networked sound - yet probably only defined on the client. When the server loads its definitions, the client cleans out all its networked sounds to make place for the sounds that the server instructs it to load. The audio buffer for this sound will be cleared, and that's why you see the crash.
Rene did some fixes so that it goes down with grace. The fix should be available in the next beta. Until then, try changing that definition to use a singleton or a new and see if that solves the problem.
#9
Duly noted, Konrad, and yes, changing datablock to singleton allow isLooping and isStreaming to work without crashing [edit!!!]= this isn't true I had Fmod on again ... it does crash still crash.
EDIT +2:20
And why does the SFXprofile have to be in the mainmenu.gui to get it to play? Because the audioProfiles.cs in art/datablocks don't get loaded until mission start! Shoulda seen that one a mile off ...
Still easier to make it a global to pass along to onSleep for ending/fadeout when a mission loads.
02/26/2010 (8:10 am)
I noticed that if I wanted to play music on the main menu using the SFXprofile, I had to have the sfxProfile in the mainmenu.gui, and that it wouldn't restart when entering the mainmenu again.Duly noted, Konrad, and yes, changing datablock to singleton allow isLooping and isStreaming to work without crashing [edit!!!]= this isn't true I had Fmod on again ... it does crash still crash.
EDIT +2:20
And why does the SFXprofile have to be in the mainmenu.gui to get it to play? Because the audioProfiles.cs in art/datablocks don't get loaded until mission start! Shoulda seen that one a mile off ...
singleton SFXProfile(theme1)
{
filename = "art/sound/music/timeogg.ogg";
description = "AudioMusicLoop2D";
preload = false;
};
function MainMenuGui::onWake(%this)
{
//....
$maintheme1=sfxCreateSource("theme1");
$maintheme1.play();
echo("Start Main Menu Theme");
}
function MainMenuGui::onSleep(%this)
{
$maintheme1.stop(2);
echo("Stop Main Menu Theme");
}Still easier to make it a global to pass along to onSleep for ending/fadeout when a mission loads.
#10
I look back again in my implementation, I have already set it as singleton. (I think I red it in the off. documentation)
I set a call to sfxplayonce in loadStartup and it crash if I set my profile as:
I also tried
without success.
For all my tests, I kept SFXDescription as they are in Stock. I didn't modifed them as Steve.
I also tried to comment preload = true; as it might have a conflict with IsStreaming = True from description, but game is crashing.
@Steve,
Can you just put the SFXDescription back and confirm the issue is still there?
@Konrad,
Are you able to get this work?
Thanks,
02/26/2010 (2:10 pm)
Thanks Konrad,I look back again in my implementation, I have already set it as singleton. (I think I red it in the off. documentation)
I set a call to sfxplayonce in loadStartup and it crash if I set my profile as:
singleton SFXProfile(AngloZulu)
{
filename = "art/sound/environment/amb";
description = AudioMusicLoop2D;
preload = true;
};I also tried
$MainTheme = sfxCreateSource(AudioMusicLoop2D, "./art/sound/music/timeogg.ogg");
without success.
For all my tests, I kept SFXDescription as they are in Stock. I didn't modifed them as Steve.
I also tried to comment preload = true; as it might have a conflict with IsStreaming = True from description, but game is crashing.
@Steve,
Can you just put the SFXDescription back and confirm the issue is still there?
@Konrad,
Are you able to get this work?
Thanks,
#11
Yeah, sorry, I got a bit ahead of myself and didn't realise that I'd swapped to Fmod from OpenAL.
Crash is still there with "isLooping" and "isStreaming" together.
02/26/2010 (2:40 pm)
@ElvinceYeah, sorry, I got a bit ahead of myself and didn't realise that I'd swapped to Fmod from OpenAL.
Crash is still there with "isLooping" and "isStreaming" together.
#12
Thanks,
02/26/2010 (2:46 pm)
No Prob!, I was just wondering if it was only my environment or a global bug that need to be fixed!Thanks,
#13
08/21/2010 (6:02 am)
Logged as TQA-865.
Associate Steve Acaster
[YorkshireRifles.com]
If you're going to play a 2D sound, it needs a source object in game space (xyz) to play from.
Also if you want something to playonce, don't loop it.
The 2Dmusic datablocks seems an oxymoron, though you'd expect things not to crash if they just don't work.
EDIT:
Reverse everything I just said!!!