1using NaughtyAttributes;
42 [AllowNesting, ShowIf(
"IsInStation")]
48 [AllowNesting, ShowIf(
"proceduralType",
ProceduralType.SineWave), Range(1, 2000)]
56 [AllowNesting, ShowIf(
"proceduralType",
ProceduralType.BrownNoise), Range(0, 1)]
61 private System.Random random;
71 private float p0 = 0, p1 = 0, p2 = 0, p3 = 0, p4 = 0, p5 = 0, p6 = 0;
88 public override void Init()
90 random =
new System.Random();
112 white = ((float)random.NextDouble() * 2) - 1;
117 white = ((float)random.NextDouble() * 2) - 1;
121 p0 = 0.99886f * p0 + white * 0.0555179f;
122 p1 = 0.99332f * p1 + white * 0.0750759f;
123 p2 = 0.96900f * p2 + white * 0.1538520f;
124 p3 = 0.86650f * p3 + white * 0.3104856f;
125 p4 = 0.55000f * p4 + white * 0.5329522f;
126 p5 = -0.7616f * p5 - white * 0.0168980f;
127 float pink = p0 + p1 + p2 + p3 + p4 + p5 + p6 + white * 0.5362f;
128 p6 = white * 0.115926f;
136 white = ((float)random.NextDouble() * 2) - 1;
149 if (
phase > 2 * Mathf.PI)
150 phase -= 2 * Mathf.PI;
159 Debug.LogError(
"Attempting to get a sample from a procedural RadioTrack with an invalid ProceduralType- this should not be possible.");
A RadioTrack that plays procedurally generated audio, such as noice, silence, and waveforms.
float brownWalkPower
The value used to define the sound of brown noise. Brown noise works by adding the generated sample...
override float GetSample(int _sampleIndex)
Get the next sample of the selected procedural audio eventType.
float duration
If this track is inside of a StationRadioTrack, then it should only play for a certain duration- this...
float phase
The progress of the waveform used when generating it.
const float NOISE_MULTIPLIER
A base multiplier for noise- because the samples can go all the way up to 1, noise tends to be a lot ...
override void Init()
Initializes this track.
const float BASE_SAMPLE_RATE
The default sample rate for the procedural tracks, can adjust this if required.
ProceduralType proceduralType
The selected eventType of noise for this track.
float lastBrown
The generated brown noise from the previous sample.
ProceduralType
The eventType of procedural audio this track is generating.
@ PinkNoise
Special eventType of noise defined by Paul Kellet's refined method (pk3): sounds "fuller" than white ...
@ BrownNoise
Special eventType of noise using a value (brownWalkPower): sounds softer and deeper.
@ Silence
Silence: samples at 0.
@ SineWave
A waveform: shaped as a sine wave at a given frequency.
@ WhiteNoise
White noise: random samples between 0 and 1.
float waveFrequency
The frequency/pitch of the waveform.
bool IsInStation
Whether this is in a station or not. Required by IStationTrack.
const float PINK_MULTIPLIER
Pink noise is even louder than the other noise types, so we curb it a little.
const string DISPLAY_NAME
The name of this class in the editor- required by RadioTrack.
A track to play as part of a radio. These are the fundamental objects that define the content of the ...
float SampleRate
The sample rate of this track.
virtual int SampleCount
The number of samples in this track.
A RadioTrack that can be played as part of a station.
Tracks to be used on a radio- includes base classes.