internal static clsMTime.clsSegment GetStartSeg(eAlign align, int qilo, int qihi, int qiwidth, int ticksperqi) { clsMTime.clsSegment startseg; switch (align) { case eAlign.Bar: startseg = new clsMTime.clsSegBar(ticksperqi, qilo, qihi); break; case eAlign.Beat: startseg = new clsMTime.clsSegBeat(ticksperqi, qilo, qihi); break; case eAlign.HalfBar: startseg = new clsMTime.clsSegHalfBar(ticksperqi, qilo, qihi); break; case eAlign.Interval: startseg = new clsMTime.clsSegInterval(ticksperqi, qilo, qihi, qiwidth); break; default: LogicError.Throw(eLogicError.X067); startseg = new clsMTime.clsSegBeat(ticksperqi, qilo, qihi); break; } return(startseg); }
internal clsChordInfo(eAlign align) { if (Align == eAlign.Auto) { LogicError.Throw(eLogicError.X084); } Align = align; }
public virtual void Reset() { isStatic = true; _subdivisionsHeight = 1; _subdivisionsWidth = 1; _align = eAlign.alignY; _invert = false; _invertNormal = false; }
internal clsChordSegs(clsFileStream filestream, Forms.frmChordMap frmnotemap, eAlign align, bool setatts) { if (align == eAlign.None) { return; } FS = filestream; frmNoteMap = frmnotemap; Align = align; ApplyChords(setatts); }
internal int GetChordCountSeg(List <clsChordInfo> listci, eAlign align) { //* get chord counts for a segment type (bar/halfbar/beat) int count = 0; foreach (clsChordInfo ci in listci) { if (ci.Align == align) { count++; } } return(count); }
private void GetScores() { eAlign[] arralign = new eAlign[] { Align }; ListCIArr = new List <clsChordInfo> [1]; //chordlist for bar only if (Align == eAlign.Auto) //try bar, half-bar, beat { arralign = new eAlign[] { eAlign.Bar, eAlign.HalfBar, eAlign.Beat }; ListCIArr = new List <clsChordInfo> [3]; //chordlists for bar, halfbar, beat } for (int i = 0; i < arralign.Length; i++) { ListCIArr[i] = Forms.frmChordMap.GetChordScores(FS, frmNoteMap, -1, -1, Cfg.DebugPath + @"\DumpChords[" + arralign[i] + "]", arralign[i]); } if (DebugChords) { DebugScores(); } }
public static string MultilineText(string text, int length, eAlign align, char?fill = null) { StringBuilder buffer = new StringBuilder(); string aux = text.Trim(), line; int n = length; while (!String.IsNullOrEmpty(aux)) { if (aux.Length < n) { n = aux.Length; } line = Util.TextAlign(aux.Substring(0, n), length, align, fill); buffer.AppendLine(line); aux = aux.Substring(n); } return(buffer.ToString()); }
internal void FillSegments(eAlign align, int qilo, int qihi, int fillpercent, int qiwidth) { //* fill or empty segments (bars/halfbars/beats) by modded note if (align == eAlign.Interval && qiwidth == 0) { return; } int ticksperqi = P.F.TicksPerQI; for (int n = 0; n < 12; n++) { clsMTime.clsSegment startseg = GetStartSeg(align, qilo, qihi, qiwidth, ticksperqi); //* quantize for (clsMTime.clsSegment segment = startseg; !segment.OOR; segment++) { int totqiall = segment.SegQIWidth; int totqion = 0; int segqilo = segment.SegQILo; int segqihi = segment.SegQIHi; for (int qi = segqilo; qi <= segqihi; qi++) { if (IsF(qi, n)) { totqion++; } } int percent = (totqion * 100) / totqiall; bool fill = false; if (totqion > 0 && percent >= fillpercent) { fill = true; //fill segment (else clear) } for (int qi = segqilo; qi <= segqihi; qi++) { SetF(qi, n, fill); //fill or clear segment } } } }
internal void RoundUp(eAlign align) { switch (align) { case eAlign.Bar: RoundUpToBar(); return; case eAlign.HalfBar: RoundUpToHalfBar(); return; case eAlign.Beat: RoundUpToBeat(); return; default: LogicError.Throw(eLogicError.X023); RoundUpToBeat(); return; } }
//DEVUELVE UNA CADENA CON EL TEXTO ALINEADO SEGUN LOS PARAMETROS ESPECIFICOS public static string TextAlign(string text, int length, eAlign align, char?fill = null) { try { string t = text.Trim(); int n = text.Length, d, i = 0; char charFill = (fill == null) ? ' ' : (char)fill; if (n > length) { t = t.Substring(0, length); } else { switch (align) { case eAlign.LEFT: t = t.PadRight(length, charFill); break; case eAlign.CENTER: d = (length - n) / 2; i = ((length - n) % 2 != 0) ? 1 : 0; t = new String(charFill, d) + t + new String(charFill, d + i); break; case eAlign.RIGHT: t = t.PadLeft(length, charFill); break; } } return(t); } catch { throw; } }
internal void ApplyTrim(eAlign aligntrim, int qilo, int qihi, int qiquant, int qiinner, int qiouter) { //* trim syncopated notes //* uses OnOffPair - apply before other filters bool pretrim = P.frmCfgChords.chkTrimPre.Checked; bool posttrim = P.frmCfgChords.chkTrimPost.Checked; if (qiinner == 0 || qiouter == 0) { return; } if (!pretrim && !posttrim) { return; } int ticksperqi = P.F.TicksPerQI; if (OnOffPairs == null) { CreateOnOffPairs(); } for (int n = 0; n < 12; n++) { clsOnOffPairs pairs = OnOffPairs[n]; if (pretrim) { clsMTime.clsSegment startseg = GetStartSeg(aligntrim, qilo, qihi, qiquant, ticksperqi); for (clsMTime.clsSegment segment = startseg; !segment.OOR; segment++) { if (qiinner > segment.SegQIWidth / 2) { continue; //'before' too large } if (qiouter < segment.SegQIWidth / 8) { continue; //'after' too small } //* check if trim required int indexoffq = pairs.IndexOffQ(segment.SegQILo); //first ON at or after SeqQILo if (indexoffq < 0) { continue; //after last event } int offq = pairs.Off(indexoffq); if (offq > segment.SegQILo + qiinner) { continue; } int onq = pairs.On(indexoffq); if (onq > segment.SegQILo - qiouter) { continue; } //* trim //for (int q = offq; q >= segment.SegQILo; q--) SetF(q, n, false); for (int q = segment.SegQILo; q < segment.SegQILo + qiinner; q++) { SetF(q, n, false); } } } if (posttrim) { clsMTime.clsSegment startseg = GetStartSeg(aligntrim, qilo, qihi, qiquant, ticksperqi); for (clsMTime.clsSegment segment = startseg; !segment.OOR; segment++) { if (qiinner > segment.SegQIWidth / 2) { continue; //'before' too large } if (qiouter < segment.SegQIWidth / 8) { continue; //'after' too small } //* check if trim required int indexonq = pairs.IndexOnQ(segment.SegQIHi); //first ON at or before SeqQIHi if (indexonq < 0) { continue; //before first event } int onq = pairs.On(indexonq); if (onq < segment.SegQIHi + 1 - qiinner) { continue; } int offq = pairs.Off(indexonq); if (offq < segment.SegQIHi + 1 + qiouter) { continue; } //* trim //for (int q = onq; q <= segment.SegQIHi; q++) SetF(q, n, false) for (int q = segment.SegQIHi; q > segment.SegQIHi - qiouter; q--) { SetF(q, n, false); } } } } }