mirror of
https://github.com/Artemis-RGB/Artemis
synced 2025-12-13 05:48:35 +00:00
Basic audio layer type
This commit is contained in:
parent
4f214b0a5f
commit
0b216d6cc2
@ -325,6 +325,12 @@
|
||||
<Compile Include="Profiles\Layers\Animations\NoneAnimation.cs" />
|
||||
<Compile Include="Profiles\Layers\Models\EventPropertiesModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Models\KeyboardEventPropertiesModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Audio\AudioPropertiesModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Audio\AudioPropertiesView.xaml.cs">
|
||||
<DependentUpon>AudioPropertiesView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Profiles\Layers\Types\Audio\AudioPropertiesViewModel.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Audio\AudioType.cs" />
|
||||
<Compile Include="Profiles\Layers\Types\Generic\GenericPropertiesView.xaml.cs">
|
||||
<DependentUpon>GenericPropertiesView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -372,12 +378,6 @@
|
||||
<Compile Include="Modules\Effects\WindowsProfile\WindowsProfileDataModel.cs" />
|
||||
<Compile Include="Modules\Effects\WindowsProfile\WindowsProfileModel.cs" />
|
||||
<Compile Include="Modules\Effects\ProfilePreview\ProfilePreviewModel.cs" />
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWave.Designer.cs">
|
||||
<DependentUpon>TypeWave.settings</DependentUpon>
|
||||
<AutoGen>True</AutoGen>
|
||||
<DesignTimeSharedInput>True</DesignTimeSharedInput>
|
||||
</Compile>
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveModel.cs" />
|
||||
<Compile Include="Models\GameModel.cs" />
|
||||
<Compile Include="Modules\Games\CounterStrike\CounterStrike.Designer.cs">
|
||||
<DependentUpon>CounterStrike.settings</DependentUpon>
|
||||
@ -445,7 +445,6 @@
|
||||
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerSettings.cs" />
|
||||
<Compile Include="Modules\Overlays\VolumeDisplay\VolumeDisplaySettings.cs" />
|
||||
<Compile Include="Modules\Games\RocketLeague\RocketLeagueSettings.cs" />
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveSettings.cs" />
|
||||
<Compile Include="InjectionModules\ArtemisModules.cs" />
|
||||
<Compile Include="InjectionModules\BaseModules.cs" />
|
||||
<Compile Include="InjectionModules\ManagerModules.cs" />
|
||||
@ -521,7 +520,6 @@
|
||||
<Compile Include="ViewModels\DebugViewModel.cs" />
|
||||
<Compile Include="ViewModels\EffectsViewModel.cs" />
|
||||
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerViewModel.cs" />
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveViewModel.cs" />
|
||||
<Compile Include="ViewModels\FlyoutBaseViewModel.cs" />
|
||||
<Compile Include="ViewModels\Flyouts\FlyoutSettingsViewModel.cs" />
|
||||
<Compile Include="ViewModels\GamesViewModel.cs" />
|
||||
@ -557,9 +555,6 @@
|
||||
<Compile Include="Modules\Effects\AudioVisualizer\AudioVisualizerView.xaml.cs">
|
||||
<DependentUpon>AudioVisualizerView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Modules\Effects\TypeWave\TypeWaveView.xaml.cs">
|
||||
<DependentUpon>TypeWaveView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="Views\GamesView.xaml.cs">
|
||||
<DependentUpon>GamesView.xaml</DependentUpon>
|
||||
</Compile>
|
||||
@ -641,10 +636,6 @@
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>Bubbles.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Modules\Effects\TypeWave\TypeWave.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>TypeWave.Designer.cs</LastGenOutput>
|
||||
</None>
|
||||
<None Include="Modules\Effects\WindowsProfile\WindowsProfile.settings">
|
||||
<Generator>SettingsSingleFileGenerator</Generator>
|
||||
<LastGenOutput>WindowsProfile.Designer.cs</LastGenOutput>
|
||||
@ -741,6 +732,10 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Profiles\Layers\Types\Audio\AudioPropertiesView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
</Page>
|
||||
<Page Include="Profiles\Layers\Types\Generic\GenericPropertiesView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
@ -777,10 +772,6 @@
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Modules\Effects\TypeWave\TypeWaveView.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
</Page>
|
||||
<Page Include="Views\Flyouts\FlyoutSettingsView.xaml">
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
<SubType>Designer</SubType>
|
||||
|
||||
@ -4,7 +4,6 @@ using Artemis.DeviceProviders.Logitech;
|
||||
using Artemis.DeviceProviders.Razer;
|
||||
using Artemis.Modules.Effects.AudioVisualizer;
|
||||
using Artemis.Modules.Effects.Bubbles;
|
||||
using Artemis.Modules.Effects.TypeWave;
|
||||
using Artemis.Modules.Effects.WindowsProfile;
|
||||
using Artemis.Modules.Games.CounterStrike;
|
||||
using Artemis.Modules.Games.Dota2;
|
||||
@ -16,6 +15,7 @@ using Artemis.Modules.Overlays.VolumeDisplay;
|
||||
using Artemis.Profiles.Layers.Animations;
|
||||
using Artemis.Profiles.Layers.Conditions;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Types.Audio;
|
||||
using Artemis.Profiles.Layers.Types.Folder;
|
||||
using Artemis.Profiles.Layers.Types.Generic;
|
||||
using Artemis.Profiles.Layers.Types.Headset;
|
||||
@ -36,7 +36,6 @@ namespace Artemis.InjectionModules
|
||||
|
||||
// Effects
|
||||
Bind<EffectViewModel>().To<AudioVisualizerViewModel>().InSingletonScope();
|
||||
Bind<EffectViewModel>().To<TypeWaveViewModel>().InSingletonScope();
|
||||
Bind<EffectViewModel>().To<BubblesViewModel>().InSingletonScope();
|
||||
Bind<EffectViewModel>().To<WindowsProfileViewModel>().InSingletonScope();
|
||||
|
||||
@ -92,9 +91,11 @@ namespace Artemis.InjectionModules
|
||||
Bind<ILayerType>().To<MouseType>();
|
||||
Bind<ILayerType>().To<GenericType>();
|
||||
Bind<ILayerType>().To<KeyPressType>();
|
||||
Bind<ILayerType>().To<AudioType>();
|
||||
|
||||
// Bind some Layer Types to self as well in order to allow JSON.NET injection
|
||||
Bind<KeyPressType>().ToSelf();
|
||||
Bind<AudioType>().ToSelf();
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@ -1,98 +0,0 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
// Runtime Version:4.0.30319.42000
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace Artemis.Modules.Effects.TypeWave {
|
||||
|
||||
|
||||
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
|
||||
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "14.0.0.0")]
|
||||
internal sealed partial class TypeWave : global::System.Configuration.ApplicationSettingsBase {
|
||||
|
||||
private static TypeWave defaultInstance = ((TypeWave)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new TypeWave())));
|
||||
|
||||
public static TypeWave Default {
|
||||
get {
|
||||
return defaultInstance;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool IsRandomColors {
|
||||
get {
|
||||
return ((bool)(this["IsRandomColors"]));
|
||||
}
|
||||
set {
|
||||
this["IsRandomColors"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("#FFFF0000")]
|
||||
public global::System.Windows.Media.Color WaveColor {
|
||||
get {
|
||||
return ((global::System.Windows.Media.Color)(this["WaveColor"]));
|
||||
}
|
||||
set {
|
||||
this["WaveColor"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("True")]
|
||||
public bool IsShiftColors {
|
||||
get {
|
||||
return ((bool)(this["IsShiftColors"]));
|
||||
}
|
||||
set {
|
||||
this["IsShiftColors"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("20")]
|
||||
public int ShiftColorSpeed {
|
||||
get {
|
||||
return ((int)(this["ShiftColorSpeed"]));
|
||||
}
|
||||
set {
|
||||
this["ShiftColorSpeed"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("500")]
|
||||
public int TimeToLive {
|
||||
get {
|
||||
return ((int)(this["TimeToLive"]));
|
||||
}
|
||||
set {
|
||||
this["TimeToLive"] = value;
|
||||
}
|
||||
}
|
||||
|
||||
[global::System.Configuration.UserScopedSettingAttribute()]
|
||||
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
|
||||
[global::System.Configuration.DefaultSettingValueAttribute("4")]
|
||||
public int SpreadSpeed {
|
||||
get {
|
||||
return ((int)(this["SpreadSpeed"]));
|
||||
}
|
||||
set {
|
||||
this["SpreadSpeed"] = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,26 +0,0 @@
|
||||
<?xml version='1.0' encoding='utf-8'?>
|
||||
|
||||
<SettingsFile xmlns="http://schemas.microsoft.com/VisualStudio/2004/01/settings" CurrentProfile="(Default)"
|
||||
GeneratedClassNamespace="Artemis.Settings" GeneratedClassName="TypeWave">
|
||||
<Profiles />
|
||||
<Settings>
|
||||
<Setting Name="IsRandomColors" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="WaveColor" Type="System.Windows.Media.Color" Scope="User">
|
||||
<Value Profile="(Default)">#FFFF0000</Value>
|
||||
</Setting>
|
||||
<Setting Name="IsShiftColors" Type="System.Boolean" Scope="User">
|
||||
<Value Profile="(Default)">True</Value>
|
||||
</Setting>
|
||||
<Setting Name="ShiftColorSpeed" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">20</Value>
|
||||
</Setting>
|
||||
<Setting Name="TimeToLive" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">500</Value>
|
||||
</Setting>
|
||||
<Setting Name="SpreadSpeed" Type="System.Int32" Scope="User">
|
||||
<Value Profile="(Default)">4</Value>
|
||||
</Setting>
|
||||
</Settings>
|
||||
</SettingsFile>
|
||||
@ -1,138 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Windows.Forms;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Utilities;
|
||||
using Artemis.Utilities.Keyboard;
|
||||
|
||||
namespace Artemis.Modules.Effects.TypeWave
|
||||
{
|
||||
public class TypeWaveModel : EffectModel
|
||||
{
|
||||
private readonly List<Wave> _waves;
|
||||
private Color _randomColor;
|
||||
|
||||
public TypeWaveModel(MainManager mainManager, TypeWaveSettings settings) : base(mainManager, null)
|
||||
{
|
||||
Name = "TypeWave";
|
||||
_waves = new List<Wave>();
|
||||
_randomColor = Color.Red;
|
||||
Settings = settings;
|
||||
Initialized = false;
|
||||
}
|
||||
|
||||
public TypeWaveSettings Settings { get; set; }
|
||||
|
||||
public override void Dispose()
|
||||
{
|
||||
Initialized = false;
|
||||
KeyboardHook.KeyDownCallback -= KeyboardHookOnKeyDownCallback;
|
||||
}
|
||||
|
||||
private void KeyboardHookOnKeyDownCallback(KeyEventArgs e)
|
||||
{
|
||||
// More than 25 waves is pointless
|
||||
if (_waves.Count >= 25)
|
||||
return;
|
||||
|
||||
var keyMatch = MainManager.DeviceManager.ActiveKeyboard.GetKeyPosition(e.KeyCode);
|
||||
if (keyMatch == null)
|
||||
return;
|
||||
|
||||
_waves.Add(Settings.IsRandomColors
|
||||
? new Wave(new Point(keyMatch.Value.X*KeyboardScale, keyMatch.Value.Y*KeyboardScale), 0, _randomColor)
|
||||
: new Wave(new Point(keyMatch.Value.X*KeyboardScale, keyMatch.Value.Y*KeyboardScale), 0,
|
||||
ColorHelpers.ToDrawingColor(Settings.WaveColor)));
|
||||
}
|
||||
|
||||
public override void Enable()
|
||||
{
|
||||
KeyboardHook.KeyDownCallback += KeyboardHookOnKeyDownCallback;
|
||||
Initialized = true;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (Settings.IsRandomColors)
|
||||
_randomColor = ColorHelpers.ShiftColor(_randomColor, 25);
|
||||
|
||||
for (var i = 0; i < _waves.Count; i++)
|
||||
{
|
||||
// TODO: Get from settings
|
||||
var fps = 25;
|
||||
|
||||
_waves[i].Size += Settings.SpreadSpeed*KeyboardScale;
|
||||
|
||||
if (Settings.IsShiftColors)
|
||||
_waves[i].Color = ColorHelpers.ShiftColor(_waves[i].Color, Settings.ShiftColorSpeed);
|
||||
|
||||
var decreaseAmount = 255/(Settings.TimeToLive/fps);
|
||||
_waves[i].Color = Color.FromArgb(
|
||||
_waves[i].Color.A - decreaseAmount, _waves[i].Color.R,
|
||||
_waves[i].Color.G,
|
||||
_waves[i].Color.B);
|
||||
|
||||
if (_waves[i].Color.A >= decreaseAmount)
|
||||
continue;
|
||||
|
||||
_waves.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
}
|
||||
|
||||
public override List<LayerModel> GetRenderLayers(bool keyboardOnly)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public override void Render(RenderFrame frame, bool keyboardOnly)
|
||||
{
|
||||
if (_waves.Count == 0)
|
||||
return;
|
||||
|
||||
// Don't want a for-each, collection is changed in different thread
|
||||
// ReSharper disable once ForCanBeConvertedToForeach
|
||||
for (var i = 0; i < _waves.Count; i++)
|
||||
{
|
||||
if (_waves[i].Size == 0)
|
||||
continue;
|
||||
var path = new GraphicsPath();
|
||||
path.AddEllipse(_waves[i].Point.X - _waves[i].Size/2, _waves[i].Point.Y - _waves[i].Size/2,
|
||||
_waves[i].Size, _waves[i].Size);
|
||||
|
||||
var pthGrBrush = new PathGradientBrush(path)
|
||||
{
|
||||
SurroundColors = new[] {_waves[i].Color},
|
||||
CenterColor = Color.Transparent
|
||||
};
|
||||
|
||||
using (var g = Graphics.FromImage(frame.KeyboardBitmap))
|
||||
{
|
||||
g.FillPath(pthGrBrush, path);
|
||||
pthGrBrush.FocusScales = new PointF(0.3f, 0.8f);
|
||||
|
||||
g.FillPath(pthGrBrush, path);
|
||||
g.DrawEllipse(new Pen(pthGrBrush, 1), _waves[i].Point.X - _waves[i].Size/2,
|
||||
_waves[i].Point.Y - _waves[i].Size/2, _waves[i].Size, _waves[i].Size);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class Wave
|
||||
{
|
||||
public Wave(Point point, int size, Color color)
|
||||
{
|
||||
Point = point;
|
||||
Size = size;
|
||||
Color = color;
|
||||
}
|
||||
|
||||
public Point Point { get; set; }
|
||||
public int Size { get; set; }
|
||||
public Color Color { get; set; }
|
||||
}
|
||||
}
|
||||
@ -1,52 +0,0 @@
|
||||
using System.Windows.Media;
|
||||
using Artemis.Models;
|
||||
|
||||
namespace Artemis.Modules.Effects.TypeWave
|
||||
{
|
||||
public class TypeWaveSettings : EffectSettings
|
||||
{
|
||||
public TypeWaveSettings()
|
||||
{
|
||||
Load();
|
||||
}
|
||||
|
||||
public bool IsRandomColors { get; set; }
|
||||
public Color WaveColor { get; set; }
|
||||
public bool IsShiftColors { get; set; }
|
||||
public int ShiftColorSpeed { get; set; }
|
||||
public int TimeToLive { get; set; }
|
||||
public int SpreadSpeed { get; set; }
|
||||
|
||||
public sealed override void Load()
|
||||
{
|
||||
IsRandomColors = TypeWave.Default.IsRandomColors;
|
||||
WaveColor = TypeWave.Default.WaveColor;
|
||||
IsShiftColors = TypeWave.Default.IsShiftColors;
|
||||
ShiftColorSpeed = TypeWave.Default.ShiftColorSpeed;
|
||||
TimeToLive = TypeWave.Default.TimeToLive;
|
||||
SpreadSpeed = TypeWave.Default.SpreadSpeed;
|
||||
}
|
||||
|
||||
public sealed override void Save()
|
||||
{
|
||||
TypeWave.Default.IsRandomColors = IsRandomColors;
|
||||
TypeWave.Default.WaveColor = WaveColor;
|
||||
TypeWave.Default.IsShiftColors = IsShiftColors;
|
||||
TypeWave.Default.ShiftColorSpeed = ShiftColorSpeed;
|
||||
TypeWave.Default.TimeToLive = TimeToLive;
|
||||
TypeWave.Default.SpreadSpeed = SpreadSpeed;
|
||||
|
||||
TypeWave.Default.Save();
|
||||
}
|
||||
|
||||
public sealed override void ToDefault()
|
||||
{
|
||||
IsRandomColors = true;
|
||||
WaveColor = Color.FromArgb(255, 255, 0, 0);
|
||||
IsShiftColors = true;
|
||||
ShiftColorSpeed = 20;
|
||||
TimeToLive = 500;
|
||||
SpreadSpeed = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,121 +0,0 @@
|
||||
<UserControl x:Class="Artemis.Modules.Effects.TypeWave.TypeWaveView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:cal="http://www.caliburnproject.org"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="476.986" d:DesignWidth="538.772">
|
||||
<ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Auto">
|
||||
<Grid Margin="15, 5, 15, 5">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="Auto" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition Height="*" />
|
||||
|
||||
</Grid.RowDefinitions>
|
||||
<StackPanel Grid.Row="0" Grid.Column="0" Grid.ColumnSpan="2" Margin="0,0,1,0">
|
||||
<Label FontSize="20" HorizontalAlignment="Left">
|
||||
<Label.Content>
|
||||
<AccessText TextWrapping="Wrap" Text="Creates waves on the keyboard as you press keys." />
|
||||
</Label.Content>
|
||||
</Label>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right">
|
||||
<Label Content="Enable effect" Margin="0 3 0 0" HorizontalAlignment="Right" />
|
||||
<ToggleButton x:Name="EffectEnabled" Margin="0 3 0 0" Width="25" Height="25"
|
||||
Style="{DynamicResource MetroCircleToggleButtonStyle}"
|
||||
cal:Message.Attach="[Event Click] = [Action ToggleEffect]" />
|
||||
<Popup PlacementTarget="{Binding ElementName=EffectEnabled}"
|
||||
IsOpen="{Binding Path=ShowDisabledPopup, Mode=TwoWay}" Placement="Left" VerticalOffset="-10"
|
||||
PopupAnimation="Fade" StaysOpen="False">
|
||||
<Border Margin="1">
|
||||
<TextBlock Background="{DynamicResource AccentColorBrush}"
|
||||
Foreground="{DynamicResource IdealForegroundColorBrush}"
|
||||
Text="You can't enable an effect when Artemis is disabled" Padding="4" />
|
||||
</Border>
|
||||
</Popup>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Color -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Wave color
|
||||
</TextBlock>
|
||||
<xctk:ColorPicker x:Name="MiddleColor"
|
||||
SelectedColor="{Binding Path=EffectSettings.WaveColor, Mode=TwoWay}"
|
||||
Grid.Row="1" Grid.Column="1" Width="110" HorizontalAlignment="Right"
|
||||
VerticalAlignment="Center" Margin="0,5,-1,5" Height="22" />
|
||||
|
||||
<!-- Random colors -->
|
||||
<TextBlock Grid.Row="2" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Use random colors
|
||||
</TextBlock>
|
||||
<controls:ToggleSwitch IsChecked="{Binding Path=EffectSettings.IsRandomColors, Mode=TwoWay}"
|
||||
Grid.Row="2" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
|
||||
OffLabel="No"
|
||||
Margin="0,0,-5,0" Width="114" />
|
||||
|
||||
<!-- Shift color -->
|
||||
<TextBlock Grid.Row="3" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Shift through colors as the wave grows
|
||||
</TextBlock>
|
||||
<controls:ToggleSwitch IsChecked="{Binding Path=EffectSettings.IsShiftColors, Mode=TwoWay}"
|
||||
Grid.Row="3" Grid.Column="1" HorizontalAlignment="Right" OnLabel="Yes"
|
||||
OffLabel="No"
|
||||
Margin="0,0,-5,0" Width="114" />
|
||||
|
||||
<!-- Shift speed -->
|
||||
<TextBlock Grid.Row="4" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Speed to shift colors at
|
||||
</TextBlock>
|
||||
<Slider x:Name="ColorShiftSpeed" Grid.Row="4" Grid.Column="1" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
|
||||
Value="{Binding Path=EffectSettings.ShiftColorSpeed, Mode=TwoWay}" Minimum="1" Maximum="200"
|
||||
SmallChange="45" IsSnapToTickEnabled="True" />
|
||||
|
||||
<!-- TTL -->
|
||||
<TextBlock Grid.Row="5" Grid.Column="0" HorizontalAlignment="Left" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,8">
|
||||
Wave time to live
|
||||
</TextBlock>
|
||||
<Slider x:Name="TimeToLive" Grid.Row="5" Grid.Column="1" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right" Width="110" TickPlacement="None" TickFrequency="1"
|
||||
Value="{Binding Path=EffectSettings.TimeToLive, Mode=TwoWay}" Minimum="100" Maximum="2000"
|
||||
SmallChange="45" IsSnapToTickEnabled="True" />
|
||||
|
||||
<!-- Growth speed -->
|
||||
<TextBlock Grid.Row="6" Grid.Column="0" HorizontalAlignment="Left" Width="116" VerticalAlignment="Center"
|
||||
Height="16" Margin="0,9,0,10">
|
||||
Wave growth speed
|
||||
</TextBlock>
|
||||
<Slider x:Name="SpreadSpeed" Grid.Row="6" Grid.Column="1" VerticalAlignment="Center"
|
||||
HorizontalAlignment="Right" Width="110" TickPlacement="BottomRight" TickFrequency="1"
|
||||
Value="{Binding Path=EffectSettings.SpreadSpeed, Mode=TwoWay}" Minimum="1" Maximum="6"
|
||||
SmallChange="1" IsSnapToTickEnabled="True" />
|
||||
|
||||
<!-- Buttons -->
|
||||
<StackPanel Grid.Column="0" Grid.Row="8" Orientation="Horizontal" VerticalAlignment="Bottom">
|
||||
<Button x:Name="ResetSettings" Content="Reset effect" VerticalAlignment="Top" Width="100"
|
||||
Style="{DynamicResource SquareButtonStyle}" />
|
||||
<Button x:Name="SaveSettings" Content="Save changes" VerticalAlignment="Top" Width="100"
|
||||
Margin="10,0,0,0"
|
||||
Style="{DynamicResource SquareButtonStyle}" />
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</ScrollViewer>
|
||||
</UserControl>
|
||||
@ -1,15 +0,0 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.Modules.Effects.TypeWave
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for TypeWaveView.xaml
|
||||
/// </summary>
|
||||
public partial class TypeWaveView : UserControl
|
||||
{
|
||||
public TypeWaveView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,25 +0,0 @@
|
||||
using Artemis.Events;
|
||||
using Artemis.Managers;
|
||||
using Artemis.ViewModels.Abstract;
|
||||
using Caliburn.Micro;
|
||||
|
||||
namespace Artemis.Modules.Effects.TypeWave
|
||||
{
|
||||
public sealed class TypeWaveViewModel : EffectViewModel, IHandle<ActiveEffectChanged>
|
||||
{
|
||||
public TypeWaveViewModel(MainManager main, IEventAggregator events)
|
||||
: base(main, new TypeWaveModel(main, new TypeWaveSettings()))
|
||||
{
|
||||
DisplayName = "Type Waves";
|
||||
events.Subscribe(this);
|
||||
|
||||
MainManager.EffectManager.EffectModels.Add(EffectModel);
|
||||
EffectSettings = ((TypeWaveModel) EffectModel).Settings;
|
||||
}
|
||||
|
||||
public void Handle(ActiveEffectChanged message)
|
||||
{
|
||||
NotifyOfPropertyChange(() => EffectEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,14 @@
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Audio
|
||||
{
|
||||
public class AudioPropertiesModel : LayerPropertiesModel
|
||||
{
|
||||
public AudioPropertiesModel(LayerPropertiesModel properties) : base(properties)
|
||||
{
|
||||
}
|
||||
|
||||
public int Sensitivity { get; set; }
|
||||
public double FadeSpeed { get; set; }
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,59 @@
|
||||
<UserControl x:Class="Artemis.Profiles.Layers.Types.Audio.AudioPropertiesView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:ncore="http://schemas.ncore.com/wpf/xaml/colorbox"
|
||||
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="600" d:DesignWidth="500">
|
||||
<Grid>
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
<!-- Scale -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="0" Margin="10,13,10,10" FontSize="13.333" Text="Scale:"
|
||||
Height="18" VerticalAlignment="Top" />
|
||||
<Slider x:Name="Scale" Grid.Row="0" Grid.Column="1" VerticalAlignment="Top"
|
||||
TickPlacement="None" TickFrequency="2"
|
||||
Value="{Binding Path=LayerModel.Properties.Scale, Mode=TwoWay}" Minimum="2" Maximum="24"
|
||||
SmallChange="2" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" LargeChange="2" />
|
||||
|
||||
<!-- Animation Speed -->
|
||||
<TextBlock Grid.Row="0" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Animation speed:"
|
||||
VerticalAlignment="Top" Height="18" />
|
||||
<Slider x:Name="RotationSpeed" Grid.Row="0" Grid.Column="3" VerticalAlignment="Top"
|
||||
TickPlacement="None" TickFrequency="0.05"
|
||||
Value="{Binding Path=LayerModel.Properties.AnimationSpeed, Mode=TwoWay}" Minimum="0.05" Maximum="3"
|
||||
SmallChange="0" IsSnapToTickEnabled="True" Margin="10,12,10,2" Height="24" />
|
||||
|
||||
<!-- Colors -->
|
||||
<StackPanel Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Orientation="Horizontal" x:Name="ShowBrush">
|
||||
<TextBlock Margin="10,13,10,0" FontSize="13.333" Text="Color(s):"
|
||||
VerticalAlignment="Top" Height="18" Width="130" />
|
||||
<Border Margin="10" BorderBrush="{StaticResource ControlBorderBrush}"
|
||||
BorderThickness="1" SnapsToDevicePixels="True" ToolTip="Click to edit">
|
||||
<ncore:ColorBox Brush="{Binding Path=Brush, Mode=TwoWay}" Height="24" Width="134" VerticalAlignment="Top" />
|
||||
</Border>
|
||||
</StackPanel>
|
||||
|
||||
<!-- Random color -->
|
||||
<TextBlock Grid.Row="1" Grid.Column="2" Margin="10,13,10,10" FontSize="13.333" Text="Random color:"
|
||||
VerticalAlignment="Top" Height="18" />
|
||||
<controls:ToggleSwitch Grid.Row="1" Grid.Column="3" OnLabel="Yes" OffLabel="No"
|
||||
IsChecked="{Binding Path=LayerModel.Properties.RandomColor, Mode=TwoWay}"
|
||||
VerticalAlignment="Top" Margin="10,5,10,2" />
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@ -0,0 +1,15 @@
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Audio
|
||||
{
|
||||
/// <summary>
|
||||
/// Interaction logic for AudioPropertiesView.xaml
|
||||
/// </summary>
|
||||
public partial class AudioPropertiesView : UserControl
|
||||
{
|
||||
public AudioPropertiesView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,18 @@
|
||||
using Artemis.Models.Interfaces;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Audio
|
||||
{
|
||||
public class AudioPropertiesViewModel : LayerPropertiesViewModel
|
||||
{
|
||||
public AudioPropertiesViewModel(LayerModel layerModel, IDataModel dataModel) : base(layerModel, dataModel)
|
||||
{
|
||||
}
|
||||
|
||||
public override void ApplyProperties()
|
||||
{
|
||||
LayerModel.Properties.Brush = Brush;
|
||||
}
|
||||
}
|
||||
}
|
||||
200
Artemis/Artemis/Profiles/Layers/Types/Audio/AudioType.cs
Normal file
200
Artemis/Artemis/Profiles/Layers/Types/Audio/AudioType.cs
Normal file
@ -0,0 +1,200 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Windows;
|
||||
using System.Windows.Media;
|
||||
using Artemis.Managers;
|
||||
using Artemis.Models.Interfaces;
|
||||
using Artemis.Modules.Effects.AudioVisualizer.Utilities;
|
||||
using Artemis.Profiles.Layers.Abstract;
|
||||
using Artemis.Profiles.Layers.Animations;
|
||||
using Artemis.Profiles.Layers.Interfaces;
|
||||
using Artemis.Profiles.Layers.Models;
|
||||
using Artemis.Properties;
|
||||
using Artemis.Utilities;
|
||||
using NAudio.CoreAudioApi;
|
||||
using NAudio.Wave;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace Artemis.Profiles.Layers.Types.Audio
|
||||
{
|
||||
internal class AudioType : ILayerType
|
||||
{
|
||||
private readonly MMDevice _device;
|
||||
private readonly MainManager _mainManager;
|
||||
private readonly SampleAggregator _sampleAggregator = new SampleAggregator(2048);
|
||||
private readonly WasapiLoopbackCapture _waveIn;
|
||||
private readonly List<LayerModel> _audioLayers = new List<LayerModel>();
|
||||
private int _lines;
|
||||
private AudioPropertiesModel _properties;
|
||||
private AudioPropertiesModel _previousSettings;
|
||||
|
||||
public AudioType(MainManager mainManager)
|
||||
{
|
||||
_mainManager = mainManager;
|
||||
_device =
|
||||
new MMDeviceEnumerator().EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active).FirstOrDefault();
|
||||
|
||||
_sampleAggregator.FftCalculated += FftCalculated;
|
||||
_sampleAggregator.PerformFFT = true;
|
||||
|
||||
// Start listening for sound data
|
||||
_waveIn = new WasapiLoopbackCapture();
|
||||
_waveIn.DataAvailable += OnDataAvailable;
|
||||
_waveIn.StartRecording();
|
||||
}
|
||||
|
||||
public List<byte> SpectrumData { get; set; } = new List<byte>();
|
||||
|
||||
public string Name { get; } = "Keyboard - Audio visualization";
|
||||
public bool ShowInEdtor { get; } = true;
|
||||
public DrawType DrawType { get; } = DrawType.Keyboard;
|
||||
|
||||
public ImageSource DrawThumbnail(LayerModel layer)
|
||||
{
|
||||
var thumbnailRect = new Rect(0, 0, 18, 18);
|
||||
var visual = new DrawingVisual();
|
||||
using (var c = visual.RenderOpen())
|
||||
c.DrawImage(ImageUtilities.BitmapToBitmapImage(Resources.gif), thumbnailRect);
|
||||
|
||||
var image = new DrawingImage(visual.Drawing);
|
||||
return image;
|
||||
}
|
||||
|
||||
public void Draw(LayerModel layer, DrawingContext c)
|
||||
{
|
||||
lock (SpectrumData)
|
||||
{
|
||||
foreach (var audioLayer in _audioLayers)
|
||||
audioLayer.LayerType.Draw(audioLayer, c);
|
||||
}
|
||||
}
|
||||
|
||||
public void Update(LayerModel layerModel, IDataModel dataModel, bool isPreview = false)
|
||||
{
|
||||
_lines = (int) layerModel.Properties.Width;
|
||||
if (_device == null || isPreview)
|
||||
return;
|
||||
|
||||
lock (SpectrumData)
|
||||
{
|
||||
if (!SpectrumData.Any())
|
||||
return;
|
||||
|
||||
CompareSettings(layerModel);
|
||||
|
||||
var index = 0;
|
||||
var settings = (AudioPropertiesModel) layerModel.Properties;
|
||||
foreach (var audioLayer in _audioLayers)
|
||||
{
|
||||
int height;
|
||||
if (SpectrumData.Count > index)
|
||||
height = (int) Math.Round(SpectrumData[index]/2.55);
|
||||
else
|
||||
height = 0;
|
||||
|
||||
var newHeight = settings.Height/100.0*height;
|
||||
if (newHeight >= audioLayer.Properties.Height)
|
||||
audioLayer.Properties.Height = newHeight;
|
||||
else
|
||||
audioLayer.Properties.Height = audioLayer.Properties.Height - settings.FadeSpeed;
|
||||
if (audioLayer.Properties.Height < 0)
|
||||
audioLayer.Properties.Height = 0;
|
||||
|
||||
audioLayer.Update(null, false, true);
|
||||
index++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CompareSettings(LayerModel layerModel)
|
||||
{
|
||||
var settings = (AudioPropertiesModel) layerModel.Properties;
|
||||
if (JsonConvert.SerializeObject(settings).Equals(JsonConvert.SerializeObject(_previousSettings)))
|
||||
return;
|
||||
|
||||
_previousSettings = GeneralHelpers.Clone((AudioPropertiesModel) layerModel.Properties);
|
||||
|
||||
_audioLayers.Clear();
|
||||
for (var i = 0; i < _lines; i++)
|
||||
{
|
||||
var layer = LayerModel.CreateLayer();
|
||||
layer.Properties.X = layerModel.Properties.X + i;
|
||||
layer.Properties.Y = layerModel.Properties.Y;
|
||||
layer.Properties.Width = 1;
|
||||
layer.Properties.Height = 0;
|
||||
layer.LayerAnimation = new NoneAnimation();
|
||||
|
||||
// TODO: Setup the brush according to settings
|
||||
layer.Properties.Brush = new SolidColorBrush(Colors.White);
|
||||
|
||||
_audioLayers.Add(layer);
|
||||
layer.Update(null, false, true);
|
||||
}
|
||||
}
|
||||
|
||||
public void SetupProperties(LayerModel layerModel)
|
||||
{
|
||||
if (layerModel.Properties is AudioPropertiesModel)
|
||||
return;
|
||||
|
||||
layerModel.Properties = new AudioPropertiesModel(layerModel.Properties)
|
||||
{
|
||||
FadeSpeed = 0.2,
|
||||
Sensitivity = 2
|
||||
};
|
||||
}
|
||||
|
||||
public LayerPropertiesViewModel SetupViewModel(LayerPropertiesViewModel layerPropertiesViewModel,
|
||||
List<ILayerAnimation> layerAnimations, IDataModel dataModel, LayerModel proposedLayer)
|
||||
{
|
||||
if (layerPropertiesViewModel is AudioPropertiesViewModel)
|
||||
return layerPropertiesViewModel;
|
||||
return new AudioPropertiesViewModel(proposedLayer, dataModel);
|
||||
}
|
||||
|
||||
private void FftCalculated(object sender, FftEventArgs e)
|
||||
{
|
||||
lock (SpectrumData)
|
||||
{
|
||||
int x;
|
||||
var b0 = 0;
|
||||
|
||||
SpectrumData.Clear();
|
||||
for (x = 0; x < _lines; x++)
|
||||
{
|
||||
float peak = 0;
|
||||
var b1 = (int) Math.Pow(2, x*10.0/(_lines - 1));
|
||||
if (b1 > 2047)
|
||||
b1 = 2047;
|
||||
if (b1 <= b0)
|
||||
b1 = b0 + 1;
|
||||
for (; b0 < b1; b0++)
|
||||
{
|
||||
if (peak < e.Result[1 + b0].X)
|
||||
peak = e.Result[1 + b0].X;
|
||||
}
|
||||
var y = (int) (Math.Sqrt(peak)*3*255 - 4);
|
||||
if (y > 255)
|
||||
y = 255;
|
||||
if (y < 0)
|
||||
y = 0;
|
||||
SpectrumData.Add((byte) y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDataAvailable(object sender, WaveInEventArgs e)
|
||||
{
|
||||
var buffer = e.Buffer;
|
||||
var bytesRecorded = e.BytesRecorded;
|
||||
var bufferIncrement = _waveIn.WaveFormat.BlockAlign;
|
||||
|
||||
for (var index = 0; index < bytesRecorded; index += bufferIncrement)
|
||||
{
|
||||
var sample32 = BitConverter.ToSingle(buffer, index);
|
||||
_sampleAggregator.Add(sample32);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -65,6 +65,9 @@ namespace Artemis.Profiles.Layers.Types.KeyPress
|
||||
|
||||
_properties = (KeyPressPropertiesModel) layerModel.Properties;
|
||||
|
||||
if (isPreview)
|
||||
return;
|
||||
|
||||
lock (_keyPressLayers)
|
||||
{
|
||||
// Remove expired key presses
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user