public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false) { if ((_device == null) || isPreview) { return; } lock (SpectrumData) { UpdateLayers(layerModel); if (!SpectrumData.Any()) { return; } var settings = (AudioPropertiesModel)layerModel.Properties; if (settings.Direction == Direction.TopToBottom || settings.Direction == Direction.BottomToTop) { ApplyVertical(settings); } else if (settings.Direction == Direction.LeftToRight || settings.Direction == Direction.RightToLeft) { ApplyHorizontal(settings); } } }
public override void Update() { // TODO: Use lock instead of a bool // Start filling the model _generating = true; if (SelectedDeviceId == null) { return; } var device = new MMDeviceEnumerator() .EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active) .FirstOrDefault(d => d.ID == SelectedDeviceId); if (device == null || SpectrumData == null) { return; } if (!SpectrumData.Any()) { return; } // Parse spectrum data for (var i = 0; i < Lines; i++) { int height; if (SpectrumData.Count - 1 < i || SpectrumData[i] == 0) { height = 0; } else { height = (int)Math.Round(SpectrumData[i] / 2.55); } // Apply Sensitivity setting height = height * _sensitivity; var keyboardHeight = (int)Math.Round(MainManager.DeviceManager.ActiveKeyboard.Height / 100.00 * height * KeyboardScale); if (keyboardHeight > SoundRectangles[i].Height) { SoundRectangles[i].Height = keyboardHeight; } else { SoundRectangles[i].Height = SoundRectangles[i].Height - 5; // was FadeSpeed setting } // Apply Bars setting SoundRectangles[i].X = i * KeyboardScale; SoundRectangles[i].Width = KeyboardScale; if (_fromBottom) { SoundRectangles[i].Y = MainManager.DeviceManager.ActiveKeyboard.Height * KeyboardScale - SoundRectangles[i].Height; } } _generating = false; }