Пример #1
0
        public void SetChordsState_SelectAll_Enabled()
        {
            var pattern = new PatternBuilder()
                          .Note(Notes.A2)
                          .Chord(new[] { Notes.D3, Notes.A1 })
                          .Build();

            pattern.SetChordsState((i, d) => true, PatternActionState.Enabled);

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 2, null, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),
                new NoteInfo(NoteName.D, 3, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),
                new NoteInfo(NoteName.A, 1, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity)
            });
        }
Пример #2
0
        public void SetChordsState_SelectNone([Values] PatternActionState state)
        {
            var pattern = new PatternBuilder()
                          .Chord(new[] { Notes.A2 })
                          .Chord(new[] { Notes.D3, Notes.ASharp5 })
                          .Build();

            pattern.SetChordsState((i, d) => false, PatternActionState.Excluded);

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 2, null, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),
                new NoteInfo(NoteName.D, 3, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),
                new NoteInfo(NoteName.ASharp, 5, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity)
            });
        }
Пример #3
0
        public void StepBack_BeyondZero()
        {
            var pattern = new PatternBuilder()
                          .MoveToTime(new MetricTimeSpan(0, 0, 10))
                          .StepForward(new MetricTimeSpan(0, 0, 30))
                          .StepBack(new MetricTimeSpan(0, 1, 37))

                          .Note(Notes.A0)

                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 0, new MetricTimeSpan(0, 0, 0), MusicalTimeSpan.Quarter)
            });
        }
Пример #4
0
        public void SetChordsState_SelectSome_Enabled()
        {
            var pattern = new PatternBuilder()
                          .Chord(new[] { Notes.A2 })
                          .Chord(new[] { Notes.D3, Notes.ASharp5 })
                          .Build();

            pattern.SetChordsState((i, d) => d.Notes.Any(n => n.Octave == 2), PatternActionState.Enabled);

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 2, null, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),
                new NoteInfo(NoteName.D, 3, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),
                new NoteInfo(NoteName.ASharp, 5, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity)
            });
        }
Пример #5
0
        public void SetChordsState_SelectSome_Excluded_Recursive()
        {
            var pattern = new PatternBuilder()
                          .Chord(new[] { Notes.A2 })
                          .Pattern(new PatternBuilder()
                                   .Chord(new[] { Notes.D3, Notes.ASharp5 })
                                   .Chord(new[] { Notes.D6 })
                                   .Build())
                          .Build();

            pattern.SetChordsState((i, d) => i == 0 || i == 1, PatternActionState.Excluded, true);

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.D, 6, null, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity)
            });
        }
        public void ReplayPattern_Notes()
        {
            var pattern1 = new PatternBuilder()
                           .Note(Notes.A4)
                           .Note(Notes.ASharp4)
                           .Build();

            var pattern2 = new PatternBuilder()
                           .ReplayPattern(pattern1)
                           .Build();

            PatternTestUtilities.TestNotes(pattern2, new[]
            {
                new NoteInfo(NoteName.A, 4, null, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),
                new NoteInfo(NoteName.ASharp, 4, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity)
            });
        }
