Minor changes

This commit is contained in:
Darth Affe 2018-01-29 13:16:28 +01:00
parent 1af8bb67c3
commit cb8146c594
14 changed files with 206 additions and 334 deletions

View File

@ -1,6 +1,4 @@
using System; using System.Collections.Generic;
using System.Collections.Generic;
using System.Linq;
using System.Windows; using System.Windows;
using KeyboardAudioVisualizer.AudioProcessing; using KeyboardAudioVisualizer.AudioProcessing;
using KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider; using KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider;
@ -69,6 +67,8 @@ namespace KeyboardAudioVisualizer
surface.LoadDevices(LogitechDeviceProvider.Instance); surface.LoadDevices(LogitechDeviceProvider.Instance);
surface.LoadDevices(CoolerMasterDeviceProvider.Instance); surface.LoadDevices(CoolerMasterDeviceProvider.Instance);
surface.AlignDevies();
ILedGroup background = new ListLedGroup(surface.Leds); ILedGroup background = new ListLedGroup(surface.Leds);
background.Brush = new SolidColorBrush(new Color(64, 0, 0, 0)); //TODO DarthAffe 06.08.2017: A-Channel gives some kind of blur - settings! background.Brush = new SolidColorBrush(new Color(64, 0, 0, 0)); //TODO DarthAffe 06.08.2017: A-Channel gives some kind of blur - settings!
@ -90,7 +90,7 @@ namespace KeyboardAudioVisualizer
IGradient keyboardLevelGradient = new LinearGradient(new GradientStop(0, new Color(0, 0, 255)), new GradientStop(1, new Color(255, 0, 0))); IGradient keyboardLevelGradient = new LinearGradient(new GradientStop(0, new Color(0, 0, 255)), new GradientStop(1, new Color(255, 0, 0)));
ILedGroup lightbarLeft = new ListLedGroup(lightbar.Left); ILedGroup lightbarLeft = new ListLedGroup(lightbar.Left);
lightbarLeft.Brush = new LinearGradientBrush(keyboardLevelGradient); lightbarLeft.Brush = new LinearGradientBrush(new Point(1.0, 0.5), new Point(0.0, 0.5), keyboardLevelGradient);
tertiaryGroups.Add((lightbarLeft, (visualizationType, visualizer) => CreateDecorator(visualizationType, visualizer, LevelBarDirection.Left, 0))); tertiaryGroups.Add((lightbarLeft, (visualizationType, visualizer) => CreateDecorator(visualizationType, visualizer, LevelBarDirection.Left, 0)));
ILedGroup lightbarRight = new ListLedGroup(lightbar.Right); ILedGroup lightbarRight = new ListLedGroup(lightbar.Right);

View File

