mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-31 17:53:32 +00:00
Fix settings apply for #205
This commit is contained in:
parent
ab82491137
commit
2482bdb7bd
@ -47,7 +47,7 @@
|
|||||||
VerticalAlignment="Top" Height="18" />
|
VerticalAlignment="Top" Height="18" />
|
||||||
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Top"
|
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Top"
|
||||||
Value="{Binding Path=LayerModel.Properties.FadeSpeed, Mode=TwoWay}" Margin="10,12,10,2"
|
Value="{Binding Path=LayerModel.Properties.FadeSpeed, Mode=TwoWay}" Margin="10,12,10,2"
|
||||||
Height="24" TickPlacement="BottomRight" TickFrequency="1" Minimum="1" Maximum="3" SmallChange="1"
|
Height="24" TickPlacement="BottomRight" TickFrequency="0.1" Minimum="0.1" Maximum="1" SmallChange="0.1"
|
||||||
IsSnapToTickEnabled="True" />
|
IsSnapToTickEnabled="True" />
|
||||||
|
|
||||||
<!-- Colors -->
|
<!-- Colors -->
|
||||||
|
|||||||
@ -28,7 +28,8 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
private readonly WasapiLoopbackCapture _waveIn;
|
private readonly WasapiLoopbackCapture _waveIn;
|
||||||
private DateTime _lastAudioUpdate;
|
private DateTime _lastAudioUpdate;
|
||||||
private int _lines;
|
private int _lines;
|
||||||
private AudioPropertiesModel _previousSettings;
|
private string _previousSettings;
|
||||||
|
private DateTime _lastUpdate;
|
||||||
|
|
||||||
public AudioType()
|
public AudioType()
|
||||||
{
|
{
|
||||||
@ -223,7 +224,7 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
audioLayer.Properties.Width = settings.Width;
|
audioLayer.Properties.Width = settings.Width;
|
||||||
audioLayer.Properties.Height = settings.Height;
|
audioLayer.Properties.Height = settings.Height;
|
||||||
audioLayer.LayerAnimation?.Update(audioLayer, true);
|
audioLayer.LayerAnimation?.Update(audioLayer, true);
|
||||||
|
|
||||||
// Restore the height and width
|
// Restore the height and width
|
||||||
audioLayer.Properties.Height = oldHeight;
|
audioLayer.Properties.Height = oldHeight;
|
||||||
audioLayer.Properties.Width = oldWidth;
|
audioLayer.Properties.Width = oldWidth;
|
||||||
@ -235,20 +236,34 @@ namespace Artemis.Profiles.Layers.Types.Audio
|
|||||||
/// <param name="layerModel"></param>
|
/// <param name="layerModel"></param>
|
||||||
private void UpdateLayers(LayerModel layerModel)
|
private void UpdateLayers(LayerModel layerModel)
|
||||||
{
|
{
|
||||||
// TODO: Animation
|
// TODO: Animation every frame before checking settings
|
||||||
var settings = (AudioPropertiesModel) layerModel.Properties;
|
|
||||||
if ((settings.Direction == _previousSettings?.Direction) &&
|
|
||||||
(settings.Sensitivity == _previousSettings.Sensitivity) &&
|
|
||||||
(Math.Abs(settings.FadeSpeed - _previousSettings.FadeSpeed) < 0.001))
|
|
||||||
return;
|
|
||||||
|
|
||||||
_previousSettings = GeneralHelpers.Clone((AudioPropertiesModel) layerModel.Properties);
|
// Checking on settings update is expensive, only do it every second
|
||||||
|
if (DateTime.Now - _lastUpdate < TimeSpan.FromSeconds(1))
|
||||||
|
return;
|
||||||
|
_lastUpdate = DateTime.Now;
|
||||||
|
|
||||||
|
var settings = (AudioPropertiesModel) layerModel.Properties;
|
||||||
|
var currentSettings = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
||||||
|
if (currentSettings == _previousSettings)
|
||||||
|
return;
|
||||||
|
|
||||||
|
_previousSettings = JsonConvert.SerializeObject(settings, Formatting.Indented);
|
||||||
|
|
||||||
_audioLayers.Clear();
|
_audioLayers.Clear();
|
||||||
if ((settings.Direction == Direction.TopToBottom) || (settings.Direction == Direction.BottomToTop))
|
switch (settings.Direction)
|
||||||
SetupVertical(settings);
|
{
|
||||||
else if ((settings.Direction == Direction.LeftToRight) || (settings.Direction == Direction.RightToLeft))
|
case Direction.TopToBottom:
|
||||||
SetupHorizontal(settings);
|
case Direction.BottomToTop:
|
||||||
|
SetupVertical(settings);
|
||||||
|
break;
|
||||||
|
case Direction.LeftToRight:
|
||||||
|
case Direction.RightToLeft:
|
||||||
|
SetupHorizontal(settings);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new ArgumentOutOfRangeException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void SetupVertical(AudioPropertiesModel settings)
|
private void SetupVertical(AudioPropertiesModel settings)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user