Пример #7
0
        public void MoveToPreviousTime_Pattern()
        {
            var subPattern = new PatternBuilder()
                             .Note(Notes.A0)
                             .Build();

            var pattern = new PatternBuilder()
                          .Pattern(subPattern)
                          .MoveToPreviousTime()
                          .Note(Notes.B0)
                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 0, null, PatternBuilder.DefaultNoteLength),
                new NoteInfo(NoteName.B, 0, null, PatternBuilder.DefaultNoteLength)
            });
        }
        public void Repeat_Previous()
        {
            var pattern = new PatternBuilder()
                          .SetStep(MusicalTimeSpan.Eighth)

                          .Anchor("A")
                          .StepForward()
                          .Anchor("B")
                          .Repeat(2, 2)
                          .MoveToNthAnchor("B", 2)
                          .Note(NoteName.A)

                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 4, 3 * MusicalTimeSpan.Eighth, MusicalTimeSpan.Quarter)
            });
        }
        public void Chord_Notes_Length_Velocity()
        {
            var defaultOctave = Octave.Get(2);

            var chordVelocity = (SevenBitNumber)70;
            var chordLength   = (MidiTimeSpan)300;

            var pattern = new PatternBuilder()
                          .SetOctave(defaultOctave)
                          .Chord(new[] { Notes.D3, Notes.E3, Notes.FSharp4 }, chordLength, chordVelocity)
                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.D, 3, null, chordLength, chordVelocity),
                new NoteInfo(NoteName.E, 3, null, chordLength, chordVelocity),
                new NoteInfo(NoteName.FSharp, 4, null, chordLength, chordVelocity)
            });
        }
        public void BuildFromPattern_Anchor()
        {
            var pattern1 = new PatternBuilder()
                           .Note(Notes.A4)
                           .Anchor("X")
                           .Note(Notes.ASharp4)
                           .MoveToFirstAnchor("X")
                           .Note(Notes.DSharp3)
                           .Build();

            var pattern2 = new PatternBuilder(pattern1).Build();

            PatternTestUtilities.TestNotes(pattern2, new[]
            {
                new NoteInfo(NoteName.A, 4, null, PatternBuilder.DefaultNoteLength),
                new NoteInfo(NoteName.ASharp, 4, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength),
                new NoteInfo(NoteName.DSharp, 3, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength)
            });
        }
        public void Chord_Intervals_RootNote_Length_Velocity()
        {
            var defaultOctave = Octave.Get(2);

            var chordVelocity = (SevenBitNumber)70;
            var chordLength   = (MidiTimeSpan)300;

            var pattern = new PatternBuilder()
                          .SetOctave(defaultOctave)
                          .Chord(new[] { Interval.FromHalfSteps(2), Interval.FromHalfSteps(4) }, Notes.D3, chordLength, chordVelocity)
                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.D, 3, null, chordLength, chordVelocity),
                new NoteInfo(NoteName.E, 3, null, chordLength, chordVelocity),
                new NoteInfo(NoteName.FSharp, 3, null, chordLength, chordVelocity)
            });
        }
        public void SplitAtAllMarkers_MultipleMarkers(bool removeEmptyPatterns)
        {
            var marker1 = "A";
            var marker2 = "B";

            var pattern = new PatternBuilder()
                          .Marker(marker1)
                          .Note(Notes.FSharp4)
                          .Note(Notes.DSharp1)
                          .Marker(marker2)
                          .Note(Notes.DSharp0)
                          .Marker(marker1)
                          .Build();

            var patterns = pattern.SplitAtAllMarkers(removeEmptyPatterns).ToList();

            var firstPatternIndex  = 0;
            var secondPatternIndex = 1;

            if (removeEmptyPatterns)
            {
                Assert.AreEqual(2, patterns.Count, "Sub-patterns count is invalid.");
            }
            else
            {
                Assert.AreEqual(3, patterns.Count, "Sub-patterns count is invalid.");
                CollectionAssert.IsEmpty(patterns[0].Actions, "First sub-pattern is not empty.");
                firstPatternIndex++;
                secondPatternIndex++;
            }

            PatternTestUtilities.TestNotes(patterns[firstPatternIndex], new[]
            {
                new NoteInfo(NoteName.FSharp, 4, null, PatternBuilder.DefaultNoteLength),
                new NoteInfo(NoteName.DSharp, 1, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength)
            });

            PatternTestUtilities.TestNotes(patterns[secondPatternIndex], new[]
            {
                new NoteInfo(NoteName.DSharp, 0, null, PatternBuilder.DefaultNoteLength)
            });
        }
Пример #13
0
        public void Note_Multiple_MetricLengths()
        {
            var pattern = new PatternBuilder()
                          .SetOctave(Octave.Get(2))

                          .Note(NoteName.G, new MetricTimeSpan(0, 0, 24))
                          .Note(NoteName.A, new MetricTimeSpan(0, 1, 0))
                          .Note(NoteName.B, new MetricTimeSpan(0, 0, 5))

                          .Build();

            var midiFile = PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.G, 2, null, new MetricTimeSpan(0, 0, 24)),
                new NoteInfo(NoteName.A, 2, new MetricTimeSpan(0, 0, 24), new MetricTimeSpan(0, 1, 0)),
                new NoteInfo(NoteName.B, 2, new MetricTimeSpan(0, 1, 24), new MetricTimeSpan(0, 0, 5)),
            });

            Assert.AreEqual(new MetricTimeSpan(0, 1, 29), midiFile.GetDuration <MetricTimeSpan>());
        }
