You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
46 lines
1.2 KiB
46 lines
1.2 KiB
// Author: Gockner, Simon
|
|
// Created: 2021-04-07
|
|
// Copyright(c) 2021 SimonG. All Rights Reserved.
|
|
|
|
using System;
|
|
using Lib.Audio.Controls.Interfaces;
|
|
using Lib.Driver.Xml;
|
|
|
|
namespace Lib.Audio.Controls
|
|
{
|
|
public class Fader : IFader
|
|
{
|
|
private const float MIN_POSITION = 0; //TODO: calibrate? get from driver?
|
|
private const float MAX_POSITION = 126; //16256; //TODO: calibrate? get from driver?
|
|
|
|
private int _position;
|
|
|
|
public Fader(XmlFader xmlFader)
|
|
{
|
|
NoteNumber = xmlFader.NoteNumber;
|
|
Controller = xmlFader.Controller;
|
|
}
|
|
|
|
public int NoteNumber { get; }
|
|
public byte Controller { get; }
|
|
|
|
public int Position
|
|
{
|
|
get => _position;
|
|
set
|
|
{
|
|
_position = value;
|
|
PositionChanged?.Invoke(this, _position);
|
|
}
|
|
}
|
|
|
|
public bool IsTouched { get; set; }
|
|
public float RelativePosition
|
|
{
|
|
get => Position / (MAX_POSITION - MIN_POSITION);
|
|
set => _position = (int) (value * (MAX_POSITION - MIN_POSITION));
|
|
}
|
|
|
|
public event EventHandler<int>? PositionChanged;
|
|
}
|
|
} |