HoloLens 2 Gait Training
The purpose of this project is to create gait training application.
Loading...
Searching...
No Matches
WhiteNoise.cs
Go to the documentation of this file.
1using Microsoft.MixedReality.Toolkit.UI;
2using UnityEngine;
3
8{
12 protected override void Awake()
13 {
14 base.Awake();
16 }
17
22 public override void GenerateNewDistribution()
23 {
24 base.GenerateNewDistribution();
26 }
27
32 public override void ApplyPattern()
33 {
35 bool noiseAppliedState = ( m_NoiseValueList.Count >= m_SampleSize ) ? true : false;
36 SetReadyMessage( noiseAppliedState, "Random" );
37 }
38
42 protected override void CalculateBaseNoise()
43 {
45 float value = 0.0f;
46
48
49 for( int i = 0; i < m_SampleSize; i++ )
50 {
51 value = m_Multiplier * (float)m_GaussianDistribution.RandomGauss( (double)m_Mean, (double)m_NoiseSTD );
52 m_StandardNoiseDistribution.Add( value );
53 }
54
55 if( m_StandardNoiseDistribution.Count > 0 )
56 {
57 m_Title.text = "Distribution is Ready";
58 }
59 else
60 {
61 m_Title.text = "Distribution is NOT Ready";
62 }
63 }
64
68 protected override void CalculateNoise()
69 {
70 float value = 0.0f;
72
73 foreach( float unscaledSignal in m_StandardNoiseDistribution )
74 {
75 value = m_MeanPeriod + ( m_SDPeriod / m_NoiseSTD ) * unscaledSignal;
76 m_NoiseValueList.Add( value );
77 }
78 }
79}
virtual void PopulateVariablesWithDataFromUI()
Populate data variables used to alter noise. The data are gained through UI lables which are set by t...
const float m_NoiseSTD
Hold the standard distribution.
float m_MeanPeriod
Hold the Mean Period Value.
void ConvertToZScore(ref List< float > basePinkNoiseList)
This converts Z values to Z Score values. May get off a small amount due to round error.
List< float > m_StandardNoiseDistribution
A List to hold Normal(Gaussian) distribution.
int m_SampleSize
Defines how many samples we want.
float m_SDPeriod
Hold the standard distribution period.
List< float > m_NoiseValueList
This list stores the calculated colored noise values.
float m_Multiplier
Used this as a multiplier to calculate pink noise.
const float m_Mean
Hold the Mean value.
void SetReadyMessage(bool flag, string lbl)
Indicate noise is successgully applied or not.
GaussianDistribution m_GaussianDistribution
Reference to GaussianDistribution script.
double RandomGauss(double mu=0, double sigma=1)
Obtains normally (Gaussian) distrubuted random numbers, using the Box-Muller transformation....
Handle the Random (White) Noise.
Definition: WhiteNoise.cs:8
override void Awake()
Extend the base class initializations.
Definition: WhiteNoise.cs:12
override void GenerateNewDistribution()
Generate a new normal(Gaussian) distribution Mapped to NoiseDataPanel NewDistribution button.
Definition: WhiteNoise.cs:22
override void CalculateNoise()
Scale the base Random/White noise.
Definition: WhiteNoise.cs:68
override void ApplyPattern()
Calculate the noise according to the user input. Mapped to NoiseDataPanel ApplyPattern button.
Definition: WhiteNoise.cs:32
override void CalculateBaseNoise()
Calculate the white/random noise.
Definition: WhiteNoise.cs:42