Open() public method

Opens this output device.
The device is already open. The device cannot be opened.
public Open ( ) : void
return void
Exemplo n.º 1
0
        public void Connect()
        {
            if (_inputDevice == null)
            {
                _inputDevice = (from device in InputDevice.InstalledDevices
                                where device.Name == _deviceName
                                select device).FirstOrDefault();
                if (_inputDevice != null)
                {
                    _inputDevice.Open();

                    _inputDevice.NoteOn += OnInputDeviceNoteOn;
                    _inputDevice.NoteOff += OnInputDeviceNoteOff;
                    _inputDevice.ControlChange += OnInputDeviewControlChange;

                    _inputDevice.StartReceiving(null);
                }
            }

            if (_outputDevice == null)
            {
                _outputDevice = (from device in OutputDevice.InstalledDevices
                                 where device.Name == _deviceName
                                 select device).FirstOrDefault();
                if (_outputDevice != null)
                {
                    _outputDevice.Open();
                    _outputDevice.SilenceAllNotes();
                }
            }
        }
Exemplo n.º 2
0
        public LaunchpadDevice(int index)
        {
            InitialiseButtons();

            int i = 0;
            mInputDevice = InputDevice.InstalledDevices.Where(x => x.Name.Contains("Launchpad")).
                FirstOrDefault(x => i++ == index);
            i = 0;
            mOutputDevice = OutputDevice.InstalledDevices.Where(x => x.Name.Contains("Launchpad")).
                FirstOrDefault(x => i++ == index);

            if (mInputDevice == null)
                throw new LaunchpadException("Unable to find input device.");
            if (mOutputDevice == null)
                throw new LaunchpadException("Unable to find output device.");

            mInputDevice.Open();
            mOutputDevice.Open();

            mInputDevice.StartReceiving(new Clock(120));
            mInputDevice.NoteOn += mInputDevice_NoteOn;
            mInputDevice.ControlChange += mInputDevice_ControlChange;

            Reset();
        }
Exemplo n.º 3
0
 public MidiDevice()
 {
     timeOuts     = new List <NoteTimeOut>();
     outputDevice = Midi.OutputDevice.InstalledDevices[0];
     outputDevice.Open();
     outputDevice.SilenceAllNotes();
     System.Threading.Thread.Sleep(200); // fixes delay during initial playing, possibly due to midi device initialization
 }
Exemplo n.º 4
0
 public MidiDevice()
 {
     timeOuts = new List<NoteTimeOut>();
     outputDevice = Midi.OutputDevice.InstalledDevices[0];
     outputDevice.Open();
     outputDevice.SilenceAllNotes();
     System.Threading.Thread.Sleep(200); // fixes delay during initial playing, possibly due to midi device initialization
 }
Exemplo n.º 5
0
        public Reversi(LaunchpadDevice device)
        {
            mLaunchpadDevice = device;

            mLaunchpadDevice.DoubleBuffered = false;
            mLaunchpadDevice.ButtonPressed += mLaunchpadDevice_ButtonPressed;

            mOutputDevice = OutputDevice.InstalledDevices[0];
            mOutputDevice.Open();

            Restart();
        }
        public Midi.OutputDevice matrixOut; // Yeet Output in

        private void requestMatrixInfo()
        {
            //Setup Midi
            Console.WriteLine("Looking for Midi input device " + matrix.Name);
            int i = 0;

            foreach (Midi.InputDevice inputDevice in Midi.InputDevice.InstalledDevices)
            {
                Console.WriteLine(inputDevice.Name);
                if (inputDevice.Name == matrix.Name)
                {
                    Console.WriteLine("Midi Input Connected: " + inputDevice.Name);
                    matrixIn = Midi.InputDevice.InstalledDevices[i];
                    if (!matrixIn.IsOpen)
                    {
                        matrixIn.Open();
                        matrixIn.SysEx += new Midi.InputDevice.SysExHandler(ReceiveSysEx);
                        matrixIn.StartReceiving(null, true);
                    }
                    break;
                }
                i++;
            }

            Console.WriteLine("Looking for Midi output device " + matrix.Name);

            i = 0;
            foreach (Midi.OutputDevice outputDevice in Midi.OutputDevice.InstalledDevices)
            {
                Console.WriteLine(outputDevice.Name);
                if (outputDevice.Name == matrix.Name)
                {
                    Console.WriteLine("Midi Output Connected: " + outputDevice.Name);
                    matrixOut = Midi.OutputDevice.InstalledDevices[i];
                    if (!matrixOut.IsOpen)
                    {
                        matrixOut.Open();
                    }
                    break;
                }
                i++;
            }

            matrixOut.SendSysEx(new byte[] { 240, 0, 2, 3, 1, 0, 17, 16, 247 });    //获取设备名字
            matrixOut.SendSysEx(new byte[] { 240, 0, 2, 3, 1, 0, 17, 17, 247 });    //获取设备序列号String
            matrixOut.SendSysEx(new byte[] { 240, 0, 2, 3, 1, 0, 17, 18, 0, 247 }); //获取设备固件String
            matrixOut.SendSysEx(new byte[] { 240, 0, 2, 3, 1, 0, 17, 18, 1, 247 }); //获取设备固件Bytes
        }
