Example #1
0
        public static void Initialize()
        {
            if (_init)
            {
                return;
            }
            //both midi in and midi out have the same ports
            uint portCount = MidiInput.GetPortCount();

            //check if there are no midi devices available
            if (portCount == 0)
            {
                //print warning
                Debug.LogError("MIDIOUT: No Midi Output Devices Found!");

                //leave
                return;
            }


            //setup output device handles
            OutPorts = new IntPtr[portCount];

            for (uint i = 0; i < portCount; i++)
            {
                OutPorts[i] = MidiInternal.rtmidi_out_create_default();
                MidiInternal.rtmidi_open_port(OutPorts[i], i, "LopeaMidi: Out " + i);
            }
            _handler           = new GameObject("Midi Output");
            _handler.hideFlags = HideFlags.HideInHierarchy;
            _handler.AddComponent <MidiOutput>();
            _init = true;
        }
Example #2
0
        //Inside this update function is the hotswapping support for MIDI output devices.
        void Update()
        {
            uint current = GetCurrentPortCount();

            if (current != portCount)
            {
                if (current == 0)
                {
                    Shutdown();
                }
                else
                {
                    for (int i = 0; i < OutPorts.Length; i++)
                    {
                        MidiInternal.rtmidi_out_free(OutPorts[i]);
                        OutPorts[i] = IntPtr.Zero;
                    }

                    count    = current;
                    OutPorts = new IntPtr[portCount];

                    for (uint i = 0; i < portCount; i++)
                    {
                        OutPorts[i] = MidiInternal.rtmidi_out_create_default();
                        MidiInternal.rtmidi_open_port(OutPorts[i], i, "LopeaMidi: Out " + i);
                    }
                }
            }
        }
Example #3
0
    // Start is called before the first frame update
    void Start()
    {
        circles = new List <CircleData>();
        circles.Add(new CircleData(0, center));
        ptr = MidiInternal.rtmidi_in_create_default();
        o   = MidiInternal.rtmidi_out_create_default();

        MidiInternal.rtmidi_open_port(ptr, 2, "da.");
        MidiInternal.rtmidi_open_port(o, 2, "yus.");
        // StartCoroutine(getdata());
    }
Example #4
0
        static uint GetCurrentPortCount()
        {
            IntPtr handle = MidiInternal.rtmidi_out_create_default();

            //get port count
            uint count = MidiInternal.rtmidi_get_port_count(handle);

            //free handle
            FreeHandle(handle);

            return(count);
        }