Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/CoreMidi/MidiServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
#nullable enable

using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using ObjCRuntime;
Expand Down Expand Up @@ -770,7 +771,7 @@ public class MidiPacket
#if !COREBUILD
public long TimeStamp;
IntPtr byteptr;
byte [] bytes = Array.Empty<byte> ();
byte []? bytes;
int start;
public ushort Length;

Expand Down Expand Up @@ -826,7 +827,7 @@ protected virtual void Dispose (bool disposing)
byteptr = IntPtr.Zero;
}

internal byte [] ByteArray {
internal byte []? ByteArray {
get { return bytes; }
}

Expand Down
47 changes: 47 additions & 0 deletions tests/monotouch-test/CoreMidi/MidiClientTest.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
//
// Unit tests for MidiClient
//
// Authors:
// Rolf Bjarne Kvinge <[email protected]>
//
// Copyright 2023 Microsoft Corp. All rights reserved.
//

#if !__TVOS__ && !__WATCHOS__
using System;
using System.Diagnostics;

using CoreMidi;
using Foundation;

using NUnit.Framework;

namespace MonoTouchFixtures.CoreMidi {
[TestFixture]
[Preserve (AllMembers = true)]
public class MidiClientTest {
[Test]
public void SendTest ()
{
if (Midi.DestinationCount <= 0)
Assert.Inconclusive ("No Midi Destinations");

using var ep = MidiEndpoint.GetDestination (0);
Assert.NotNull (ep, "EndPoint");

var mevent = new byte [] { 0x90, 0x40, 0x70 };
using var client = new MidiClient ($"outputclient-{Process.GetCurrentProcess ().Id}");
using var port = client.CreateOutputPort ($"outputport-{Process.GetCurrentProcess ().Id}");
unsafe {
fixed (byte* meventPtr = mevent) {
using var packet1 = new MidiPacket (0, (ushort) mevent.Length, (IntPtr) meventPtr);
using var packet2 = new MidiPacket (0, mevent);
using var packet3 = new MidiPacket (0, mevent, 0, mevent.Length);
var packets = new MidiPacket [] { packet1, packet2, packet3 };
port.Send (ep, packets);
}
}
}
}
}
#endif