Exemplo n.º 7
0
        public RainSequencer(LaunchpadDevice device)
        {
            mLaunchpadDevice = device;
            mOutputDevice = OutputDevice.InstalledDevices[0];
            mOutputDevice.Open();

            mLaunchpadDevice.ButtonPressed += mLaunchpadDevice_ButtonPressed;

            /*
            Random rand = new Random();
            for (int y = 0; y < NumRows; y++)
                for (int x = 0; x < NumRows; x++)
                    if (rand.Next(0, 12) == 0)
                        mSequence[x, y] = true;
             * */
        }
Exemplo n.º 8
0
		public GeneratorFramework(float beatsPerMinute)
		{
			_clock = new Clock(beatsPerMinute);

			char c = 'a';
			Dictionary<char, OutputDevice> _outdevices = new Dictionary<char, OutputDevice>();

			Console.WriteLine("Select output device");
			foreach (OutputDevice device in OutputDevice.InstalledDevices)
			{
				Console.WriteLine($"{c} - {device.Name}");
				_outdevices.Add(c++, device);

			}

			do
			{
				c = Console.ReadKey(true).KeyChar;
			} while (!_outdevices.ContainsKey(c));

			_outputDevice = _outdevices[c];
			Console.WriteLine("Using {0} as output", _outputDevice.Name);
			_outputDevice.Open();
		}
Exemplo n.º 9
0
        private void btnReceiveOut_Click(object sender, EventArgs e)
        {
            if (listBox2.SelectedItem == null)
            MessageBox.Show("No device selected!");
              else
              {
            outDevice = (OutputDevice)listBox2.SelectedItem;
            outDevice.Open();
            if (comboBox1.SelectedItem != null)
              outDevice.SendNoteOn(Channel.Channel1, (Pitch)comboBox1.SelectedItem, trackBar1.Value);

            outDevice.Close();
              }
        }
Exemplo n.º 10
0
 protected static void UseOutputDevice(Midi.OutputDevice odNew)
 {
     if ((odNew == _devOut) || (odNew == null)) return;
      if (_midiClock.IsRunning) { _midiClock.Stop(); _midiClock.Reset(); }
      if ((_devOut != null) && _devOut.IsOpen) _devOut.Close();
      _devOut = odNew;
      _devOut.Open();
      _midiClock.Start();
 }
Exemplo n.º 11
0
 /// <summary>
 /// output MIDI device has been changed
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void selectDevice(object sender, RoutedEventArgs e)
 {
     if (outputDevice != null) outputDevice.Close();
     try
     {
         outputDevice = OutputDevice.InstalledDevices[this.outDevices.SelectedIndex];
         outputDevice.Open();
     }
     catch (Midi.DeviceException exception)
     {
         log("MIDI device exception: " + exception.Message, "error");
     }
 }
Exemplo n.º 12
0
 public GeneratorFramework(float beatsPerMinute)
 {
     _clock = new Clock(beatsPerMinute);
     _outputDevice = OutputDevice.InstalledDevices[0];
     _outputDevice.Open();
 }
Exemplo n.º 13
0
 // Switches output devices, turning off the old one (if any) and turning on the new one.
 private void UseOutputDevice(OutputDevice newOutputDevice)
 {
     if (newOutputDevice == outputDevice)
     {
         return;
     }
     if (clock.IsRunning)
     {
         clock.Stop();
         clock.Reset();
     }
     if (outputDevice != null)
     {
         if (outputDevice.IsOpen)
         {
             outputDevice.Close();
         }
     }
     outputDevice = newOutputDevice;
     outputDevice.Open();
     clock.Start();
 }
Exemplo n.º 14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            savedMelodysList = new List<Melody>();
            savedMelodysList = Parser.GetAllMelodys();
            for (int i = 0; i < savedMelodysList.Count; i++)
            {
                savedMelodysComboBox.Items.Add(savedMelodysList[i].Name + "(" + savedMelodysList[i].ScaleName.ToString() + ")");
            }
            if(savedMelodysComboBox.Items.Count != 0)
                savedMelodysComboBox.SelectedIndex = 0;
            nameLabel.Text = "Сгенерируйте мелодию!";
            notesTextBox.Text = "";
            rhythmTextBox.Text = "";
            notesCountTextBox.Text = "16";

            //Melody.Number = melodyList.Count + 1;

            generatedMelodysList = new List<Melody>();

            gridButtons = new int[6, 16];

            /* Гаммы можно менять, но их длина должна оставаться прежней.
             * В противном случае, нужно произвести изменения в файле MyRandom.cs
             */
            minorScale = new int[7] { 2, 1, 2, 2, 1, 2, 2 };
            majorScale = new int[7] { 2, 2, 1, 2, 2, 2, 1 };
            flamencoScale = new int[7] { 1, 3, 1, 2, 1, 3, 1 };
            bluesScale = new int[] { 3, 2, 1, 1, 3, 2 };
            flamenco2Scale = new int[7] { 1, 3, 1, 2, 1, 2, 2 };

            int[] scaleIntervals = minorScale;
            ScaleName scaleName = ScaleName.Minor;
            selectedScale = new MyScale(scaleName, scaleIntervals);

            tonica = Note.A3;

            scaleComboBox.SelectedIndex = 0;

            buttons = new Button[6, 16];
            player = new MediaPlayer();
            player.Volume = 0.3;
            outputDevice = ExampleUtil.ChooseOutputDeviceFromConsole();
            outputDevice.Open();
            outputDevice.SendProgramChange(Channel.Channel1, Instrument.AcousticGuitarSteel);

            grifNotes = new Note[6, 16];

            //Заполняем 6 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[5, i] = (Note)(40 + i);
            }
            //Заполняем 5 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[4, i] = (Note)(45 + i);
            }
            //Заполняем 4 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[3, i] = (Note)(50 + i);
            }
            //Заполняем 3 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[2, i] = (Note)(55 + i);
            }
            //Заполняем 2 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[1, i] = (Note)(59 + i);
            }
            //Заполняем 1 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[0, i] = (Note)(64 + i);
            }

            int tabindex = 4;
            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    buttons[i, j] = (Button)this.Controls["s" + (i + 1).ToString() + j.ToString()];
                    buttons[i, j].TabIndex = tabindex;
                    tabindex++;
                }
            }

            //Создание надписей над аппликатурой
            labels = new Label[6, 16]; this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    labels[i, j] = new Label();
                    labels[i, j].AutoSize = true;
                    labels[i, j].Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
                    labels[i, j].ForeColor = System.Drawing.Color.Black;
                    Point p = new Point();
                    p.X = buttons[i, j].Location.X;// +buttons[i, j].Width / 2;
                    p.Y = buttons[i, j].Location.Y;
                    labels[i, j].Location = p;
                    labels[i, j].Name = "label" + i.ToString() + j.ToString();
                    labels[i, j].Size = new System.Drawing.Size(15, 13);
                    //labels[i, j].TabIndex = 113;
                    labels[i, j].Text = "T";
                    labels[i, j].Visible = false;
                    labels[i, j].BackColor = System.Drawing.Color.Transparent;
                    this.Controls.Add(labels[i, j]);
                    labels[i, j].BringToFront();
                }
            }

            for (int j = 0; j < 6; j++)
            {
                for (int k = 0; k < 16; k++)
                {
                    buttons[j, k].Click += grif_Click;
                }
            }
        }
Exemplo n.º 15
0
 public void SetOutputDevice(string deviceName)
 {
     if (OutputDevice != null) OutputDevice.Close();
     OutputDevice = MidiIO.GetOutputDevice(deviceName);
     OutputDevice.Open();
 }
Exemplo n.º 16
0
 public MidiDrums()
 {
     outputDevice = OutputDevice.InstalledDevices[0];
     outputDevice.Open();
 }