Skip to content

"start_index + length > array length" with sample code #76

@jamesdlow

Description

@jamesdlow

I'm getting an error when I try to execute the sample code on macOS. I've tried running on iOS and it errors too. I've debugged and the output exists and I have its name/id. Any idea what the issue is?

Message:

start_index + length > array length
Parameter name: length

The exception is a System.ArgumentException

Stacktrace:

Parameter name: length
  at (wrapper managed-to-native) System.Runtime.InteropServices.Marshal.copy_to_unmanaged_fixed(System.Array,int,intptr,int,void*)
  at System.Runtime.InteropServices.Marshal.copy_to_unmanaged (System.Byte[] source, System.Int32 startIndex, System.IntPtr destination, System.Int32 length) [0x00009] in <a6df87efff2943d29ff8026b1ac9d2b4>:0 
  at System.Runtime.InteropServices.Marshal.Copy (System.Byte[] source, System.Int32 startIndex, System.IntPtr destination, System.Int32 length) [0x00009] in <a6df87efff2943d29ff8026b1ac9d2b4>:0 
  at CoreMidi.MidiPacket.CreatePacketList (CoreMidi.MidiPacket[] packets) [0x000c3] in <2735c8d44acc4ce5b6bc41d44dbdcd65>:0 
  at CoreMidi.MidiPort.Send (CoreMidi.MidiEndpoint endpoint, CoreMidi.MidiPacket[] packets) [0x00027] in <2735c8d44acc4ce5b6bc41d44dbdcd65>:0 
  at Commons.Music.Midi.CoreMidiApi.CoreMidiOutput.Send (System.Byte[] mevent, System.Int32 offset, System.Int32 length, System.Int64 timestamp) [0x00045] in <01d9a7dce4614f6abd73f7ca4c00c2ae>:0 
  at PadMIDI.App.Down_Clicked (System.Object sender, System.EventArgs e) [0x0006c] in <44638a4d7b7f4c21a78010334ae19de6>:0 

Code:

var access = MidiAccessManager.Default;
if (access.Outputs.Count() > 0) {
	var output = access.OpenOutputAsync(access.Outputs.Last().Id).Result;
	output.Send(new byte[] { MidiEvent.NoteOn, 0x40, 0x70 }, 0, 3, 0);
	output.CloseAsync();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions