Esempio n. 1
0
        private int?MidiOnSub_KBChord(int inpitch)
        {
            //* B[1] = key pressed
            //* pitch = pitch calculated by KBScale, or B[1]

            if (MidiOn_ThisPlayChord == null)
            {
                LastPitchOn     = inpitch - TransposeKB + TransposeKBPitch;
                LastPitchOnTime = null;
            }
            else
            {
                int pitch = MidiOn_ThisPlayChord.GetNearestPitch(inpitch);
                if (pitch < 0)
                {
                    LastPitchOn = inpitch - TransposeKB + TransposeKBPitch;
                    return(LastPitchOn); //return for MidiOnSub
                }
                if (P.frmStart.chkKBChordMatch.Checked)
                {
                    bool up = (B[1] >= LastKeyOn ||
                               !LastPitchOnTime.HasValue ||
                               (DateTime.Now - LastPitchOnTime.Value).TotalMilliseconds < 100);
                    while (KBPitchList.GetPitch(false, pitch + TransposeKBPitch).Count > 0) //look for next highest if pitch already playing
                    {
                        if (up)
                        {
                            pitch = MidiOn_ThisPlayChord.GetNextUp(pitch); //chord or ascending arpeggio
                        }
                        else
                        {
                            pitch = MidiOn_ThisPlayChord.GetNextDown(pitch); //descending arpeggio
                        }
                        if (pitch < 0)
                        {
                            return(null); //return for MidiOnSub
                        }
                    }
                }
                pitch          += TransposeKBPitch;
                LastPitchOn     = pitch;
                LastPitchOnTime = DateTime.Now;
            }
            return(LastPitchOn);
        }
Esempio n. 2
0
 internal override bool MidiOnDup(int pitch)
 {
     if (PedalDown)
     {
         lock (clsPlay.KBPitchList) {
             List <clsKBPitch> kbpl = KBPitchList.GetPitch(null, pitch);
             for (int i = 0; i < kbpl.Count; i++)
             {
                 clsKBPitch kbp = kbpl[i];
                 //* if pitch is sustained, associate with this kb
                 //* else add new kb for this pitch
                 if (kbp.Sustained)
                 {
                     clsPlay.KBPitchList.Remove(kbp);
                 }
                 ///////////KBPitchList.Add(B[1], pitch);
             }
         }
         return(true);
     }
     return(false);
 }