There is no spoon

Difference between revisions of "UE1:RMusicPlayer"

From Unreal Wiki, The Unreal Engine Documentation Site
Jump to: navigation, search
m (Gametype integration (with save support))
(Unreal Tournament)
 
(15 intermediate revisions by the same user not shown)
Line 13: Line 13:
 
* You can't have more then one DSP plugin
 
* You can't have more then one DSP plugin
 
* Additional codecs doesn't work
 
* Additional codecs doesn't work
 
ToDo:
 
* Add complete readme about [[UE1:RMusic_Player|RMusic_Player]] native function, non-native functions and variables
 
* Fix DSP plugin architecture
 
* Fix loading additional codecs
 
  
 
==Class tree==
 
==Class tree==
Line 23: Line 18:
 
  +- [[Legacy:Actor_(UT)|Actor_(UT)]]
 
  +- [[Legacy:Actor_(UT)|Actor_(UT)]]
 
     +- RMusic_Component - holds everything toghether and implements some basic functions
 
     +- RMusic_Component - holds everything toghether and implements some basic functions
         +- RMusic_Controller - controls RMusic_Player
+
         +- [[UE1:RMusic_Controller|RMusic_Controller]] - controls RMusic_Player
 
         +- [[UE1:RMusic_Player|RMusic_Player]] - plays music. This class is spawned either by RMusic_Controller or game type/console.
 
         +- [[UE1:RMusic_Player|RMusic_Player]] - plays music. This class is spawned either by RMusic_Controller or game type/console.
 
         +- RMusic_Save - spawned by RMusic_Controller. Stores information about last used RMusic_Controller
 
         +- RMusic_Save - spawned by RMusic_Controller. Stores information about last used RMusic_Controller
  
==Usage==
+
==Advanced usage (gametype/console integration)==
In ActorBrowser find Actor->RMusic_Component->RMusic_Controller, place it on map and configure it.
+
This are just two simple samples. More can be found in zip file.
  
===RMusic_Controller properties===
+
===Gametype integration with save support===
You can configure following properties:
+
 
+
'''Name:''' PlayerClass
+
 
+
'''Type:''' class<RMusic_Player>
+
 
+
'''Description:''' Player class (if you want to have own music directory)
+
 
+
 
+
'''Name:''' RMusic_File
+
 
+
'''Type:''' string
+
 
+
'''Description:''' Music file to play
+
 
+
 
+
'''Name:''' RMusic_PlayAtStartup
+
 
+
'''Type:''' bool
+
 
+
'''Description:''' Should it be played at level start
+
 
+
 
+
'''Name:''' RMusic_MuteUMX
+
 
+
'''Type:''' bool
+
 
+
'''Description:''' If true will mute all music in umx files
+
 
+
 
+
'''Name:''' RMusic_BroadcastToAll
+
 
+
'''Type:''' bool
+
 
+
'''Description:''' If true, it'll broadcast functions to all players
+
 
+
 
+
'''Name:''' RMusic_bUnloadPreviousDSP
+
 
+
'''Type:''' bool
+
 
+
'''Description:''' If true, all DSP plugins will be unloaded
+
 
+
 
+
'''Name:''' RMusic_bOwnFadeUpdateTime
+
           
+
'''Type:''' bool
+
 
+
'''Description:''' If true, RMusic_OwnFadeUpdateTime will be used instead of default FaderUpdateTime in RMusic_Player
+
 
+
 
+
'''Name:''' RMusic_OwnFadeUpdateTime
+
 
+
'''Type:''' float
+
 
+
'''Description:'''  Defines how fast music will fade in/out
+
 
+
 
+
'''Name:''' RMusic_bUseSaveControl
+
 
+
'''Type:''' bool
+
 
+
'''Description:''' If true, special RMusic_Save will be spawned to track last used controller
+
 
+
 
+
'''Name:''' RMusic_DSPPlugins[16]
+
 
+
'''Type:''' string
+
 
+
'''Description:'''  DSP plugins to load
+
 
+
 
+
'''Name:''' Action
+
 
+
'''Type:''' ENum
+
 
