private void Slot_MouseDownBlow(object sender, MouseEventArgs e) { var hs = (Button)sender; var nc = (KeyValuePair <AirSlotAttributesClass, InstrumentsNotesClass>)hs.Tag; Application.DoEvents(); hs.BackColor = Color.Green; sa.NoteOn(nc.Value.GetNoteByte(), 65, 0); if (writeNoteToText) { timePlayed.Restart(); SongText.AppendText($@"{nc.Value.Note}"); } Application.DoEvents(); Thread.Sleep(100); }
/* * public int GetHarpSlotnDiff(AirSlotAttributesClass HarpSlot, HarpInstrumentClass refHarpInstrument) * { * int notediff = 0; * if (this.Name != refHarpInstrument.Name) * { * //Referenzinstument ist diffeernt, es muß die R0wDiff errechnet werden * * KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass> instrument = new KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass>(); * KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass> instrumentRef = new KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass>(); * * foreach (KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass> ins in InstrumentNotesDefinition) * { * if ((ins.Key.BreathDirection == HarpSlot.BreathDirection) && (ins.Key.Slot == HarpSlot.Slot)) * { * instrument = ins; * break; * } * } * * foreach (KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass> ins in refHarpInstrument.InstrumentNotesDefinition) * { * if ((ins.Key.BreathDirection == HarpSlot.BreathDirection) && (ins.Key.Slot == HarpSlot.Slot)) * { * instrumentRef = ins; * break; * } * } * * if (instrumentRef.Value != null && instrument.Value != null) * { * notediff = instrument.Value.NoteDiff - instrumentRef.Value.NoteDiff; * } * } * return notediff; * } */ /* * public byte Play(AirSlotAttributesClass HarpSlot, SimpleApi sa, HarpInstrumentClass refHarpInstrument) * { * int notediff = GetHarpSlotnDiff(HarpSlot, refHarpInstrument); * KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass> instrument = new KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass>(); * * foreach (KeyValuePair<AirSlotAttributesClass, InstrumentsNotesClass> ins in InstrumentNotesDefinition) * { * if ((ins.Key.BreathDirection == HarpSlot.BreathDirection) && (ins.Key.Slot == HarpSlot.Slot - notediff)) * { * instrument = ins; * break; * } * } * byte playByte = 0; * * if (instrument.Value != null) * { * * playByte = instrument.Value.GetNoteByte(); * //sa.SetTranspose(transpose); * sa.NoteOn(playByte); * } * return playByte; * } */ public byte Play(AirSlotAttributesClass HarpSlot, SimpleApi sa) { //int notediff = GetHarpSlotnDiff(HarpSlot, refHarpInstrument); KeyValuePair <AirSlotAttributesClass, InstrumentsNotesClass> instrument = new KeyValuePair <AirSlotAttributesClass, InstrumentsNotesClass>(); foreach (KeyValuePair <AirSlotAttributesClass, InstrumentsNotesClass> ins in InstrumentNotesDefinition) { if ((ins.Key.BreathDirection == HarpSlot.BreathDirection) && (ins.Key.Slot == HarpSlot.Slot)) { instrument = ins; break; } } byte playByte = 0; if (instrument.Value != null) { playByte = instrument.Value.GetNoteByte(); //sa.SetTranspose(transpose); sa.NoteOn(playByte); } return(playByte); }