예제 #1
0
        private void ChordsRawToRun()
        {
            //* convert ChordsRaw to ChordsRun
            string runningtxt = "#";

            for (int b = 0; b < BeatToBBT[NumBeats].Beats; b++) //BarToBBT includes bar after last (Numbars+1)
            {
                clsMTime.clsBBT bbt   = BeatToBBT[b];
                int             bar   = bbt.Bar;
                int             beat  = bbt.BeatsRemBar;
                clsChord        chord = ChordsRaw[bar, beat];
                string          txt   = chord.Txt;
                if (txt == null || txt == "")
                {
                    LogicError.Throw(eLogicError.X006, "txt = " + txt); //invalid beat (> NN) or not raw
                    ChordsRun[bar, beat] = new clsChord("", 0);
                }
                //if (txt != runningtxt || (beat == 0 && P.F.CF.Sections.Boundaries[bar])) {
                //if (txt != runningtxt || P.F.CF.QSections.FirstBeatName(bbt) != '*') {
                if (txt != runningtxt || (bar == 0 && beat == 0))
                {
                    ChordsRun[bar, beat] = chord.Copy();
                }
                else
                {
                    ChordsRun[bar, beat] = new clsChord("", 0);
                }
                runningtxt = txt;
            }
        }
예제 #2
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);
        }
예제 #3
0
 internal bool SequenceEqual(clsChord ch)
 {
     if (ch == null)
     {
         return(false);
     }
     return(Notes.SequenceEqual(ch.Notes));
 }
예제 #4
0
 internal bool IsEquiv(clsChord chord)
 {
     if (Txt == chord.Txt && Offset == chord.Offset)
     {
         return(true);
     }
     return(false);
 }
예제 #5
0
        private void ChordsRawToNoteMap(clsChord[,] copy)
        {
            //* update notemap with chord changes
            for (int b = 0; b < NumBeats; b++)
            {
                clsMTime.clsBBT bbt   = BeatToBBT[b];
                int             bar   = bbt.Bar;
                int             beat  = bbt.BeatsRemBar;
                clsChord        chord = ChordsRaw[bar, beat];
                if (chord.Txt == "***")
                {
                    continue;
                }
                if (copy[bar, beat].IsEquiv(chord))
                {
                    continue;
                }
                string txt = chord.Txt;

                //* transpose if necessary
                //int diff = (Frm.ChordTransposeNamesVal - Frm.ChordTransposeNotesVal).Mod12();
                int diff = Frm.TransposeChordNamesVal;
                if (diff != 0 && txt != "null")
                {
                    string qualifier;
                    int    pc = NoteName.GetPitchAndQualifier(chord.Txt, out qualifier);
                    if (pc < 0)
                    {
                        LogicError.Throw(eLogicError.X007, "pc = " + pc);
                        pc = 0;
                    }
                    pc  = Frm.ChordTransposeReverse(pc);
                    txt = NoteName.PitchToKeyStr(pc, P.F.Keys[0].Scale).TrimEnd() + qualifier;
                }

                int qilo = bbt.Ticks / P.F.TicksPerQI;
                int qihi = new clsMTime.clsBBT(b + 1, true).Ticks / P.F.TicksPerQI;
                if (qihi > P.F.MaxBBT.QI)
                {
                    break;                //???
                }
                string dottxt = (chord.Txt == "null") ? "null" : "." + txt;
                if (!P.F.CF.NoteMap.PropagateNoteMapBeat(bbt, dottxt, qilo, qihi))
                {
                    LogicError.Throw(eLogicError.X008);
                    P.F.CF.NoteMap.PropagateNoteMapBeat(bbt, "null", qilo, qihi);
                }
            }

            //Frm.picNoteMapFile.Refresh();
            Frm.RefreshpicNoteMapFile();
        }
예제 #6
0
 internal bool Contains(clsChord ch)
 {
     if (ch == null)
     {
         return(false);
     }
     for (int i = 0; i < ch.Notes.Length; i++)
     {
         if (ch[i] && !Notes[i])
         {
             return(false);
         }
     }
     return(true);
 }
예제 #7
0
 private clsChord[,] CopyChords(clsChord[,] chords)
 {
     //* create copy of ChordsRun or ChordsRaw
     clsChord[,] ret = new clsChord[chords.GetLength(0), chords.GetLength(1)];
     for (int i = 0; i < chords.GetLength(0); i++)
     {
         for (int j = 0; j < chords.GetLength(1); j++)
         {
             if (chords[i, j] == null)
             {
                 continue;              //bar with less than MaxNN beats
             }
             ret[i, j] = chords[i, j].Copy();
         }
     }
     return(ret);
 }
예제 #8
0
        private void ChordsRunToRaw()
        {
            //* convert ChordsRun to ChordsRaw
            clsChord runningchord = new clsChord("null", 0);

            for (int b = 0; b < NumBeats; b++)
            {
                clsMTime.clsBBT bbt   = BeatToBBT[b];
                int             bar   = bbt.Bar;
                int             beat  = bbt.BeatsRemBar;
                clsChord        chord = ChordsRun[bar, beat];
                if (chord != null && !string.IsNullOrWhiteSpace(chord.Txt))
                {
                    runningchord = chord;
                }
                ChordsRaw[bar, beat] = runningchord.Copy();
            }
        }
예제 #9
0
        private void DGV_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            if (MidiPlay.Sync.indPlayActive != clsSync.ePlay.None)
            {
                //e.Cancel = true;
                return;
            }
            string txt = ((string)e.FormattedValue).ToLower();
            //Debug.WriteLine("DGV_CellValidating [" + e.ColumnIndex + ", " + e.RowIndex + "] - " + txt);
            DataGridViewCell cell  = DGV.Rows[e.RowIndex].Cells[e.ColumnIndex];
            clsChord         chord = clsChord.Validate(txt);

            if (cell.ReadOnly) //greater than tsig.nn for this bar (greyed out)
            //e.Cancel = true;
            {
            }
            else if (chord == null) //invalid chord
            //cell.ErrorText = "@@@" + txt;
            {
                e.Cancel = true;
            }
            else if (!chord.IsEquiv(ChordsRun[e.ColumnIndex, e.RowIndex])) //different chord
            //if (String.IsNullOrWhiteSpace(chord.Txt) && P.F.CF.QSections.FirstBeatName(bbt) != '*') {
            //* what are the next 3 lines doing???
            //*if (String.IsNullOrWhiteSpace(chord.Txt) && e.ColumnIndex == 0 && e.RowIndex == 0) {
            //*  chord = ChordsRaw[e.ColumnIndex, e.RowIndex];  //replace "" with raw chord
            //*}
            {
                ChordsRun[e.ColumnIndex, e.RowIndex] = chord;
                clsChord[,] chordsrawcopy            = CopyChords(ChordsRaw);
                ChordsRunToRaw();
                ChordsRawToNoteMap(chordsrawcopy);
                cell.Value = chord.Txt;
                //CopySimBars(chordsrawcopy);
                Frm.SetNoteMapFileChanged(undoredo: true, indqi: true); //no copysimbars - already done
            }
            DGV.RefreshEdit();
        }
예제 #10
0
 internal clsTimeChord(int ticks, clsChord chord)
 {
     Ticks = ticks;
     Chord = chord;
 }