Пример #1
0
        private void scaleComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int[]     scaleIntervals = minorScale;
            ScaleName scaleName      = ScaleName.Minor;

            switch (scaleComboBox.SelectedIndex)
            {
            case 0:    //Выбран натуральный минор
                scaleIntervals = minorScale;
                scaleName      = ScaleName.Minor;
                break;

            case 1:    //Выбран натуральный мажор
                scaleIntervals = majorScale;
                scaleName      = ScaleName.Major;
                break;

            case 2:
                scaleIntervals = flamencoScale;
                scaleName      = ScaleName.Flamenco;
                break;

            case 3:
                scaleIntervals = bluesScale;
                scaleName      = ScaleName.Blues;
                break;

            case 4:
                scaleIntervals = flamenco2Scale;
                scaleName      = ScaleName.Flamenco2;
                break;
            }

            selectedScale = new MyScale(scaleName, scaleIntervals);
        }
Пример #2
0
        public static int[] GetProbabilities(int[] values, ScaleName scaleName)
        {
            int[] probabilities = new int[values.Length];

            /* По умолчанию сделаем равномерное распределение */
            for (int i = 0; i < values.Length; i++)
            {
                values[i]        = i;
                probabilities[i] = 100 / probabilities.Length;
            }
            probabilities[0] += 100 - probabilities.Sum();

            if (scaleName != ScaleName.Other && values.Length == 8)
            {
                probabilities = new int[] { 3, 40, 19, 19, 5, 5, 5, 4 };
            }

            if (scaleName == ScaleName.Flamenco && values.Length == 8)
            {
                probabilities = new int[] { 2, 75, 9, 3, 3, 3, 3, 2 };
            }

            if (scaleName == ScaleName.Flamenco2 && values.Length == 8)
            {
                probabilities = new int[] { 2, 75, 9, 3, 3, 3, 3, 2 };
            }

            if (scaleName == ScaleName.Blues && values.Length == 7)
            {
                probabilities = new int[] { 5, 40, 24, 19, 4, 4, 4 };
            }

            return(probabilities);
        }
Пример #3
0
        public static int[] GetProbabilities(int[] values, ScaleName scaleName)
        {
            int[] probabilities = new int[values.Length];

            /* По умолчанию сделаем равномерное распределение */
            for (int i = 0; i < values.Length; i++)
            {
                values[i] = i;
                probabilities[i] = 100 / probabilities.Length;
            }
            probabilities[0] += 100 - probabilities.Sum();

            if (scaleName != ScaleName.Other && values.Length == 8)
            {
                probabilities = new int[] { 3, 40, 19, 19, 5, 5, 5, 4 };
            }

            if (scaleName == ScaleName.Flamenco && values.Length == 8)
            {
                probabilities = new int[] { 2, 75, 9, 3, 3, 3, 3, 2 };
            }

            if (scaleName == ScaleName.Flamenco2 && values.Length == 8)
            {
                probabilities = new int[] { 2, 75, 9, 3, 3, 3, 3, 2 };
            }

            if (scaleName == ScaleName.Blues && values.Length == 7)
            {
                probabilities = new int[] { 5, 40, 24, 19, 4, 4, 4 };
            }

            return probabilities;
        }
Пример #4
0
        public static ScaleName GetScaleName(string text)
        {
            ScaleName scaleName = ScaleName.Other;

            switch (text)
            {
            case "Minor":
                scaleName = ScaleName.Minor;
                break;

            case "Major":
                scaleName = ScaleName.Major;
                break;

            case "Blues":
                scaleName = ScaleName.Blues;
                break;

            case "Flamenco":
                scaleName = ScaleName.Flamenco;
                break;

            case "Flamenco2":
                scaleName = ScaleName.Flamenco2;
                break;
            }
            return(scaleName);
        }
Пример #5
0
        public IEnumerable <Note> GetNotesOfScale(string key, ScaleName name)
        {
            var notes      = _noteRepository.GetAll(key);
            var intervals  = Get(name).Intervals;
            var scaleNotes = new List <Note>();
            var index      = 0;

            for (int i = 0; i < intervals.Length; i++)
            {
                scaleNotes.Add(notes[index]);
                index += intervals[i];
            }
            return(scaleNotes);
        }
