コード例 #1
0
 /// <summary>
 /// 播放一小节函数,供NewPlay函数调用(四轨道重载)
 /// 默认主旋律音量127=max 和弦轨音量100
 /// </summary>
 /// <param name="MIDI设备"></param>
 /// <param name="主旋律"></param>
 /// <param name="主音色"></param>
 /// <param name="和弦一"></param>
 /// <param name="音色一"></param>
 /// <param name="和弦二"></param>
 /// <param name="音色二"></param>
 /// <param name="和弦三"></param>
 /// <param name="音色三"></param>
 public static void playMidi(MidiDevice device, string note0, int n0, string note1, int n1, string note2, int n2, string note3, int n3)
 {
     playThread_right(device, note0, n0, 0, 127);
     playThread_left(device, note1, n1, 1, 100);
     playThread_left(device, note2, n2, 2, 100);
     playThread_left(device, note3, n3, 3, 100);
 }
コード例 #2
0
        void InitDevice(string deviceName, List <ControllerMapping> mappings, int Idx)
        {
            MidiDevice device = new MidiDevice();

            device.OpenMidiIn(Idx, deviceName);

            Dictionary <int, MidMessageHandler> deviceBindings = BindMappingHandlers(mappings);
            ControllerBinding ctrlBinding = new ControllerBinding {
                DeviceName = deviceName, DeviceIndex = Idx, Device = device, CmdBindings = deviceBindings
            };

            bindings.Add(Idx, ctrlBinding);


            device.onMidiDebugMessage += onMidiDebugMsg;
            device.onMidiInput        += OnMidiInput;

            if (deviceName == "CMD PL-1")
            {
                PL1InitialButtonLights(device);                            //W2PA- Initialize the Behringer CMD PL-1 and Micro LED button lights
            }
            if (deviceName == "CMD Micro")
            {
                MicroInitialButtonLights(device);
            }
        }
コード例 #3
0
        /// <summary>
        /// 小节对齐播放/控制函数(四轨道重载)
        /// 每小节之间用,隔开
        /// </summary>
        /// <param name="MIDI设备"></param>
        /// <param name="主旋律轨"></param>
        /// <param name="主音色"></param>
        /// <param name="和弦一轨"></param>
        /// <param name="音色一"></param>
        /// <param name="和弦二轨"></param>
        /// <param name="音色二"></param>
        /// <param name="和弦三轨"></param>
        /// <param name="音色三"></param>
        public static void NewPlay(MidiDevice Device, string inf1, int n1, string inf2, int n2, string inf3, int n3, string inf4, int n4)
        {
            string[] note1 = inf1.Split(',');
            string[] note2 = inf2.Split(',');
            string[] note3 = inf3.Split(',');
            string[] note4 = inf4.Split(',');
            int      index = note1.Length;

            for (int i = 0; i < index; i++)
            {
                Console.WriteLine("主旋律:note1[" + i + "]=" + note1[i]);
                Console.WriteLine("和弦:note2[" + i + "]=" + note2[i]);
                Console.WriteLine("和弦:note3[" + i + "]=" + note3[i]);
                Console.WriteLine("和弦:note4[" + i + "]=" + note4[i]);
                double sleeptime = 0;
                double littletime;
                int    lenth = note1[i].Length;
                for (int j = 0; j < lenth - 5; j += 8)
                {
                    littletime = (60000 / beat / 16 * (int)Math.Pow(2, (int)note1[i][j + 3] - 48));
                    if (note1[i][j + 4] == '1')
                    {
                        littletime *= 1.5;
                    }

                    sleeptime += littletime;
                }
                Console.WriteLine("小节播放时间:" + (int)sleeptime);
                Device.Reset();
                playMidi(Device, note1[i], n1, note2[i], n2, note3[i], n3, note4[i], n4);
                Thread.Sleep((int)sleeptime + dely);
                Device.Reset();
            }
        }
コード例 #4
0
ファイル: ModContainer.cs プロジェクト: cc004/MusicBuilder
        public override void Unload()
        {
            device.Dispose();
            device = null;

            instance = null;
        }
