/// <summary> /// Limit cue settings have changed. Release any previously allocated AudioHelper that /// was handling the limit audio and allocate a new helper with the new configuration. /// </summary> /// <param name="isEnabled"></param> /// <param name="updated"></param> public void UpdatedLimitCues(bool isEnabled, CueUpdates updated) { if ((updated == CueUpdates.All) || ((updated & CueUpdates.Name) == CueUpdates.Name)) { if (_audioLimit != null) { _audioLimit.AudioCompleted -= _audioLimit_AudioCompleted; _audioLimit.Dispose(); _audioLimit = null; } } if (isEnabled) { if ((updated == CueUpdates.All) || ((updated & CueUpdates.Name) == CueUpdates.Name)) { var filename = Settings.FilenameForCue(Settings.LimitCue); _audioLimit = new AudioHelper(filename, Settings.LimitVol, false); _audioLimit.AudioCompleted += _audioLimit_AudioCompleted; } else if ((updated & CueUpdates.Volume) == CueUpdates.Volume) { _audioLimit.Volume = Settings.LimitVol; } } #if DEBUG_LOGGING Console.WriteLine($"UpdatedLimitCues: cue {Settings.LimitCue}, vol {Settings.LimitVol}"); #endif }
public void Dispose() { _timerCheckDCS.Stop(); _timerCheckDCS.Dispose(); _timerSample.Stop(); _timerSample.Dispose(); _joystick?.Dispose(); _audioThreshold?.Dispose(); _audioLimit?.Dispose(); }
/// <summary> /// Threshold cue settings have changed. Release any previously allocated AudioHelper /// that was handling the threshold audio and allocate a new helper with the new /// configuration. Update the min/max bounds of the threshold. /// </summary> /// <param name="isEnabled"></param> /// <param name="updated"></param> public void UpdatedThresholdCues(bool isEnabled, CueUpdates updated) { if ((updated == CueUpdates.All) || ((updated & CueUpdates.Threshold) == CueUpdates.Threshold)) { var steps = (int)Math.Round((Settings.Threshold * 0.01) * (_maxInt / 2)); _alertLowerMax = (_maxInt / 2) - steps; _alertUpperMin = (_maxInt / 2) + steps; } if ((updated == CueUpdates.All) || ((updated & CueUpdates.Name) == CueUpdates.Name)) { if (_audioThreshold != null) { _audioThreshold.AudioCompleted -= _audioThreshold_AudioCompleted; _audioThreshold.Dispose(); _audioThreshold = null; } } if (isEnabled) { if ((updated == CueUpdates.All) || ((updated & CueUpdates.Name) == CueUpdates.Name)) { var filename = Settings.FilenameForCue(Settings.ThresholdCue); _audioThreshold = new AudioHelper(filename, Settings.ThresholdVol, false); _audioThreshold.AudioCompleted += _audioThreshold_AudioCompleted; } else if ((updated & CueUpdates.Volume) == CueUpdates.Volume) { _audioThreshold.Volume = Settings.ThresholdVol; } } #if DEBUG_LOGGING Console.WriteLine($"UpdatedThresholdCues: alert [{_alertLowerMax}, {_alertUpperMin}], cue {Settings.ThresholdCue}, vol {Settings.ThresholdVol}"); #endif }