+
'''Values:'''
+
* '''AC_Play''' -  Plays music
+
* '''AC_Stop''' - Stops music
+
* '''AC_ShutDown''' - Shutdown FMODEX (avoid this one ;) )
+
'''Description:''' Action
+
 
+
 
+
'''Name:''' RMusic_PlayType
+
 
+
'''Type:''' ENum
+
 
+
'''Values:'''
+
* '''PT_Loop''' - Loops music
+
* '''PT_PlayOnce''' - Plays once
+
'''Description:''' Play type
+
 
+
 
+
'''Name:''' RMusic_Transition
+
 
+
'''Type:''' ENum
+
 
+
'''Values:'''
+
* '''TRANS_Instanly''' - Instant transition
+
* '''TRANS_Fade''' - Smooth fade
+
'''Description:''' Transition type
+
 
+
===Advanced usage (gametype/console integration)===
+
RMusicPlayer can be also integrated with gametypes, console.
+
 
+
====Gametype integration (with save support)====
+
 
Subclass of SinglePlayer2 (SinglePlayer2 is part of OldSkool by UsAaR33)
 
Subclass of SinglePlayer2 (SinglePlayer2 is part of OldSkool by UsAaR33)
 
<uscript>
 
<uscript>
Line 143: Line 32:
 
event PostLogin( playerpawn NewPlayer )
 
event PostLogin( playerpawn NewPlayer )
 
{
 
{
local RMusic_Controller RMusic_Controller;
+
        local RMusic_Controller RMusic_Controller;
local RMusic_Save RMusic_Save;
+
        local RMusic_Save RMusic_Save;
local RMusic_Player RMusic_Player;
+
        local RMusic_Player RMusic_Player;
 
+
 
         Super.PostLogin(NewPlayer);
 
         Super.PostLogin(NewPlayer);
 
+
if(Level.NetMode != NM_DedicatedServer && Level.NetMode != NM_ListenServer)
+
        if(Level.NetMode != NM_DedicatedServer)
{
+
        {
if(NewPlayer.GetEntryLevel() != none)
+
                //we have to find out we're in save or not
 +
                foreach AllActors(class'RMusic_Save', RMusic_Save)
 +
                {
 +
                        //we have to check if we have saved controller
 +
                        if(RMusic_Save.SavedController != none)
 +
                        {
 +
                                RMusic_Controller=RMusic_Save.SavedController;
 +
                                break;
 +
                        }
 +
                }
 +
                //if save controller is found, we have to restore music
 +
                if(RMusic_Controller != none) RMusic_Controller.EVENT_Player();
 +
else
 
{
 
{
//we have to find music player in Entry level
+
//we found RMusic_Save, so RMusic_Controller is used, but wasn't activated. We have to stop the music if playing
foreach NewPlayer.GetEntryLevel().AllActors(class'RMusic_Player',RMusic_Player)
+
RMusic_Player = class'RMusic_Component'.static.Find_RMusicPlayerByPPawn(NewPlayer,none,true);
 +
if( RMusic_Player != none)
 
{
 
{
//then we stops currently played song
+
if( RMusic_Player.RMusic_IsPlaying() ) RMusic_Player.RMusic_Stop();
RMusic_Player.RMusic_Stop(false);
+
//and eventually add info about player/current level
+
if( RMusic_Player.bAuthoritative )
+
{
+
RMusic_Player.RMusic_LocalPlayer = NewPlayer;
+
RMusic_Player.RMusic_OldLevel = NewPlayer.Level;
+
}
+
 
}
 
}
 
}
 
}
//we have to found save part
+
        }
foreach AllActors(class'RMusic_Save', RMusic_Save)
+
{
+
//we have to check if we have saved controller
+
if(RMusic_Save.SavedController != none)
+
{
+
RMusic_Controller=RMusic_Save.SavedController;
+
break;
+
}
+
}
+
//if saved controller is found, we have to restore music
+
if(RMusic_Controller != none) RMusic_Controller.EVENT_Player();
+
}
+
 
}
 
}
 
</uscript>
 
</uscript>
  