コード例 #5
0
        public void SendUpdateToMidi(CatCmd cmd, double pct)  //-W2PA Send Pl-1 knob or slider LED update message (CMD Micro doesn't have such LEDs)
        {
            int index = PL1Index();

            if (index < 0)
            {
                return;             // no Behringer PL-1 is connected so no need to do anything
            }
            ControllerMapping mapping;

            mapping = DB.GetReverseMapping(bindings[index].DeviceName, cmd);

            MidiDevice device = bindings[index].Device;

            if (mapping != null)
            {
                int ctlID = mapping.MidiControlId;
                int n     = Convert.ToInt32(16.0 * pct);
                if (ctlID == 73)
                {
                    device.SetPL1KnobLight(n, 10);              // If it's actually the slider, its LEDs need ctlID=10
                }
                else
                {
                    device.SetPL1KnobLight(n, ctlID);   // All other Pl-1 knobs
                }
            }

            return;
        }
コード例 #6
0
 Element MakeDevice(MidiDevice dev)
 {
     return(new RootElement(String.Format("{2} {0} {1}", dev.Manufacturer, dev.Model, dev.EntityCount))
     {
         new Section("Entities")
         {
             from ex in Enumerable.Range(0, dev.EntityCount)
             let entity = dev.GetEntity(ex)
                          select(Element) new RootElement(entity.Name)
             {
                 new Section("Sources")
                 {
                     from sx in Enumerable.Range(0, entity.Sources)
                     let endpoint = entity.GetSource(sx)
                                    select MakeEndpoint(endpoint)
                 },
                 new Section("Destinations")
                 {
                     from sx in Enumerable.Range(0, entity.Destinations)
                     let endpoint = entity.GetDestination(sx)
                                    select MakeEndpoint(endpoint)
                 }
             }
         }
     });
 }
コード例 #7
0
        Element MakeDevice(MidiDevice dev)
        {
            var entities = new Section("Entities");

            foreach (var ex in Enumerable.Range(0, (int)dev.EntityCount))
            {
                var entity        = dev.GetEntity(ex);
                var sourceSection = new Section("Sources");
                sourceSection.AddAll(
                    from sx in Enumerable.Range(0, (int)entity.Sources)
                    let endpoint = entity.GetSource(sx)
                                   select MakeEndpoint(endpoint)
                    );
                var destinationSection = new Section("Destinations");
                destinationSection.AddAll(
                    from sx in Enumerable.Range(0, (int)entity.Destinations)
                    let endpoint = entity.GetDestination(sx)
                                   select MakeEndpoint(endpoint)
                    );
                entities.Add(new RootElement(entity.Name)
                {
                    sourceSection,
                    destinationSection
                });
            }

            return(new RootElement(String.Format("{2} {0} {1}", dev.Manufacturer, dev.Model, dev.EntityCount))
            {
                entities
            });
        }
コード例 #8
0
 public void OnDeviceOpened(MidiDevice device)
 {
     //var port = device.OpenInputPort (device.Info.GetPorts ().First (p => p.Type == MidiPortType.Input).PortNumber);
     //port.Send (new Byte [] { 0xC0, 0x0 }, 0, 2);
     //port.Send (new byte [] { 0x90, 0x64, 110 }, 0, 3);
     //port.Send (new byte [] { 0x80, 0x64, 110 }, 0, 3);
     Console.WriteLine("Sent noteOn and noteOff");
 }
コード例 #9
0
 public MidiTaskScorePlayer(Score score, MidiDevice device) : base(score)
 {
     outDevice = device;
     if (!outDevice.IsOpen)
     {
         outDevice.Open();
     }
 }
コード例 #10
0
 public void MicroInitialButtonLights(MidiDevice device)
 {
     //-W2PA Channel, Value, Status, ControlID, message bytes - but apparently it only pays attention to the string, others can all be zero
     device.SendMsg(0x00, 0x00, 0x00, 0x00, "901701");  //-W2PA L-Play/Pause button
     device.SendMsg(0x00, 0x00, 0x00, 0x00, "901801");  //-W2PA L-CUE button
     device.SendMsg(0x00, 0x00, 0x00, 0x00, "902701");  //-W2PA R-Play/Pause button
     device.SendMsg(0x00, 0x00, 0x00, 0x00, "902801");  //-W2PA R-CUE button
 }
