36 public double Progress {
get;
private set; } = 0;
49 float maxSamples = TrackW.SampleCount - 1;
50 return Mathf.Clamp01((
float)
Progress / maxSamples);
64 public Action<RadioTrackPlayer>
DoDestroy {
get;
set; } =
new(_ => { });
67 public Action<RadioTrackPlayer>
OnPlay {
get;
set; } =
new(_ => { });
69 public Action<RadioTrackPlayer>
OnStop {
get;
set; } =
new(_ => { });
71 public Action<RadioTrackPlayer, bool>
OnPause {
get;
set; } =
new((_, _) => { });
73 public Action<RadioTrackPlayer>
OnSample {
get;
set; } =
new(_ => { });
77 private Action<RadioTrackPlayer> onEnd = _ => { };
80 public Action<RadioTrackPlayer>
OnEnd
87 public Action<RadioTrackPlayer, float>
OnVolume {
get;
set; } =
new((_, _) => { });
89 public Action<RadioTrackPlayer, float>
OnGain {
get;
set; } =
new((_, _) => { });
91 public Action<RadioTrackPlayer, float>
OnTunePower {
get;
set; } =
new((_, _) => { });
93 public Action<RadioTrackPlayer, float>
OnBroadcastPower {
get;
set; } =
new((_, _) => { });
95 public Action<RadioTrackPlayer, float>
OnInsulation {
get;
set; } =
new((_, _) => { });
99 private bool paused =
false;
148 TrackW.AddToPlayerEndCallback(ref onEnd);
187 public float GetSample(
float _tune, Vector3 _receiverPosition,
float _otherVolume, out
float _outVolume,
bool _applyVolume =
true)
222 float tunePower =
TrackW.GetTunePower(_tune, _otherVolume);
238 float insulationMultiplier =
GetInsulation(_receiverPosition);
242 volume = tunePower * broadcastPower * insulationMultiplier;
266 void NormalIncrement()
358 if (
TrackW.broadcasters.Count > 0)
361 outPower = Mathf.Max(outPower, broadcaster.
GetPower(_receiverPosition));
377 return Mathf.Clamp01(outPower);
391 outGain -= insulator.
GetPower(_receiverPosition);
399 return Mathf.Clamp01(outGain);
A "broadcaster" for a RadioTrackWrapper - the closer the RadioOutput that's playing the track is to a...
float GetPower(Vector3 _receiverPos)
Gets the broadcast power of this particular broadcaster using the Output's position.
An "insulator" for a RadioTrackWrapper - if a RadioOutput is inside the bounds of this object,...
float GetPower(Vector3 _position)
Gets the power of this insulator at a specific position.
float ProgressFraction
How far through the track this player is, from [0 - 1].
Action< RadioTrackPlayer > OnSample
Event called when this player retreieves a sample from its track.
Action< RadioTrackPlayer, float > OnInsulation
Event called when the insulation for this player is captured for a sample. Insulation is the quietnes...
double Progress
How many samples through the track this player is- not a whole number as we increment it with differe...
void Stop()
Stop playback and destroy this player. Make sure any references to it are removed as well.
RadioTrackPlayer(RadioTrackWrapper _trackW, PlayerType _playerType, float _baseSampleRate)
Creates a new player for the provided track.
Action< RadioTrackPlayer, float > OnGain
Event called when the gain for this player is captured for a sample. Gain is a direct change to the l...
float GetSample(float _tune, Vector3 _receiverPosition, float _otherVolume, out float _outVolume, bool _applyVolume=true)
Gets the current sample from the track according to playback. I would recommend reading the code comm...
PlayerType
The different types of Player- mainly changes what it does when the end of the track is reached.
@ Loop
When it ends, the player goes back to the start and plays the track again.
@ OneShot
When it ends, the player destroys itself and stops playing.
void UpdateSampleIncrement()
Updates the sampleIncrement variable to match the current track.
Action< RadioTrackPlayer > OnStop
Event called when the player is stopped through Stop()
bool Paused
Whether or not this player has been paused, temporarily halting playback of the track....
float baseSampleRate
The sample rate of the RadioOutput that this player is used by- that is, the sample rate of the radio...
Action< RadioTrackPlayer, float > OnVolume
Event called when the volume of this player is captured for a sample. Volume is the product of Tune p...
PlayerType PlayType
The type of player this is- what happens when the track ends.
float GetBroadcastPower(Vector3 _receiverPosition)
Gets the broadcast power of this player using the position of the Output and any any RadioBroadcaster...
void Destroy()
Invokes DoDestroy, destroying the player.
void IncrementSample()
Move this player to the next sample.
bool isStopped
Whether or not this player has been stopped- prevents it from being stopped multiple times.
Action< RadioTrackPlayer, float > OnTunePower
Event called when the tune power for this player is captured for a sample. Tune power is the loudness...
Action< RadioTrackPlayer, bool > OnPause
Event called when the player's pause state is changed- the bool is true if the player is being paused...
Action< RadioTrackPlayer, float > OnBroadcastPower
Event called when the broadcast power for this player is captured for a sample. Broadcast power is th...
float sampleIncrement
The amount that Progress is increased by every sample- the ratio of the track's sample speed to the b...
void ResetProgress()
Resets the Progress of this player to 0.
Action< RadioTrackPlayer > DoDestroy
Event called in order to destroy this player- this can either be invoked directly or as part of the D...
RadioTrackWrapper TrackW
The track that this player is associated with and plays during runtime.
float GetInsulation(Vector3 _receiverPosition)
Gets the insulation multiplier of this player using the position of the output and the bounds of any ...
Action< RadioTrackPlayer > OnPlay
Event called when the player starts playing.
Action< RadioTrackPlayer > OnEnd
Event called when the player reaches the end of its track naturally, before it takes an action depend...
A wrapper class for RadioTrack so that track types can be switched between in the inspector!...
Components to be placed on scene objects, e.g: Outputs, Broadcasters, Observers.
Tracks to be used on a radio- includes base classes.