예제 #1
0
        // [input device port] --> [RETURNED PORT] --> app handles messages
        AlsaPortInfo CreateInputConnectedPort(AlsaSequencer seq, AlsaPortInfo pinfo, string portName = "alsa-sharp input")
        {
            var portId = seq.CreateSimplePort(portName, input_connected_cap, midi_port_type);
            var sub    = new AlsaPortSubscription();

            sub.Destination.Client = (byte)seq.CurrentClientId;
            sub.Destination.Port   = (byte)portId;
            sub.Sender.Client      = (byte)pinfo.Client;
            sub.Sender.Port        = (byte)pinfo.Port;
            seq.SubscribePort(sub);
            return(seq.GetPort(sub.Destination.Client, sub.Destination.Port));
        }
예제 #2
0
        // app generates messages --> [RETURNED PORT] --> [output device port]
        AlsaPortInfo CreateOutputConnectedPort(AlsaPortInfo pinfo, string portName = "alsa-sharp output")
        {
            var portId = output.CreateSimplePort(portName, output_connected_cap, midi_port_type);
            var sub    = new AlsaPortSubscription();

            sub.Sender.Client      = (byte)output_client_id;
            sub.Sender.Port        = (byte)portId;
            sub.Destination.Client = (byte)pinfo.Client;
            sub.Destination.Port   = (byte)pinfo.Port;
            output.SubscribePort(sub);
            return(output.GetPort(sub.Sender.Client, sub.Sender.Port));
        }
예제 #3
0
 public void SubscribeUnsubscribePort()
 {
     using (var seq = new AlsaSequencer(AlsaIOType.Input, AlsaIOMode.NonBlocking)) {
         var subs = new AlsaPortSubscription();
         subs.Sender.Client      = AlsaSequencer.ClientSystem;
         subs.Sender.Port        = AlsaPortInfo.PortSystemAnnouncement;
         subs.Destination.Client = (byte)seq.CurrentClientId;
         subs.Destination.Port   = (byte)seq.CreateSimplePort("test in port", AlsaPortCapabilities.SubsRead | AlsaPortCapabilities.Read, AlsaPortType.MidiGeneric | AlsaPortType.Application);
         try {
             seq.SubscribePort(subs);
             foreach (var ppi in subs.GetType().GetProperties())
             {
                 TextWriter.Null.WriteLine($"    [{ppi}]\t{ppi.GetValue (subs)}");
             }
             seq.UnsubscribePort(subs);
         } finally {
             seq.DeleteSimplePort(subs.Destination.Port);
         }
     }
 }