Пример #1
0
        private clsChord EvToTxt(clsCFPC.clsEv ev)
        {
            //* get chord txt from ev ("null", "***", chord)
            clsChord chord;

            if (ev.Notes.Length == 0)
            {
                chord = new clsChord("null", 0);                  //null chord
            }
            else if (!ev.Root)
            {
                chord = new clsChord("***", 0); //non-recognisable chord
            }
            else
            {
                clsKeyTicks keyticks = P.F.Keys[ev.OnTime];
                //int midikey = P.F.Keys[ev.OnTime].MidiKey;  //current key
                if (Frm.TransposeChordNamesVal != 0)
                {
                    keyticks = keyticks.GetTransposeNames(Frm.TransposeChordNamesVal);
                    //midikey = keyticks.MidiKey;
                }
                int    rootpitch = Frm.ChordTranspose(ev.Notes[0].PC[eKBTrans.None]);
                string root      = NoteName.ToSharpFlat(NoteName.GetNoteName(keyticks, rootpitch));
                root  = root.Trim();
                chord = new clsChord(root + ev.ChordQualifier, root.Length);
            }
            return(chord);
        }
Пример #2
0
        internal static void ShowPicChordStatic(clsCFPC.clsEv ev, Graphics xgr, bool roundup)
        {
            //******** show unmodded (Pitch_NoKBTrans/KBTrans) if not null
            //******** still need to set Pitch_NoKBTrans
            if (ev.Notes == null || ev.Notes.Length == 0)
            {
                return;
            }

            //if (KBScale) {  //show chord notes on white keys
            //  if (ev == null || ev.PlayChord == null || ev.PlayChord.Chord == null) return;
            //  clsKey key = P.F.Keys[ev.PlayChord.OnTime];
            //  foreach (int cmajpc in ChordScales.CMajorToPC) {
            //    int? sfp = ChordScales.GetNearestDiaPitch(~cmajpc, key, ev.PlayChord);
            //    if (sfp.HasValue && ev.PlayChord.Chord.Contains(sfp.Value)) {
            //      frmSC.ShowChordNoteRiff(xgr, ev, cmajpc, sfp.Value);
            //    }
            //  }
            //  return;
            //}

            bool first     = true;
            int  rootpitch = -1;

            foreach (clsCFPC.clsEv.clsNote npw in ev.Notes)
            {
                bool dom = false;
                if (first && ev.Root) //root note
                //rootpitch = npw.PC_NoKBTrans;
                {
                    rootpitch = npw.PC[eKBTrans.None];
                }
                else if (rootpitch >= 0)
                {
                    //int interval = npw.PC_NoKBTrans - rootpitch + 12;
                    int interval = npw.PC[eKBTrans.None] - rootpitch + 12;
                    if (interval.Mod12() == 7)
                    {
                        dom = true;
                    }
                }
                clsCFPC.clsEv.sPitchPC pitchpc_kbtrans = npw.PitchPC_KBTrans;
                P.frmSC.ShowChordNote(xgr, pitchpc_kbtrans,
                                      ev.OnTime, npw.OnBBT.Ticks, ev.OffTime, first && ev.Root, dom, true, roundup);
                first = false;
            }
            if (P.frmSC.Play != null && ev.Notes.Length > 0 && ev.PlayChord == null) //support for KBChord
            {
                int[] chord = new int[ev.Notes.Length];
                int   i     = 0;
                foreach (clsCFPC.clsEv.clsNote notepitchweight in ev.Notes)
                {
                    //chord[i++] = notepitchweight.PC_KBTrans;
                    chord[i++] = notepitchweight.PC[eKBTrans.Add];
                }
                ev.PlayChord = new clsChordEvTimed(P.frmSC.Play, ev, chord);
            }
        }
Пример #3
0
 protected bool CheckDup(clsCFPC.clsEv ev2)
 {
     //* return true if duplicate
     bool[] bool1 = new bool[12];
     bool[] bool2 = new bool[12];
     foreach (clsCFPC.clsEv.clsNote s in Notes)
     {
         bool1[s.PC[eKBTrans.None]] = true;
     }
     foreach (clsCFPC.clsEv.clsNote s in ev2.Notes)
     {
         bool2[s.PC[eKBTrans.None]] = true;
     }
     return(bool1.SequenceEqual(bool2));
 }
