コード例 #1
0
ファイル: MidiServices.cs プロジェクト: jorik041/maccore
		public MidiError Send (MidiEndpoint endpoint, MidiPacket [] packets)
		{
			if (endpoint == null)
				throw new ArgumentNullException ("endpoint");
			if (packets == null)
				throw new ArgumentNullException ("packets");
			var p = Midi.EncodePackets (packets);
			var code = MIDISend (handle, endpoint.handle, p);
			Marshal.FreeHGlobal (p);
			return code;
		}
コード例 #2
0
ファイル: MidiServices.cs プロジェクト: jorik041/maccore
		internal static IntPtr EncodePackets (MidiPacket [] packets)
		{
			int size = 4;
			for (int i = packets.Length; i > 0; i--){
				int plen = packets [i - 1].Length;
				plen = (plen + 3)&(~3);
				size += 8 + 4 + plen;
			}
			IntPtr buffer = Marshal.AllocHGlobal (size);
			Marshal.WriteInt32 (buffer, 0, packets.Length);
			int dest = 4;
			for (int i = 0; i < packets.Length; i++){
				Marshal.WriteInt64 (buffer, dest, packets [i].TimeStamp);
				dest += 8;
				Marshal.WriteInt16 (buffer, dest, (short) packets [i].Length);
				dest += 2;
				Midi.memcpy ((IntPtr)((long)buffer + dest), packets [i].Bytes, packets [i].Length);
				dest += (packets [i].Length+3)&(~3);
			}
			return buffer;
		}
コード例 #3
0
ファイル: MidiServices.cs プロジェクト: jorik041/maccore
		internal static MidiPacket [] ToPackets (IntPtr packetList)
		{
			int npackets = Marshal.ReadInt32 (packetList);
			int p = 4;
			var packets = new MidiPacket [npackets];
			for (int i = 0; i < npackets; i++){
				ushort len = (ushort) Marshal.ReadInt16 (p, 8);
				packets [i] = new MidiPacket (Marshal.ReadInt64 (packetList, p), len, (IntPtr)((long)packetList + 10));
				p += 10 + len;
			}
			return packets;
		}
コード例 #4
0
ファイル: MidiServices.cs プロジェクト: jorik041/maccore
		public MidiError Received (MidiPacket [] packets)
		{
			if (packets == null)
				throw new ArgumentNullException ("packets");

			var block = Midi.EncodePackets (packets);
			var code = MIDIReceived (handle, block);
			Marshal.FreeHGlobal (block);
			return code;
		}
コード例 #5
0
ファイル: MidiRouter.cs プロジェクト: cansik/midimodifier
 public void TransmitMidiData(MidiEndpoint endpoint, MidiMessage msg)
 {
     var packages = new MidiPacket[] { msg.ToMidiPacket () };
     outputPort.Send (endpoint, packages);
 }
コード例 #6
0
ファイル: MidiServices.cs プロジェクト: polipo/maccore
		internal static MidiPacket [] ToPackets (IntPtr packetList)
		{
			int npackets = Marshal.ReadInt32 (packetList);
			int p = 4;
			var packets = new MidiPacket [npackets];
			for (int i = 0; i < npackets; i++){
				ushort len = (ushort) Marshal.ReadInt16 (packetList, p+8);
				packets [i] = new MidiPacket (Marshal.ReadInt64 (packetList, p), len, (IntPtr)((long)packetList + p + 10));
#if !MONOMAC
				// MIDIPacket must be 4-byte aligned for ARM
				if (isDevice)
					p += (((10 + len) + 3) & ~3);
				else
#endif
					p += 10 + len;
			}
			return packets;
		}
コード例 #7
0
ファイル: MidiHandler.cs プロジェクト: cansik/midimodifier
 public void SendMidiMessage(MidiMessage msg)
 {
     var packages = new MidiPacket[] { msg.ToMidiPacket () };
     //endpoint.Received (packages);
     this.outputPort.Send (endpoint, packages);
 }