コード例 #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;
        }
コード例 #2
0
ファイル: MidiInput.cs プロジェクト: lopea/LopeaMidi
        /// <summary>
        /// Initializes MidiInput and connects all Midi Devices.
        /// While it is not necessary to run this function as all Get"" functions intialize properly,
        /// this function exists to be able to initialize at Awake().
        /// </summary>
        public static void Initialize()
        {
            //run only if the system has not been initialized
            if (!_initialized)
            {
                //get port count
                portCount = GetPortCount();
                //dont initialize if there are no midi devices available
                if (portCount == 0)
                {
                    Debug.LogError("MIDIIN: No Midi Device Available! Lopea Midi is not Initializing.");
                    return;
                }

                //get the gameobject with MidiInput Component
                _update = FindObjectOfType <MidiInput>();

                //if gameobject does not exist, make a new one.
                if (_update == null)
                {
                    _update = new GameObject("LopeaMidi").AddComponent <MidiInput>();
                }
                //hide the game object from everything
                //_update.gameObject.hideFlags = HideFlags.HideInHierarchy;

                currdevices = new MidiInDevice[portCount];
                //add all devices
                for (uint i = 0; i < portCount; i++)
                {
                    currdevices[i] = CreateDevice(i);
                }
                _initialized = true;
            }
        }
コード例 #3
0
ファイル: MidiInput.cs プロジェクト: lopea/VFXGraphSandbox
 //remove all references of midi devices and clean all values.
 static void Shutdown()
 {
     for (uint i = 0; i < currdevices.Length; i++)
     {
         removeDevice(i);
     }
     currdevices  = null;
     _update      = null;
     _initialized = false;
 }
コード例 #4
0
ファイル: MidiInput.cs プロジェクト: lopea/LopeaMidi
        //remove all references of midi devices and clean all values.
        public static void Shutdown()
        {
            //call event
            //?.Invoke();
            if (!_initialized)
            {
                return;
            }


            for (uint i = 0; i < currdevices.Length; i++)
            {
                removeDevice(i);
            }
            currdevices = null;
            Destroy(_update);
            _update      = null;
            _initialized = false;
            OnShutdown   = null;
        }