Exemplo n.º 1
0
 unsafe void ConnectPorts(List <string> outlets, List <string> inlets)
 {
     for (int i = 0; i < Math.Min(outlets.Count, inlets.Count); i++)
     {
         PortApi.Connect(JackClient, outlets [i], inlets [i]);
     }
 }
Exemplo n.º 2
0
        unsafe UnsafeStructs.jack_port_t *RegisterPort(Direction direction, PortType portType)
        {
            var typeName = GetTypeName(portType);
            var flags    = GetJackPortFlags(direction);

            return(PortApi.Register(_jackClient, Name, typeName, flags, 0));
        }
Exemplo n.º 3
0
        protected unsafe List <PortReference> GetAllJackPorts()
        {
            IntPtr initialPorts        = PortApi.GetPorts(JackClient, null, null, 0);
            List <PortReference> ports = PortListFromPointer(initialPorts);

            Invoke.Free(initialPorts);
            return(ports);
        }
Exemplo n.º 4
0
 unsafe PortReference MapPort(uint portId)
 {
     UnsafeStructs.jack_port_t *portPointer = PortApi.GetPortById(JackClient, portId);
     if (portPointer == null)
     {
         return(null);
     }
     return(new PortReference(portPointer));
 }
Exemplo n.º 5
0
 unsafe PortReference MapPort(string portName)
 {
     UnsafeStructs.jack_port_t *portPointer = PortApi.GetPortByName(JackClient, portName);
     if (portPointer == null)
     {
         return(null);
     }
     return(new PortReference(portPointer));
 }
Exemplo n.º 6
0
 unsafe void Dispose(bool isDisposing)
 {
     if (_jackClient == null || _port == null)
     {
         return;
     }
     if (PortApi.Unregister(_jackClient, _port) == 0)
     {
         _jackClient = null;
         _port       = null;
     }
 }
Exemplo n.º 7
0
        internal unsafe PortReference(UnsafeStructs.jack_port_t *portPointer)
        {
            PortPointer = portPointer;
            FullName    = PortApi.GetName(portPointer).PtrToString();
            bool      isPhysicalPort;
            Direction direction;

            ReadJackPortFlags(portPointer, out direction, out isPhysicalPort);
            Direction      = direction;
            IsPhysicalPort = isPhysicalPort;
            PortType       = GetPortType(portPointer);
        }
Exemplo n.º 8
0
        internal static unsafe void WriteToJackMidi(this MidiEventCollection <MidiOutEvent> midiEvents, uint nframes)
        {
            float *portBuf = PortApi.GetBuffer(midiEvents.Port._port, nframes);

            MidiApi.ClearBuffer(portBuf);
            foreach (MidiOutEvent midiEvent in midiEvents)
            {
                byte *buffer = MidiApi.ReserveEvent(portBuf, (uint)midiEvent.Time, (uint)midiEvent.MidiData.Length);
                StructPointer <byte> bufferPointer = new StructPointer <byte> ((IntPtr)buffer, (uint)midiEvent.MidiData.Length);
                bufferPointer.Array = midiEvent.MidiData;
                bufferPointer.CopyToPointer();
            }
        }
Exemplo n.º 9
0
        static unsafe PortType GetPortType(UnsafeStructs.jack_port_t *portPointer)
        {
            string connectionTypeName = PortApi.GetType(portPointer).PtrToString();

            switch (connectionTypeName)
            {
            case Constants.JACK_DEFAULT_AUDIO_TYPE:
                return(PortType.Audio);

            case Constants.JACK_DEFAULT_MIDI_TYPE:
                return(PortType.Midi);
            }
            throw new IndexOutOfRangeException("jack_port_type");
        }
Exemplo n.º 10
0
        internal unsafe List <MidiInEvent> GetMidiEvents(uint nframes)
        {
            List <MidiInEvent> midiEvents = new List <MidiInEvent> ();

            IntPtr portBuffer = (IntPtr)PortApi.GetBuffer(_port, nframes);
            uint   eventCount = MidiApi.GetEventCount(portBuffer);

            for (uint i = 0; i < eventCount; i++)
            {
                UnsafeStructs.jack_midi_event_t inEvent;
                MidiApi.GetEvent(&inEvent, portBuffer, i);
                midiEvents.Add(new MidiInEvent(inEvent));
            }
            return(midiEvents);
        }
