예제 #1
0
            internal clsEvPC(clsCFPC chordfile, clsMTime.clsBBT onbbt, bool[] chord, List <int> chnotes) //create from notemap etc.
            //* chnotes optional
            {
                CF    = chordfile;
                OnBBT = onbbt;
                if (chnotes == null || chnotes.Count == 0)
                {
                    chnotes = new List <int>();
                    Root    = false;
                    for (int i = 0; i < 12; i++)
                    {
                        if (chord[i])
                        {
                            chnotes.Add(i);
                        }
                    }
                }
                else
                {
                    Root = true;
                }
                List <clsNotePC> listnpw = new List <clsNotePC>();

                foreach (int n in chnotes)
                {
                    listnpw.Add(new clsNotePC(n));
                }
                _Notes = listnpw.ToArray();
            }
예제 #2
0
        internal bool?Compare(clsCFPC cf, int seg)
        {
            //* compare key from this to key from txtkey - return true if the same
            clsKeyTicks algkey = Keys[seg];

            if (algkey == null)
            {
                return(null);
            }
            //algkey = algkey.Transpose(-cf.Transpose_File);
            int seglo = seg - ErrorMargin;
            int seghi = seg + ErrorMargin;

            for (int s = seglo; s <= seghi; s++)
            {
                if (s < 0 || s >= Keys.Count)
                {
                    continue;
                }
                int ticks = new clsMTime.clsBBT(s, 0, 0).Ticks;
                //int ticks = cf.MTime.GetTicks(s);
                clsKeyTicks txtkey = P.F.Keys[ticks];
                if (algkey.IsEquiv(txtkey))
                {
                    return(true);
                }
            }
            return(false);
        }
예제 #3
0
            }                            //clone for different time

            internal clsEvPC(clsCFPC cf, clsMTime.clsBBT onbbt, string[] ll)
                : this(cf, ll) //read .chp lines
            {
                OnBBT = onbbt;
                int ontime = onbbt.Ticks;

                if (ontime < 0)
                {
                    throw new ChordFileException();
                }
            }
예제 #4
0
            internal clsEvPC(clsCFPC chordfile, clsMTime.clsBBT onbbt, bool[] chord, int root) //create from notemapCF
            {
                CF    = chordfile;
                OnBBT = onbbt;
                List <int>       notelist = ConvBoolArrayToListInt(root, chord, out Root);
                List <clsNotePC> listnpw  = new List <clsNotePC>();

                foreach (int n in notelist)
                {
                    listnpw.Add(new clsNotePC(n));
                }
                _Notes = listnpw.ToArray();
            }
예제 #5
0
 internal clsPicNoteMapNM(Forms.IShowNoteMap ishownotemap, clsCFPC cftxt, PictureBox pic)
     : base(pic, null, true, ishownotemap.BarFont, false)
 {
     //* called from frmNoteMap using CF (chordfile)
     IShowNoteMap = ishownotemap;
     CFtxt        = cftxt;
     //FileName = cftxt.Txtfilename;
     //NoteMap = cftxt.NoteMap;
     //P.F.MaxQTime = maxqtime;
     //maxqtime.MaxQTime = cftxt.MaxQTime;
     //NumTrks = 1;
     //QIdd = clsFileStream.QIdd;
     //TicksPerQI = P.F.TicksPerQI;
     SetPicSize(null); //probably not necessary to do here
 }
예제 #6
0
            internal clsEvPC(clsCFPC chordfile, clsMTime.clsBBT onbbt, int[] chord) //BIAB, ManChords
            {
                CF    = chordfile;
                OnBBT = onbbt;
                Root  = true;
                List <clsNotePC> listnpw = new List <clsNotePC>();

                for (int i = 0; i < chord.Length; i++)
                {
                    clsNotePC npw = new clsNotePC();
                    //npw.PC_NoKBTrans = chord[i].Mod12();
                    npw.Set_PC_NoKBTrans(chord[i]);
                    listnpw.Add(npw);
                }
                _Notes = listnpw.ToArray();
            }