Пример #14
0
        public void SetNotesState_SelectSome_Excluded_Recursive()
        {
            var pattern = new PatternBuilder()
                          .Note(Notes.A2)
                          .Note(Notes.C3)
                          .Pattern(new PatternBuilder()
                                   .Note(Notes.DSharp3)
                                   .Note(Notes.B1)
                                   .Build())
                          .Build();

            pattern.SetNotesState((i, d) => i == 0 || i == 2, PatternActionState.Excluded, true);

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.C, 3, null, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),

                new NoteInfo(NoteName.B, 1, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity)
            });
        }
Пример #15
0
        public void TransformNotes_Original()
        {
            var noteLength = MusicalTimeSpan.Eighth;
            var velocity   = (SevenBitNumber)90;

            var pattern = new PatternBuilder()
                          .SetNoteLength(noteLength)
                          .SetVelocity(velocity)
                          .Note(Notes.A0)
                          .Note(Notes.C1)
                          .Build();

            pattern = pattern.TransformNotes(d => d);

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 0, null, noteLength, velocity),
                new NoteInfo(NoteName.C, 1, noteLength, noteLength, velocity)
            });
        }
        public void TransformNotes_Selection_SelectNone()
        {
            var noteLength = MusicalTimeSpan.Eighth;
            var velocity   = (SevenBitNumber)90;

            var pattern = new PatternBuilder()
                          .SetNoteLength(noteLength)
                          .SetVelocity(velocity)
                          .Note(Notes.A0)
                          .Note(Notes.C1)
                          .Build();

            pattern = pattern.TransformNotes((i, d) => false, d => new NoteDescriptor(Notes.A2, (SevenBitNumber)70, MusicalTimeSpan.Half));

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 0, null, noteLength, velocity),
                new NoteInfo(NoteName.C, 1, noteLength, noteLength, velocity)
            });
        }
Пример #17
0
        public void Note_Multiple_Interval()
        {
            var defaultNoteLength = MusicalTimeSpan.Quarter;
            var defaultVelocity   = (SevenBitNumber)90;

            var pattern = new PatternBuilder()
                          .SetNoteLength(defaultNoteLength)
                          .SetVelocity(defaultVelocity)
                          .SetRootNote(Notes.CSharp5)

                          .Note(Interval.Two)
                          .Note(-Interval.Four)

                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.DSharp, 5, null, defaultNoteLength, defaultVelocity),
                new NoteInfo(NoteName.A, 4, defaultNoteLength, defaultNoteLength, defaultVelocity)
            });
        }
Пример #18
0
        public void TransformChords_Selection_SelectSome_Pattern_Recursive()
        {
            var noteLength = (MidiTimeSpan)200;
            var velocity   = (SevenBitNumber)90;

            var subPattern = new PatternBuilder()
                             .Chord(new[] { Notes.A0, Notes.CSharp2 })
                             .Chord(new[] { Notes.B2, Notes.B3, Notes.B4 })
                             .Build();

            var pattern = new PatternBuilder()
                          .SetNoteLength(noteLength)
                          .SetVelocity(velocity)
                          .Note(Notes.A2)
                          .Note(Notes.C3)
                          .Pattern(subPattern)
                          .Build();

            pattern = pattern.TransformChords(
                (i, d) => i == 1,
                d => new ChordDescriptor(
                    d.Notes.Select(n => n.Transpose(Interval.One)),
                    (SevenBitNumber)65,
                    (MidiTimeSpan)100),
                true);

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 2, null, noteLength, velocity),
                new NoteInfo(NoteName.C, 3, noteLength, noteLength, velocity),

                new NoteInfo(NoteName.A, 0, (MidiTimeSpan)(2 * noteLength), PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),
                new NoteInfo(NoteName.CSharp, 2, (MidiTimeSpan)(2 * noteLength), PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultVelocity),

                new NoteInfo(NoteName.C, 3, ((MidiTimeSpan)(2 * noteLength)).Add(PatternBuilder.DefaultNoteLength, TimeSpanMode.TimeLength), (MidiTimeSpan)100, (SevenBitNumber)65),
                new NoteInfo(NoteName.C, 4, ((MidiTimeSpan)(2 * noteLength)).Add(PatternBuilder.DefaultNoteLength, TimeSpanMode.TimeLength), (MidiTimeSpan)100, (SevenBitNumber)65),
                new NoteInfo(NoteName.C, 5, ((MidiTimeSpan)(2 * noteLength)).Add(PatternBuilder.DefaultNoteLength, TimeSpanMode.TimeLength), (MidiTimeSpan)100, (SevenBitNumber)65)
            });
        }
