This commit is contained in:
Philip Schell 2020-02-05 15:35:43 +01:00
parent 4966a0d1d8
commit 207b2ec5ec
8 changed files with 149 additions and 0 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
/.vs
/MidiTest/obj
/MidiTest/bin

25
MidiTest.sln Normal file
View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29519.87
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MidiTest", "MidiTest\MidiTest.csproj", "{97E33DEC-C501-48D2-9B95-88EE74E95F79}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{97E33DEC-C501-48D2-9B95-88EE74E95F79}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{97E33DEC-C501-48D2-9B95-88EE74E95F79}.Debug|Any CPU.Build.0 = Debug|Any CPU
{97E33DEC-C501-48D2-9B95-88EE74E95F79}.Release|Any CPU.ActiveCfg = Release|Any CPU
{97E33DEC-C501-48D2-9B95-88EE74E95F79}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {ED349F40-20F8-4E2B-82C3-4D31BB875F22}
EndGlobalSection
EndGlobal

9
MidiTest/App.xaml Normal file
View File

@ -0,0 +1,9 @@
<Application x:Class="MidiTest.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MidiTest"
StartupUri="MainWindow.xaml">
<Application.Resources>
</Application.Resources>
</Application>

15
MidiTest/App.xaml.cs Normal file
View File

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace MidiTest {
/// <summary>
/// Interaction logic for App.xaml
/// </summary>
public partial class App : Application {
}
}

34
MidiTest/MainWindow.xaml Normal file
View File

@ -0,0 +1,34 @@
<Window x:Class="MidiTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:MidiTest"
mc:Ignorable="d"
Title="MainWindow" Height="443" Width="497">
<Grid>
<Label Content="Midi-Device" HorizontalAlignment="Left" Margin="10,10,0,0" VerticalAlignment="Top"/>
<ComboBox x:Name="MidiSelector" HorizontalAlignment="Left" Margin="89,12,0,0" VerticalAlignment="Top" Width="300"/>
<Grid Margin="10,50,10,10">
<Ellipse HorizontalAlignment="Left" Height="40" Margin="10,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Ellipse HorizontalAlignment="Left" Height="40" Margin="60,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Ellipse HorizontalAlignment="Left" Height="40" Margin="110,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Ellipse HorizontalAlignment="Left" Height="40" Margin="160,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Ellipse HorizontalAlignment="Left" Height="40" Margin="210,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Ellipse HorizontalAlignment="Left" Height="40" Margin="260,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Ellipse HorizontalAlignment="Left" Height="40" Margin="310,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Ellipse HorizontalAlignment="Left" Height="40" Margin="360,10,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Rectangle HorizontalAlignment="Left" Height="40" Margin="10,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40" MouseDown="test" Fill="Black"/>
<Rectangle HorizontalAlignment="Left" Height="40" Margin="60,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Rectangle HorizontalAlignment="Left" Height="40" Margin="110,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Rectangle HorizontalAlignment="Left" Height="40" Margin="160,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Rectangle HorizontalAlignment="Left" Height="40" Margin="210,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Rectangle HorizontalAlignment="Left" Height="40" Margin="260,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Rectangle HorizontalAlignment="Left" Height="40" Margin="310,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Rectangle HorizontalAlignment="Left" Height="40" Margin="360,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
<Ellipse HorizontalAlignment="Left" Height="40" Margin="410,60,0,0" Stroke="Black" VerticalAlignment="Top" Width="40"/>
</Grid>
</Grid>
</Window>

View File

@ -0,0 +1,36 @@
using System;
using System.Windows;
using Commons.Music.Midi;
namespace MidiTest {
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window {
public MainWindow() {
this.InitializeComponent();
this.DetectMidi();
}
private void DetectMidi() {
IMidiAccess access = MidiAccessManager.Default;
foreach (IMidiPortDetails item in access.Outputs) {
_ = this.MidiSelector.Items.Add(new Tuple<String, String>(item.Manufacturer + " - " + item.Name, item.Id));
}
}
private void test(Object sender, System.Windows.Input.MouseButtonEventArgs e) {
IMidiOutput outp = MidiAccessManager.Default.OpenOutputAsync(((Tuple<String, String>)this.MidiSelector.SelectedItem).Item2).Result;
outp.Send(new Byte[] { 144, 81, 45 }, 0, 3, 0);
outp.Send(new Byte[] { 176, 106, 53 }, 0, 3, 0);
outp.Send(new Byte[] { 145, 11, 5 }, 0, 3, 0);
outp.Send(new Byte[] { 144, 12, 21 }, 0, 3, 0);
outp.Send(new Byte[] { 145, 12, 5 }, 0, 3, 0);
outp.Send(new Byte[] { 146, 88, 81 }, 0, 3, 0);
}
}
}

13
MidiTest/MidiTest.csproj Normal file
View File

@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.0</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="managed-midi" Version="1.9.13" />
</ItemGroup>
</Project>

View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup />
<ItemGroup>
<ApplicationDefinition Update="App.xaml">
<SubType>Designer</SubType>
</ApplicationDefinition>
</ItemGroup>
<ItemGroup>
<Page Update="MainWindow.xaml">
<SubType>Designer</SubType>
</Page>
</ItemGroup>
</Project>