public void StopChord(MidiChord chord) { for (int i = 12; i < 128; i++) { MidiModule.StopNote(i); } }
public void PlayChord(MidiChord chord) { List <int> notes = new List <int>(); int minInterval; int maxInterval; for (int i = 0; i < chord.interval.Count; i++) { int thisNote = (int)chord.rootNote + chord.interval[i]; for (int j = 0; j < 5; j++) { minInterval = 36 + j * 12; maxInterval = 47 + j * 12; if (reeds.Contains(j)) { if ((thisNote + (j + 1) * 12 <= maxInterval && thisNote + (j + 1) * 12 >= minInterval)) { if (!(notes.Contains((int)chord.rootNote + chord.interval[i] + (j + 1) * 12))) { notes.Add((int)chord.rootNote + chord.interval[i] + (j + 1) * 12); } } if (thisNote + j * 12 <= maxInterval && thisNote + j * 12 >= minInterval) { if (!(notes.Contains((int)chord.rootNote + chord.interval[i] + j * 12))) { notes.Add((int)chord.rootNote + chord.interval[i] + j * 12); } } if (thisNote + (j - 1) * 12 <= maxInterval && thisNote + (j - 1) * 12 >= minInterval) { if (!(notes.Contains((int)chord.rootNote + chord.interval[i] + (j - 1) * 12))) { notes.Add((int)chord.rootNote + chord.interval[i] + (j - 1) * 12); } } } } } if (!(reeds.Count == 0)) { int min = reeds.Min(); notes.Add((int)chord.rootNote + (min - 1) * 12); } for (int i = 0; i < notes.Count; i++) { MidiModule.PlayNote(notes[i], velocity); } }
public Flower(MidiNotes rootNote, FlowerConfig config, Point center) { this.RootNote = rootNote; FlowerFamily = config.Family; MidiChord ChordC = new MidiChord(RootNote, config.ChordType_C); MidiChord ChordL = new MidiChord(RootNote, config.ChordType_L); MidiChord ChordU = new MidiChord(RootNote, config.ChordType_U); MidiChord ChordR = new MidiChord(RootNote, config.ChordType_R); MidiChord ChordD = new MidiChord(RootNote, config.ChordType_D); Point CoordC = new Point(center.X, center.Y); Point CoordL = new Point(center.X - 1, center.Y); Point CoordU = new Point(center.X, center.Y + 1); Point CoordR = new Point(center.X + 1, center.Y); Point CoordD = new Point(center.X, center.Y - 1); ButtonC = new FlowerButton(CoordC); ButtonC.SetColor(new SolidColorBrush(FlowerFamily.GetColor(FlowerButtonPositions.C))); ButtonL = new FlowerButton(CoordL); ButtonL.SetColor(new SolidColorBrush(FlowerFamily.GetColor(FlowerButtonPositions.L))); ButtonU = new FlowerButton(CoordU); ButtonU.SetColor(new SolidColorBrush(FlowerFamily.GetColor(FlowerButtonPositions.U))); ButtonR = new FlowerButton(CoordR); ButtonR.SetColor(new SolidColorBrush(FlowerFamily.GetColor(FlowerButtonPositions.R))); ButtonD = new FlowerButton(CoordD); ButtonD.SetColor(new SolidColorBrush(FlowerFamily.GetColor(FlowerButtonPositions.D))); ButtonC.Chord = ChordC; ButtonL.Chord = ChordL; ButtonU.Chord = ChordU; ButtonR.Chord = ChordR; ButtonD.Chord = ChordD; FlowerButtons = new List <FlowerButton> { ButtonC, ButtonD, ButtonL, ButtonU, ButtonR }; }
private void MidiEventDemoButton_Click(object sender, EventArgs e) { if (M.HasError(_allTextBoxes)) { DoErrorMessage("Can't play because there is an error in one or more of the fields."); } else { Button midiEventDemoButton = sender as Button; DurationDef durationDef = GetDurationDef(); MidiChordDef midiChordDef = durationDef as MidiChordDef; RestDef restDef = durationDef as RestDef; if (midiChordDef != null) { int midiChannel = 0; OutputDevice outputDevice = M.Preferences.CurrentMultimediaMidiOutputDevice; if (_paletteForm.IsPercussionPalette) { midiChannel = 9; outputDevice = M.Preferences.GetMidiOutputDevice("Microsoft GS Wavetable Synth"); } MidiChord midiChord = new MidiChord(midiChannel, midiChordDef, outputDevice); midiChord.Send(); //sends in this thread (blocks the current thread -- keeping the button selected) } else { midiEventDemoButton.Hide(); Refresh(); // shows "rest" behind button Debug.Assert(restDef != null); Thread.Sleep(restDef.MsDuration); midiEventDemoButton.Show(); Refresh(); } } }