Beispiel #1
0
        private void checkBox_CheckedChanged(object sender, EventArgs e)
        {
            //prepsani checkboxu mohla volat i jina metoda, veskere dalsi akce se vsak provadi pouze pokud byly prepsany skutecne, "manualne"
            if (radioChordNotes.Checked)
            {
                if ((comboRoot.SelectedIndex == -1) || (checkboxes[(int)root].Checked == false))
                {
                    //pokud ton s funkci zakladniho tonu (rootu) je odznacen, vybere se novy - nejnizsi zaskrtnuty
                    comboRoot.SelectedIndex = -1;
                    for (int i = 0; i < 12; i++)
                    {
                        if (checkboxes[i].Checked)
                        {
                            comboRoot.SelectedIndex = i;
                            break;
                        }
                    }
                }


                //pokusi se sestavit ze zadanych tonu schema a vyplnit sekci "Struktura akordu"
                ChordFormula current = tryBuildFormula();
                if (current == null)
                {
                    //pokud se nepovedlo, vynulujeme udaje v sekci 'Struktura' (tony zrejme netvori korektni akord)
                    current = new ChordFormula("", 0, 0, 0, 0, 0, 0);
                }
                comboThird.SelectedIndex      = current.Third;
                comboFifth.SelectedIndex      = current.Fifth;
                comboSeventh.SelectedIndex    = current.Seventh;
                comboNinth.SelectedIndex      = current.Ninth;
                comboEleventh.SelectedIndex   = current.Eleventh;
                comboThirteenth.SelectedIndex = current.Thirteenth;
            }
        }
Beispiel #2
0
        private bool isFormula(ChordFormula formula)
        {
            //funkce porovna parametry v sekci "struktura akordu" s konkretnim schematem
            if (comboThird.SelectedIndex != formula.Third)
            {
                return(false);
            }
            if (comboFifth.SelectedIndex != formula.Fifth)
            {
                return(false);
            }
            if (comboSeventh.SelectedIndex != formula.Seventh)
            {
                return(false);
            }
            if (comboNinth.SelectedIndex != formula.Ninth)
            {
                return(false);
            }
            if (comboEleventh.SelectedIndex != formula.Eleventh)
            {
                return(false);
            }
            if (comboThirteenth.SelectedIndex != formula.Thirteenth)
            {
                return(false);
            }

            return(true);
        }
Beispiel #3
0
 //manualni zmena nazvu akordu - prepsani informaci v sekci ' struktura' (coz nasledne vede k prepsani checkboxu)
 private void comboChordName_SelectedIndexChanged(object sender, EventArgs e)
 {
     if ((comboChordName.SelectedIndex > -1) && (radioName.Checked))
     {
         ChordFormula current = knownFormulas[comboChordName.SelectedIndex];
         comboThird.SelectedIndex      = current.Third;
         comboFifth.SelectedIndex      = current.Fifth;
         comboSeventh.SelectedIndex    = current.Seventh;
         comboNinth.SelectedIndex      = current.Ninth;
         comboEleventh.SelectedIndex   = current.Eleventh;
         comboThirteenth.SelectedIndex = current.Thirteenth;
     }
 }
Beispiel #4
0
        private ChordFormula tryBuildFormula()
        {
            //funkce se pokusi sestavit ze zadanych tonu akord a dosadit patricne hodnoty do sekce Struktura

            ChordFormula formulaUnderConstruction = new ChordFormula("", 0, 0, 0, 0, 0, 0);
            int          found = 0;

            //snazime se najit a priradit prislusne harmonicke funkci konkretni ton. Zkousime vsechny mozne modulace intervalu (napr. tercie
            //muze byt velka, mala, zmensena nebo zvetsena).

            //tercie
            if (checkboxes[((int)root + 4) % 12].Checked)
            {
                formulaUnderConstruction.Third = 3; found++;
            }
            else
            {
                if (checkboxes[((int)root + 3) % 12].Checked)
                {
                    formulaUnderConstruction.Third = 2; found++;
                }
                else
                {
                    if (checkboxes[((int)root + 2) % 12].Checked)
                    {
                        formulaUnderConstruction.Third = 1; found++;
                    }
                    else
                    {
                        if (checkboxes[((int)root + 5) % 12].Checked)
                        {
                            formulaUnderConstruction.Third = 4; found++;
                        }
                    }
                }
            }
            //kvinta
            if (checkboxes[((int)root + 7) % 12].Checked)
            {
                formulaUnderConstruction.Fifth = 2; found++;
            }
            else
            {
                if (checkboxes[((int)root + 6) % 12].Checked)
                {
                    formulaUnderConstruction.Fifth = 1; found++;
                }
                else
                {
                    if (checkboxes[((int)root + 8) % 12].Checked)
                    {
                        formulaUnderConstruction.Fifth = 3; found++;
                    }
                }
            }
            //septima
            if (checkboxes[((int)root + 10) % 12].Checked)
            {
                formulaUnderConstruction.Seventh = 2; found++;
            }
            else
            {
                if (checkboxes[((int)root + 11) % 12].Checked)
                {
                    formulaUnderConstruction.Seventh = 3; found++;
                }
                else
                {
                    if (checkboxes[((int)root + 9) % 12].Checked)
                    {
                        formulaUnderConstruction.Seventh = 1; found++;
                    }
                }
            }
            //nona
            if ((checkboxes[((int)root + 2) % 12].Checked) && (formulaUnderConstruction.Third > 1))
            {
                formulaUnderConstruction.Ninth = 2; found++;
            }
            else
            {
                if (checkboxes[((int)root + 1) % 12].Checked)
                {
                    formulaUnderConstruction.Ninth = 1; found++;
                }
            }
            //undecima
            if ((checkboxes[((int)root + 5) % 12].Checked) && (formulaUnderConstruction.Third < 4))
            {
                formulaUnderConstruction.Eleventh = 1; found++;
            }
            else
            {
                if ((checkboxes[((int)root + 6) % 12].Checked) && (formulaUnderConstruction.Fifth > 1))
                {
                    formulaUnderConstruction.Eleventh = 1; found++;
                }
            }
            //tercdecima
            if ((checkboxes[((int)root + 9) % 12].Checked) && (formulaUnderConstruction.Seventh > 1))
            {
                formulaUnderConstruction.Thirteenth = 2; found++;
            }
            else
            {
                if ((checkboxes[((int)root + 8) % 12].Checked) && (formulaUnderConstruction.Fifth < 3))
                {
                    formulaUnderConstruction.Thirteenth = 1; found++;
                }
            }
            //pozn. poradi testu na intervaly je DULEZITE! Napr. interval 2 muze znamenat zmensenou tercii, ale i cistou nonu; musime testovat tercii driv,
            //protoze v akordove skladbe ma prednost. Pouze v pripade, ze jsme j*z nasli cistou tercii (malou - 3 nebo velkou - 4) muze byt interval 2
            //interpretovan jako nona.

            int checkedCount = 0;

            for (int i = 0; i < 12; i++)
            {
                if (checkboxes[i].Checked)
                {
                    checkedCount++;
                }
            }
            //kontrola, zda pocet tonu zadanych pomoci checkboxu je stejny, jako pocet nalezenych harmonickych funkci
            if (checkedCount > found + 1) //+1 znamena root (ten se v prubehu funkce nezapocetl)
            {
                return(null);             //nepodarilo se najit schema zahrnujici vsechny tony
            }
            return(formulaUnderConstruction);
        }