@ -52,24 +52,27 @@ namespace KeyboardAudioVisualizer.AudioCapture
} }
} }
public void CopyLeftInto(ref float[] data, int offset) public void CopyLeftInto(ref float[] data, int offset) => CopyLeftInto(ref data, offset, _capacity);
public void CopyLeftInto(ref float[] data, int offset, int count)
{ {
lock (_bufferLeft) lock (_bufferLeft)
for (int i = 0; i < _capacity; i++) for (int i = _capacity - count; i < count; i++)
data[offset + i] = _bufferLeft[(_currentIndex + i) % _capacity]; data[offset + i] = _bufferLeft[(_currentIndex + i) % _capacity];
} }
public void CopyRightInto(ref float[] data, int offset) public void CopyRightInto(ref float[] data, int offset) => CopyRightInto(ref data, offset, _capacity);
public void CopyRightInto(ref float[] data, int offset, int count)
{ {
lock (_bufferLeft) lock (_bufferRight)
for (int i = 0; i < _capacity; i++) for (int i = _capacity - count; i < count; i++)
data[offset + i] = _bufferRight[(_currentIndex + i) % _capacity]; data[offset + i] = _bufferRight[(_currentIndex + i) % _capacity];
} }
public void CopyMixInto(ref float[] data, int offset) public void CopyMixInto(ref float[] data, int offset) => CopyMixInto(ref data, offset, _capacity);
public void CopyMixInto(ref float[] data, int offset, int count)
{ {
lock (_bufferLeft) lock (_bufferLeft)
for (int i = 0; i < _capacity; i++) for (int i = _capacity - count; i < count; i++)
{ {
int index = (_currentIndex + i) % _capacity; int index = (_currentIndex + i) % _capacity;
data[offset + i] = (_bufferLeft[index] + _bufferRight[index]) / 2f; data[offset + i] = (_bufferLeft[index] + _bufferRight[index]) / 2f;

View File

@ -2,7 +2,6 @@
using KeyboardAudioVisualizer.AudioProcessing.Equalizer; using KeyboardAudioVisualizer.AudioProcessing.Equalizer;
using KeyboardAudioVisualizer.AudioProcessing.Spectrum; using KeyboardAudioVisualizer.AudioProcessing.Spectrum;
using KeyboardAudioVisualizer.Configuration; using KeyboardAudioVisualizer.Configuration;
using RGB.NET.Core;
namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
{ {
@ -93,9 +92,6 @@ namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
public IConfiguration Configuration => _configuration; public IConfiguration Configuration => _configuration;
public float[] VisualizationData { get; private set; } public float[] VisualizationData { get; private set; }
public string DisplayName => "Spectrometer";
public RGBDeviceType VisualizerFor => RGBDeviceType.Keyboard | RGBDeviceType.LedMatrix;
#endregion #endregion
#region Constructors #region Constructors

View File

@ -1,9 +1,6 @@
using System; using KeyboardAudioVisualizer.AudioProcessing.Spectrum;
using System.Linq;
using KeyboardAudioVisualizer.AudioProcessing.Spectrum;
using KeyboardAudioVisualizer.Configuration; using KeyboardAudioVisualizer.Configuration;
using KeyboardAudioVisualizer.Helper; using KeyboardAudioVisualizer.Helper;
using RGB.NET.Core;
namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
{ {
@ -16,7 +13,6 @@ namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
#endregion #endregion
// Port of https://github.com/kctess5/Processing-Beat-Detection
public class BeatVisualizationProvider : AbstractAudioProcessor, IVisualizationProvider public class BeatVisualizationProvider : AbstractAudioProcessor, IVisualizationProvider
{ {
#region Properties & Fields #region Properties & Fields
@ -24,47 +20,11 @@ namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
private readonly BeatVisualizationProviderConfiguration _configuration; private readonly BeatVisualizationProviderConfiguration _configuration;
private readonly ISpectrumProvider _specturProvider; private readonly ISpectrumProvider _specturProvider;
private int _beatBands = 30; //Number of bands to montiter, higher for more accuracy, lower for speed private RingBuffer[] _history;
private int _longTermAverageSamples = 60; //gets average volume over a period of time
private int _shortTermAverageSamples = 1; //average volume over a shorter "instantanious" time
private int _deltaArraySamples = 300; //number of energy deltas between long & short average to sum together
private int _beatAverageSamples = 100;
private int _beatCounterArraySamples = 400;
private int _maxTime = 200;
private float _predictiveInfluenceConstant = 0.1f;
private float _predictiveInfluence;
private int _cyclePerBeatIntensity;
private float[][] _deltaArray;
private float[][] _shortAverageArray;
private float[][] _longAverageArray;
private float[] _globalAverageArray;
private int[] _beatCounterArray;
private int[] _beatSpread;
private int _beatCounterPosition;
private int _cyclesPerBeat;
private int _longPosition;
private int _shortPosition;
private int _deltaPosition;
private int[] _count;
private float[] _totalLong;
private float[] _totalShort;
private float[] _delta;
private float[] _c;
private int _beat;
private int _beatCounter;
private float[] _beatAverage;
private float _totalBeat;
private int _beatPosition;
private float _totalGlobal;
private float _threshold;
private float _standardDeviation;
public IConfiguration Configuration => _configuration; public IConfiguration Configuration => _configuration;
public float[] VisualizationData { get; } = new float[1]; public float[] VisualizationData { get; } = new float[1];
public string DisplayName => "Beat";
public RGBDeviceType VisualizerFor => (RGBDeviceType)0xFF;
#endregion #endregion
#region Constructors #region Constructors
@ -81,181 +41,30 @@ namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
public override void Initialize() public override void Initialize()
{ {
_deltaArray = new float[_deltaArraySamples][]; _history = new RingBuffer[64];
for (int i = 0; i < _deltaArray.Length; i++) for (int i = 0; i < _history.Length; i++)
_deltaArray[i] = new float[_beatBands]; _history[i] = new RingBuffer(32);
_shortAverageArray = new float[_shortTermAverageSamples][];
for (int i = 0; i < _shortAverageArray.Length; i++)
_shortAverageArray[i] = new float[_beatBands];
_longAverageArray = new float[_longTermAverageSamples / _shortTermAverageSamples][];
for (int i = 0; i < _longAverageArray.Length; i++)
_longAverageArray[i] = new float[_beatBands];
_globalAverageArray = new float[_longTermAverageSamples];
_beatCounterArray = new int[_beatCounterArraySamples];
_beatSpread = new int[_maxTime];
_count = new int[_beatBands];
_totalLong = new float[_beatBands];
_totalShort = new float[_beatBands];
_delta = new float[_beatBands];
_c = new float[_beatBands]; //multiplier used to determain threshold
_beatAverage = new float[_beatAverageSamples];
} }
public override void Update() public override void Update()
{ {
ISpectrum spectrum = _specturProvider.GetLogarithmicSpectrum(60, minFrequency: 60); VisualizationData[0] = 0;
if (_shortPosition >= _shortTermAverageSamples) _shortPosition = 0; //Resets incremental variables ISpectrum spectrum = _specturProvider.GetLogarithmicSpectrum(64);
if (_longPosition >= (_longTermAverageSamples / _shortTermAverageSamples)) _longPosition = 0; for (int i = 0; i < 32; i++)
if (_deltaPosition >= _deltaArraySamples) _deltaPosition = 0;
if (_beatPosition >= _beatAverageSamples) _beatPosition = 0;
/////////////////////////////////////Calculate short and long term array averages///////////////////////////////////////////////////////////////////////////////////////////////////////////
for (int i = 0; i < _beatBands; i++)
{ {
_shortAverageArray[_shortPosition][i] = spectrum[i].Average; //stores the average intensity between the freq. bounds to the short term array float currentEnergy = spectrum[i].Average;
_totalLong[i] = 0; float averageEnergy = _history[i].Average;
_totalShort[i] = 0; _history[i].Put(currentEnergy);
for (int j = 0; j < (_longTermAverageSamples / _shortTermAverageSamples); j++)
_totalLong[i] += _longAverageArray[j][i]; //adds up all the values in both of these arrays, for averaging
for (int j = 0; j < _shortTermAverageSamples; j++)
_totalShort[i] += _shortAverageArray[j][i];
}
///////////////////////////////////////////Find wideband frequency average intensity///////////////////////////////////////////////////////////////////////////////////////////////////// if (currentEnergy > (35 * averageEnergy))
_totalGlobal = 0;
_globalAverageArray[_longPosition] = spectrum[0, 2000].Average(x => x.Average);
for (int j = 0; j < _longTermAverageSamples; j++)
_totalGlobal += _globalAverageArray[j];
_totalGlobal = _totalGlobal / _longTermAverageSamples;
//////////////////////////////////Populate long term average array//////////////////////////////////////////////////////////////////////////////////////////////////////////////
if ((_shortPosition % _shortTermAverageSamples) == 0)
{ //every time the short array is completely new it is added to long array
for (int i = 0; i < _beatBands; i++)
_longAverageArray[_longPosition][i] = _totalShort[i]; //increases speed of program, but is the same as if each individual value was stored in long array
_longPosition++;
}
/////////////////////////////////////////Find index of variation for each band///////////////////////////////////////////////////////////////////////////////////////////////////////
for (int i = 0; i < _beatBands; i++)
{
_totalLong[i] = _totalLong[i] / (float)_longTermAverageSamples / (float)_shortTermAverageSamples;
_delta[i] = 0;
_deltaArray[_deltaPosition][i] = (float)Math.Pow(Math.Abs(_totalLong[i] - _totalShort[i]), 2);
for (int j = 0; j < _deltaArraySamples; j++)
_delta[i] += _deltaArray[j][i];
_delta[i] /= _deltaArraySamples;
///////////////////////////////////////////Find local beats/////////////////////////////////////////////////////////////////////////////////////////////////////
_c[i] = (float)((1.3 + MathHelper.Clamp(Map(_delta[i], 0, 3000, 0, 0.4), 0, 0.4) //delta is usually bellow 2000
+ Map(MathHelper.Clamp(Math.Pow(_totalLong[i], 0.5), 0, 6), 0, 20, 0.3, 0) //possibly comment this out, adds weight to the lower end
+ Map(MathHelper.Clamp(_count[i], 0, 15), 0, 15, 1, 0))
- Map(MathHelper.Clamp(_count[i], 30, 200), 30, 200, 0, 0.75));
if ((_cyclePerBeatIntensity / _standardDeviation) > 3.5)
{ {
_predictiveInfluence = (float)(_predictiveInfluenceConstant * (1 - (Math.Cos(_beatCounter * (Math.PI * Math.PI)) / _cyclesPerBeat))); VisualizationData[0] = 1;
_predictiveInfluence *= (float)Map(MathHelper.Clamp(_cyclePerBeatIntensity / _standardDeviation, 3.5, 20), 3.5, 15, 1, 6); break;
if (_cyclesPerBeat > 10)
_c[i] += _predictiveInfluence;
} }
} }
_beat = 0;
for (int i = 0; i < _beatBands; i++)
{
if ((_totalShort[i] > (_totalLong[i] * _c[i])) & (_count[i] > 7))
{ //If beat is detected
if ((_count[i] > 12) & (_count[i] < 200))
{
_beatCounterArray[_beatCounterPosition % _beatCounterArraySamples] = _count[i];
_beatCounterPosition++;
}
_count[i] = 0; //resets counter
}
}
/////////////////////////////////////////Figure out # of beats, and average///////////////////////////////////////////////////////////////////////////////////////////////////////
for (int i = 0; i < _beatBands; i++)
if (_count[i] < 2)
_beat++; //If there has been a recent beat in a band add to the global beat value
_beatAverage[_beatPosition] = _beat;
for (int j = 0; j < _beatAverageSamples; j++)
_totalBeat += _beatAverage[j];
_totalBeat = _totalBeat / _beatAverageSamples;
/////////////////////////////////////////////////find global beat///////////////////////////////////////////////////////////////////////////////////////////////
_c[0] = (float)(3.25 + Map(MathHelper.Clamp(_beatCounter, 0, 5), 0, 5, 5, 0));
if (_cyclesPerBeat > 10)
_c[0] = (float)(_c[0] + (0.75 * (1 - (Math.Cos(_beatCounter * (Math.PI * Math.PI)) / _cyclesPerBeat))));
_threshold = (float)MathHelper.Clamp((_c[0] * _totalBeat) + Map(MathHelper.Clamp(_totalGlobal, 0, 2), 0, 2, 4, 0), 5, 1000);
if ((_beat > _threshold) & (_beatCounter > 5))
{
VisualizationData[0] = 1;
_beatCounter = 0;
}
else
VisualizationData[0] = 0;
/////////////////////////////////////////////////////Calculate beat spreads///////////////////////////////////////////////////////////////////////////////////////////
//average = beatCounterArraySamples/200 !!!
for (int i = 0; i < _maxTime; i++)
_beatSpread[i] = 0;
for (int i = 0; i < _beatCounterArraySamples; i++)
_beatSpread[_beatCounterArray[i]]++;
_cyclesPerBeat = Mode(_beatCounterArray);
if (_cyclesPerBeat < 20)
_cyclesPerBeat *= 2;
_cyclePerBeatIntensity = _beatSpread.Max();
_standardDeviation = 0;
for (int i = 0; i < _maxTime; i++)
_standardDeviation += (float)Math.Pow((_beatCounterArraySamples / _maxTime) - _beatSpread[i], 2);
_standardDeviation = (float)Math.Pow(_standardDeviation / _maxTime, 0.5);
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
_shortPosition++;
_deltaPosition++;
for (int i = 0; i < _beatBands; i++) _count[i]++;
_beatCounter++;
_beatPosition++;
} }
private int Mode(int[] array)
{
int[] modeMap = new int[array.Length];
int maxEl = array[0];
int maxCount = 1;
for (int i = 0; i < array.Length; i++)
{
int el = array[i];
if (modeMap[el] == 0)
modeMap[el] = 1;
else
modeMap[el]++;
if (modeMap[el] > maxCount)
{
maxEl = el;
maxCount = modeMap[el];
}
}
return maxEl;
}
private static double Map(double value, double oldMin, double oldMax, double newMin, double newMax) => newMin + ((newMax - newMin) * ((value - oldMin) / (oldMax - oldMin)));
#endregion #endregion
} }
} }

View File

@ -3,7 +3,6 @@ using System.Linq;
using KeyboardAudioVisualizer.AudioCapture; using KeyboardAudioVisualizer.AudioCapture;
using KeyboardAudioVisualizer.Configuration; using KeyboardAudioVisualizer.Configuration;
using KeyboardAudioVisualizer.Helper; using KeyboardAudioVisualizer.Helper;
using RGB.NET.Core;
namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
{ {
@ -63,10 +62,6 @@ namespace KeyboardAudioVisualizer.AudioProcessing.VisualizationProvider
public IConfiguration Configuration => _configuration; public IConfiguration Configuration => _configuration;
public float[] VisualizationData { get; } = new float[3]; public float[] VisualizationData { get; } = new float[3];
public string DisplayName => "Level";
public RGBDeviceType VisualizerFor => RGBDeviceType.Keyboard | RGBDeviceType.LedMatrix | RGBDeviceType.LedStripe | RGBDeviceType.Mousepad;
#endregion #endregion
#region Constructors #region Constructors

View File

@ -4,12 +4,12 @@ using System.Windows.Controls;
namespace KeyboardAudioVisualizer.Controls namespace KeyboardAudioVisualizer.Controls
{ {
public class Formular : Panel public class Form : Panel
{ {
#region DependencyProperties #region DependencyProperties
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
public static readonly DependencyProperty RowHeightProperty = DependencyProperty.Register("RowHeight", typeof(double), typeof(Formular), public static readonly DependencyProperty RowHeightProperty = DependencyProperty.Register("RowHeight", typeof(double), typeof(Form),
new FrameworkPropertyMetadata(24.0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); new FrameworkPropertyMetadata(24.0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
public double RowHeight public double RowHeight
@ -22,7 +22,7 @@ namespace KeyboardAudioVisualizer.Controls
} }
} }
public static readonly DependencyProperty LabelWidthProperty = DependencyProperty.Register("LabelWidth", typeof(double), typeof(Formular), public static readonly DependencyProperty LabelWidthProperty = DependencyProperty.Register("LabelWidth", typeof(double), typeof(Form),
new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); new FrameworkPropertyMetadata(100.0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
public double LabelWidth public double LabelWidth
@ -35,7 +35,7 @@ namespace KeyboardAudioVisualizer.Controls
} }
} }
public static readonly DependencyProperty ElementSpacingProperty = DependencyProperty.Register("ElementSpacing", typeof(double), typeof(Formular), public static readonly DependencyProperty ElementSpacingProperty = DependencyProperty.Register("ElementSpacing", typeof(double), typeof(Form),
new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
public double ElementSpacing public double ElementSpacing
@ -44,7 +44,7 @@ namespace KeyboardAudioVisualizer.Controls
set => SetValue(ElementSpacingProperty, value); set => SetValue(ElementSpacingProperty, value);
} }
public static readonly DependencyProperty RowSpacingProperty = DependencyProperty.Register("RowSpacing", typeof(double), typeof(Formular), public static readonly DependencyProperty RowSpacingProperty = DependencyProperty.Register("RowSpacing", typeof(double), typeof(Form),
new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); new FrameworkPropertyMetadata(default(double), FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
public double RowSpacing public double RowSpacing
@ -59,25 +59,25 @@ namespace KeyboardAudioVisualizer.Controls
#region AttachedProperties #region AttachedProperties
// ReSharper disable InconsistentNaming // ReSharper disable InconsistentNaming
public static readonly DependencyProperty IsLabelProperty = DependencyProperty.RegisterAttached("IsLabel", typeof(bool), typeof(Formular), public static readonly DependencyProperty IsLabelProperty = DependencyProperty.RegisterAttached("IsLabel", typeof(bool), typeof(Form),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
public static void SetIsLabel(UIElement element, bool value) => element.SetValue(IsLabelProperty, value); public static void SetIsLabel(UIElement element, bool value) => element.SetValue(IsLabelProperty, value);
public static bool GetIsLabel(UIElement element) => (bool)element.GetValue(IsLabelProperty); public static bool GetIsLabel(UIElement element) => (bool)element.GetValue(IsLabelProperty);
public static readonly DependencyProperty LineBreaksProperty = DependencyProperty.RegisterAttached("LineBreaks", typeof(int), typeof(Formular), public static readonly DependencyProperty LineBreaksProperty = DependencyProperty.RegisterAttached("LineBreaks", typeof(int), typeof(Form),
new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); new FrameworkPropertyMetadata(0, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
public static void SetLineBreaks(UIElement element, int value) => element.SetValue(LineBreaksProperty, value); public static void SetLineBreaks(UIElement element, int value) => element.SetValue(LineBreaksProperty, value);
public static int GetLineBreaks(UIElement element) => (int)element.GetValue(LineBreaksProperty); public static int GetLineBreaks(UIElement element) => (int)element.GetValue(LineBreaksProperty);
public static readonly DependencyProperty RowSpanProperty = DependencyProperty.RegisterAttached("RowSpan", typeof(int), typeof(Formular), public static readonly DependencyProperty RowSpanProperty = DependencyProperty.RegisterAttached("RowSpan", typeof(int), typeof(Form),
new FrameworkPropertyMetadata(1, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); new FrameworkPropertyMetadata(1, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
public static void SetRowSpan(DependencyObject element, int value) => element.SetValue(RowSpanProperty, value); public static void SetRowSpan(DependencyObject element, int value) => element.SetValue(RowSpanProperty, value);
public static int GetRowSpan(DependencyObject element) => (int)element.GetValue(RowSpanProperty); public static int GetRowSpan(DependencyObject element) => (int)element.GetValue(RowSpanProperty);
public static readonly DependencyProperty FillProperty = DependencyProperty.RegisterAttached("Fill", typeof(bool), typeof(Formular), public static readonly DependencyProperty FillProperty = DependencyProperty.RegisterAttached("Fill", typeof(bool), typeof(Form),
new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure)); new FrameworkPropertyMetadata(false, FrameworkPropertyMetadataOptions.AffectsArrange | FrameworkPropertyMetadataOptions.AffectsMeasure));
public static void SetFill(DependencyObject element, bool value) => element.SetValue(FillProperty, value); public static void SetFill(DependencyObject element, bool value) => element.SetValue(FillProperty, value);
@ -92,7 +92,7 @@ namespace KeyboardAudioVisualizer.Controls
{ {
if (InternalChildren.Count == 0) return new Size(0, 0); if (InternalChildren.Count == 0) return new Size(0, 0);
FormularLayout layout = new FormularLayout(RowHeight, LabelWidth, ElementSpacing, RowSpacing); FormLayout layout = new FormLayout(RowHeight, LabelWidth, ElementSpacing, RowSpacing);
foreach (UIElement child in InternalChildren) foreach (UIElement child in InternalChildren)
{ {
@ -107,7 +107,7 @@ namespace KeyboardAudioVisualizer.Controls
{ {
if (InternalChildren.Count == 0) return new Size(0, 0); if (InternalChildren.Count == 0) return new Size(0, 0);
FormularLayout layout = new FormularLayout(RowHeight, LabelWidth, ElementSpacing, RowSpacing); FormLayout layout = new FormLayout(RowHeight, LabelWidth, ElementSpacing, RowSpacing);
foreach (UIElement child in InternalChildren) foreach (UIElement child in InternalChildren)
child.Arrange(layout.AddElement(child, finalSize.Width)); child.Arrange(layout.AddElement(child, finalSize.Width));
@ -119,7 +119,7 @@ namespace KeyboardAudioVisualizer.Controls
#region Data #region Data
private class FormularLayout private class FormLayout
{ {
#region Properties & Fields #region Properties & Fields
@ -140,7 +140,7 @@ namespace KeyboardAudioVisualizer.Controls
#region Constructors #region Constructors
public FormularLayout(double rowHeight, double labelWidth, double elementSpacing, double rowSpacing) public FormLayout(double rowHeight, double labelWidth, double elementSpacing, double rowSpacing)
{ {
this._rowHeight = rowHeight; this._rowHeight = rowHeight;
this._labelWidth = labelWidth; this._labelWidth = labelWidth;

View File

@ -0,0 +1,68 @@
using System.Linq;
namespace KeyboardAudioVisualizer.Helper
{
public class RingBuffer
{
#region Properties & Fields
private readonly int _capacity;
private readonly float[] _buffer;
private int _currentIndex;
public int Size => _capacity;
public float Average => _buffer.Average();
public float Min => _buffer.Min();
public float Max => _buffer.Max();
public float Sum => _buffer.Sum();
#endregion
#region Constructors
public RingBuffer(int capacity)
{
this._capacity = capacity;
_buffer = new float[capacity];
}
#endregion
#region Methods
public void Put(float value) => Put(new[] { value }, 0, 1);
public void Put(float[] src, int offset, int count)
{
lock (_buffer)
{
if (count > _capacity)
{
offset += count - _capacity;
count = _capacity;
}
for (int i = 0; i < count; i++)
{
_currentIndex++;
if (_currentIndex >= _capacity) _currentIndex = 0;
_buffer[_currentIndex] = src[offset + i];
}
}
}
public void CopyInto(ref float[] data, int offset) => CopyInto(ref data, offset, _capacity);
public void CopyInto(ref float[] data, int offset, int count)
{
lock (_buffer)
for (int i = _capacity - count; i < count; i++)
data[offset + i] = _buffer[(_currentIndex + i) % _capacity];
}
#endregion
}
}

View File

@ -149,7 +149,7 @@
<Compile Include="Configuration\AbstractConfiguration.cs" /> <Compile Include="Configuration\AbstractConfiguration.cs" />
<Compile Include="Configuration\EqualizerConfiguration.cs" /> <Compile Include="Configuration\EqualizerConfiguration.cs" />
<Compile Include="Configuration\IConfiguration.cs" /> <Compile Include="Configuration\IConfiguration.cs" />
<Compile Include="Controls\Formular.cs" /> <Compile Include="Controls\Form.cs" />
<Compile Include="Controls\ImageButton.cs" /> <Compile Include="Controls\ImageButton.cs" />
<Compile Include="Converter\BoolToVisibilityConverter.cs" /> <Compile Include="Converter\BoolToVisibilityConverter.cs" />
<Compile Include="Converter\EqualizerBandsToPointsConverter.cs" /> <Compile Include="Converter\EqualizerBandsToPointsConverter.cs" />
@ -162,6 +162,7 @@
<Compile Include="Helper\FrequencyHelper.cs" /> <Compile Include="Helper\FrequencyHelper.cs" />
<Compile Include="Helper\MathHelper.cs" /> <Compile Include="Helper\MathHelper.cs" />
<Compile Include="Helper\ObservableDictionary.cs" /> <Compile Include="Helper\ObservableDictionary.cs" />
<Compile Include="Helper\RingBuffer.cs" />
<Compile Include="Helper\VisualizationIndex.cs" /> <Compile Include="Helper\VisualizationIndex.cs" />
<Compile Include="Helper\WPFHelper.cs" /> <Compile Include="Helper\WPFHelper.cs" />
<Compile Include="Configuration\Settings.cs" /> <Compile Include="Configuration\Settings.cs" />
@ -256,7 +257,7 @@
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>
<Page Include="Styles\Formular.xaml"> <Page Include="Styles\Form.xaml">
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType> <SubType>Designer</SubType>
</Page> </Page>

View File

@ -8,7 +8,7 @@
<styles:CachedResourceDictionary.MergedDictionaries> <styles:CachedResourceDictionary.MergedDictionaries>
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/BlurredDecorationWindow.xaml" /> <styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/BlurredDecorationWindow.xaml" />
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/ImageButton.xaml" /> <styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/ImageButton.xaml" />
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/Formular.xaml" /> <styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/Form.xaml" />
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/GroupBox.xaml" /> <styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/GroupBox.xaml" />
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/ToolTip.xaml" /> <styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/ToolTip.xaml" />
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/ComboBox.xaml" /> <styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/ComboBox.xaml" />
@ -22,7 +22,7 @@
<Style TargetType="{x:Type controls:BlurredDecorationWindow}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" /> <Style TargetType="{x:Type controls:BlurredDecorationWindow}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" />
<Style TargetType="{x:Type ui:ConfigurationWindow}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" /> <Style TargetType="{x:Type ui:ConfigurationWindow}" BasedOn="{StaticResource StyleBlurredDecorationWindow}" />
<Style TargetType="{x:Type controls:ImageButton}" BasedOn="{StaticResource StyleImageButton}" /> <Style TargetType="{x:Type controls:ImageButton}" BasedOn="{StaticResource StyleImageButton}" />
<Style TargetType="{x:Type controls:Formular}" BasedOn="{StaticResource StyleFormular}" /> <Style TargetType="{x:Type controls:Form}" BasedOn="{StaticResource StyleForm}" />
<Style TargetType="GroupBox" BasedOn="{StaticResource StyleGroupBoxBox}" /> <Style TargetType="GroupBox" BasedOn="{StaticResource StyleGroupBoxBox}" />
<Style TargetType="ToolTip" BasedOn="{StaticResource StyleToolTip}" /> <Style TargetType="ToolTip" BasedOn="{StaticResource StyleToolTip}" />
<Style TargetType="ComboBox" BasedOn="{StaticResource StyleComboBox}" /> <Style TargetType="ComboBox" BasedOn="{StaticResource StyleComboBox}" />

View File

@ -7,9 +7,9 @@
<styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/FrameworkElement.xaml" /> <styles:CachedResourceDictionary Source="/KeyboardAudioVisualizer;component/Styles/FrameworkElement.xaml" />
</styles:CachedResourceDictionary.MergedDictionaries> </styles:CachedResourceDictionary.MergedDictionaries>
<Style x:Key="StyleFormular" <Style x:Key="StyleForm"
BasedOn="{StaticResource StyleFrameworkElement}" BasedOn="{StaticResource StyleFrameworkElement}"
TargetType="{x:Type controls:Formular}"> TargetType="{x:Type controls:Form}">
<Setter Property="VerticalAlignment" Value="Top" /> <Setter Property="VerticalAlignment" Value="Top" />
<Setter Property="HorizontalAlignment" Value="Stretch" /> <Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="LabelWidth" Value="112" /> <Setter Property="LabelWidth" Value="112" />
@ -17,7 +17,7 @@
<Setter Property="RowSpacing" Value="8" /> <Setter Property="RowSpacing" Value="8" />
</Style> </Style>
<Style x:Key="StyleLabelFormular" <Style x:Key="StyleLabelForm"
TargetType="Label"> TargetType="Label">
<Setter Property="Foreground" Value="{StaticResource BrushForeground}" /> <Setter Property="Foreground" Value="{StaticResource BrushForeground}" />
<Setter Property="FontSize" Value="{StaticResource FontSizeDefault}" /> <Setter Property="FontSize" Value="{StaticResource FontSizeDefault}" />
@ -44,7 +44,7 @@
</Setter> </Setter>
</Style> </Style>
<Style x:Key="StyleTextBlockFormular" <Style x:Key="StyleTextBlockForm"
TargetType="TextBlock"> TargetType="TextBlock">
<Setter Property="Foreground" Value="{StaticResource BrushForeground}" /> <Setter Property="Foreground" Value="{StaticResource BrushForeground}" />
<Setter Property="FontSize" Value="{StaticResource FontSizeDefault}" /> <Setter Property="FontSize" Value="{StaticResource FontSizeDefault}" />
@ -53,7 +53,7 @@
<Setter Property="TextAlignment" Value="Left" /> <Setter Property="TextAlignment" Value="Left" />
</Style> </Style>
<Style x:Key="StyleListBoxItemFormular" <Style x:Key="StyleListBoxItemForm"
TargetType="ListBoxItem"> TargetType="ListBoxItem">
<Setter Property="MinWidth" Value="0" /> <Setter Property="MinWidth" Value="0" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" />
@ -77,7 +77,7 @@
</Setter> </Setter>
</Style> </Style>
<Style x:Key="StyleListBoxFormular" <Style x:Key="StyleListBoxForm"
TargetType="ListBox"> TargetType="ListBox">
<Setter Property="Focusable" Value="False" /> <Setter Property="Focusable" Value="False" />
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" /> <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Disabled" />
@ -92,7 +92,7 @@
<Setter Property="VerticalAlignment" Value="Stretch" /> <Setter Property="VerticalAlignment" Value="Stretch" />
<Setter Property="Background" Value="Transparent" /> <Setter Property="Background" Value="Transparent" />
<Setter Property="BorderThickness" Value="0" /> <Setter Property="BorderThickness" Value="0" />
<Setter Property="ItemContainerStyle" Value="{StaticResource StyleListBoxItemFormular}" /> <Setter Property="ItemContainerStyle" Value="{StaticResource StyleListBoxItemForm}" />
</Style> </Style>
</styles:CachedResourceDictionary> </styles:CachedResourceDictionary>

View File

@ -13,14 +13,14 @@
<DataTemplate DataType="{x:Type visualizationProvider:BeatVisualizationProviderConfiguration}"> <DataTemplate DataType="{x:Type visualizationProvider:BeatVisualizationProviderConfiguration}">
<Grid> <Grid>
<Grid.Resources> <Grid.Resources>
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" /> <Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" /> <Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" /> <Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
</Grid.Resources> </Grid.Resources>
<controls:Formular LabelWidth="240"> <controls:Form LabelWidth="240">
<Label controls:Formular.IsLabel="True" Content="No configuration available ..." /> <Label controls:Form.IsLabel="True" Content="No configuration available ..." />
</controls:Formular> </controls:Form>
</Grid> </Grid>
</DataTemplate> </DataTemplate>

View File

@ -14,9 +14,9 @@
<DataTemplate DataType="{x:Type visualizationProvider:FrequencyBarsVisualizationProviderConfiguration}"> <DataTemplate DataType="{x:Type visualizationProvider:FrequencyBarsVisualizationProviderConfiguration}">
<Grid> <Grid>
<Grid.Resources> <Grid.Resources>
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" /> <Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" /> <Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" /> <Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
<ObjectDataProvider x:Key="SpectrumModes" MethodName="GetValues" ObjectType="{x:Type system:Enum}"> <ObjectDataProvider x:Key="SpectrumModes" MethodName="GetValues" ObjectType="{x:Type system:Enum}">
<ObjectDataProvider.MethodParameters> <ObjectDataProvider.MethodParameters>
@ -39,62 +39,62 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<controls:Formular Grid.Column="0"> <controls:Form Grid.Column="0">
<Label controls:Formular.IsLabel="True" Content="Spectrum:" /> <Label controls:Form.IsLabel="True" Content="Spectrum:" />
<ComboBox controls:Formular.Fill="True" <ComboBox controls:Form.Fill="True"
ItemsSource="{Binding Source={StaticResource SpectrumModes}}" ItemsSource="{Binding Source={StaticResource SpectrumModes}}"
SelectedItem="{Binding SpectrumMode}" SelectedItem="{Binding SpectrumMode}"
ToolTip="Defines how the spectrum is grouped together.&#x0a; - Linear: Each bar represents the same range of frequencies.&#x0a; - Logarithmic: The higher the frequencies get the wider the range of grouped frequencies.&#x0a; - Gamma: Uses a configurable Gamma-Value to group the frequencies." /> ToolTip="Defines how the spectrum is grouped together.&#x0a; - Linear: Each bar represents the same range of frequencies.&#x0a; - Logarithmic: The higher the frequencies get the wider the range of grouped frequencies.&#x0a; - Gamma: Uses a configurable Gamma-Value to group the frequencies." />
<Label controls:Formular.IsLabel="True" Content="Value:" /> <Label controls:Form.IsLabel="True" Content="Value:" />
<ComboBox controls:Formular.Fill="True" <ComboBox controls:Form.Fill="True"
ItemsSource="{Binding Source={StaticResource ValueModes}}" ItemsSource="{Binding Source={StaticResource ValueModes}}"
SelectedItem="{Binding ValueMode}" SelectedItem="{Binding ValueMode}"
ToolTip="Defines how the value of a bar is calculated.&#x0a; - Sum: Sums the power of all frequencies grouped in the bar using all available data.&#x0a; - Max: Uses the maximum value in each group making sure peaks are caught well.&#x0a; - Average: Uses the average of all frequencies grouped in the bar. " /> ToolTip="Defines how the value of a bar is calculated.&#x0a; - Sum: Sums the power of all frequencies grouped in the bar using all available data.&#x0a; - Max: Uses the maximum value in each group making sure peaks are caught well.&#x0a; - Average: Uses the average of all frequencies grouped in the bar. " />
<Label controls:Formular.IsLabel="True" Content="Bars:" /> <Label controls:Form.IsLabel="True" Content="Bars:" />
<Slider controls:Formular.Fill="True" Minimum="1" Maximum="96" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" <Slider controls:Form.Fill="True" Minimum="1" Maximum="96" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight"
Value="{Binding Bars}" Value="{Binding Bars}"
ToolTip="The number of bars used to represent the spectrum.." /> ToolTip="The number of bars used to represent the spectrum.." />
</controls:Formular> </controls:Form>
<controls:Formular Grid.Column="2"> <controls:Form Grid.Column="2">
<Label controls:Formular.IsLabel="True" Content="Min Freq.:" /> <Label controls:Form.IsLabel="True" Content="Min Freq.:" />
<Slider controls:Formular.Fill="True" Minimum="0" Maximum="22100" IsSnapToTickEnabled="True" TickFrequency="10" TickPlacement="None" <Slider controls:Form.Fill="True" Minimum="0" Maximum="22100" IsSnapToTickEnabled="True" TickFrequency="10" TickPlacement="None"
Value="{Binding MinFrequency}" Value="{Binding MinFrequency}"
attached:SliderValue.Unit="Hz" attached:SliderValue.Unit="Hz"
ToolTip="The minimum frequency used in the graph." /> ToolTip="The minimum frequency used in the graph." />
<Label controls:Formular.IsLabel="True" Content="Max Freq.:" /> <Label controls:Form.IsLabel="True" Content="Max Freq.:" />
<Slider controls:Formular.Fill="True" Minimum="0" Maximum="22100" IsSnapToTickEnabled="True" TickFrequency="10" TickPlacement="None" <Slider controls:Form.Fill="True" Minimum="0" Maximum="22100" IsSnapToTickEnabled="True" TickFrequency="10" TickPlacement="None"
Value="{Binding MaxFrequency}" Value="{Binding MaxFrequency}"
attached:SliderValue.Unit="Hz" attached:SliderValue.Unit="Hz"
ToolTip="The maximum frequency used in the graph." /> ToolTip="The maximum frequency used in the graph." />
<Label controls:Formular.IsLabel="True" Content="Gamma:" /> <Label controls:Form.IsLabel="True" Content="Gamma:" />
<Slider controls:Formular.Fill="True" Minimum="1" Maximum="6" IsSnapToTickEnabled="True" TickFrequency="0.25" TickPlacement="BottomRight" <Slider controls:Form.Fill="True" Minimum="1" Maximum="6" IsSnapToTickEnabled="True" TickFrequency="0.25" TickPlacement="BottomRight"
IsEnabled="{Binding SpectrumMode, Converter={StaticResource EqualsToBoolConverter}, ConverterParameter={x:Static visualizationProvider:SpectrumMode.Gamma}}" IsEnabled="{Binding SpectrumMode, Converter={StaticResource EqualsToBoolConverter}, ConverterParameter={x:Static visualizationProvider:SpectrumMode.Gamma}}"
Value="{Binding Gamma}" Value="{Binding Gamma}"
ToolTip="Only used if 'Gamma' is selected as spectrum!&#x0a;Higher values cause more compression of high frequencies." /> ToolTip="Only used if 'Gamma' is selected as spectrum!&#x0a;Higher values cause more compression of high frequencies." />
</controls:Formular> </controls:Form>
<controls:Formular Grid.Column="4"> <controls:Form Grid.Column="4">
<Label controls:Formular.IsLabel="True" controls:Formular.LineBreaks="1" Content="Reference:" /> <Label controls:Form.IsLabel="True" controls:Form.LineBreaks="1" Content="Reference:" />
<Slider controls:Formular.Fill="True" Minimum="1" Maximum="240" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="None" <Slider controls:Form.Fill="True" Minimum="1" Maximum="240" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="None"
Value="{Binding ReferenceLevel}" Value="{Binding ReferenceLevel}"
attached:SliderValue.Unit="dB" attached:SliderValue.Unit="dB"
ToolTip="The reference value used to calculate the power of each bar.&#x0a;(You can read this as 'scaling')" /> ToolTip="The reference value used to calculate the power of each bar.&#x0a;(You can read this as 'scaling')" />
<Label controls:Formular.IsLabel="True" controls:Formular.LineBreaks="1" Content="Smoothing:" /> <Label controls:Form.IsLabel="True" controls:Form.LineBreaks="1" Content="Smoothing:" />
<Slider controls:Formular.Fill="True" Minimum="1" Maximum="10" IsSnapToTickEnabled="True" TickFrequency="0.5" TickPlacement="BottomRight" <Slider controls:Form.Fill="True" Minimum="1" Maximum="10" IsSnapToTickEnabled="True" TickFrequency="0.5" TickPlacement="BottomRight"
Value="{Binding Smoothing}" Value="{Binding Smoothing}"
ToolTip="Smooths the graph to prevent flickering.&#x0a;Low values will cause a hectic fast plot, high values a slow one without peaks." /> ToolTip="Smooths the graph to prevent flickering.&#x0a;Low values will cause a hectic fast plot, high values a slow one without peaks." />
<Label controls:Formular.IsLabel="True" controls:Formular.LineBreaks="1" Content="Emphasize:" /> <Label controls:Form.IsLabel="True" controls:Form.LineBreaks="1" Content="Emphasize:" />
<Slider controls:Formular.Fill="True" Minimum="0" Maximum="2" IsSnapToTickEnabled="True" TickFrequency="0.05" TickPlacement="BottomRight" <Slider controls:Form.Fill="True" Minimum="0" Maximum="2" IsSnapToTickEnabled="True" TickFrequency="0.05" TickPlacement="BottomRight"
Value="{Binding EmphasisePeaks}" Value="{Binding EmphasisePeaks}"
ToolTip="Emphasizes peaks. The higher the value, the bigger the difference between a 'loud-bar' and a 'quite-bar'." /> ToolTip="Emphasizes peaks. The higher the value, the bigger the difference between a 'loud-bar' and a 'quite-bar'." />
</controls:Formular> </controls:Form>
</Grid> </Grid>
</DataTemplate> </DataTemplate>

View File

@ -13,9 +13,9 @@
<DataTemplate DataType="{x:Type visualizationProvider:LevelVisualizationProviderConfiguration}"> <DataTemplate DataType="{x:Type visualizationProvider:LevelVisualizationProviderConfiguration}">
<Grid> <Grid>
<Grid.Resources> <Grid.Resources>
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" /> <Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" /> <Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" /> <Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
<ObjectDataProvider x:Key="ConversionModes" MethodName="GetValues" ObjectType="{x:Type system:Enum}"> <ObjectDataProvider x:Key="ConversionModes" MethodName="GetValues" ObjectType="{x:Type system:Enum}">
<ObjectDataProvider.MethodParameters> <ObjectDataProvider.MethodParameters>
@ -32,27 +32,27 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<controls:Formular Grid.Column="0"> <controls:Form Grid.Column="0">
<Label controls:Formular.IsLabel="True" Content="Calculation:" /> <Label controls:Form.IsLabel="True" Content="Calculation:" />
<ComboBox controls:Formular.Fill="True" <ComboBox controls:Form.Fill="True"
ItemsSource="{Binding Source={StaticResource ConversionModes}}" ItemsSource="{Binding Source={StaticResource ConversionModes}}"
SelectedItem="{Binding ConversionMode}" SelectedItem="{Binding ConversionMode}"
ToolTip="Defines how the RMS of the audio is plotted.&#x0a;Exponential has the widest range of peaks while linear has the least." /> ToolTip="Defines how the RMS of the audio is plotted.&#x0a;Exponential has the widest range of peaks while linear has the least." />
</controls:Formular> </controls:Form>
<controls:Formular Grid.Column="2"> <controls:Form Grid.Column="2">
<Label controls:Formular.IsLabel="True" Content="Scale:" /> <Label controls:Form.IsLabel="True" Content="Scale:" />
<Slider controls:Formular.Fill="True" Minimum="1" Maximum="20" IsSnapToTickEnabled="True" TickFrequency="0.5" TickPlacement="BottomRight" <Slider controls:Form.Fill="True" Minimum="1" Maximum="20" IsSnapToTickEnabled="True" TickFrequency="0.5" TickPlacement="BottomRight"
Value="{Binding Scale}" Value="{Binding Scale}"
ToolTip="Scales the whole graph." /> ToolTip="Scales the whole graph." />
</controls:Formular> </controls:Form>
<controls:Formular Grid.Column="4"> <controls:Form Grid.Column="4">
<Label controls:Formular.IsLabel="True" controls:Formular.LineBreaks="1" Content="Smoothing:" /> <Label controls:Form.IsLabel="True" controls:Form.LineBreaks="1" Content="Smoothing:" />
<Slider controls:Formular.Fill="True" Minimum="1" Maximum="10" IsSnapToTickEnabled="True" TickFrequency="0.5" TickPlacement="BottomRight" <Slider controls:Form.Fill="True" Minimum="1" Maximum="10" IsSnapToTickEnabled="True" TickFrequency="0.5" TickPlacement="BottomRight"
Value="{Binding Smoothing}" Value="{Binding Smoothing}"
ToolTip="Smooths the plot to prevent flickering.&#x0a;Low values will cause a hectic fast plot, high values a slow one without peaks." /> ToolTip="Smooths the plot to prevent flickering.&#x0a;Low values will cause a hectic fast plot, high values a slow one without peaks." />
</controls:Formular> </controls:Form>
</Grid> </Grid>
</DataTemplate> </DataTemplate>

View File

@ -56,21 +56,21 @@
<AdornerDecorator> <AdornerDecorator>
<DockPanel LastChildFill="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=Visualizations[(helper:VisualizationIndex)Primary], Converter={StaticResource VisualizationToLastChildFillConverter}}"> <DockPanel LastChildFill="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=Visualizations[(helper:VisualizationIndex)Primary], Converter={StaticResource VisualizationToLastChildFillConverter}}">
<GroupBox DockPanel.Dock="Top"> <GroupBox DockPanel.Dock="Top">
<controls:Formular> <controls:Form>
<controls:Formular.Resources> <controls:Form.Resources>
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" /> <Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" /> <Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" /> <Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
</controls:Formular.Resources> </controls:Form.Resources>
<Label controls:Formular.IsLabel="True" Content="Visualization: " /> <Label controls:Form.IsLabel="True" Content="Visualization: " />
<ComboBox controls:Formular.Fill="True" SelectedIndex="0" <ComboBox controls:Form.Fill="True" SelectedIndex="0"
ItemTemplate="{StaticResource DataTemplateVisualizationSelection}" ItemTemplate="{StaticResource DataTemplateVisualizationSelection}"
ItemsSource="{Binding Source={StaticResource DataProviderVisualizationTypes}, ItemsSource="{Binding Source={StaticResource DataProviderVisualizationTypes},
Converter={StaticResource VisualizationProviderSelectableConverter}, ConverterParameter={x:Static core:RGBDeviceType.Keyboard}}" Converter={StaticResource VisualizationProviderSelectableConverter}, ConverterParameter={x:Static core:RGBDeviceType.Keyboard}}"
SelectedItem="{Binding SelectedPrimaryVisualization}" SelectedItem="{Binding SelectedPrimaryVisualization}"
ToolTip="The visualization shown on the device.&#x0a; - Frequency Bars: Shows vertical bars representing the frequencies of the song.&#x0a; - Level: Shows two horizontal bars representing the loudness of the song (left and right).&#x0a; - Beat: Shows a flash to the beat of the song (this doesn't work too well right now :()" /> ToolTip="The visualization shown on the device.&#x0a; - Frequency Bars: Shows vertical bars representing the frequencies of the song.&#x0a; - Level: Shows two horizontal bars representing the loudness of the song (left and right).&#x0a; - Beat: Shows a flash to the beat of the song (this doesn't work too well right now :()" />
</controls:Formular> </controls:Form>
</GroupBox> </GroupBox>
<GroupBox Margin="0,8,0,0" DockPanel.Dock="Top"> <GroupBox Margin="0,8,0,0" DockPanel.Dock="Top">
@ -88,20 +88,20 @@
<AdornerDecorator> <AdornerDecorator>
<DockPanel LastChildFill="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=Visualizations[(helper:VisualizationIndex)Secondary], Converter={StaticResource VisualizationToLastChildFillConverter}}"> <DockPanel LastChildFill="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=Visualizations[(helper:VisualizationIndex)Secondary], Converter={StaticResource VisualizationToLastChildFillConverter}}">
<GroupBox DockPanel.Dock="Top"> <GroupBox DockPanel.Dock="Top">
<controls:Formular> <controls:Form>
<controls:Formular.Resources> <controls:Form.Resources>
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" /> <Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" /> <Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" /> <Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
</controls:Formular.Resources> </controls:Form.Resources>
<Label controls:Formular.IsLabel="True" Content="Visualization: " /> <Label controls:Form.IsLabel="True" Content="Visualization: " />
<ComboBox controls:Formular.Fill="True" SelectedIndex="0" <ComboBox controls:Form.Fill="True" SelectedIndex="0"
ItemTemplate="{StaticResource DataTemplateVisualizationSelection}" ItemTemplate="{StaticResource DataTemplateVisualizationSelection}"
ItemsSource="{Binding Source={StaticResource DataProviderVisualizationTypes}, ItemsSource="{Binding Source={StaticResource DataProviderVisualizationTypes},
Converter={StaticResource VisualizationProviderSelectableConverter}, ConverterParameter={x:Static core:RGBDeviceType.Mouse}}" Converter={StaticResource VisualizationProviderSelectableConverter}, ConverterParameter={x:Static core:RGBDeviceType.Mouse}}"
SelectedItem="{Binding SelectedSecondaryVisualization}" /> SelectedItem="{Binding SelectedSecondaryVisualization}" />
</controls:Formular> </controls:Form>
</GroupBox> </GroupBox>
<GroupBox Margin="0,8,0,0" DockPanel.Dock="Top"> <GroupBox Margin="0,8,0,0" DockPanel.Dock="Top">
@ -119,20 +119,20 @@
<AdornerDecorator> <AdornerDecorator>
<DockPanel LastChildFill="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=Visualizations[(helper:VisualizationIndex)Tertiary], Converter={StaticResource VisualizationToLastChildFillConverter}}"> <DockPanel LastChildFill="{Binding Source={x:Static keyboardAudioVisualizer:ApplicationManager.Instance}, Path=Visualizations[(helper:VisualizationIndex)Tertiary], Converter={StaticResource VisualizationToLastChildFillConverter}}">
<GroupBox DockPanel.Dock="Top"> <GroupBox DockPanel.Dock="Top">
<controls:Formular> <controls:Form>
<controls:Formular.Resources> <controls:Form.Resources>
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" /> <Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" /> <Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" /> <Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
</controls:Formular.Resources> </controls:Form.Resources>
<Label controls:Formular.IsLabel="True" Content="Visualization: " /> <Label controls:Form.IsLabel="True" Content="Visualization: " />
<ComboBox controls:Formular.Fill="True" SelectedIndex="0" <ComboBox controls:Form.Fill="True" SelectedIndex="0"
ItemTemplate="{StaticResource DataTemplateVisualizationSelection}" ItemTemplate="{StaticResource DataTemplateVisualizationSelection}"
ItemsSource="{Binding Source={StaticResource DataProviderVisualizationTypes}, ItemsSource="{Binding Source={StaticResource DataProviderVisualizationTypes},
Converter={StaticResource VisualizationProviderSelectableConverter}, ConverterParameter={x:Static core:RGBDeviceType.Mousepad}}" Converter={StaticResource VisualizationProviderSelectableConverter}, ConverterParameter={x:Static core:RGBDeviceType.Mousepad}}"
SelectedItem="{Binding SelectedTertiaryVisualization}" /> SelectedItem="{Binding SelectedTertiaryVisualization}" />
</controls:Formular> </controls:Form>
</GroupBox> </GroupBox>
<GroupBox Margin="0,8,0,0" DockPanel.Dock="Top"> <GroupBox Margin="0,8,0,0" DockPanel.Dock="Top">
@ -152,9 +152,9 @@
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
<Grid> <Grid>
<Grid.Resources> <Grid.Resources>
<Style BasedOn="{StaticResource StyleLabelFormular}" TargetType="Label" /> <Style BasedOn="{StaticResource StyleLabelForm}" TargetType="Label" />
<Style BasedOn="{StaticResource StyleTextBlockFormular}" TargetType="TextBlock" /> <Style BasedOn="{StaticResource StyleTextBlockForm}" TargetType="TextBlock" />
<Style BasedOn="{StaticResource StyleListBoxFormular}" TargetType="ListBox" /> <Style BasedOn="{StaticResource StyleListBoxForm}" TargetType="ListBox" />
</Grid.Resources> </Grid.Resources>
<Grid.ColumnDefinitions> <Grid.ColumnDefinitions>
@ -165,25 +165,25 @@
<ColumnDefinition Width="*" /> <ColumnDefinition Width="*" />
</Grid.ColumnDefinitions> </Grid.ColumnDefinitions>
<controls:Formular Grid.Column="0"> <controls:Form Grid.Column="0">
<Label controls:Formular.IsLabel="True" Content="Version:" /> <Label controls:Form.IsLabel="True" Content="Version:" />
<TextBlock Text="{Binding Version}" /> <TextBlock Text="{Binding Version}" />
<Label controls:Formular.IsLabel="True" Content="Update-Rate" /> <Label controls:Form.IsLabel="True" Content="Update-Rate" />
<Slider Minimum="1" Maximum="40" controls:Formular.Fill="True" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight" <Slider Minimum="1" Maximum="40" controls:Form.Fill="True" IsSnapToTickEnabled="True" TickFrequency="1" TickPlacement="BottomRight"
Value="{Binding UpdateRate}" Value="{Binding UpdateRate}"
attached:SliderValue.Unit="FPS" attached:SliderValue.Unit="FPS"
ToolTip="Defines how fast the data is updated.&#x0a;Low values can reduce CPU-usage but will cause stuttering." /> ToolTip="Defines how fast the data is updated.&#x0a;Low values can reduce CPU-usage but will cause stuttering." />
<Label controls:Formular.LineBreaks="1" controls:Formular.IsLabel="True" Content="Devices:" /> <Label controls:Form.LineBreaks="1" controls:Form.IsLabel="True" Content="Devices:" />
</controls:Formular> </controls:Form>
</Grid> </Grid>
<!-- TODO DarthAffe 05.08.2017: Fix the formular to support that use-case --> <!-- TODO DarthAffe 05.08.2017: Fix the formular to support that use-case -->
<ItemsControl VerticalAlignment="Top" HorizontalAlignment="Left" Margin="120,-22,0,0" ItemsSource="{Binding Source={x:Static core:RGBSurface.Instance}, Path=Devices}"> <ItemsControl VerticalAlignment="Top" HorizontalAlignment="Left" Margin="120,-22,0,0" ItemsSource="{Binding Source={x:Static core:RGBSurface.Instance}, Path=Devices}">
<ItemsControl.ItemTemplate> <ItemsControl.ItemTemplate>
<DataTemplate> <DataTemplate>
<TextBlock Style="{StaticResource StyleTextBlockFormular}"> <TextBlock Style="{StaticResource StyleTextBlockForm}">
<TextBlock.Text> <TextBlock.Text>
<MultiBinding StringFormat="> {0} {1} ({2})"> <MultiBinding StringFormat="> {0} {1} ({2})">
<Binding Path="DeviceInfo.Manufacturer" /> <Binding Path="DeviceInfo.Manufacturer" />