Ejemplo n.º 1
0
        public void WhenScaleInstanceIsCreated_ThenNotesCountIsCorrect()
        {
            // Arrange
            var sourceScale = this.chordData.Scales[0];
            var noteNames   = NoteSequenceUtilities.GetNotes(this.chordData, "bb", sourceScale);

            // Act
            var scaleInstance = ScaleInstance.Create(sourceScale.Description, sourceScale.Notes, noteNames.ToList());

            // Assert
            Assert.AreEqual(sourceScale.Notes.Count, scaleInstance.Notes.Count);
        }
Ejemplo n.º 2
0
        public void WhenChordInstanceIsCreated_ThenDisplayNameIsCorrect()
        {
            // Arrange
            var sourceChord = this.chordData.Chords[0];
            var noteNames   = NoteSequenceUtilities.GetNotes(this.chordData, "bb", sourceChord);

            // Act
            var chordInstance = ChordInstance.Create(sourceChord.Description, sourceChord.Notes, noteNames.ToList());

            // Assert
            Assert.AreEqual("Bb/A# Major", chordInstance.DisplayName);
        }
Ejemplo n.º 3
0
        public IEnumerable <ChordInstance> ChordNotes(string root, string searchTerm)
        {
            searchTerm = searchTerm.Trim();
            this.logger.LogInformation($"APP LOGGING ===> ChordNotes with root: {root} and searchTerm: {searchTerm}");
            var chordResults   = NoteSequenceUtilities.SearchDescriptions(this.chordData.Chords, searchTerm);
            var chordArray     = chordResults as Chord[] ?? chordResults.ToArray();
            var chordInstances = new List <ChordInstance>(chordArray.Length);

            foreach (var chord in chordArray)
            {
                var chordInstance = ChordInstance.Create(
                    chord.Description,
                    chord.Notes,
                    (List <string>)NoteSequenceUtilities.GetNotes(this.chordData, root, chord));

                chordInstances.Add(chordInstance);
            }

            return(chordInstances);
        }
Ejemplo n.º 4
0
        public IEnumerable <ScaleInstance> ScaleNotes(string root, string searchTerm)
        {
            searchTerm = searchTerm.Trim();

            this.logger.LogInformation($"APP LOGGING ===> ScaleNotes with root: {root} and searchTerm: {searchTerm}");
            var scaleResults   = NoteSequenceUtilities.SearchDescriptions(this.chordData.Scales, searchTerm);
            var scaleArray     = scaleResults as Scale[] ?? scaleResults.ToArray();
            var scaleInstances = new List <ScaleInstance>(scaleArray.Length);

            foreach (var scale in scaleArray)
            {
                var scaleInstance = ScaleInstance.Create(
                    scale.Description,
                    scale.Notes,
                    (List <string>)NoteSequenceUtilities.GetNotes(this.chordData, root, scale));

                scaleInstances.Add(scaleInstance);
            }

            return(scaleInstances);
        }
Ejemplo n.º 5
0
        public void WhenGetNotesIsCalledForBbASharpMajorSixthTetrad_ThenBbDbFNoteNamesIsReturned()
        {
            // Arrange
            var sourceChord   = this.chordData.Chords[6];
            var expectedNotes = new[] { "Bb/A#", "D", "F", "G" };

            // Act
            var notes = NoteSequenceUtilities.GetNotes(this.chordData, "Bb", sourceChord);

            // Assert
            Assert.IsNotNull(notes);

            var notesArray = notes as string[] ?? notes.ToArray();

            Assert.AreEqual(4, notesArray.Length);

            for (var noteIndex = 0; noteIndex < 4; noteIndex++)
            {
                Assert.AreEqual(expectedNotes[noteIndex], notesArray[noteIndex]);
            }
        }
Ejemplo n.º 6
0
        public void WhenGetNotesIsCalledForCMajorTriad_ThenCEGNoteNamesIsReturned()
        {
            // Arrange
            var sourceChord   = this.chordData.Chords[0];
            var expectedNotes = new[] { "C", "E", "G" };

            // Act
            var notes = NoteSequenceUtilities.GetNotes(this.chordData, "c", sourceChord);

            // Assert
            Assert.IsNotNull(notes);

            var notesArray = notes as string[] ?? notes.ToArray();

            Assert.AreEqual(3, notesArray.Length);

            for (var noteIndex = 0; noteIndex < 3; noteIndex++)
            {
                Assert.AreEqual(expectedNotes[noteIndex], notesArray[noteIndex]);
            }
        }