예제 #7
0
        internal float GetPercent(clsCFPC cf)
        {
            //* return percentage of keys that are the same
            int samecnt = 0, validcnt = 0;

            for (int seg = 0; seg < Keys.Count; seg++)
            {
                bool?result = Compare(cf, seg);
                if (result.HasValue)
                {
                    validcnt++;
                    if (result.Value)
                    {
                        samecnt++;
                    }
                }
            }
            return((samecnt * 100) / validcnt);
        }
예제 #8
0
            internal clsEvPC(clsCFPC cf, string[] ll) //null bbt, or called by other constructor
            //bars. beats, twelfths start at 0
            {
                CF = cf;
                //Index = index;

                if (ll[1] == "null") //no chord - use scale (7 note chord)
                {
                    _Notes = new clsNotePC[0];
                    return; //show nothing
                }

                List <clsNotePC> listnpw = new List <clsNotePC>();
                int chordpitch           = -1;
                int notecnt = 0;

                for (int i = 1; i < ll.Length; i++) //ll = space delimited line, incl bbt
                {
                    string l = ll[i];
                    if (l.StartsWith(".."))                         //bassnote
                    {
                        BassNote = l.TrimStart(new char[] { '.' }); //not yet used...
                    }
                    else if (l.StartsWith("."))                     //chordname
                    {
                        string name = l.TrimStart(new char[] { '.' });
                        chordpitch = NoteName.GetPitchAndQualifier(name, out ChordQualifier);
                        if (chordpitch < 0)
                        {
                            throw new ChordFileException();      //should be ChordFileException
                        }
                        //} else if (l.StartsWith(":")) {  //chordname (marked)
                        //  string name = l.TrimStart(new char[] { ':' });
                        //  chordpitch = NoteName.GetPitchAndQualifier(name, out ChordQualifier);
                        //  if (chordpitch < 0) throw new ChordFileException();  //should be ChordFileException
                        //  Mark = true;
                    }
                    else //note
                    {
                        if (++notecnt > (int)P.frmStart.nudMaxChordSize.Value)
                        {
                            continue;
                        }
                        clsNotePC npw   = new clsNotePC();
                        int       pitch = NoteName.GetPitch(l);
                        if (pitch < 0) //not a valid note - assume chord+qualifier
                        {
                            ll[i--] = "." + l;
                            continue;
                        }
                        npw.Set_PC_NoKBTrans(NoteName.GetPitch(l));
                        listnpw.Add(npw);
                    }
                }

                if (chordpitch >= 0) //chordname present, with or without notes
                {
                    string qual = ChordQualifier.ToLower();
                    ChordAnalysis.clsTemplate t = ChordAnalysis.NameToTemplate[qual];
                    ChordQualifier = t.Name;                    //change to correct case and spelling (if necessary)
                    if (listnpw.Count == 0)                     //get notes from ChordAnalysis
                    {
                        listnpw.Add(new clsNotePC(chordpitch)); //root
                        for (int p = 1; p < 12; p++)            //start at 1 - root already added
                        {
                            if (t.PC[p])
                            {
                                listnpw.Add(new clsNotePC((chordpitch + p).Mod12()));
                            }
                        }
                        //* if (listnpw.Count == 0) throw new ChordFileException();  //chord qualifier not found
                        //* temp frig - need to get user exceptions working with the debugger
                        if (listnpw.Count == 0)
                        {
                            throw new ChordFileException();
                        }
                    }
                }

                if (listnpw.Count < P.frmStart.nudMinChordSize.Value) //should be 0 unless advanced...
                {
                    _Notes = new clsNotePC[0];                        //null chord
                }
                else
                {
                    _Notes = listnpw.ToArray();
                    if (chordpitch == Notes[0].PC[eKBTrans.None])
                    {
                        Root = true;
                    }
                }
            }