Пример #6
0
 public void ScaleSwap()
 {
     if (scaleName == ScaleName.full)
     {
         scaleName = ScaleName.threeEighths;
         SetScale(0.03125f);
         scaleText.text = "3/8\" = 1'";
     }
     else if (scaleName == ScaleName.threeEighths)
     {
         scaleName = ScaleName.full;
         SetScale(1f);
         scaleText.text = "1:1 Full Scale";
     }
 }
Пример #7
0
        public Melody(string name, int[] notes, int[] rhythm, ScaleName scaleName)
        {
            int sum = rhythm.Sum();
            if (sum > notes.Length)
            {
                int[] newNotes = new int[sum];
                for (int i = 0; i < notes.Length; i++)
                {
                    newNotes[i] = notes[i];
                }
            }

            this.Name = name;
            this.Notes = notes;
            this.Rhythm = rhythm;
            this.ScaleName = scaleName;
        }
Пример #8
0
        public static List <Melody> GetAllMelodys()
        {
            List <Melody> list = new List <Melody>();
            StreamReader  sr   = new StreamReader("Melodys.txt", Encoding.Default);
            String        line = "";

            while ((line = sr.ReadLine()) != null)
            {
                if (line == "")
                {
                    continue;
                }
                char[]   separators = { ';' };
                string[] tokens     = line.Split(separators, StringSplitOptions.RemoveEmptyEntries);

                string name       = tokens[0];
                string scale      = tokens[1];
                string notesLine  = tokens[2];
                string rhythmLine = tokens[3];

                ScaleName scaleName = MyScale.GetScaleName(scale);


                char[]   separators2  = { ' ' };
                string[] stringNotes  = notesLine.Split(separators2, StringSplitOptions.RemoveEmptyEntries);
                string[] stringRhythm = rhythmLine.Split(separators2, StringSplitOptions.RemoveEmptyEntries);

                int[] notes  = new int[stringNotes.Length];
                int[] rhythm = new int[stringRhythm.Length];

                for (int i = 0; i < rhythm.Length; i++)
                {
                    rhythm[i] = int.Parse(stringRhythm[i]);
                }
                for (int i = 0; i < notes.Length; i++)
                {
                    notes[i] = int.Parse(stringNotes[i]);
                }

                Melody melody = new Melody(name, notes, rhythm, scaleName);
                list.Add(melody);
            }

            sr.Close();
            return(list);
        }
Пример #9
0
        public Melody(string name, int[] notes, int[] rhythm, ScaleName scaleName)
        {
            int sum = rhythm.Sum();

            if (sum > notes.Length)
            {
                int[] newNotes = new int[sum];
                for (int i = 0; i < notes.Length; i++)
                {
                    newNotes[i] = notes[i];
                }
            }

            this.Name      = name;
            this.Notes     = notes;
            this.Rhythm    = rhythm;
            this.ScaleName = scaleName;
        }
Пример #10
0
        public IEnumerable <NeckString> AddScale(string key, ScaleName scale, Tuning tuning)
        {
            key = key?.ToUpper();
            ValidateNoteExists(key);
            var scaleNotes  = _scaleRepository.GetNotesOfScale(key, scale);
            var neckStrings = _neckService.GetAllNotesOfNeck(tuning);

            foreach (var neckString in neckStrings)
            {
                foreach (var stringNote in neckString.Notes)
                {
                    if (scaleNotes.Any(n => n.Name == stringNote.Note.Trim()))
                    {
                        stringNote.Set = 1; // Only displays 1 scale at a time.
                    }
                }
            }
            return(neckStrings);
        }
Пример #11
0
        public static ScaleName GetScaleName(string text)
        {
            ScaleName scaleName = ScaleName.Other;
            switch (text)
            {
                case "Minor":
                    scaleName = ScaleName.Minor;
                    break;
                case "Major":
                    scaleName = ScaleName.Major;
                    break;
                case "Blues":
                    scaleName = ScaleName.Blues;
                    break;
                case "Flamenco":
                    scaleName = ScaleName.Flamenco;
                    break;
                case "Flamenco2":
                    scaleName = ScaleName.Flamenco2;
                    break;

            }
            return scaleName;
        }
