[UT'99] Sound mute when disabling music.

  • Two Factor Authentication is now available on BeyondUnreal Forums. To configure it, visit your Profile and look for the "Two Step Verification" option on the left side. We can send codes via email (may be slower) or you can set up any TOTP Authenticator app on your phone (Authy, Google Authenticator, etc) to deliver codes. It is highly recommended that you configure this to keep your account safe.

Raven

Member
Jan 17, 2004
147
0
16
40
turniej.unreal.pl
I created custom class that play's mp3 form uax file (galaxy can handle mp3's imported directly to uax as well). But I have problem with disabling music. When music is not loaded in to the level, everything works fine (sound plays properly), but when I load music (in LevelProperties) and then plays mp3 with my trigger (with var bDisableMusic turned on), sound plays for 2 seconds and instantly mute. I though that this problem comes from ClientPlaySound, So I write a new one:

Code:
simulated function RPGPlaySound(sound ASound, optional ESoundSlot Slot, optional bool bInterrupt, optional bool bVolumeControl )
{	
	local actor SoundPlayer;

	LastPlaySound = Level.TimeSeconds;	// so voice messages won't overlap
	SoundPlayer = self;
	SoundPlayer.PlaySound(ASound, Slot, 16.0, bInterrupt);
}
but this doesn’t change nothing. So now I don't know why this code don't work as I want it to. Anyone can help me with this? Here is Trigger code:
Code:
class TCOMusicPlayer extends TCOTriggers;

//#exec TEXTURE IMPORT NAME=empeT FILE="textures\Icons\mp3t.bmp" GROUP=Icons LODSET=2
#exec TEXTURE IMPORT NAME=empeP FILE="textures\Icons\mp3p.bmp" GROUP=Icons LODSET=2
#exec OBJ LOAD FILE="..\Music\NoMusic.umx" PACKAGE=NoMusic


var(Mp3Player) sound MPThree;   //mp3
var(Mp3Player) bool bLoopMusic; //loop mp3?
var(Mp3Player) bool bAffectAllPlayers;
var(Mp3Player) bool bDisableMusic; //disable music
var(Mp3Player) music SilentSong;
var MaleFour PlayerInstigator;
//play control stuff
var float SoundLength;
var float DebugSL; // for debug
var bool bPlaying;


function PostBeginPlay()
{
      disable('Tick');
}

function Trigger( actor Other, pawn EventInstigator )
{
      if(MPThree != none)
      {
            PlayerInstigator=MaleFour(EventInstigator);
            PlayMPThree();
            enable('Tick');
      }
}

function GetSoundLength()
{
        SoundLength=GetSoundDuration(MPThree);
        DebugSL=GetSoundDuration(MPThree); //for debug
}

function CheckForMusic()
{
	local pawn P;

        if(bAffectAllPlayers)
        {
	   for (P=Level.PawnList; P!=None; P=P.NextPawn)
		if (P.bIsPlayer && P.IsA('PlayerPawn'))
                {
				PlayerPawn(P).ClientSetMusic(SilentSong, 0, 255, MTRAN_Fade);
		}
	}
        else
        {
                PlayerInstigator.ClientSetMusic(SilentSong, 0, 255, MTRAN_Fade);
        }

}

function PlayMPThree()
{
	local pawn P;

        GetSoundLength();
        bPlaying=true;
        if(bAffectAllPlayers)
        {
            for ( P=Level.PawnList; P!=None; P=P.NextPawn )
	   	    if ( P.bIsPlayer && P.IsA('MaleFour') )
			    MaleFour(P).RPGPlaySound(MPThree, SLOT_Interface, true);
        }
        else
        {
              PlayerInstigator.RPGPlaySound(MPThree, SLOT_Interface, true);
//              BroadCastMessage("mp3="$MPThree);
        }
        if(bDisableMusic)
        {
              CheckForMusic();
        }
//                	BroadCastMessage("Test!!! Played: "$SoundLength$" from: "$DebugSL); //debug
}

