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); }
internal static string GetNoteNameOrRoman(int pitch, clsKeyTicks key) { if (P.frmSC.chkShowChordsRel.Checked) { //return GetDegree(pitch, key.KBTrans_KeyNote); return(GetDegree(pitch, key.KeyNote)); } else { return(NoteName.ToSharpFlat(NoteName._Names[key.MajMin, key.MidiKey + 7, pitch].TrimEnd())); } }
//internal string ChordName(sNote[] notes) { //eg C, Am, F#dim internal string ChordName(eKBTrans kbtranspc, bool kbtranskey) //eg C, Am, F#dim //* show in txt boxes { if (Notes == null || Notes.Length == 0) { return("null"); } if (Root) { //int pitch = (kbtrans) ? Notes[0].PC_KBTrans : Notes[0].PC_NoKBTrans; int pitch = Notes[0].PC[kbtranspc]; //int midikey = P.F.Keys[OnTime].KBTrans_MidiKey; clsKey key = P.F.Keys[OnTime, kbtranskey]; //return NoteName.ToSharpFlat(NoteName._Names[midikey + 7][pitch].TrimEnd()) + ChordQualifier; return(NoteName.ToSharpFlat(NoteName.GetName(key, pitch).TrimEnd()) + ChordQualifier); } else { return("xxxx"); } }
internal static clsChord Validate(string txt) { if (string.IsNullOrWhiteSpace(txt)) { return(new clsChord("", 0)); } if (txt == "***" || txt == "null") { return(new clsChord(txt, 0)); } string qualifier; int pc = NoteName.GetPitchAndQualifier(txt, out qualifier); if (pc < 0) { return(null); //invalid chord } //string root = NoteName.ToSharpFlat(NoteName._Names[P.F.Keys[0].MidiKey + 7][pc]).TrimEnd(); string root = NoteName.ToSharpFlat(NoteName.GetName(P.F.Keys[0], pc).TrimEnd()); return(new clsChord(root + qualifier, root.Length)); }
internal static string ShowChordText(int[] chord, clsKeyTicks key) { //* form thread //* show current playchord (root and qualifier) if (chord == null || chord.Length < 3) { //P.frmSC.txtChordBottom.Text = ""; return(""); } bool[] pcs = new bool[12]; foreach (int c in chord) { pcs[c] = true; } int rootpc = chord[0]; //List<string> names = ChordAnalysis.GetMatchingChordNames(pcs, rootpc); //string qualifier = (names.Count == 0) ? "xxx" : names[0]; string qualifier = ChordAnalysis.GetName(pcs); //string txt = NoteName.ToSharpFlat(NoteName._Names[key.MidiKey + 7][rootpc].TrimEnd()) + qualifier; string txt = NoteName.ToSharpFlat(NoteName.GetName(key, rootpc).TrimEnd()) + qualifier; return(txt); }
private static string GetNoteName(int note, clsKey mkey) { return(NoteName.ToSharpFlat(NoteName.GetNoteName(mkey, note.Mod12()))); }