Пример #4
0
        //internal clsManChords ManChordsZZZ;
        //internal static bool PlayChordNotes = false;

        //protected override clsChordEv MidiOn_ThisPlayChord {
        //  get {
        //    if (ManChords != null) return ManChords.PlayChord;
        //    return _MidiOn_ThisPlayChord;
        //  }
        //  set {
        //    _MidiOn_ThisPlayChord = value;
        //  }
        //}

        private void InitPlayEvents()
        {
            for (int i = 0; i < CF.Evs.Count; i++) //for each chord
            {
                clsCFPC.clsEv ev = CF.Evs[i];
                if (ev.Notes.Length == 0)
                {
                    continue;
                }
                List <int> e = new List <int>(); //notes in Cf.Evs[i]
                //foreach (clsCFPC.clsEv.clsNote n in ev.Notes) e.Add(n.PC_NoKBTrans);
                foreach (clsCFPC.clsEv.clsNote n in ev.Notes)
                {
                    e.Add(n.PC[eKBTrans.None]);
                }
                ev.PlayChord = new clsChordEvTimed(this, ev, e.ToArray());
            }
        }
Пример #5
0
 internal override void ShowPicChord(clsCFPC.clsEv ev, Graphics xgr, bool roundup)
 {
     //show graphical chord notes
     if (ev.PlayChord == null)
     {
         if (ev.Notes.Length == 0)
         {
             frmSC.ShowNullChord(xgr, ev.OnTime);
             return;
         }
         int[] chord = new int[ev.Notes.Length];
         int   i     = 0;
         foreach (clsCFPC.clsEv.clsNote notepitchweight in ev.Notes)
         {
             //chord[i++] = notepitchweight.PC_KBTrans;
             chord[i++] = notepitchweight.PC[eKBTrans.Add];
         }
         ev.PlayChord = new clsChordEvTimed(this, ev, chord);
     }
     frmSC.ShowChord(xgr, (clsChordEvTimed)ev.PlayChord, true);
 }
Пример #6
0
 internal override void ShowPicChord(clsCFPC.clsEv ev, Graphics xgr, bool roundup)
 {
     ShowPicChordStatic(ev, xgr, roundup);
 }
Пример #7
0
 internal clsChordEvTimed(clsPlay play, clsCFPC.clsEv ev, int[] chord) : base(play, chord, ev.Root)
 {
     OnTime = ev.OnTime;
 }