コード例 #11
0
        public void OnDeviceOpened(MidiDevice device)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            _taskCompletionSource.SetResult(device);
        }
コード例 #12
0
        public void PL1InitialButtonLights(MidiDevice device)
        {
            //-W2PA Channel, Value, Status, ControlID, message bytes - but apparently it only pays attention to the string, others can all be zero
            device.SendMsg(0x01, 0x01, 0x90, 0x22, "902201");  //-W2PA CUE button
            device.SendMsg(0x01, 0x01, 0x90, 0x23, "902301");  //-W2PA play/pause button
            device.SendMsg(0x01, 0x01, 0x90, 0x26, "902601");  //-W2PA - button
            device.SendMsg(0x01, 0x01, 0x90, 0x27, "902701");  //-W2PA + button
            device.SendMsg(0x01, 0x00, 0x90, 0x24, "902400");  //-W2PA Rew button
            device.SendMsg(0x01, 0x00, 0x90, 0x25, "902500");  //-W2PA FF button
            device.SendMsg(0x01, 0x01, 0x90, 0x20, "902001");  //-W2PA SYNC button
            device.SendMsg(0x01, 0x01, 0x90, 0x21, "902101");  //-W2PA TAP button
            device.SendMsg(0x01, 0x01, 0x90, 0x1B, "901B01");  //-W2PA SCRATCH button
            device.SendMsg(0x01, 0x01, 0x90, 0x10, "901001");  //-W2PA 1 button
            device.SendMsg(0x01, 0x01, 0x90, 0x11, "901101");  //-W2PA 2 button
            device.SendMsg(0x01, 0x01, 0x90, 0x12, "901201");  //-W2PA 3 button
            device.SendMsg(0x01, 0x01, 0x90, 0x13, "901301");  //-W2PA 4 button
            device.SendMsg(0x01, 0x01, 0x90, 0x14, "901401");  //-W2PA 5 button
            device.SendMsg(0x01, 0x01, 0x90, 0x15, "901501");  //-W2PA 6 button
            device.SendMsg(0x01, 0x01, 0x90, 0x16, "901601");  //-W2PA 7 button
            device.SendMsg(0x01, 0x01, 0x90, 0x17, "901701");  //-W2PA 8 button
            device.SendMsg(0x01, 0x01, 0x90, 0x18, "901801");  //-W2PA LOAD button
            device.SendMsg(0x00, 0x00, 0x00, 0x00, "901900");  //-W2PA LOCK button
            //device.SendMsg(0x00, 0x00, 0x00, 0x00, "901A01");  //-W2PA DECK button - doesn't seem to work

            //-W2PA A silly but useful routine during startup to search for Behringer LED codes while in debug mode. Play with initial values and limits.
            //-W2PA Comment out the above set of light settings first.
            //int dev = 10;
            //int val = 0;
            //int stbyte = 176;
            //string dB;
            //string vB;
            //string stBs;
            //string m2s;
            //while (stbyte <= 0xFF)
            //{
            //    stBs = stbyte.ToString("X2");
            //    while (dev <= 0xFF)
            //    {
            //        dB = dev.ToString("X2");
            //        while (val <= 0x10)
            //        {
            //            vB = val.ToString("X2");
            //            m2s = stBs + dB + vB;
            //            device.SendMsg(0x01, 0x01, 0x90, dev, m2s);
            //            //Thread.Sleep(1);
            //            val++;
            //        }
            //        dev++;
            //        val = 0;
            //    }
            //    stbyte++;
            //    dev = 10;
            //}

            return;
        }
コード例 #13
0
 public void OnDeviceOpened(MidiDevice device)
 {
     if (device == null)
     {
         throw new ArgumentNullException(nameof(device));
     }
     this.device = device;
     parent.open_devices.Add(device);
     wait.Set();
 }
コード例 #14
0
ファイル: PortEnvoi.cs プロジェクト: benbouare/eMaestro-2.0
 public void OnDeviceOpened(MidiDevice device)
 {
     if (device != null)
     {
         inputPort = device.OpenInputPort(index);
     }
     else
     {
         Toast.MakeText(activity, "Can't open MIDI Device !", ToastLength.Long).Show();
     }
 }
