예제 #1
0
        // MajorScalePattern - whole, whole, half, whole, whole, whole, half
        private ChromaticScale[] MajorScalePatternForKey(ChromaticScale note)
        {
            ChromaticScale[] scalePattern = new ChromaticScale[7];
            ChromaticScale   nextStep     = note;

            for (int i = 0; i < scalePattern.Length; i++)
            {
                if (i == 0) // root
                {
                    scalePattern[i] = note;
                }
                else if ((i == 3) || (i == 7)) // half step
                {
                    nextStep        = FindNextInterval(1, nextStep);
                    scalePattern[i] = nextStep;
                }
                else // whole step
                {
                    nextStep        = FindNextInterval(2, nextStep);
                    scalePattern[i] = nextStep;
                }
            }

            return(scalePattern);
        }
        public void TestGFlatChromatic()
        {
            var scale = new ChromaticScale(MusicNotes.GFlat);

            Assert.Equal(12, scale.Notes.Length);

            Assert.Equal(MusicNotes.GFlat, scale.Notes[0].Note);

            Assert.Equal(MusicNotes.ADoubleFlat, scale.Notes[1].Note);

            Assert.Equal(MusicNotes.AFlat, scale.Notes[2].Note);

            Assert.Equal(MusicNotes.BDoubleFlat, scale.Notes[3].Note);

            Assert.Equal(MusicNotes.BFlat, scale.Notes[4].Note);

            Assert.Equal(MusicNotes.CFlat, scale.Notes[5].Note);

            Assert.Equal(MusicNotes.DDoubleFlat, scale.Notes[6].Note);

            Assert.Equal(MusicNotes.DFlat, scale.Notes[7].Note);

            Assert.Equal(MusicNotes.EDoubleFlat, scale.Notes[8].Note);

            Assert.Equal(MusicNotes.EFlat, scale.Notes[9].Note);

            Assert.Equal(MusicNotes.FFlat, scale.Notes[10].Note);

            Assert.Equal(MusicNotes.F, scale.Notes[11].Note);
        }
        public void TestASharpChromatic()
        {
            var scale = new ChromaticScale(MusicNotes.ASharp);

            Assert.Equal(12, scale.Notes.Length);

            Assert.Equal(MusicNotes.ASharp, scale.Notes[0].Note);

            Assert.Equal(MusicNotes.B, scale.Notes[1].Note);

            Assert.Equal(MusicNotes.BSharp, scale.Notes[2].Note);

            Assert.Equal(MusicNotes.CSharp, scale.Notes[3].Note);

            Assert.Equal(MusicNotes.CDoubleSharp, scale.Notes[4].Note);

            Assert.Equal(MusicNotes.DSharp, scale.Notes[5].Note);

            Assert.Equal(MusicNotes.E, scale.Notes[6].Note);

            Assert.Equal(MusicNotes.ESharp, scale.Notes[7].Note);

            Assert.Equal(MusicNotes.FSharp, scale.Notes[8].Note);

            Assert.Equal(MusicNotes.FDoubleSharp, scale.Notes[9].Note);

            Assert.Equal(MusicNotes.GSharp, scale.Notes[10].Note);

            Assert.Equal(MusicNotes.GDoubleSharp, scale.Notes[11].Note);
        }