Пример #8
0
        //private void CopySimBars(clsChord[,] chordsrawcopy) {
        //  //* copy simbars
        //  if (P.F.frmNoteMapAdv != null && !P.F.frmNoteMapAdv.chkSectionsCopy.Checked || P.F.CF.QSections.Count == 0) return;
        //  for (int bar = 0; bar < NumBars; bar++) {
        //    int nn = BarToBBT[bar].TSig.NN;
        //    //for (int beat = 0; beat < nn; beat++) {
        //    //  if (!ChordsRaw[bar, beat].IsEquiv(chordsrawcopy[bar, beat])) {
        //    //    Frm.CopySimBars(bar, bar);  //copy whole bar if any beat is different
        //    //    break;
        //    //  }
        //    //}
        //    for (int beat = 0; beat < nn; beat++) {
        //      if (!ChordsRaw[bar, beat].IsEquiv(chordsrawcopy[bar, beat])) {
        //        clsMTime.clsBBT bbt = new clsMTime.clsBBT(bar, beat, 0);
        //        int qilo = bbt.Ticks / P.F.TicksPerQI;
        //        bbt.NextBeat();
        //        int qihi = bbt.Ticks / P.F.TicksPerQI;
        //        P.F.CF.QSections.CopyNoteMap(qilo, qihi);
        //      }
        //    }
        //  }
        //}

        //* raw -> run: set first beat of section or gap to current chord
        //*
        //* run -> raw: no propagation over section boundary

        //private void CheckSection(DataGridViewCellValidatingEventArgs e, clsChord chord) {
        //  //* stop new chord from going over a section boundary
        //  if (chord.Txt != "null") {
        //    int sectchangebar = P.F.CF.Sections.GetNextChange(e.ColumnIndex);
        //    if (sectchangebar < NumBars) {
        //      for (int bar = e.ColumnIndex; bar < NumBars; bar++) {
        //        clsMTime.clsBBT bbtbar = new clsMTime.clsBBT(bar, 0, 0);
        //        for (int beat = 0; beat < bbtbar.TSig.NN; beat++) {
        //          if (!String.IsNullOrWhiteSpace(ChordsRun[bar, beat].Txt)) break;
        //          if (bar == sectchangebar) {
        //            ChordsRun[bar, beat] = ChordsRaw[e.ColumnIndex, e.RowIndex].Copy();
        //            break;
        //          }
        //        }
        //      }
        //    }
        //  }
        //}

        //private void DGV_CellEndEdit(object sender, DataGridViewCellEventArgs e) {
        //  Debug.WriteLine("DGV_CellEndEdit");
        //  // Clear the row error in case the user presses ESC.
        //  DataGridViewCell cell = DGV.Rows[e.RowIndex].Cells[e.ColumnIndex];
        //  //DGV.Rows[e.RowIndex].ErrorText = String.Empty;
        //  cell.ErrorText = String.Empty;
        //}

        private void EvsToChordsRaw(int beatfrom, int beatto)
        {
            //* create ChordRun[bar, beat] from P.F.CF.Evs
            clsMTime.clsBBT bbtlo = new clsMTime.clsBBT(beatfrom, true);
            //clsMTime.clsBBT bbthi = new clsMTime.clsBBT(beatsto + 1, true);
            int firstevi = 0;

            if (beatfrom > 0)
            {
                firstevi = P.F.CF.Evs.BinarySearch(new clsCFPC.clsEvPC(bbtlo));
                if (firstevi < 0)
                {
                    firstevi = Math.Max(0, ~firstevi - 1);        //index before bbt
                }
            }
            clsCFPC.clsEv ev;
            for (int i = firstevi; i <= P.F.CF.Evs.Count; i++)
            {
                if (i == P.F.CF.Evs.Count) //gap at end - pad with null ev
                {
                    if (P.F.CF.Evs.Count == 0)
                    {
                        ev = new clsCFPC.clsEvPC(P.F.CF, new clsMTime.clsBBT(0), new int[0]); //pad after lastev
                    }
                    else
                    {
                        clsCFPC.clsEv evlast = P.F.CF.Evs[i - 1];
                        if (evlast.OffTime >= P.F.MaxBBT.Ticks)
                        {
                            break;
                        }
                        ev = new clsCFPC.clsEvPC(P.F.CF, evlast.OffBBT, new int[0]); //pad after lastev
                    }
                    //ev.OffBBT = new clsMTime.clsBBT(P.F.MaxTicks);
                    ev.OffBBT = P.F.MaxBBT.BBTCopy;
                }
                else
                {
                    ev = P.F.CF.Evs[i];
                }
                //* look at ALL beats (lines) contained in the ev
                if (ev.OnTime >= new clsMTime.clsBBT(beatto, true).Ticks)
                {
                    break;
                }
                for (int beat = ev.OnBBT.Beats; beat < ev.OffBBT.Beats; beat++)
                {
                    if (beat < beatfrom)
                    {
                        continue;         //before start of beats range
                    }
                    if (beat > beatto)
                    {
                        break;       //after end of beats range
                    }
                    clsMTime.clsBBT bbt       = new clsMTime.clsBBT(beat, true);
                    int             ticks     = bbt.Ticks;
                    int             nextticks = new clsMTime.clsBBT(beat + 1, true).Ticks;
                    if (ticks >= ev.OnBBT.Ticks && nextticks <= ev.OffBBT.Ticks) //ev fills beat
                    {
                        ChordsRaw[bbt.Bar, bbt.BeatsRemBar] = EvToTxt(ev);
                    }
                    else
                    {
                        ChordsRaw[bbt.Bar, bbt.BeatsRemBar] = new clsChord("***", 0);
                    }
                }
            }

            //* set initial, end (or all) empty ChordsRaw to null
            for (int beat = 0; beat < NumBeats; beat++)
            {
                //if (beat == 270) Debugger.Break();  //temp
                clsMTime.clsBBT bbt = BeatToBBT[beat];
                if (ChordsRaw[bbt.Bar, bbt.BeatsRemBar] != null)
                {
                    continue;
                }
                ChordsRaw[bbt.Bar, bbt.BeatsRemBar] = new clsChord("null", 0);
            }
        }