Пример #19
0
        public void MoveToFirstAnchor_Keyed_OneUnkeyedAndOneKeyed()
        {
            var anchorTime = new MetricTimeSpan(0, 0, 30);

            var pattern = new PatternBuilder()
                          .MoveToTime(new MetricTimeSpan(0, 0, 10))
                          .StepForward(new MetricTimeSpan(0, 0, 11))
                          .Anchor()
                          .MoveToTime(anchorTime)
                          .Anchor("Test")
                          .StepBack(new MetricTimeSpan(0, 0, 5))
                          .MoveToFirstAnchor("Test")

                          .Note(Notes.A0)

                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 0, anchorTime, MusicalTimeSpan.Quarter)
            });
        }
        public void Chord_Notes()
        {
            var defaultVelocity   = (SevenBitNumber)90;
            var defaultOctave     = Octave.Get(2);
            var defaultNoteLength = (MidiTimeSpan)300;

            var chordTime = MusicalTimeSpan.Eighth;

            var pattern = new PatternBuilder()
                          .SetVelocity(defaultVelocity)
                          .SetOctave(defaultOctave)
                          .SetNoteLength(defaultNoteLength)
                          .MoveToTime(chordTime)
                          .Chord(new[] { Notes.D3, Notes.E3, Notes.FSharp4 })
                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.D, 3, chordTime, defaultNoteLength, defaultVelocity),
                new NoteInfo(NoteName.E, 3, chordTime, defaultNoteLength, defaultVelocity),
                new NoteInfo(NoteName.FSharp, 4, chordTime, defaultNoteLength, defaultVelocity)
            });
        }
        public void CombineInSequence()
        {
            var pattern1 = new PatternBuilder()
                           .Note(Notes.DSharp2)
                           .Build();

            var noteLength = MusicalTimeSpan.Sixteenth;
            var pattern2   = new PatternBuilder()
                             .SetNoteLength(noteLength)
                             .Note(Notes.A4)
                             .Note(Notes.ASharp4)
                             .Build();

            var pattern = new[] { pattern1, pattern2 }.CombineInSequence();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.DSharp, 2, null, PatternBuilder.DefaultNoteLength),

                new NoteInfo(NoteName.A, 4, PatternBuilder.DefaultNoteLength, noteLength),
                new NoteInfo(NoteName.ASharp, 4, PatternBuilder.DefaultNoteLength.Add(noteLength, TimeSpanMode.LengthLength), noteLength)
            });
        }
Пример #22
0
        public void Note_MixedLengthAndVelocity()
        {
            var defaultNoteLength = MusicalTimeSpan.Quarter;
            var defaultVelocity   = (SevenBitNumber)90;

            var specifiedLength   = new MetricTimeSpan(0, 0, 10);
            var specifiedVelocity = (SevenBitNumber)95;

            var pattern = new PatternBuilder()
                          .SetNoteLength(defaultNoteLength)
                          .SetVelocity(defaultVelocity)

                          .Note(Notes.A0)
                          .Note(Notes.C1, specifiedLength, specifiedVelocity)

                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 0, null, defaultNoteLength, defaultVelocity),
                new NoteInfo(NoteName.C, 1, MusicalTimeSpan.Quarter, specifiedLength, specifiedVelocity)
            });
        }
Пример #23
0
        public void TransformNotes_Changed()
        {
            var noteLength = MusicalTimeSpan.Eighth;
            var velocity   = (SevenBitNumber)90;

            var pattern = new PatternBuilder()
                          .SetNoteLength(noteLength)
                          .SetVelocity(velocity)
                          .Note(Notes.A2)
                          .Note(Notes.C3)
                          .Build();

            pattern = pattern.TransformNotes(d => new NoteDescriptor(
                                                 d.Note == Notes.A2 ? d.Note.Transpose(Interval.Two) : d.Note.Transpose(-Interval.Three),
                                                 (SevenBitNumber)(d.Velocity - 10),
                                                 d.Length.Subtract(MusicalTimeSpan.ThirtySecond, TimeSpanMode.LengthLength)));

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.B, 2, null, 3 * MusicalTimeSpan.ThirtySecond, (SevenBitNumber)80),
                new NoteInfo(NoteName.A, 2, 3 * MusicalTimeSpan.ThirtySecond, 3 * MusicalTimeSpan.ThirtySecond, (SevenBitNumber)80)
            });
        }
        public void Chord_Intervals_RootNoteName()
        {
            var defaultVelocity   = (SevenBitNumber)90;
            var defaultOctave     = Octave.Get(2);
            var defaultNoteLength = (MidiTimeSpan)300;

            var chordTime = MusicalTimeSpan.Eighth;

            var pattern = new PatternBuilder()
                          .SetVelocity(defaultVelocity)
                          .SetOctave(defaultOctave)
                          .SetNoteLength(defaultNoteLength)
                          .MoveToTime(chordTime)
                          .Chord(new[] { Interval.FromHalfSteps(2), Interval.FromHalfSteps(4) }, NoteName.D)
                          .Build();

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.D, defaultOctave.Number, chordTime, defaultNoteLength, defaultVelocity),
                new NoteInfo(NoteName.E, defaultOctave.Number, chordTime, defaultNoteLength, defaultVelocity),
                new NoteInfo(NoteName.FSharp, defaultOctave.Number, chordTime, defaultNoteLength, defaultVelocity)
            });
        }
