/// <summary> /// Gets the absolute power of the specified frequency band. If samplesBefore is not specified, /// return the most recently updated value, otherwise return the samplesBefore'th most recent value. /// </summary> /// <param name="freqBand"></param> /// <param name="samplesBefore"></param> /// <returns></returns> public static float[] GetAbsoluteFrequency(EEG_BANDS freqBand, int samplesBefore = 0) { int currPos = currBufferPositionFreq[(int)freqBand]; Debug.Log(currPos); return(EEGData.freqData[(int)freqBand][(Mathf.Max(currPos - 1, 0) - samplesBefore) % EEGData.bufferSize]); }
public static float GetRelativeFrequency(EEG_BANDS freqBand, int samplesBefore = 0) { float sumBands = 0f; foreach (EEG_BANDS eegBand in Enum.GetValues(typeof(EEG_BANDS))) { sumBands += Mathf.Abs(EEGData.GetAverage(eegBand, samplesBefore)); } float relFreq = 0f; if (sumBands > 0) { relFreq = Mathf.Abs(EEGData.GetAverage(freqBand, samplesBefore) / sumBands); } return(relFreq); }
public static float GetAverage(EEG_BANDS freqBand, int samplesBefore = 0) { return(EEGData.GetAbsoluteFrequency(freqBand, samplesBefore).Average()); }