Ryle Radio 1.0.0
An open-source "radio" system for Unity, allowing tracks, tuning, broadcasters, and more!
Loading...
Searching...
No Matches
RyleRadio.Components.RadioBroadcaster Class Reference

A "broadcaster" for a RadioTrackWrapper - the closer the RadioOutput that's playing the track is to a broadcaster (taking into consideration broadcast radius, power, etc), the louder the track is in the Output. More...

Inheritance diagram for RyleRadio.Components.RadioBroadcaster:

Public Member Functions

float GetPower (Vector3 _receiverPos)
 Gets the broadcast power of this particular broadcaster using the Output's position.
Public Member Functions inherited from RyleRadio.Components.Base.RadioComponentDataAccessor
override void Init ()
 Initialises this component and links its affected tracks.
Public Member Functions inherited from RyleRadio.Components.Base.RadioComponent
void Init ()
 Initialises this component.

Public Attributes

Vector2 broadcastRadius
 The inner and outer radii of this broadcaster.

Protected Member Functions

override void AssignToTrack (RadioTrackWrapper _track)
 Links this broadcaster to a track.
override void RemoveFromTrack (RadioTrackWrapper _track)
 Unlinks this broadcaster from a track.
Protected Member Functions inherited from RyleRadio.Components.Base.RadioComponentDataAccessor
void AssignToTrack (RadioTrackWrapper _track)
 Links this component to a track.
void RemoveFromTrack (RadioTrackWrapper _track)
 Unlinks this component from a track.
virtual void AccessorInit ()
 Allows extra code for initialization so that Init() can still be called.

Protected Attributes

Vector2 broadcastPowers = new(0, 1)
 The power of this broadcaster at the maximum and minimum radii.
AnimationCurve distanceFalloff
 The falloff curve between the inner and outer broadcast radii- the x-value is how far between the radii the Output is, and the y-value is how far between broadcastPowers x and y the track's broadcast power is.
Protected Attributes inherited from RyleRadio.Components.Base.RadioComponent
RadioData data
 The RadioData (aka just radio) that this component is linked to.

Properties

bool ShowApplyToAllOutputs [get]
 Shows applyToAllOutputsOutside when the x-value of broadcastPowers is greater than 0.
Properties inherited from RyleRadio.Components.Base.RadioComponentDataAccessor
List< string > TrackNames [get]
 The list of tracks on the RadioData that this component can choose from.
Action< RadioComponentOnInit = new(_ => { }) [get, set]
 Event called when the component is initialized.
Properties inherited from RyleRadio.Components.Base.RadioComponent
RadioData Data [get]
 Read-only accessor for data.

Private Member Functions

void Update ()
 Updates the position of this broadcaster.

Private Attributes

bool applyToAllOutputsOutside = false
 If the x-value of broadcastPowers should be applied to all Outputs outside of this broadcaster's radii- effectively makes it global.
Vector3 cachedPos
 The position of the broadcaster in the previous frame- we can't access transform.position in the audio thread, so we need to cache it in update.

Detailed Description

A "broadcaster" for a RadioTrackWrapper - the closer the RadioOutput that's playing the track is to a broadcaster (taking into consideration broadcast radius, power, etc), the louder the track is in the Output.

Somewhat similar to real world broadcasters- at least, that was the original intention :)

This has a custom editor in RadioBroadcasterEditor

Definition at line 17 of file RadioBroadcaster.cs.

Member Function Documentation

◆ AssignToTrack()

override void RyleRadio.Components.RadioBroadcaster.AssignToTrack ( RadioTrackWrapper _track)
protected

Links this broadcaster to a track.

Parameters
_trackThe track to link to

Definition at line 80 of file RadioBroadcaster.cs.

◆ GetPower()

float RyleRadio.Components.RadioBroadcaster.GetPower ( Vector3 _receiverPos)

Gets the broadcast power of this particular broadcaster using the Output's position.

Parameters
_receiverPosThe position of the Output
Returns
A value between 0 and 1, used as a multiplier to the loudness of a track

Definition at line 102 of file RadioBroadcaster.cs.

Referenced by RyleRadio.Tracks.RadioTrackPlayer.GetBroadcastPower().

◆ RemoveFromTrack()

override void RyleRadio.Components.RadioBroadcaster.RemoveFromTrack ( RadioTrackWrapper _track)
protected

Unlinks this broadcaster from a track.

Parameters
_trackThe track to unlink from

Definition at line 90 of file RadioBroadcaster.cs.

◆ Update()

void RyleRadio.Components.RadioBroadcaster.Update ( )
private

Updates the position of this broadcaster.

Definition at line 70 of file RadioBroadcaster.cs.

Member Data Documentation

◆ applyToAllOutputsOutside

bool RyleRadio.Components.RadioBroadcaster.applyToAllOutputsOutside = false
private

If the x-value of broadcastPowers should be applied to all Outputs outside of this broadcaster's radii- effectively makes it global.

Definition at line 54 of file RadioBroadcaster.cs.

Referenced by GetPower().

◆ broadcastPowers

Vector2 RyleRadio.Components.RadioBroadcaster.broadcastPowers = new(0, 1)
protected

The power of this broadcaster at the maximum and minimum radii.

The x-value is the broadcast power right on the outer radius, and the y-value is the broadcast power within the inner radius. Broadcast power between the inner and outer radii will be somewhere in this range, defined by the distanceFalloff

If the x-value is greater than 0, you might want to enable applyToAllOutputsOutside so that all Outputs are affected by this broadcaster.

Definition at line 39 of file RadioBroadcaster.cs.

Referenced by GetPower().

◆ broadcastRadius

Vector2 RyleRadio.Components.RadioBroadcaster.broadcastRadius

The inner and outer radii of this broadcaster.

radiusProg is the x-value in the distanceFalloff that we use to evaluate broadcast power If the Output is within the inner radius, the radiusProg is 1. If the Output is between the inner and outer radii, the radiusProg is between 0 and 1. If the Output is outside both radii, the radiusProg is 0.

Definition at line 28 of file RadioBroadcaster.cs.

Referenced by GetPower().

◆ cachedPos

Vector3 RyleRadio.Components.RadioBroadcaster.cachedPos
private

The position of the broadcaster in the previous frame- we can't access transform.position in the audio thread, so we need to cache it in update.

Definition at line 59 of file RadioBroadcaster.cs.

Referenced by GetPower(), and Update().

◆ distanceFalloff

AnimationCurve RyleRadio.Components.RadioBroadcaster.distanceFalloff
protected
Initial value:
= new(new Keyframe[2] {
new(0, 1, 0, 0),
new(1, 0, 0, 0)
})

The falloff curve between the inner and outer broadcast radii- the x-value is how far between the radii the Output is, and the y-value is how far between broadcastPowers x and y the track's broadcast power is.

Definition at line 45 of file RadioBroadcaster.cs.

Referenced by GetPower().

Property Documentation

◆ ShowApplyToAllOutputs

bool RyleRadio.Components.RadioBroadcaster.ShowApplyToAllOutputs
getprivate

Shows applyToAllOutputsOutside when the x-value of broadcastPowers is greater than 0.

Definition at line 64 of file RadioBroadcaster.cs.

Referenced by GetPower().


The documentation for this class was generated from the following file: