private void CbxDevice_SelectedIndexChanged(object sender, EventArgs e) { //If there is a midi device, we create a new midi player if (MidiIn.NumberOfDevices > 0) { if (cbxDevice.SelectedItem.ToString() != NO_DEVICE_DETECTED_MESSAGE) { //The midi player must be diposed before being reconstructed to release the midi device if (midiPlayer != null) { midiPlayer.Dispose(); } midiPlayer = new MIDIPlayer(cbxDevice.SelectedIndex, o1, o2, o3); } } }
public SynthView() { InitializeComponent(); KeyPreview = true; o1 = new Oscillator(); o2 = new Oscillator(); o3 = new Oscillator(); Oscillator1Buttons = new List <Button>() { btnNoise1, btnSawTooth1, btnSine1, btnSquare1, btnTriangle1 }; Oscillator2Buttons = new List <Button>() { btnNoise2, btnSawTooth2, btnSine2, btnSquare2, btnTriangle2 }; Oscillator3Buttons = new List <Button>() { btnNoise3, btnSawTooth3, btnSine3, btnSquare3, btnTriangle3 }; //If there is a midi device, we create a new midi player if (MidiIn.NumberOfDevices > 0) { midiPlayer = new MIDIPlayer(DEFAULT_MIDI_DEVICE_ID, o1, o2, o3); } }