Пример #25
0
        public void TransformChords_Selection_SelectNone()
        {
            var noteLength = MusicalTimeSpan.Eighth;
            var velocity   = (SevenBitNumber)90;

            var pattern = new PatternBuilder()
                          .SetNoteLength(noteLength)
                          .SetVelocity(velocity)
                          .Chord(new[] { Notes.A0, Notes.CSharp2 })
                          .Chord(new[] { Notes.B2, Notes.B3, Notes.B4 })
                          .Build();

            pattern = pattern.TransformChords((i, d) => false, d => new ChordDescriptor(Enumerable.Empty <DryWetMidi.MusicTheory.Note>(), SevenBitNumber.MinValue, MusicalTimeSpan.Half));

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 0, null, noteLength, velocity),
                new NoteInfo(NoteName.CSharp, 2, null, noteLength, velocity),

                new NoteInfo(NoteName.B, 2, noteLength, noteLength, velocity),
                new NoteInfo(NoteName.B, 3, noteLength, noteLength, velocity),
                new NoteInfo(NoteName.B, 4, noteLength, noteLength, velocity)
            });
        }
Пример #26
0
        public void SplitAtAnchor_MultipleAnchors(bool removeEmptyPatterns)
        {
            var anchor1 = "A";
            var anchor2 = "B";

            var pattern = new PatternBuilder()
                          .Anchor(anchor1)
                          .Note(Notes.FSharp4)
                          .Note(Notes.DSharp1)
                          .Anchor(anchor2)
                          .Note(Notes.DSharp0)
                          .Anchor(anchor1)
                          .Build();

            var patterns = pattern.SplitAtAnchor(anchor1, removeEmptyPatterns).ToList();

            var subPatternIndex = 0;

            if (removeEmptyPatterns)
            {
                Assert.AreEqual(1, patterns.Count, "Sub-patterns count is invalid.");
            }
            else
            {
                Assert.AreEqual(2, patterns.Count, "Sub-patterns count is invalid.");
                CollectionAssert.IsEmpty(patterns[0].Actions, "First sub-pattern is not empty.");
                subPatternIndex++;
            }

            PatternTestUtilities.TestNotes(patterns[subPatternIndex], new[]
            {
                new NoteInfo(NoteName.FSharp, 4, null, PatternBuilder.DefaultNoteLength),
                new NoteInfo(NoteName.DSharp, 1, PatternBuilder.DefaultNoteLength, PatternBuilder.DefaultNoteLength),
                new NoteInfo(NoteName.DSharp, 0, PatternBuilder.DefaultNoteLength.Multiply(2), PatternBuilder.DefaultNoteLength)
            });
        }