예제 #4
0
        private String NoteStringValue(ChromaticScale note)
        {
            String noteString = "";

            switch (note)
            {
            case ChromaticScale.A:  noteString = "A";  break;

            case ChromaticScale.AS: noteString = "A#"; break;

            case ChromaticScale.B:  noteString = "B";  break;

            case ChromaticScale.C:  noteString = "C";  break;

            case ChromaticScale.CS: noteString = "C#"; break;

            case ChromaticScale.D:  noteString = "D";  break;

            case ChromaticScale.DS: noteString = "D#"; break;

            case ChromaticScale.E:  noteString = "E";  break;

            case ChromaticScale.F:  noteString = "F";  break;

            case ChromaticScale.FS: noteString = "F#"; break;

            case ChromaticScale.G:  noteString = "G";  break;

            case ChromaticScale.GS: noteString = "G#"; break;

            default: break;
            }

            return(noteString);
        }
        public void TestANaturalChromatic()
        {
            var scale = new ChromaticScale(MusicNotes.A);

            Assert.Equal(12, scale.Notes.Length);

            Assert.Equal(MusicNotes.A, scale.Notes[0].Note);

            Assert.Equal(MusicNotes.BFlat, scale.Notes[1].Note);

            Assert.Equal(MusicNotes.B, scale.Notes[2].Note);

            Assert.Equal(MusicNotes.C, scale.Notes[3].Note);

            Assert.Equal(MusicNotes.CSharp, scale.Notes[4].Note);

            Assert.Equal(MusicNotes.D, scale.Notes[5].Note);

            Assert.Equal(MusicNotes.EFlat, scale.Notes[6].Note);

            Assert.Equal(MusicNotes.E, scale.Notes[7].Note);

            Assert.Equal(MusicNotes.F, scale.Notes[8].Note);

            Assert.Equal(MusicNotes.FSharp, scale.Notes[9].Note);

            Assert.Equal(MusicNotes.G, scale.Notes[10].Note);

            Assert.Equal(MusicNotes.GSharp, scale.Notes[11].Note);
        }
예제 #6
0
        private void SetupGuitarKeyBarManager()
        {
            guitarKeyBarManager = new BarManager {
                Form = this
            };
            guitarKeyPopupMenu = new PopupMenu();
            ChromaticScale key        = ChromaticScale.A;
            string         noteString = NoteStringValue(key);

            for (int i = 0; i < guitarKeyButtons.Length; i++)
            {
                guitarKeyButtons[i] = new BarButtonItem(keyBarManager, noteString)
                {
                    Tag = noteString
                };
                guitarKeyButtons[i].ItemClick += new DevExpress.XtraBars.ItemClickEventHandler(this.GuitarKeySelected);
                guitarKeyPopupMenu.AddItem(guitarKeyButtons[i]);

                key        = FindNextInterval(1, key);
                noteString = NoteStringValue(key);
            }

            guitarKeyDropDown.Parent          = this;
            guitarKeyDropDown.DropDownControl = guitarKeyPopupMenu;
            ItemClickEventArgs guitarKeySetupArgs = new ItemClickEventArgs(guitarKeyButtons[7], null);

            GuitarKeySelected(guitarKeyBarManager, guitarKeySetupArgs);
        }
예제 #7
0
        private ChromaticScale ScaleValue(string scaleChar)
        {
            ChromaticScale note = ChromaticScale.A;

            switch (scaleChar)
            {
            case "A":  note = ChromaticScale.A;  break;

            case "A#": note = ChromaticScale.AS; break;

            case "B":  note = ChromaticScale.B;  break;

            case "C":  note = ChromaticScale.C;  break;

            case "C#": note = ChromaticScale.CS; break;

            case "D":  note = ChromaticScale.D;  break;

            case "D#": note = ChromaticScale.DS; break;

            case "E":  note = ChromaticScale.E;  break;

            case "F":  note = ChromaticScale.F;  break;

            case "F#": note = ChromaticScale.FS; break;

            case "G":  note = ChromaticScale.G;  break;

            case "G#": note = ChromaticScale.GS; break;

            default: break;
            }
            return(note); // maybe should have an error but we'll see.
        }
예제 #8
0
        private void FingerNotes()
        {
            ChromaticScale[] scalePattern = UpdateScalePattern();

            foreach (DataGridViewRow guitarString in fretBoardGrid.Rows)
            {
                // Get the first scale note available on the string from the header.
                ChromaticScale chromaticNote = ScaleValue(guitarString.HeaderCell.Value.ToString());

                for (int i = 0; i < guitarString.Cells.Count; i++)
                {
                    // if this note is contained in our scale pattern,
                    // we mark it with a note or number based on toggle switch value.
                    if (scalePattern.Contains(chromaticNote))
                    {
                        if (fretsToNotesToggle.IsOn)
                        {
                            guitarString.Cells[i].Value = i.ToString();
                        }
                        else
                        {
                            guitarString.Cells[i].Value = NoteStringValue(chromaticNote);
                        }
                    }
                    else
                    {
                        guitarString.Cells[i].Value = "";
                    }

                    chromaticNote = FindNextInterval(1, chromaticNote);
                }
            }

            UpdateScalePatternInstruction(scalePattern);
        }
