-
Notifications
You must be signed in to change notification settings - Fork 0
/
MidiNoteMappings.cs
58 lines (42 loc) · 1.52 KB
/
MidiNoteMappings.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Pillowsoft.GhostKeys
{
public class MidiNoteMappings : Dictionary<int, MidiNoteMapping>
{
public int? RequiredChannels { get; set; }
public int? MaxVelocity { get; set; }
public int? MinVelocity { get; set; }
public int MaxMidiDeltaTime { get; set; } = 0;
internal IEnumerable<int> GetGpioPins()
{
return this.Values.Select(x => x.RelayChannel.GpioPin);
}
public void WriteToConsole()
{
Console.WriteLine();
Console.WriteLine($"Required Number of Channels: {this.RequiredChannels}");
Console.WriteLine($"Max Velocity: {this.MaxVelocity?.ToString() ?? "N/A"}");
Console.WriteLine($"Min Velocity: {this.MinVelocity?.ToString() ?? "N/A"}");
Console.WriteLine($"Max Midi Delta Time: {this.MaxMidiDeltaTime }");
Console.WriteLine();
foreach (var (midiNote, mapping) in this)
{
Console.WriteLine($"CH {mapping.RelayChannel.RelayChannelNumber} = {mapping.NoteName} ({midiNote})");
}
Console.WriteLine();
}
}
public record MidiNoteMapping
{
public string? NoteName { get; init; }
public RelayChannel RelayChannel { get; }
public MidiNoteMapping(RelayChannel relayChannel)
{
this.RelayChannel = relayChannel;
}
}
}