//internal void CopyQI(int srcqi, int destqi) { // //* copy one qi - no transpose or undo/redo (used by frmNoteMap.ChSymbols...) // SetChordAndAtts(destqi, NewMap[srcqi], ChordAtt[srcqi]); //} internal bool PropagateNoteMapBeat(clsMTime.clsBBT bbt, string txt, int qilo, int qihi) { clsCFPC.clsEv ev; //temp ev try { ev = new clsCFPC.clsEvPC(P.F.CF, new string[] { "", txt }); } catch (ChordFileException) { //invalid chord return(false); } ev.OnBBT = bbt; ev.OffBBT = new clsMTime.clsBBT(bbt.Beats + 1, true); //one beat bool[] boolarray = new bool[12]; foreach (clsCFPC.clsEv.clsNote note in ev.Notes) { boolarray[note.PC[eKBTrans.None]] = true; } for (int qi = qilo; qi < qihi; qi++) //was <= { int root = (ev.Root) ? ev.Notes[0].PC[eKBTrans.None] : -1; sChordAtt att = new sChordAtt( (sbyte)root, clsNoteMap.DescToPtr(ev.ChordQualifier)); SetChordAndAtts(qi, boolarray, att); //if (qi == 9) qi = qi; //temp debugging } return(true); }
//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); } }