====Gametype integration (without save support)====
+
===Console integration===
Subclass of coopgame2 (coopgame2 is part of OldSkool by UsAaR33)
+
<uscript>
+
class RMusic_CoopGameInfo extends coopgame2;
+
 
+
event PostLogin( playerpawn NewPlayer )
+
{
+
local RMusic_Controller RMusic_Controller;
+
local RMusic_Save RMusic_Save;
+
local RMusic_Player RMusic_Player;
+
+
Super.PostLogin(NewPlayer);
+
+
if(Level.NetMode != NM_DedicatedServer && Level.NetMode != NM_ListenServer)
+
{
+
//we have to find music player in Entry level
+
foreach NewPlayer.GetEntryLevel().AllActors(class'RMusic_Player',RMusic_Player)
+
{
+
//then we stops currently played song
+
RMusic_Player.RMusic_Stop(false);
+
//and eventually add info about player/current level
+
if( RMusic_Player.bAuthoritative )
+
{
+
RMusic_Player.RMusic_LocalPlayer = NewPlayer;
+
RMusic_Player.RMusic_OldLevel = NewPlayer.Level;
+
}
+
}
+
}
+
}
+
</uscript>
+
 
+
====Console integration====
+
 
Subclass of UTConsole
 
Subclass of UTConsole
 
<uscript>
 
<uscript>
Line 228: Line 80:
 
if(PP != none)
 
if(PP != none)
 
{
 
{
foreach PP.GetEntryLevel().AllActors(class'RMusic_Player', RMusic_Player) break;
+
if(PP.GetEntryLevel() != none)
 
+
{
if (RMusic_Player != none) RMusic_Player.RMusic_Stop(false);
+
foreach PP.GetEntryLevel().AllActors(class'RMusic_Player', RMusic_Player) break;
 +
 +
if (RMusic_Player != none && RMusic_Player.RMusic_IsPlaying()) RMusic_Player.RMusic_Stop();
 +
}
 
}
 
}
 
}
 
}
Line 236: Line 91:
 
}
 
}
 
</uscript>
 
</uscript>
 +
 +
 +
==Changelog==
 +
 +
*'''v 0.1.4'''
 +
**File is searched in all paths ([Core.System] in main ini) with *.umx
 +
*'''v 0.1.3'''
 +
**added information about current volume to the menu.
 +
**removed unused configuration from advanced options->audio
 +
*'''v 0.1.2'''
 +
**RMusic_Controller spawns RMusic_Save at startup
 +
**RMusic_SingleGameInfo2 detects save and stops/plays correct music
 +
*'''v 0.1.1'''
 +
**fixed Trigger function in RMusic_Controller
 +
**in RMusic_Player function RMusic_Play stops music (if something is playing), before playing new one
 +
*'''v 0.1.0'''
 +
**added new RMusic_Controller actions (AC_Pause and AC_UnPause)
 +
**DSP manager moved form RMusic_Controller into RMusic_DSPController
 +
**new samples in SDK (integration with gametype and playerpawn)
 +
*'''v 0.0.3'''
 +
**fixed fade in/out/corssfade bug
 +
**fixed crashes on dedicated server
 +
**added DSP related functions into RMusic_Player
 +
*'''v 0.0.2 (first public release)'''
 +
**fixed few RMusic_Player bugs
  
 
==Download==
 
