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

A RadioTrack that plays procedurally generated audio, such as noice, silence, and waveforms. More...

Inheritance diagram for RyleRadio.Tracks.ProceduralRadioTrack:

Public Types

enum  ProceduralType {
  WhiteNoise , PinkNoise , BrownNoise , SineWave ,
  Silence
}
 The eventType of procedural audio this track is generating. More...

Public Member Functions

override void Init ()
 Initializes this track.
override float GetSample (int _sampleIndex)
 Get the next sample of the selected procedural audio eventType.
Public Member Functions inherited from RyleRadio.Tracks.RadioTrack
void Init ()
 Initializes this track.
float GetSample (int _sampleIndex)
 Gets a sample from the 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 when the previous one ends.

Public Attributes

ProceduralType proceduralType = ProceduralType.WhiteNoise
 The selected eventType of noise for this track.
float duration = 0
 If this track is inside of a StationRadioTrack, then it should only play for a certain duration- this is that duration.
float waveFrequency = 100
 The frequency/pitch of the waveform.
float brownWalkPower = 0.5f
 The value used to define the sound of brown noise.

Brown noise works by adding the generated sample to all previous generated samples. This float is what these generated samples are multiplied by when stored. This means that the higher the walk power, the larger the difference that each sample makes on average, and the closer it sounds to white noise.

Static Public Attributes

const string DISPLAY_NAME = "Procedural"
 The name of this class in the editor- required by RadioTrack.

Properties

bool IsInStation [get, set]
 Whether this is in a station or not. Required by IStationTrack.
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 Attributes

float phase = 0
 The progress of the waveform used when generating it.
float lastBrown = 0
 The generated brown noise from the previous sample.

Static Private Attributes

const float NOISE_MULTIPLIER = .2f
 A base multiplier for noise- because the samples can go all the way up to 1, noise tends to be a lot louder than other tracks, e.g: AudioClips in ClipRadioTrack.
const float PINK_MULTIPLIER = .5f
 Pink noise is even louder than the other noise types, so we curb it a little.
const float BASE_SAMPLE_RATE = 44100
 The default sample rate for the procedural tracks, can adjust this if required.

Detailed Description

A RadioTrack that plays procedurally generated audio, such as noice, silence, and waveforms.

Definition at line 11 of file ProceduralRadioTrack.cs.

Member Enumeration Documentation

◆ ProceduralType

The eventType of procedural audio this track is generating.

Enumerator
WhiteNoise 

White noise: random samples between 0 and 1.

PinkNoise 

Special eventType of noise defined by Paul Kellet's refined method (pk3): sounds "fuller" than white noise.

BrownNoise 

Special eventType of noise using a value (brownWalkPower): sounds softer and deeper.

SineWave 

A waveform: shaped as a sine wave at a given frequency.

Silence 

Silence: samples at 0.

Definition at line 21 of file ProceduralRadioTrack.cs.

Member Function Documentation

◆ GetSample()

override float RyleRadio.Tracks.ProceduralRadioTrack.GetSample ( int _sampleIndex)

Get the next sample of the selected procedural audio eventType.

Parameters
_sampleIndexThe index of the sample- useless for noise, useful for waveforms
Returns
The sample of generated audio

Implements RyleRadio.Tracks.IRadioTrack.

Definition at line 103 of file ProceduralRadioTrack.cs.

◆ Init()

override void RyleRadio.Tracks.ProceduralRadioTrack.Init ( )

Initializes this track.

Implements RyleRadio.Tracks.IRadioTrack.

Definition at line 88 of file ProceduralRadioTrack.cs.

Member Data Documentation

◆ BASE_SAMPLE_RATE

const float RyleRadio.Tracks.ProceduralRadioTrack.BASE_SAMPLE_RATE = 44100
staticprivate

The default sample rate for the procedural tracks, can adjust this if required.

Definition at line 32 of file ProceduralRadioTrack.cs.

Referenced by Init().

◆ brownWalkPower

float RyleRadio.Tracks.ProceduralRadioTrack.brownWalkPower = 0.5f

The value used to define the sound of brown noise.

Brown noise works by adding the generated sample to all previous generated samples. This float is what these generated samples are multiplied by when stored. This means that the higher the walk power, the larger the difference that each sample makes on average, and the closer it sounds to white noise.

Definition at line 57 of file ProceduralRadioTrack.cs.

Referenced by GetSample().

◆ DISPLAY_NAME

const string RyleRadio.Tracks.ProceduralRadioTrack.DISPLAY_NAME = "Procedural"
static

The name of this class in the editor- required by RadioTrack.

Definition at line 16 of file ProceduralRadioTrack.cs.

◆ duration

float RyleRadio.Tracks.ProceduralRadioTrack.duration = 0

If this track is inside of a StationRadioTrack, then it should only play for a certain duration- this is that duration.

Definition at line 43 of file ProceduralRadioTrack.cs.

Referenced by Init().

◆ lastBrown

float RyleRadio.Tracks.ProceduralRadioTrack.lastBrown = 0
private

The generated brown noise from the previous sample.

Definition at line 77 of file ProceduralRadioTrack.cs.

Referenced by GetSample().

◆ NOISE_MULTIPLIER

const float RyleRadio.Tracks.ProceduralRadioTrack.NOISE_MULTIPLIER = .2f
staticprivate

A base multiplier for noise- because the samples can go all the way up to 1, noise tends to be a lot louder than other tracks, e.g: AudioClips in ClipRadioTrack.

Definition at line 30 of file ProceduralRadioTrack.cs.

Referenced by GetSample().

◆ phase

float RyleRadio.Tracks.ProceduralRadioTrack.phase = 0
private

The progress of the waveform used when generating it.

Definition at line 67 of file ProceduralRadioTrack.cs.

Referenced by GetSample(), and Init().

◆ PINK_MULTIPLIER

const float RyleRadio.Tracks.ProceduralRadioTrack.PINK_MULTIPLIER = .5f
staticprivate

Pink noise is even louder than the other noise types, so we curb it a little.

Definition at line 31 of file ProceduralRadioTrack.cs.

Referenced by GetSample().

◆ proceduralType

ProceduralType RyleRadio.Tracks.ProceduralRadioTrack.proceduralType = ProceduralType.WhiteNoise

The selected eventType of noise for this track.

Definition at line 37 of file ProceduralRadioTrack.cs.

Referenced by GetSample().

◆ waveFrequency

float RyleRadio.Tracks.ProceduralRadioTrack.waveFrequency = 100

The frequency/pitch of the waveform.

Definition at line 49 of file ProceduralRadioTrack.cs.

Referenced by GetSample().

Property Documentation

◆ IsInStation

bool RyleRadio.Tracks.ProceduralRadioTrack.IsInStation
getset

Whether this is in a station or not. Required by IStationTrack.

Implements RyleRadio.Tracks.IStationTrack.

Definition at line 82 of file ProceduralRadioTrack.cs.


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