Exemple #1
0
        public static float GetFrequency(IonianScale scale, bool sharp, float octave, int semitones = 0)
        {
            double freq       = 27.5 * Math.Pow(2, octave);
            int    scaleTimes = semitones + (int)scale * 2;

            switch (scale)
            {
            case IonianScale.C:
            case IonianScale.D:
            case IonianScale.E:
                scaleTimes--;
                break;

            case IonianScale.F:
            case IonianScale.G:
                scaleTimes -= 2;
                break;
            }

            if (sharp)
            {
                scaleTimes++;
            }

            freq *= Math.Pow(Math.Pow(2, 1.0 / 12.0), scaleTimes);

            return((float)freq);
        }
        public void TestMajorScaleNoteIntervals()
        {
            var scale = new IonianScale(MusicNotes.A);

            Assert.Equal(IntervalQuality.P1, scale.Notes[0].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.M2, scale.Notes[1].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.M3, scale.Notes[2].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.P4, scale.Notes[3].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.P5, scale.Notes[4].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.M6, scale.Notes[5].Interval.IntervalQuality);
            Assert.Equal(IntervalQuality.M7, scale.Notes[6].Interval.IntervalQuality);
        }
Exemple #3
0
        private void AddPianoKeyView(int column, int span, IonianScale scale, bool sharp)
        {
            var view = new PianoKey()
            {
                Sharp          = sharp,
                Scale          = scale,
                AttackCommand  = OnAttack,
                ReleaseCommand = OnRelease,
            };

            Grid.SetColumn(view, column);
            Grid.SetColumnSpan(view, span);
            Grid.SetRowSpan(view, sharp ? 1 : 2);
            grid.Children.Add(view);
        }
        public void TestBFlatMajor()
        {
            var scale = new IonianScale(MusicNotes.BFlat);

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

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

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

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

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

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

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

            Assert.Equal(MusicNotes.A, scale.Notes[6].Note);
        }
        public void TestASharpMajor()
        {
            var scale = new IonianScale(MusicNotes.ASharp);

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

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

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

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

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

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

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

            Assert.Equal(MusicNotes.GDoubleSharp, scale.Notes[6].Note);
        }
        public void TestAMajor()
        {
            var scale = new IonianScale(MusicNotes.A);

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

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

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

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

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

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

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

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