Пример #27
0
        public void TransformChords_Changed_Pattern_Recursive()
        {
            var noteLength = (MidiTimeSpan)200;
            var velocity   = (SevenBitNumber)90;

            var subPattern = new PatternBuilder()
                             .Chord(new[] { Notes.A0, Notes.CSharp2 })
                             .Chord(new[] { Notes.B2, Notes.B3, Notes.B4 })
                             .Build();

            var pattern = new PatternBuilder()
                          .SetNoteLength(noteLength)
                          .SetVelocity(velocity)
                          .Note(Notes.A2)
                          .Note(Notes.C3)
                          .Pattern(subPattern)
                          .Build();

            pattern = pattern.TransformChords(d => new ChordDescriptor(
                                                  d.Notes.Select(n => n.Transpose(Interval.One)),
                                                  (SevenBitNumber)65,
                                                  (MidiTimeSpan)100));

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 2, null, noteLength, velocity),
                new NoteInfo(NoteName.C, 3, noteLength, noteLength, velocity),

                new NoteInfo(NoteName.ASharp, 0, (MidiTimeSpan)(2 * noteLength), (MidiTimeSpan)100, (SevenBitNumber)65),
                new NoteInfo(NoteName.D, 2, (MidiTimeSpan)(2 * noteLength), (MidiTimeSpan)100, (SevenBitNumber)65),

                new NoteInfo(NoteName.C, 3, (MidiTimeSpan)(2 * noteLength) + (MidiTimeSpan)100, (MidiTimeSpan)100, (SevenBitNumber)65),
                new NoteInfo(NoteName.C, 4, (MidiTimeSpan)(2 * noteLength) + (MidiTimeSpan)100, (MidiTimeSpan)100, (SevenBitNumber)65),
                new NoteInfo(NoteName.C, 5, (MidiTimeSpan)(2 * noteLength) + (MidiTimeSpan)100, (MidiTimeSpan)100, (SevenBitNumber)65)
            });
        }
Пример #28
0
        public void TransformChords_Original()
        {
            var noteLength = MusicalTimeSpan.Eighth;
            var velocity   = (SevenBitNumber)90;

            var pattern = new PatternBuilder()
                          .SetNoteLength(noteLength)
                          .SetVelocity(velocity)
                          .Chord(new[] { Notes.A0, Notes.CSharp2 })
                          .Chord(new[] { Notes.B2, Notes.B3, Notes.B4 })
                          .Build();

            pattern = pattern.TransformChords(d => d);

            PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.A, 0, null, noteLength, velocity),
                new NoteInfo(NoteName.CSharp, 2, null, noteLength, velocity),

                new NoteInfo(NoteName.B, 2, noteLength, noteLength, velocity),
                new NoteInfo(NoteName.B, 3, noteLength, noteLength, velocity),
                new NoteInfo(NoteName.B, 4, noteLength, noteLength, velocity)
            });
        }
        public void Pattern_Repeat()
        {
            var noteLength1 = MusicalTimeSpan.Quarter;
            var pattern1    = new PatternBuilder()
                              .SetNoteLength(noteLength1)
                              .Note(Notes.A0)
                              .Note(Notes.C1)
                              .Build();

            var pattern2 = new PatternBuilder()
                           .Pattern(pattern1)
                           .Repeat(2)
                           .Build();

            PatternTestUtilities.TestNotes(pattern2, new[]
            {
                new NoteInfo(NoteName.A, 0, null, noteLength1),
                new NoteInfo(NoteName.C, 1, noteLength1, noteLength1),
                new NoteInfo(NoteName.A, 0, 2 * noteLength1, noteLength1),
                new NoteInfo(NoteName.C, 1, 3 * noteLength1, noteLength1),
                new NoteInfo(NoteName.A, 0, 4 * noteLength1, noteLength1),
                new NoteInfo(NoteName.C, 1, 5 * noteLength1, noteLength1)
            });
        }
Пример #30
0
        public void Note_Multiple_MetricLengths_TempoChanged()
        {
            var pattern = new PatternBuilder()
                          .SetOctave(Octave.Get(2))

                          .Note(NoteName.G, new MetricTimeSpan(0, 0, 24))
                          .Note(NoteName.A, new MetricTimeSpan(0, 1, 0))
                          .Note(NoteName.B, new MetricTimeSpan(0, 0, 5))

                          .Build();

            var midiFile = PatternTestUtilities.TestNotes(pattern, new[]
            {
                new NoteInfo(NoteName.G, 2, null, new MetricTimeSpan(0, 0, 24)),
                new NoteInfo(NoteName.A, 2, new MetricTimeSpan(0, 0, 24), new MetricTimeSpan(0, 1, 0)),
                new NoteInfo(NoteName.B, 2, new MetricTimeSpan(0, 1, 24), new MetricTimeSpan(0, 0, 5)),
            },
                                                          Enumerable.Range(0, 7)
                                                          .Select(i => Tuple.Create(i * 1000L, new Tempo(i * 100 + 10)))
                                                          .ToArray());

            Assert.AreEqual(new MetricTimeSpan(0, 1, 29).TotalMicroseconds,
                            midiFile.GetDuration <MetricTimeSpan>().TotalMicroseconds);
        }