==Download==
'''link:''' [http://turniej.unreal.pl/files/RMusicPlayer.zip]
+
As always source code is included in zip file.
 +
 
 +
===Unreal Tournament===
 +
'''link:''' [http://turniej.unreal.pl/files/RMusicPlayer_newbeta.zip RMusicPlayer 0.1.4 (~694kb)]
 +
 
 +
===Rune===
 +
'''link:''' [http://turniej.unreal.pl/files/RMusicPlayer_Rune.zip RMusicPlayer 0.1.4 beta for Rune (~694kb)]

Latest revision as of 15:18, 7 June 2009

About[edit]

RMusicPlayer is new version of RvMp3Player. The code has been completly rewritten, this time using FMODEX. Features:

  • Mod support (you can subclass RMusic_Player to define new music directory)
  • Save support in SP games
  • Supports many audio files (flac, mp2, mp3, ogg, wma, wav)
  • Crossfades/fades in/fades out music

Current bugs (will be fixed):

  • DSP plugins - everything loads fine, but I can't hear difference :)
  • You can't have more then one DSP plugin
  • Additional codecs doesn't work

Class tree[edit]

+- Actor_(UT)
   +- RMusic_Component - holds everything toghether and implements some basic functions
       +- RMusic_Controller - controls RMusic_Player
       +- RMusic_Player - plays music. This class is spawned either by RMusic_Controller or game type/console.
       +- RMusic_Save - spawned by RMusic_Controller. Stores information about last used RMusic_Controller

Advanced usage (gametype/console integration)[edit]

This are just two simple samples. More can be found in zip file.

Gametype integration with save support[edit]

Subclass of SinglePlayer2 (SinglePlayer2 is part of OldSkool by UsAaR33)

class RMusic_SingleGameInfo extends SinglePlayer2;
 
event PostLogin( playerpawn NewPlayer )
{
        local RMusic_Controller RMusic_Controller;
        local RMusic_Save RMusic_Save;
        local RMusic_Player RMusic_Player;
 
        Super.PostLogin(NewPlayer);
 
        if(Level.NetMode != NM_DedicatedServer)
        {
                //we have to find out we're in save or not
                foreach AllActors(class'RMusic_Save', RMusic_Save)
                {
                        //we have to check if we have saved controller
                        if(RMusic_Save.SavedController != none)
                        {
                                RMusic_Controller=RMusic_Save.SavedController;
                                break;
                        }
                }
                //if save controller is found, we have to restore music
                if(RMusic_Controller != none) RMusic_Controller.EVENT_Player();
		else
		{
			//we found RMusic_Save, so RMusic_Controller is used, but wasn't activated. We have to stop the music if playing
			RMusic_Player = class'RMusic_Component'.static.Find_RMusicPlayerByPPawn(NewPlayer,none,true);
			if( RMusic_Player != none)
			{
				if( RMusic_Player.RMusic_IsPlaying() ) RMusic_Player.RMusic_Stop();
			}
		}
        }
}

Console integration[edit]

Subclass of UTConsole

class RMusic_Console extends UTConsole;
 
function DrawLevelAction( canvas C )
{
	local RMusic_Player RMusic_Player;
	local PlayerPawn PP;
 
	if ( Viewport.Actor.Level.LevelAction == LEVACT_Loading ) // Loading Screen
	{
		PP = Root.GetPlayerOwner();
		if(PP != none)
		{
			if(PP.GetEntryLevel() != none)
			{
				foreach PP.GetEntryLevel().AllActors(class'RMusic_Player', RMusic_Player) break;
 
				if (RMusic_Player != none && RMusic_Player.RMusic_IsPlaying()) RMusic_Player.RMusic_Stop();
			}
		}	
	}
	Super.DrawLevelAction(C);
}


Changelog[edit]

  • v 0.1.4
    • File is searched in all paths ([Core.System] in main ini) with *.umx
  • v 0.1.3
    • added information about current volume to the menu.
    • removed unused configuration from advanced options->audio
  • v 0.1.2
    • RMusic_Controller spawns RMusic_Save at startup
    • RMusic_SingleGameInfo2 detects save and stops/plays correct music
  • v 0.1.1
    • fixed Trigger function in RMusic_Controller
    • in RMusic_Player function RMusic_Play stops music (if something is playing), before playing new one
  • v 0.1.0
    • added new RMusic_Controller actions (AC_Pause and AC_UnPause)
    • DSP manager moved form RMusic_Controller into RMusic_DSPController
    • new samples in SDK (integration with gametype and playerpawn)
  • v 0.0.3
    • fixed fade in/out/corssfade bug
    • fixed crashes on dedicated server
    • added DSP related functions into RMusic_Player
  • v 0.0.2 (first public release)
    • fixed few RMusic_Player bugs

Download[edit]

As always source code is included in zip file.

Unreal Tournament[edit]

link: RMusicPlayer 0.1.4 (~694kb)

Rune[edit]

link: RMusicPlayer 0.1.4 beta for Rune (~694kb)