![]() |
Ryle Radio 1.0.0
An open-source "radio" system for Unity, allowing tracks, tuning, broadcasters, and more!
|
A wrapper class for RadioTrack so that track types can be switched between in the inspector! Also contains various values that are track-agnostic. More...
Public Member Functions | |
| RadioTrackWrapper () | |
| Creates an empty wrapper. | |
| void | Init () |
| Initialize this wrapper and its track. | |
| override string | ToString () |
| Changes the name of this class from "RadioTrackWrapper" to "Wrapper for `track.Name`". | |
| void | CreateTrackLocal () |
| Set track to a new track with eventType defined by trackType See also: CreateTrackEditor() | |
| void | AddToPlayerEndCallback (ref Action< RadioTrackPlayer > _callback) |
| Used if track needs to access a RadioTrackPlayer that it's linked to when that player ends, this method adds an event for it. Really only needed for a StationRadioTrack. | |
| float | GetTunePower (float _tune, float _otherVolume) |
| Calculates the power of this track when an Output is at a specific Tune value. It does this by finding where the Tune is over the track's range, where that point lies on the rangeCurve, and applies attenuation. | |
| float | GetSample (int _sampleIndex) |
| Get a sample from the contained track. | |
Static Public Member Functions | |
| static string | GetTrackType (string _typeName) |
| Converts the typename (NOT display name) of a track eventType to the actual eventType. | |
| static IRadioTrack | CreateTrackEditor (string _name) |
| Static; creates a new track for a wrapper using the given track eventType's display name. | |
Public Attributes | |
| string | id |
| The ID of this track- used to find and manipulate it in custom code. | |
| string | name |
| The name of this track for use (and easy identification) in the inspector. This is usually in the format of {ID}, {range.x} - {range.y} | |
| Vector2 | range |
| The range of tunes in which this track can be heard. If a RadioOutput.Tune value is within this range, the tune power of this track will be > 0, and it will be audible (not counting spatial components+gain+etc) | |
| AnimationCurve | rangeCurve = new(DefaultRangeCurve.keys) |
| The curve defining the loudness of the track over its range. The progress between range.x and range.y the RadioOutput.Tune value is, is the progress along this curve the tune power is. | |
| float | attenuation = 0.1f |
| The amount that this track gets quieter when another track is playing on top of it (and that other track is above this one in RadioData.trackWs. | |
| bool | forceGlobal = true |
| If true, this track ignores any RadioBroadcaster influence and plays everywhere. | |
| bool | playOnInit = true |
| If true, this track plays on RadioData.Init() - usually on game start. | |
| List< RadioBroadcaster > | broadcasters |
| The broadcasters in the scene that have this track selected. | |
| List< RadioInsulator > | insulators |
| The insulators in the scene that have this track selected. | |
Protected Attributes | |
| IRadioTrack | track |
| The actual RadioTrack in this wrapper, its eventType chosen in trackType. | |
Properties | |
| static AnimationCurve | DefaultRangeCurve [get] |
| The default rangeCurve to use when an empty wrapper is created. It's a super basic and smooth closed curve from 0 to 0. | |
| Action< RadioTrackWrapper > | OnInit = new(_ => { }) [get, set] |
| An event called when the wrapper is initialised. | |
| Action< RadioTrackWrapper > | BeforeInit = new(_ => { }) [get, set] |
| An event called just before the wrapper is initialised. | |
| Action< RadioBroadcaster, RadioTrackWrapper > | OnAddBroadcaster = new((_, _) => { }) [get, set] |
| An event called when a broadcaster is added to the track. | |
| Action< RadioBroadcaster, RadioTrackWrapper > | OnRemoveBroadcaster = new((_, _) => { }) [get, set] |
| An event called when a broadcaster is removed from this track. | |
| Action< RadioInsulator, RadioTrackWrapper > | OnAddInsulator = new((_, _) => { }) [get, set] |
| An event called when an insulator is added to the track. | |
| Action< RadioInsulator, RadioTrackWrapper > | OnRemoveInsulator = new((_, _) => { }) [get, set] |
| An event called when an insulator is removed from this track. | |
| float | Gain [get] |
| The gain value scaled down to ones- e.g gain at 200 is Gain at 2. | |
| static Type[] | TrackTypes [get] |
| A list of each eventType of track that this wrapper can contain- this is anything that inherits from IRadioTrack, and updates dynamically when creating new track types. See also: RadioUtils.FindDerivedTypes() | |
| static string[] | TrackTypesAsStrings [get] |
| Static; the list of available track types stored as their typename, NOT as their display names. This is used when reassigning track types in RadioDataEditor when the editor reloads, as we only have the typename of the track. | |
| static string[] | TrackNames [get] |
| Static; the list of track types stored as their display names. This is shown as a dropdown for trackType and is how types are usually displayed in the inspector. | |
| float | SampleRate [get] |
| An alias for the track's SampleRate as other classes cannot access track directly. | |
| int | SampleCount [get] |
| An alias for the track's SampleCount as other classes cannot access track directly. | |
Private Member Functions | |
| void | ScaleRange () |
| Limits the number of decimal points on the range This is called whenever the range is changed. See: RANGE_DECIMAL_MULTIPLIER. | |
Private Attributes | |
| float | gain = 100 |
| An added value to the volume of the track. This is applied before any other volume is calculated. | |
| string | trackType |
| The eventType of track for this wrapper to contain, selectable in the inspector. This variable is stored as the track name and displays with a dropdown according to TrackNames. | |
Static Private Attributes | |
| const float | RANGE_DECIMAL_MULTIPLIER = 10f |
| The number of decimal places used in the range- the number of zeroes is the number of decimal points, e.g: 10 == 1dp, 100 == 2dp, 1 == 0dp (whole numbers) | |
A wrapper class for RadioTrack so that track types can be switched between in the inspector! Also contains various values that are track-agnostic.
This is how a RadioTrack is stored and accessed in RadioData.
If we didn't use a wrapper like this, you wouldn't be able to choose trackType in a dropdown and see it change in the inspector- it's not possible (to my knowledge) to do that without some kind of wrapper and [SerializeReference].
Wrappers also contain variables that exist for every track eventType, such as range and gain.
Definition at line 19 of file RadioTrackWrapper.cs.
| RyleRadio.Tracks.RadioTrackWrapper.RadioTrackWrapper | ( | ) |
Creates an empty wrapper.
Definition at line 212 of file RadioTrackWrapper.cs.
| void RyleRadio.Tracks.RadioTrackWrapper.AddToPlayerEndCallback | ( | ref Action< RadioTrackPlayer > | _callback | ) |
Used if track needs to access a RadioTrackPlayer that it's linked to when that player ends, this method adds an event for it. Really only needed for a StationRadioTrack.
| _callback | The event called on RadioTrackPlayer.OnEnd |
Definition at line 305 of file RadioTrackWrapper.cs.
|
static |
Static; creates a new track for a wrapper using the given track eventType's display name.
| _name | Display name of a track eventType |
Definition at line 274 of file RadioTrackWrapper.cs.
Referenced by CreateTrackLocal().
| void RyleRadio.Tracks.RadioTrackWrapper.CreateTrackLocal | ( | ) |
Set track to a new track with eventType defined by trackType
See also: CreateTrackEditor()
Definition at line 296 of file RadioTrackWrapper.cs.
Referenced by RadioTrackWrapper().
| float RyleRadio.Tracks.RadioTrackWrapper.GetSample | ( | int | _sampleIndex | ) |
Get a sample from the contained track.
| _sampleIndex | The index of the sample to get |
Definition at line 346 of file RadioTrackWrapper.cs.
|
static |
Converts the typename (NOT display name) of a track eventType to the actual eventType.
| _typeName | The name of the eventType |
Definition at line 263 of file RadioTrackWrapper.cs.
| float RyleRadio.Tracks.RadioTrackWrapper.GetTunePower | ( | float | _tune, |
| float | _otherVolume ) |
Calculates the power of this track when an Output is at a specific Tune value. It does this by finding where the Tune is over the track's range, where that point lies on the rangeCurve, and applies attenuation.
| _tune | The tune value to evaluate |
| _otherVolume | The volume of any previous tracks, used for attenuation |
Definition at line 330 of file RadioTrackWrapper.cs.
| void RyleRadio.Tracks.RadioTrackWrapper.Init | ( | ) |
Initialize this wrapper and its track.
Definition at line 238 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.RadioData.Init().
|
private |
Limits the number of decimal points on the range
This is called whenever the range is changed.
See: RANGE_DECIMAL_MULTIPLIER.
Definition at line 315 of file RadioTrackWrapper.cs.
| float RyleRadio.Tracks.RadioTrackWrapper.attenuation = 0.1f |
The amount that this track gets quieter when another track is playing on top of it (and that other track is above this one in RadioData.trackWs.
Definition at line 77 of file RadioTrackWrapper.cs.
Referenced by GetTunePower().
| List<RadioBroadcaster> RyleRadio.Tracks.RadioTrackWrapper.broadcasters |
The broadcasters in the scene that have this track selected.
A RadioBroadcaster is a scene component that allows a track to be heard exclusively or louder in a certain area.
See also: insulators
Definition at line 95 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.Components.RadioBroadcaster.AssignToTrack(), Init(), and RyleRadio.Components.RadioBroadcaster.RemoveFromTrack().
| bool RyleRadio.Tracks.RadioTrackWrapper.forceGlobal = true |
If true, this track ignores any RadioBroadcaster influence and plays everywhere.
Definition at line 82 of file RadioTrackWrapper.cs.
|
private |
An added value to the volume of the track. This is applied before any other volume is calculated.
Definition at line 71 of file RadioTrackWrapper.cs.
| string RyleRadio.Tracks.RadioTrackWrapper.id |
The ID of this track- used to find and manipulate it in custom code.
Definition at line 38 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.RadioData.PopulateTrackIDs().
| List<RadioInsulator> RyleRadio.Tracks.RadioTrackWrapper.insulators |
The insulators in the scene that have this track selected.
A RadioInsulator is a scene component that makes a track quieter in a certain area.
See also: broadcasters
Definition at line 103 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.Components.RadioInsulator.AssignToTrack(), Init(), and RyleRadio.Components.RadioInsulator.RemoveFromTrack().
| string RyleRadio.Tracks.RadioTrackWrapper.name |
The name of this track for use (and easy identification) in the inspector. This is usually in the format of {ID}, {range.x} - {range.y}
This is assigned in RadioDataEditor.InitNewTrack()
Definition at line 45 of file RadioTrackWrapper.cs.
Referenced by ToString().
| bool RyleRadio.Tracks.RadioTrackWrapper.playOnInit = true |
If true, this track plays on RadioData.Init() - usually on game start.
Definition at line 87 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.Components.RadioOutput.StartPlayers().
| Vector2 RyleRadio.Tracks.RadioTrackWrapper.range |
The range of tunes in which this track can be heard. If a RadioOutput.Tune value is within this range, the tune power of this track will be > 0, and it will be audible (not counting spatial components+gain+etc)
This range is clamped between RadioData.LOW_TUNE and RadioData.HIGH_TUNE
Definition at line 53 of file RadioTrackWrapper.cs.
Referenced by GetTunePower(), and ScaleRange().
|
staticprivate |
The number of decimal places used in the range- the number of zeroes is the number of decimal points, e.g: 10 == 1dp, 100 == 2dp, 1 == 0dp (whole numbers)
Definition at line 33 of file RadioTrackWrapper.cs.
Referenced by ScaleRange().
| AnimationCurve RyleRadio.Tracks.RadioTrackWrapper.rangeCurve = new(DefaultRangeCurve.keys) |
The curve defining the loudness of the track over its range. The progress between range.x and range.y the RadioOutput.Tune value is, is the progress along this curve the tune power is.
Definition at line 65 of file RadioTrackWrapper.cs.
Referenced by GetTunePower().
|
protected |
The actual RadioTrack in this wrapper, its eventType chosen in trackType.
We keep this private so that no other classes can access the track directly- this isn't really necessary but it is very safe for custom code
Definition at line 117 of file RadioTrackWrapper.cs.
Referenced by AddToPlayerEndCallback(), CreateTrackLocal(), GetSample(), Init(), and RadioTrackWrapper().
|
private |
The eventType of track for this wrapper to contain, selectable in the inspector. This variable is stored as the track name and displays with a dropdown according to TrackNames.
Definition at line 109 of file RadioTrackWrapper.cs.
Referenced by CreateTrackLocal(), and RadioTrackWrapper().
|
getset |
An event called just before the wrapper is initialised.
Definition at line 123 of file RadioTrackWrapper.cs.
Referenced by Init().
|
staticget |
The default rangeCurve to use when an empty wrapper is created. It's a super basic and smooth closed curve from 0 to 0.
Definition at line 24 of file RadioTrackWrapper.cs.
|
get |
The gain value scaled down to ones- e.g gain at 200 is Gain at 2.
Definition at line 139 of file RadioTrackWrapper.cs.
|
getset |
An event called when a broadcaster is added to the track.
Definition at line 126 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.Components.RadioBroadcaster.AssignToTrack().
|
getset |
An event called when an insulator is added to the track.
Definition at line 131 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.Components.RadioInsulator.AssignToTrack().
|
getset |
An event called when the wrapper is initialised.
Definition at line 121 of file RadioTrackWrapper.cs.
Referenced by Init().
|
getset |
An event called when a broadcaster is removed from this track.
Definition at line 128 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.Components.RadioBroadcaster.RemoveFromTrack().
|
getset |
An event called when an insulator is removed from this track.
Definition at line 133 of file RadioTrackWrapper.cs.
Referenced by RyleRadio.Components.RadioInsulator.RemoveFromTrack().
|
get |
An alias for the track's SampleCount as other classes cannot access track directly.
Definition at line 206 of file RadioTrackWrapper.cs.
|
get |
An alias for the track's SampleRate as other classes cannot access track directly.
Definition at line 203 of file RadioTrackWrapper.cs.
|
staticgetprivate |
Static; the list of track types stored as their display names. This is shown as a dropdown for trackType and is how types are usually displayed in the inspector.
Definition at line 188 of file RadioTrackWrapper.cs.
Referenced by CreateTrackEditor(), and GetTrackType().
|
staticgetprivate |
A list of each eventType of track that this wrapper can contain- this is anything that inherits from IRadioTrack, and updates dynamically when creating new track types.
See also: RadioUtils.FindDerivedTypes()
Definition at line 150 of file RadioTrackWrapper.cs.
Referenced by CreateTrackEditor().
|
staticgetprivate |
Static; the list of available track types stored as their typename, NOT as their display names. This is used when reassigning track types in RadioDataEditor when the editor reloads, as we only have the typename of the track.
Definition at line 168 of file RadioTrackWrapper.cs.
Referenced by GetTrackType().