Ryle Radio 1.0.0
An open-source "radio" system for Unity, allowing tracks, tuning, broadcasters, and more!
Loading...
Searching...
No Matches
RadioTrack.cs
1using System;
2
3namespace RyleRadio.Tracks
4{
5 // a track in a RadioData, playable in a RadioOutput
6 // these are your basic objects to be played in the radio, can be clips, procedural, stations, and more if you create custom tracks
7 /// <summary>
8 /// A track to play as part of a radio. These are the fundamental objects that define the content of the radio, such as clips, procedural audio, stations, and any custom content you create.
9 /// </summary>
10 /// <see cref="IRadioTrack"/>
11 /// <remarks><b>NOTE FOR CUSTOM TRACK CREATORS!!</b>
12 ///
13 /// !!! IMPORTANT NOTE - if you're creating a custom RadioTrack, you need to both inherit from this class AND have a const string named `DISPLAY_NAME`.
14 /// Because the version of c# unity uses does not support static virtual data, we have no way of enforcing that you do this- but you will get errors otherwise
15 /// It's necessary for wrappers when they're listing each available track eventType in a dropdown- NaughtyAttributes' reflection system is used to pull
16 ///the display id so that it's selectable in the inspector. the only downside is a lack of enforcement :(((
17 /// </remarks>
18 [System.Serializable]
19 public abstract class RadioTrack : IRadioTrack
20 {
21 // main comments are in IRadioTrack.cs
22
23 /// <summary>
24 /// The sample rate of this track.
25 /// </summary>
26 /// <see cref="IRadioTrack.SampleRate"/>
27 public float SampleRate { get; set; }
28
29 /// <summary>
30 /// The number of samples in this track.
31 /// </summary>
32 /// <see cref="IRadioTrack.SampleCount"/>
33 public virtual int SampleCount { get; set; }
34
35 /// <summary>
36 /// Initializes this track.
37 /// </summary>
38 /// <see cref="IRadioTrack.Init"/>
39 public abstract void Init();
40
41 /// <summary>
42 /// Gets a sample from the track
43 /// </summary>
44 /// <param name="_sampleIndex">The index of the sample to retrieve</param>
45 /// <returns>The height of the sample</returns>
46 /// <see cref="IRadioTrack.GetSample(int)"/>
47 public abstract float GetSample(int _sampleIndex);
48
49 /// <summary>
50 /// Activates an event to run whenever this track ends. This is mainly used for stations to switch track when the previous one ends
51 /// </summary>
52 /// <param name="_callback">A function to run when this track ends</param>
53 public virtual void AddToPlayerEndCallback(ref Action<RadioTrackPlayer> _callback) { }
54 }
55
56}
A track to play as part of a radio. These are the fundamental objects that define the content of the ...
Definition RadioTrack.cs:20
float SampleRate
The sample rate of this track.
Definition RadioTrack.cs:27
float GetSample(int _sampleIndex)
Gets a sample from the track.
void Init()
Initializes this track.
virtual void AddToPlayerEndCallback(ref Action< RadioTrackPlayer > _callback)
Activates an event to run whenever this track ends. This is mainly used for stations to switch track ...
Definition RadioTrack.cs:53
virtual int SampleCount
The number of samples in this track.
Definition RadioTrack.cs:33
Internal interface for a RadioTrack.
Tracks to be used on a radio- includes base classes.
Definition RadioUtils.cs:20