コード例 #15
0
ファイル: MidiPlay.cs プロジェクト: qqaaqqaa123456/iChord
        public static void playBasic(MidiDevice Device, string note, int trmbre, int channel)
        {
            Device.ChangeProgram(channel, trmbre, 0);
            int lenth = note.Length;
            int location;
            int speed;

            for (int i = 0; i < lenth - 2; i += 3)
            {
                location  = 60;
                location += 12 * (int)(note[i + 1] - 53);

                switch (note[i])
                {
                case 'C':
                case 'c': location += 0; break;

                case '!': location += 1; break;

                case 'D':
                case 'd': location += 2; break;

                case '#': location += 3; break;

                case 'E':
                case 'e': location += 4; break;

                case 'F':
                case 'f': location += 5; break;

                case '%': location += 6; break;

                case 'G':
                case 'g': location += 7; break;

                case '*': location += 8; break;

                case 'A':
                case 'a': location += 9; break;

                case 'B':
                case 'b': location += 11; break;

                default: location = -1; break;
                }

                //speed = 2 * int2Pow(note[i + 2] - 44);
                // speed = (int)(60000 / beat / 16 * (int)Math.Pow(2, (int)note[i + 2] - 48));
                speed = (int)(beat * int2Pow(note[i + 2] - 48));
                Device.Note_On(channel, location, 100);
                Thread.Sleep(speed);
                Device.Note_Off(channel, location, 100);
            }
        }
コード例 #16
0
        void OnMidiInput(MidiDevice Device, int DeviceIdx, int ControlId, int Data, int Status, int Voice, int Channel)
        {
            Device.latestControlID = ControlId;  //-W2PA used when making PL-1 LEDs respond to control action
            try
            {
                ControllerBinding ctrlBinding;
                if (bindings.TryGetValue(DeviceIdx, out ctrlBinding))
                {
                    MidMessageHandler handlers;
                    CmdState          state = CmdState.NoChange;

                    if (ctrlBinding.CmdBindings.TryGetValue(ControlId, out handlers))
                    {
                        if (handlers != null)
                        {
                            lock (midi_handler_lock)
                            {
                                if (handlers.CmdHandler != null)
                                {
                                    handlers.CmdHandler(Data, Device);
                                    if (Data <= 0)
                                    {
                                        state = CmdState.Off;
                                    }
                                    else
                                    {
                                        state = CmdState.On;
                                    }
                                }
                                else if (handlers.ToggleCmdHandler != null)
                                {
                                    state = handlers.ToggleCmdHandler(Data, Device);
                                }

                                if (state == CmdState.On && handlers.MidiOutCmdDown != null)
                                {
                                    Device.SendMsg(Channel, 0x7F, Status, ControlId, handlers.MidiOutCmdDown);
                                }
                                if (state == CmdState.Off && handlers.MidiOutCmdUp != null)
                                {
                                    Device.SendMsg(Channel, 0x00, Status, ControlId, handlers.MidiOutCmdUp);
                                }
                                if (handlers.MidiOutCmdSetValue != null)
                                {
                                    Device.SendMsg(Channel, Data, Status, ControlId, handlers.MidiOutCmdSetValue);
                                }
                            }
                        }
                    }
                }
            }
            catch { }
        }
コード例 #17
0
ファイル: MidiInPort.Android.cs プロジェクト: jokm1/uno-2
        internal async Task InitializeAsync()
        {
            var completionSource = new TaskCompletionSource <MidiDevice>();

            using (var deviceOpenListener = new MidiDeviceOpenedListener(completionSource))
            {
                _midiManager.OpenDevice(_deviceInfo, deviceOpenListener, null);
                _midiDevice = await completionSource.Task;
                // This is not a bug, Android uses "output" for input.
                _midiPort = _midiDevice.OpenOutputPort(_portInfo.PortNumber);
            }
        }