function Tick(float DeltaTime)
{
        if (bPlaying)
	{
                SoundLength -= DeltaTime;
//                BroadCastMessage("Tick works! Played: "$SoundLength$" from: "$DebugSL); //another debug :)
		if (SoundLength <= 0)
		{
			if(bLoopMusic)
			       PlayMPThree();
			else if(!bLoopMusic)
                        {
                               bPlaying=false;
                               disable('Tick');
                        }
		}
	}
}

defaultproperties
{
    DrawType=DT_Sprite
    bHidden=true
    Texture=Texture'CHSystem.Icons.empeP'
    bLoopMusic=true
    bPlaying=false
    bAffectAllPlayers=false
    bDisableMusic=true
    SilentSong=music'NoMusic.null'
}
 

Asgard

New Member
Oct 6, 2000
265
0
0
Visit site
Not sure what you mean here?
Your mp3's dont play if music if music is triggered? Or if music is in a level your mp's play for 2 seconds them quit or does the music play for 2 seconds and quits.

Perhaps setting the ClientSetMusic to a non package is causing you problems.
Have you tried setting ClientSetMusic (None, etc)? and perhaps doing this before the mp3 is played.

From Tim Sweeny
*******************
MusicEvent actors work similarly to SpecialEvent actors, in that they let you cause music changes in response to any event, such as the player touching a trigger, killing a monster, etc. In multiplayer games, MusicEvent actors only cause a music change in the player which caused the event, not all players in the game. MusicEvents have a "Song" variable which you can set to "None" if you want to use the song you set for the level in Options/Level.
*******************

Setting song to none would be the same as ClientSetMusic (None, etc)
It might be an idea to use ClientSetMusic for your mp3s rather than playsound aswell so theres no overlap if your mp3 is playing and a musicevent is triggered (2 types of music at once)

cheers
 

Raven

Member
Jan 17, 2004
147
0
16
40
turniej.unreal.pl
I know, my english sucks :) I tried ClientSetMusic before playing mp3, with the same result. And I mean, that when NO music is playing and then I to trigger Mp3Player music plays fine (it'll be better when I'd say "PlayersPlaysSound", beacouse it's the same effect like SpecialEvent). But, when music IS in level and then I trigger Mp3Player (and use ClientSetMusic to play blank.umx), player plays mp3 for 2sec and stops. And I don't know why :). Anyway, I started to code native class, that wil play mp3's, but I have many errors :). THX for answer.
 

Asgard

New Member
Oct 6, 2000
265
0
0
Visit site
Ok but :)
In your default properties you have
SilentSong=music'NoMusic.null'

Try setting this to
SilentSong=none

And instead of
function PlayMPThree()
MaleFour(P).RPGPlaySound(MPThree, SLOT_Interface, true);


Try
function PlayMPThree()
MaleFour(P).ClientSetMusic( MPThree, blah , blah, blah);

Have a look at the class'musicevent'

Cheers
 

Raven

Member
Jan 17, 2004
147
0
16
40
turniej.unreal.pl
Try
function PlayMPThree()
MaleFour(P).ClientSetMusic( MPThree, blah , blah, blah);
but MPThree is sound not music :) it's Mp3 imported to uax file and it acts like normal unlooped sound :). That's why i can not use ClientSetMusic for MPThree var, and it's reason why I try to create native class using fmod.dll :). But this one is also usefull to many things in mod :)
 
Last edited:

Asgard

New Member
Oct 6, 2000
265
0
0
Visit site
Yeah fair enough..

I thought by resetting the music "SilentSong=none" not "SilentSong=music'NoMusic.null'" and disabling the musicevent triggers may help..
I was thinking perhaps you was messing up the sound by setting SilentSong=music'NoMusic.null' which doesnt exist, unless you made this package. (blank.umx or rather NoMusic.umx)

Anyway sorry I couldnt help

cheers