예제 #9
0
        // Minor Pentatonic Pattern - 3,2,2,3 (semitones)
        private ChromaticScale[] MinorPentatonicScalePatternForKey(ChromaticScale note)
        {
            ChromaticScale[] scalePattern = new ChromaticScale[5];
            ChromaticScale   nextStep     = note;

            for (int i = 0; i < scalePattern.Length; i++)
            {
                if (i == 0) // root
                {
                    scalePattern[i] = note;
                }
                else if ((i == 2) || (i == 3)) // 2 semitones
                {
                    nextStep        = FindNextInterval(2, nextStep);
                    scalePattern[i] = nextStep;
                }
                else // 3 semitones
                {
                    nextStep        = FindNextInterval(3, nextStep);
                    scalePattern[i] = nextStep;
                }
            }

            return(scalePattern);
        }
예제 #10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AirCompModel" /> class.
        /// </summary>
        /// <param name="config">The configuration.</param>
        /// <param name="outDevices">The list of out devices.</param>
        /// <param name="outChannels">The list of out channels.</param>
        protected CompModelBase(CompConfig config, IEnumerable <string> outDevices, IEnumerable <int> outChannels)
        {
            _config              = config;
            AvailableOutDevices  = outDevices;
            AvailableOutChannels = outChannels;

            CurrentScale = new ChromaticScale(Tone.C);
        }
예제 #11
0
        public void ChromaticScale_Constructor_Test()
        {
            // Arrange

            // Act
            var target = new ChromaticScale(Tone.C);

            // Assert
            Assert.AreEqual(Tone.C, target.BaseTone);
        }
예제 #12
0
        // Do not pass an interval > 11
        private ChromaticScale FindNextInterval(int interval, ChromaticScale note)
        {
            note += interval;
            if (!Enum.IsDefined(typeof(ChromaticScale), note))
            {
                note -= 12;
            }

            return(note);
        }
예제 #13
0
 private ChromaticScale[] PentatonicScalePatternForKey(ChromaticScale note)
 {
     if (minorMajorToggleSwitch.IsOn)
     {
         return(MajorPentatonicScalePatternForKey(note));
     }
     else
     {
         return(MinorPentatonicScalePatternForKey(note));
     }
 }
예제 #14
0
        private ChromaticScale TuneSecondString(ChromaticScale note) // 'B' string
        {
            ChromaticScale secondString = note;

            if (tuningTypeDropDown.Text.Equals("Standard") || tuningTypeDropDown.Text.Equals("Drop")) // (E) 5th (A) 5th(D) 5th (G) 4th (B) 5th(E)
            {
                secondString = FindFourth(note);
            }
            else if (tuningTypeDropDown.Text.Equals("Open")) // (E) 6th (B) 5th (E) 4th (G#) 3rd (B) 5th (E)
            {
                secondString = FindThird(note);
            }

            return(secondString);
        }
        public void TestChromaticScaleNoteIntervals()
        {
            var scale = new ChromaticScale(MusicNotes.A);

            Assert.Equal(IntervalQuality.P1, scale.Notes[0].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.m2, scale.Notes[1].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.M2, scale.Notes[2].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.m3, scale.Notes[3].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.M3, scale.Notes[4].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.P4, scale.Notes[5].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.d5, scale.Notes[6].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.P5, scale.Notes[7].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.m6, scale.Notes[8].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.M6, scale.Notes[9].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.m7, scale.Notes[10].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.M7, scale.Notes[11].Interval.IntervalQuality);
        }