コード例 #18
0
 /// <summary>
 /// Checks all available hardware interfaces and returns
 /// the name of the first interface that thinks it's the
 /// correct mapping.
 /// </summary>
 public static string AutoMap(MidiDevice device)
 {
     foreach (var key in _availableInstances.Keys)
     {
         var instance = _availableInstances[key];
         if (instance.Supports(device))
         {
             return(key);
         }
     }
     return(null);
 }
コード例 #19
0
ファイル: MidiPlay.cs プロジェクト: qqaaqqaa123456/iChord
        public static void playThread(MidiDevice Device, string note, int trmbre, int channel)
        {
            MutilVariable bus = new MutilVariable();

            bus.setdevice(Device);
            bus.setnote(note);
            bus.setchannel(channel);
            bus.settrmbre(trmbre);
            Thread t = new Thread(new ThreadStart(bus.run));

            //t.IsBackground = false;
            t.Start();
        }
コード例 #20
0
        /// <summary>
        /// 和弦播放的多线程启动方法
        /// </summary>
        /// <param name="MIDI设备"></param>
        /// <param name="乐谱"></param>
        /// <param name="音色"></param>
        /// <param name="MIDI频道"></param>
        /// <param name="音量"></param>
        public static void playThread_left(MidiDevice Device, string note, int trmbre, int channel, int playvolume)
        {
            MutilVariable bus = new MutilVariable();

            bus.setdevice(Device);
            bus.setnote(note);
            bus.setchannel(channel);
            bus.settrmbre(trmbre);
            Thread t = new Thread(new ThreadStart(bus.run_left));

            bus.setplayvolume(playvolume);
            t.IsBackground = true;
            t.Start();
        }
コード例 #21
0
 public OpenDeviceListener(MidiAccess parent, MidiDevice device, MidiPortDetails portToOpen)
 {
     if (parent == null)
     {
         throw new ArgumentNullException(nameof(parent));
     }
     if (portToOpen == null)
     {
         throw new ArgumentNullException(nameof(portToOpen));
     }
     this.parent  = parent;
     this.device  = device;
     port_to_open = portToOpen;
 }
コード例 #22
0
ファイル: ModContainer.cs プロジェクト: cc004/MusicBuilder
        public override void Load()
        {
            Random rand = new Random();

            instance = this;

            Registries.noteData = new Dictionary <Prog, NoteData>();

            for (int i = 0; i < 129; ++i)
            {
                Registries.noteData.Add((Prog)(1024 + i), new NoteData(new Color(0, 0, 0), ColorUtils.ColorHue(i / 129.0f), Instrument[i]));
            }

            device = new MidiDevice();
        }
コード例 #23
0
ファイル: MidiOutPort.Android.cs プロジェクト: jokm1/uno-2
        internal async Task OpenAsync()
        {
            if (this.Log().IsEnabled(LogLevel.Debug))
            {
                this.Log().LogDebug($"Opening the MIDI out port, port number {_portInfo.PortNumber}");
            }
            var completionSource = new TaskCompletionSource <MidiDevice>();

            using (var deviceOpenListener = new MidiDeviceOpenedListener(completionSource))
            {
                _midiManager.OpenDevice(_deviceInfo, deviceOpenListener, null);
                _midiDevice = await completionSource.Task;
                // This is not a bug, Android uses "input" for output.
                _midiPort = _midiDevice.OpenInputPort(_portInfo.PortNumber);
            }
        }
コード例 #24
0
        /// <summary>
        /// Gets all MIDI resources needed to use the selected device.
        /// </summary>
        private void Acquire(MidiDevice device)
        {
            lock (_acquireLock)
            {
                if (device != null)
                {
                    // setup the input device
                    if (device.CanRead)
                    {
                        // grab the device id by name
                        uint deviceId = 0;
                        if (_deviceIdByName.TryGetValue("IN_" + device.ID, out deviceId) == false)
                        {
                            throw new Exception("Could not find MIDI input device " + device.ID);
                        }

                        // start streaming the input
                        WinMM.CheckReturnCode(Win32API.midiInOpen(out _inputHandle, (UIntPtr)deviceId, _callback, (UIntPtr)0));
                        WinMM.CheckReturnCode(Win32API.midiInStart(_inputHandle));
                        _inputOpen = true;
                    }
                    else
                    {
                        _inputOpen = false;
                    }

                    // setup the output device
                    if (device.CanWrite)
                    {
                        // grab the device id by name
                        uint deviceId = 0;
                        if (_deviceIdByName.TryGetValue("OUT_" + device.ID, out deviceId) == false)
                        {
                            throw new Exception("Could not find MIDI output device " + device.ID);
                        }

                        // setup the device
                        WinMM.CheckReturnCode(Win32API.midiOutOpen(out _outputHandle, (UIntPtr)deviceId, null, (UIntPtr)0));
                        _outputOpen = true;
                    }
                    else
                    {
                        _outputOpen = false;
                    }
                }
            }
        }