Пример #12
0
        private void Form1_Load(object sender, EventArgs e)
        {
            savedMelodysList = new List <Melody>();
            savedMelodysList = Parser.GetAllMelodys();
            for (int i = 0; i < savedMelodysList.Count; i++)
            {
                savedMelodysComboBox.Items.Add(savedMelodysList[i].Name + "(" + savedMelodysList[i].ScaleName.ToString() + ")");
            }
            if (savedMelodysComboBox.Items.Count != 0)
            {
                savedMelodysComboBox.SelectedIndex = 0;
            }
            nameLabel.Text         = "Сгенерируйте мелодию!";
            notesTextBox.Text      = "";
            rhythmTextBox.Text     = "";
            notesCountTextBox.Text = "16";

            //Melody.Number = melodyList.Count + 1;

            generatedMelodysList = new List <Melody>();

            gridButtons = new int[6, 16];

            /* Гаммы можно менять, но их длина должна оставаться прежней.
             * В противном случае, нужно произвести изменения в файле MyRandom.cs
             */
            minorScale = new int[7] {
                2, 1, 2, 2, 1, 2, 2
            };
            majorScale = new int[7] {
                2, 2, 1, 2, 2, 2, 1
            };
            flamencoScale = new int[7] {
                1, 3, 1, 2, 1, 3, 1
            };
            bluesScale     = new int[] { 3, 2, 1, 1, 3, 2 };
            flamenco2Scale = new int[7] {
                1, 3, 1, 2, 1, 2, 2
            };

            int[]     scaleIntervals = minorScale;
            ScaleName scaleName      = ScaleName.Minor;

            selectedScale = new MyScale(scaleName, scaleIntervals);

            tonica = Note.A3;

            scaleComboBox.SelectedIndex = 0;

            buttons       = new Button[6, 16];
            player        = new MediaPlayer();
            player.Volume = 0.3;
            outputDevice  = ExampleUtil.ChooseOutputDeviceFromConsole();
            outputDevice.Open();
            outputDevice.SendProgramChange(Channel.Channel1, Instrument.AcousticGuitarSteel);

            grifNotes = new Note[6, 16];

            //Заполняем 6 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[5, i] = (Note)(40 + i);
            }
            //Заполняем 5 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[4, i] = (Note)(45 + i);
            }
            //Заполняем 4 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[3, i] = (Note)(50 + i);
            }
            //Заполняем 3 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[2, i] = (Note)(55 + i);
            }
            //Заполняем 2 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[1, i] = (Note)(59 + i);
            }
            //Заполняем 1 струну
            for (int i = 0; i < grifNotes.GetLength(1); i++)
            {
                grifNotes[0, i] = (Note)(64 + i);
            }

            int tabindex = 4;

            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    buttons[i, j]          = (Button)this.Controls["s" + (i + 1).ToString() + j.ToString()];
                    buttons[i, j].TabIndex = tabindex;
                    tabindex++;
                }
            }

            //Создание надписей над аппликатурой
            labels = new Label[6, 16]; this.SetStyle(ControlStyles.SupportsTransparentBackColor, true);
            for (int i = 0; i < 6; i++)
            {
                for (int j = 0; j < 16; j++)
                {
                    labels[i, j]           = new Label();
                    labels[i, j].AutoSize  = true;
                    labels[i, j].Font      = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(204)));
                    labels[i, j].ForeColor = System.Drawing.Color.Black;
                    Point p = new Point();
                    p.X = buttons[i, j].Location.X;// +buttons[i, j].Width / 2;
                    p.Y = buttons[i, j].Location.Y;
                    labels[i, j].Location = p;
                    labels[i, j].Name     = "label" + i.ToString() + j.ToString();
                    labels[i, j].Size     = new System.Drawing.Size(15, 13);
                    //labels[i, j].TabIndex = 113;
                    labels[i, j].Text      = "T";
                    labels[i, j].Visible   = false;
                    labels[i, j].BackColor = System.Drawing.Color.Transparent;
                    this.Controls.Add(labels[i, j]);
                    labels[i, j].BringToFront();
                }
            }

            for (int j = 0; j < 6; j++)
            {
                for (int k = 0; k < 16; k++)
                {
                    buttons[j, k].Click += grif_Click;
                }
            }
        }
Пример #13
0
 // Use this for initialization
 void Start()
 {
     scaleName = ScaleName.full;
     ScaleSwap();
 }
Пример #14
0
 public MyScale(ScaleName _scaleName, int[] _scale)
 {
     scaleName      = _scaleName;
     scaleIntervals = _scale;
 }
Пример #15
0
 public MyScale(ScaleName _scaleName, int[] _scale)
 {
     scaleName = _scaleName;
     scaleIntervals = _scale;
 }
Пример #16
0
 public Scale Get(ScaleName scaleName)
 {
     return(scales[scaleName]);
 }