private void RemovePad_Click(object sender, RoutedEventArgs e) { var parent = (WrapPanel)this.Parent; parent.Children.Remove(this); GlobalStaticContext.RemovePad(this); //MainWrapPanel.Children.Add(pc); }
private void MidiVolumeSliderLearnCallback(object sender, MidiInMessageEventArgs e) { ControlChangeEvent evento = (ControlChangeEvent)e.MidiEvent; _volumeSliderMidiController = evento.Controller; GlobalStaticContext.RegisterPadWithMidiController(this, _volumeSliderMidiController.Value); GlobalStaticContext.ExitLearnMode(); }
private void MidiPushButtonLearnCallback(object sender, MidiInMessageEventArgs e) { NoteOnEvent evento = (NoteOnEvent)e.MidiEvent; _pushButtonMidiNote = evento.NoteNumber; GlobalStaticContext.RegisterPadWithMidiNote(this, _pushButtonMidiNote); GlobalStaticContext.ExitLearnMode(); }
private void _player_OnSoundStateChange(AudioPlayer.SoundState state) { if (_pushButtonMidiNote > 0) { if (state == AudioPlayer.SoundState.Started) { GlobalStaticContext.SendMidiMessage(MidiMessage.StartNote(_pushButtonMidiNote, 24, 1).RawData); Application.Current.Dispatcher.Invoke(new Action(() => { btnPlaySound.Background = new SolidColorBrush(Color.FromRgb(123, 237, 154)); })); } else { GlobalStaticContext.SendMidiMessage(MidiMessage.StopNote(_pushButtonMidiNote, 0, 1).RawData); Application.Current.Dispatcher.Invoke(new Action(() => { btnPlaySound.Background = new SolidColorBrush(Color.FromRgb(201, 201, 201)); })); } } }
public PadControl(string audiodevice, float volume, string audioFilePath, int midiNote, MidiController?volumeSilderContr) { InitializeComponent(); int audiodeviceID = -1; int callbackdeviceID = -1; for (int i = 0; i < WaveOut.DeviceCount; i++) { if (WaveOut.GetCapabilities(i).ProductName == audiodevice) { audiodeviceID = i; } if (WaveOut.GetCapabilities(i).ProductName == ApplicationSettings.CallbackDeviceID) { callbackdeviceID = i; } } _player = new AudioPlayer("", callbackdeviceID); _player.OnSoundStateChange += _player_OnSoundStateChange; _player.OnAudioTrackChange += _player_OnAudioTrackChange; _player.ChangeAudioDevice(audiodeviceID); _player.ChangeAudioTrack(audioFilePath); ChangeVolume(Convert.ToInt32(volume * 100), false); this._pushButtonMidiNote = midiNote; if (this._pushButtonMidiNote != -1) { GlobalStaticContext.RegisterPadWithMidiNote(this, midiNote); } if (volumeSilderContr.HasValue) { this._volumeSliderMidiController = volumeSilderContr.Value; GlobalStaticContext.RegisterPadWithMidiController(this, volumeSilderContr.Value); } }
private void LearnMidiSlider_Click(object sender, RoutedEventArgs e) { GlobalStaticContext.EnterLearnMode(MidiVolumeSliderLearnCallback); }
private void LearnMidiButton_Click(object sender, RoutedEventArgs e) { GlobalStaticContext.EnterLearnMode(MidiPushButtonLearnCallback); }