コード例 #25
0
        void InitDevice(string deviceName, List <ControllerMapping> mappings, int Idx)
        {
            MidiDevice device = new MidiDevice();

            device.OpenMidiIn(Idx, deviceName);

            Dictionary <int, MidMessageHandler> deviceBindings = BindMappingHandlers(mappings);
            ControllerBinding ctrlBinding = new ControllerBinding {
                DeviceName = deviceName, DeviceIndex = Idx, Device = device, CmdBindings = deviceBindings
            };

            bindings.Add(Idx, ctrlBinding);


            device.onMidiDebugMessage += onMidiDebugMsg;
            device.onMidiInput        += OnMidiInput;
        }
コード例 #26
0
        /// <summary>
        /// BrandNew方法为了用单独的线程启动播放  不卡界面线程(三轨道重载)
        /// </summary>
        /// <param name="MIDI设备"></param>
        /// <param name="主旋律轨"></param>
        /// <param name="主音色"></param>
        /// <param name="和弦一轨"></param>
        /// <param name="音色一"></param>
        /// <param name="和弦二轨"></param>
        /// <param name="音色二"></param>
        public static void BrandNew(MidiDevice Device, string inf1, int n1, string inf2, int n2, string inf3, int n3)
        {
            MutilThread engine = new MutilThread();

            engine.setdevice(Device);
            engine.setinf1(inf1);
            engine.setinf2(inf2);
            engine.setinf3(inf3);
            engine.setinf4(null);
            engine.setn1(n1);
            engine.setn2(n2);
            engine.setn3(n3);
            Thread t = new Thread(new ThreadStart(engine.run));

            t.IsBackground = true;
            t.Start();
        }
コード例 #27
0
    // Update is called once per frame
    void Update()
    {
        var endpointCountIn = CountEndpoints();

        midiInDeviceCount = endpointCountIn;
        midiInDevices.Clear();
        var endpointCountSend = CountSendEndpoints();

        midiOutDeviceCount = endpointCountSend;
        midiOutDevices.Clear();

        for (var i = 0; i < endpointCountIn; i++)
        {
            var        id   = GetEndpointIdAtIndex(i);
            var        name = GetInEndpointName(id);
            MidiDevice mi   = new MidiDevice(id, name);
            midiInDevices.Add(mi);
        }
        for (var i = 0; i < endpointCountSend; i++)
        {
            var        id   = GetSendEndpointIdAtIndex(i);
            var        name = GetSendEndpointName(id);
            MidiDevice mo   = new MidiDevice(id, name);
            midiOutDevices.Add(mo);
        }

        // indicate Push2
        if (midiOutDeviceCountBefore != midiOutDeviceCount)
        {
            for (var i = 0; i < midiOutDeviceCount; i++)
            {
                var option = Push2Manager.MidiOutDevices[i];
                if (option.Name.IndexOf("Ableton Push 2") == 0)
                {
                    SetPush2MIDIOutDevice(i);
                    WakeupPush2();
                    push2State = Push2State.PERFORM_WAKENING;
                    push2State = Push2State.READY;
                }
            }
        }
        midiInDeviceCountBefore  = midiInDeviceCount;
        midiOutDeviceCountBefore = midiOutDeviceCount;
    }