Exemplo n.º 11
0
        static unsafe void ReadJackPortFlags(UnsafeStructs.jack_port_t *portPointer, out Direction direction, out bool isPhysicalPort)
        {
            JackPortFlags portFlags = (JackPortFlags)PortApi.GetPortFlags(portPointer);

            isPhysicalPort = (portFlags & JackPortFlags.JackPortIsPhysical) == JackPortFlags.JackPortIsPhysical;
            if ((portFlags & JackPortFlags.JackPortIsInput) == JackPortFlags.JackPortIsInput)
            {
                direction = Direction.In;
                return;
            }
            if ((portFlags & JackPortFlags.JackPortIsOutput) == JackPortFlags.JackPortIsOutput)
            {
                direction = Direction.Out;
                return;
            }
            throw new IndexOutOfRangeException("jack_port_flags");
        }
Exemplo n.º 12
0
        unsafe void GetAndSendConnections(List <PortReference> allPorts)
        {
            // In ports are connected to out ports, so we only need to map these.
            foreach (PortReference port in allPorts.Where(p => p.Direction == Direction.Out))
            {
                IntPtr connectedPortNames           = PortApi.GetConnections(port.PortPointer);
                List <PortReference> connectedPorts = PortListFromPointer(connectedPortNames);

                if (ConnectionChanged != null)
                {
                    foreach (PortReference connected in connectedPorts)
                    {
                        ConnectionChanged(this, new ConnectionChangeEventArgs(port, connected, ChangeType.New));
                    }
                }
                Invoke.Free(connectedPortNames);
            }
        }
Exemplo n.º 13
0
        unsafe void AutoConnectPorts()
        {
            List <PortReference> ports = GetAllJackPorts().Where(p => p.IsPhysicalPort).ToList();

            List <string> outlets = ports.Where(p => p.Direction == Direction.Out && p.PortType == PortType.Audio).Select(p => p.FullName).ToList();
            List <string> inlets  = _audioInPorts.Select(p => PortApi.GetName(p._port).PtrToString()).ToList();

            ConnectPorts(outlets, inlets);

            outlets = _audioOutPorts.Select(p => PortApi.GetName(p._port).PtrToString()).ToList();
            inlets  = ports.Where(p => p.Direction == Direction.In && p.PortType == PortType.Audio).Select(p => p.FullName).ToList();
            ConnectPorts(outlets, inlets);

            outlets = ports.Where(p => p.Direction == Direction.Out && p.PortType == PortType.Midi).Select(p => p.FullName).ToList();
            inlets  = _midiInPorts.Select(p => PortApi.GetName(p._port).PtrToString()).ToList();
            ConnectPorts(outlets, inlets);

            outlets = _midiOutPorts.Select(p => PortApi.GetName(p._port).PtrToString()).ToList();
            inlets  = ports.Where(p => p.Direction == Direction.In && p.PortType == PortType.Midi).Select(p => p.FullName).ToList();
            ConnectPorts(outlets, inlets);
        }
Exemplo n.º 14
0
 public SetIntersightPortMacBinding()
 {
     ApiInstance = new PortApi(Config);
     ModelObject = new PortMacBinding();
     MethodName  = "UpdatePortMacBindingWithHttpInfo";
 }
Exemplo n.º 15
0
 /// <summary>
 /// Disconnect the specified outPort and inPort.
 /// </summary>
 /// <param name="outPort">Out port.</param>
 /// <param name="inPort">In port.</param>
 public bool Disconnect(PortReference outPort, PortReference inPort)
 {
     unsafe {
         return(PortApi.Disconnect(JackClient, outPort.FullName, inPort.FullName) == 0);
     }
 }
Exemplo n.º 16
0
 internal unsafe StructPointer <float> GetBuffer(uint nframes)
 {
     Debug.Assert(PortType == PortType.Audio);
     return(new StructPointer <float> ((IntPtr)PortApi.GetBuffer(_port, nframes), nframes));
 }
Exemplo n.º 17
0
 public SetIntersightPortSubGroup()
 {
     ApiInstance = new PortApi(Config);
     ModelObject = new PortSubGroup();
     MethodName  = "UpdatePortSubGroupWithHttpInfo";
 }
Exemplo n.º 18
0
 public GetIntersightPortMacBinding()
 {
     ApiInstance = new PortApi(Config);
     MethodName  = "GetPortMacBindingListWithHttpInfo";
 }
Exemplo n.º 19
0
 public GetIntersightPortSubGroup()
 {
     ApiInstance = new PortApi(Config);
     MethodName  = "GetPortSubGroupListWithHttpInfo";
 }