![]() |
Ryle Radio 1.0.0
An open-source "radio" system for Unity, allowing tracks, tuning, broadcasters, and more!
|
A eventType of RadioTrack that contains other tracks. Has a custom editor in StationRadioTrackEditor
This is meant to emulate an actual radio station by storing multiple different tracks and switching between them as it plays. It can be used for really any purpose that calls for switching tracks, though- e.g: ''''procedural'''' music, complex ambience, easter eggs (kinda)
More...
Public Member Functions | |
| override void | Init () |
| Initializes this station and all contained tracks. | |
| override void | AddToPlayerEndCallback (ref Action< RadioTrackPlayer > _callback) |
| When a RadioTrackPlayer for this station finishes the track we've given it, we update it to use whatever the next track chosen is. This method is called when the Player finishes, so we update it here. This works because the Player only gets destroyed if it's a one-shot- in which case only one track from the station will be playing anyway. | |
| override float | GetSample (int _sampleIndex) |
| Gets a sample from the currently playing track. | |
| Public Member Functions inherited from RyleRadio.Tracks.RadioTrack | |
| void | Init () |
| Initializes this track. | |
| float | GetSample (int _sampleIndex) |
| Gets a sample from the track. | |
Public Attributes | |
| bool | randomSequence = true |
| Whether or not this station plays in a random or semi-random order. | |
| float | thresholdBeforeRepeats |
| When randomSequence is true, this is the number of other tracks that need to be played before the same one is chosen again. Stops the same track from playing back-to-back, and forces variety in the track order. | |
| List< StationRadioTrackWrapper > | stationTrackWs |
| The tracks contained within this station. | |
Static Public Attributes | |
| const string | DISPLAY_NAME = "Station aka Multi-select" |
| The display name of this track in the editor. Required by RadioTrack. | |
Properties | |
| StationRadioTrackWrapper | CurrentTrackW [get] |
| A reference to the track that's currently playing. | |
| Properties inherited from RyleRadio.Tracks.RadioTrack | |
| float | SampleRate [get, set] |
| The sample rate of this track. | |
| virtual int | SampleCount [get, set] |
| The number of samples in this track. | |
Private Member Functions | |
| void | NextTrack () |
| Selects the next track for this station to play. | |
Private Attributes | |
| int | currentTrackIndex |
| The index of the contained track that's currently playing. | |
| int[] | remainingTracksBeforeRepeat |
| The number of plays that need to happen before each track can be played again. Follows the layout described in thresholdBeforeRepeats. | |
A eventType of RadioTrack that contains other tracks. Has a custom editor in StationRadioTrackEditor
This is meant to emulate an actual radio station by storing multiple different tracks and switching between them as it plays. It can be used for really any purpose that calls for switching tracks, though- e.g: ''''procedural'''' music, complex ambience, easter eggs (kinda)
Also uses StationRadioTrackWrapper
Definition at line 16 of file StationRadioTrack.cs.
|
virtual |
When a RadioTrackPlayer for this station finishes the track we've given it, we update it to use whatever the next track chosen is. This method is called when the Player finishes, so we update it here. This works because the Player only gets destroyed if it's a one-shot- in which case only one track from the station will be playing anyway.
| _callback | The callback invoked when the RadioTrackPlayer ends |
Reimplemented from RyleRadio.Tracks.RadioTrack.
Definition at line 103 of file StationRadioTrack.cs.
| override float RyleRadio.Tracks.StationRadioTrack.GetSample | ( | int | _sampleIndex | ) |
Gets a sample from the currently playing track.
| _sampleIndex | The index of the sample |
Implements RyleRadio.Tracks.IRadioTrack.
Definition at line 114 of file StationRadioTrack.cs.
| override void RyleRadio.Tracks.StationRadioTrack.Init | ( | ) |
Initializes this station and all contained tracks.
Implements RyleRadio.Tracks.IRadioTrack.
Definition at line 80 of file StationRadioTrack.cs.
|
private |
Selects the next track for this station to play.
Definition at line 124 of file StationRadioTrack.cs.
Referenced by AddToPlayerEndCallback(), and Init().
|
private |
The index of the contained track that's currently playing.
Definition at line 48 of file StationRadioTrack.cs.
Referenced by Init(), and NextTrack().
|
static |
The display name of this track in the editor. Required by RadioTrack.
Definition at line 21 of file StationRadioTrack.cs.
| bool RyleRadio.Tracks.StationRadioTrack.randomSequence = true |
Whether or not this station plays in a random or semi-random order.
Definition at line 26 of file StationRadioTrack.cs.
Referenced by NextTrack().
|
private |
The number of plays that need to happen before each track can be played again. Follows the layout described in thresholdBeforeRepeats.
i.e if tracks A, B and C are being randomly chosen with a thresholdBeforeRepeats of 0.5f, they each need to have 1 other track play before each can repeat (see comments above thresholdBeforeRepeats)
So if track A was just played after B and C, this array would look like [1, 0, -1]. That is, track A needs another track to be played once before it can be repeated, B doesn't need any other tracks to play and thus can be repeated, and same for C
(a number below 0 is treated as 0 for this system)
See: NextTrack()
Definition at line 64 of file StationRadioTrack.cs.
Referenced by Init(), and NextTrack().
| List<StationRadioTrackWrapper> RyleRadio.Tracks.StationRadioTrack.stationTrackWs |
The tracks contained within this station.
Definition at line 43 of file StationRadioTrack.cs.
Referenced by Init(), and NextTrack().
| float RyleRadio.Tracks.StationRadioTrack.thresholdBeforeRepeats |
When randomSequence is true, this is the number of other tracks that need to be played before the same one is chosen again. Stops the same track from playing back-to-back, and forces variety in the track order.
The number of tracks to be played before one can be played again is round_down( (track_count - 1) * threshold ).
i.e with four tracks and a threshold of 0.5f, round_down((4 - 1 == 3) * 0.5) == 1: one other track will need to be played before a repeat
i.e with four tracks and a threshold of 0.7f, round_down((4 - 1 == 3) * 0.7) == 2: two other tracks will need to be played before a repeat
i.e with four tracks and a threshold of 1f, round_down((4 - 1 == 3) * 1) == 3: three other tracks (all other tracks) will need to be played before a repeat
i.e with eleven tracks and a threshold of 0.8f, round_down((11 - 1 == 10) * 0.8f == 8: eight other tracks will need to be played before a repeat Do note that if this is set to 1, the tracks are forced to play in the same randomized sequence repeatedly
Definition at line 38 of file StationRadioTrack.cs.
Referenced by NextTrack().
|
getprivate |
A reference to the track that's currently playing.
Definition at line 74 of file StationRadioTrack.cs.
Referenced by GetSample(), and NextTrack().