コード例 #28
0
    // Update is called once per frame
    void Update()
    {
        var endpointCountIn = CountEndpoints();

        midiInDeviceCount = endpointCountIn;
        midiInDevices.Clear();
        var endpointCountSend = CountSendEndpoints();

        midiOutDeviceCount = endpointCountSend;
        midiOutDevices.Clear();

        for (var i = 0; i < endpointCountIn; i++)
        {
            var        id   = GetEndpointIdAtIndex(i);
            var        name = GetInEndpointName(id);
            MidiDevice mi   = new MidiDevice(id, name);
            midiInDevices.Add(mi);
        }
        for (var i = 0; i < endpointCountSend; i++)
        {
            var        id   = GetSendEndpointIdAtIndex(i);
            var        name = GetSendEndpointName(id);
            MidiDevice mo   = new MidiDevice(id, name);
            midiOutDevices.Add(mo);
        }

        // indicate Push2
        if (midiOutDeviceCountBefore != midiOutDeviceCount)
        {
            for (var i = 0; i < midiOutDeviceCount; i++)
            {
                var option = MIDIManager.MidiOutDevices[i];
                if (option.Name.IndexOf("Ableton Push 2") == 0)
                {
                    // push2OptionIndex = i;
                }
            }
        }
        midiInDeviceCountBefore  = midiInDeviceCount;
        midiOutDeviceCountBefore = midiOutDeviceCount;
    }
コード例 #29
0
        public MidiDevice PL1Device()
        {
            if (bindings.Count == 0)
            {
                return(null);
            }
            int index = 0;

            foreach (var binding in bindings.Values)
            {
                if (binding.DeviceName == "CMD PL-1")
                {
                    index = binding.DeviceIndex;
                }
                break;
            }

            MidiDevice device = bindings[index].Device;

            return(device);
        }
コード例 #30
0
 /// <summary>
 /// Output is never automapped.
 /// </summary>
 public override bool Supports(MidiDevice device)
 {
     return(false);
 }
コード例 #31
0
 public void OnDeviceOpened(MidiDevice device)
 {
     //var port = device.OpenInputPort (device.Info.GetPorts ().First (p => p.Type == MidiPortType.Input).PortNumber);
     //port.Send (new Byte [] { 0xC0, 0x0 }, 0, 2);
     //port.Send (new byte [] { 0x90, 0x64, 110 }, 0, 3);
     //port.Send (new byte [] { 0x80, 0x64, 110 }, 0, 3);
     Console.WriteLine ("Sent noteOn and noteOff");
 }
コード例 #32
0
		Element MakeDevice (MidiDevice dev)
		{
			var entities = new Section ("Entities");
			foreach (var ex in Enumerable.Range(0, (int)dev.EntityCount)) {
				var entity = dev.GetEntity (ex);
				var sourceSection = new Section ("Sources");
				sourceSection.AddAll (
					from sx in Enumerable.Range (0, (int)entity.Sources)
					let endpoint = entity.GetSource (sx)
					select MakeEndpoint (endpoint)
				);
				var destinationSection = new Section ("Destinations");
				destinationSection.AddAll (
					from sx in Enumerable.Range (0, (int)entity.Destinations)
					let endpoint = entity.GetDestination (sx)
					select MakeEndpoint (endpoint)
				);
				entities.Add(new RootElement (entity.Name) {
					sourceSection,
					destinationSection
				});
			}

			return new RootElement (String.Format ("{2} {0} {1}", dev.Manufacturer, dev.Model, dev.EntityCount)) {
				entities
			};
		}
コード例 #33
0
		Element MakeDevice (MidiDevice dev)
		{
			return new RootElement (String.Format ("{2} {0} {1}", dev.Manufacturer, dev.Model, dev.EntityCount)){
				new Section ("Entities") {
					from ex in Enumerable.Range (0, dev.EntityCount)
						let entity = dev.GetEntity (ex)
						select (Element) new RootElement (entity.Name) {
							new Section ("Sources"){
								from sx in Enumerable.Range (0, entity.Sources)
									let endpoint = entity.GetSource (sx)
									select MakeEndpoint (endpoint)
							},
							new Section ("Destinations"){
								from sx in Enumerable.Range (0, entity.Destinations)
									let endpoint = entity.GetDestination (sx)
									select MakeEndpoint (endpoint)
							}
						}
				}
			};
		}