예제 #16
0
        private ChromaticScale TuneFifthString(ChromaticScale note) // 'A' string
        {
            ChromaticScale fifthString = note;

            if (tuningTypeDropDown.Text.Equals("Standard")) // (E) 5th (A) 5th(D) 5th (G) 4th (B) 5th(E)
            {
                fifthString = FindFifth(note);
            }
            else if (tuningTypeDropDown.Text.Equals("Drop")) // (D) 7th (A) 5th (D) 5th (G) 4th (B) 5th (E)
            {
                fifthString = FindSeventh(note);
            }
            else if (tuningTypeDropDown.Text.Equals("Open")) // (E) 6th (B) 5th (E) 4th (G#) 3rd (B) 5th (E)
            {
                fifthString = FindSixth(note);
            }

            return(fifthString);
        }
예제 #17
0
        public void ChromaticGFromG0ToG1_GetScaleMembers_Test()
        {
            // Arrange
            var target = new ChromaticScale(Tone.G);

            // Act
            var scaleInG = target.GetMembers(new Pitch(0, Tone.G), new Pitch(1, Tone.G));

            // Assert
            Assert.AreEqual(new Pitch(0, Tone.G), scaleInG[0]);
            Assert.AreEqual(new Pitch(0, Tone.Gsharp), scaleInG[1]);
            Assert.AreEqual(new Pitch(0, Tone.A), scaleInG[2]);
            Assert.AreEqual(new Pitch(0, Tone.Asharp), scaleInG[3]);
            Assert.AreEqual(new Pitch(0, Tone.B), scaleInG[4]);
            Assert.AreEqual(new Pitch(1, Tone.C), scaleInG[5]);
            Assert.AreEqual(new Pitch(1, Tone.Csharp), scaleInG[6]);
            Assert.AreEqual(new Pitch(1, Tone.D), scaleInG[7]);
            Assert.AreEqual(new Pitch(1, Tone.Dsharp), scaleInG[8]);
            Assert.AreEqual(new Pitch(1, Tone.E), scaleInG[9]);
            Assert.AreEqual(new Pitch(1, Tone.F), scaleInG[10]);
            Assert.AreEqual(new Pitch(1, Tone.Fsharp), scaleInG[11]);
            Assert.AreEqual(new Pitch(1, Tone.G), scaleInG[12]);
        }
예제 #18
0
        private void ReStringGuitar()
        {
            ChromaticScale sixthString = TuneSixthString();

            fretBoardGrid.Rows[5].HeaderCell.Value = NoteStringValue(sixthString);
            ChromaticScale fifthString = TuneFifthString(sixthString);

            fretBoardGrid.Rows[4].HeaderCell.Value = NoteStringValue(fifthString);
            ChromaticScale fourthString = TuneFourthString(fifthString);

            fretBoardGrid.Rows[3].HeaderCell.Value = NoteStringValue(fourthString);
            ChromaticScale thirdString = TuneThirdString(fourthString);

            fretBoardGrid.Rows[2].HeaderCell.Value = NoteStringValue(thirdString);
            ChromaticScale secondString = TuneSecondString(thirdString);

            fretBoardGrid.Rows[1].HeaderCell.Value = NoteStringValue(secondString);
            ChromaticScale firstString = TuneFirstString(secondString);

            fretBoardGrid.Rows[0].HeaderCell.Value = NoteStringValue(firstString);

            UpdateGuitarTuningInstruction();
        }
예제 #19
0
 private ChromaticScale FindThird(ChromaticScale note) => FindNextInterval(3, note);
예제 #20
0
 private ChromaticScale FindFourth(ChromaticScale note) => FindNextInterval(4, note);
예제 #21
0
 private ChromaticScale FindFifth(ChromaticScale note) => FindNextInterval(5, note);
예제 #22
0
 private ChromaticScale TuneFirstString(ChromaticScale note) // 'E' string(high)
 {
     return(FindFifth(note));
 }
예제 #23
0
 private ChromaticScale FindSixth(ChromaticScale note) => FindNextInterval(6, note);
예제 #24
0
 private ChromaticScale TuneFourthString(ChromaticScale note) // 'D' string
 {
     return(FindFifth(note));
 }
예제 #25
0
 private ChromaticScale FindSeventh(ChromaticScale note) => FindNextInterval(7, note);