Example #1
0
        public void PlayAllNotesWithNAudioToneProvider() {

            var setOfTones = new NoteUtility(_nAudioToneProvider);
            foreach (var note in setOfTones.GetAllNotes()) {
                setOfTones.PlayNote(note);
            }
        }
Example #2
0
        public void PlayIntervalsAndConfirmTheirName() {

            const int totalIterations = 10;
            const int sectionCount = 2;
            const int iterationsPerSection = totalIterations / sectionCount;
            const int secondsToSleep = 5;
            var notes = new MusicalNotes();
            var setOfTones = new NoteUtility(_toneProvider);
            var upperLimit = notes.GetAllNotes().Count - 1;

            SpeakIntroduction();
            for (var i = 0; i < totalIterations; i++) {
                // do a break so that the listener has time to consolidate a bit
                if (i % iterationsPerSection == 0) {
                    _synth.Speak($"This is; Musical Intervals: Section {i / iterationsPerSection + 1}");
                }
                //we want substantially more ascending than descending intervals - this spread gives about 80%:
                var currentDirectionType = i % 3 == 0 ? NumberUtilities.Direction.Random : NumberUtilities.Direction.Ascending;
                var interval = NumberUtilities.GetRandomInterval(0, upperLimit, 12, _random, currentDirectionType);

                if (i < (totalIterations/2)) {
                    // play the voice/piano versions...
                    setOfTones.PlayIntervalWithCommentary(interval, secondsToSleep, "Emm", true);
                }
                else {
                    setOfTones.PlayIntervalWithCommentary(interval, secondsToSleep);
                }
            }


        }
Example #3
0
        public void PlayAllNotes() {

            const int totalIterations = 1000;
            const int delayInSecondsBetweenAudioSnippets = 5;
            var notes = new MusicalNotes();
            var setOfTones = new NoteUtility(_toneProvider);
            var frequencies = notes.GetAllFrequencies();

            for (var i = 0; i < totalIterations; i++) {
                var intervalBoundaries = NumberUtilities.GetRandomInterval(0, 24, 12, _random);
                var frequency0 = frequencies[intervalBoundaries[0]];
                var frequency1 = frequencies[intervalBoundaries[1]];

                setOfTones.PlayNote(notes.GetNoteFromIndex(intervalBoundaries[0]));
                setOfTones.PlayNote(notes.GetNoteFromIndex(intervalBoundaries[1]));
                Console.WriteLine(frequency0);
                Console.WriteLine(frequency1);
                Console.WriteLine(frequency1 - frequency0);

                Thread.Sleep(delayInSecondsBetweenAudioSnippets * 1000);
                setOfTones.PlayNote(notes.GetNoteFromIndex(intervalBoundaries[0]));
                setOfTones.PlayNote(notes.GetNoteFromIndex(intervalBoundaries[1]));
                Thread.Sleep(delayInSecondsBetweenAudioSnippets * 1000);

                var semitoneCount = intervalBoundaries[1] - intervalBoundaries[0];
                var spokenInterval = Intervals.GetInterval(semitoneCount);

                _synth.Speak(spokenInterval);
                Thread.Sleep(delayInSecondsBetweenAudioSnippets * 1000);
            }
        }
Example #4
0
        public void PlayAllNotesWithMockToneProvider() {
            var toneProvider = new Mock<IToneProvider>(MockBehavior.Strict);
            toneProvider.Setup(x => x.PlayTone(It.IsAny<int>(), It.IsAny<double>()));

            var setOfTones = new NoteUtility(toneProvider.Object);
            foreach (var note in setOfTones.GetAllNotes()) {
                setOfTones.PlayNote(note);
            }
        }
Example #5
0
 public void VoiceCallingNoteUtilitySoundsAsExpected() {
     var setOfTones = new NoteUtility(_nAudioToneProvider);
     setOfTones.Speak("what voice am I?");
 }
Example #6
0
 public void RequestForNotFoundFrequencyThrowsException() {
     TraceExecutingMethod();
     var toneSet = new NoteUtility(_toneProvider);
     try {
         toneSet.GetNoteElements(9999);
     }
     catch (ArgumentException ex) {
         Assert.AreEqual("[The frequency [9999] was not found in the set of available notes]", ex.Message);
         throw;
     }
 }
Example #7
0
 public void RequestForFrequencyC3ReturnsExpectedElements() {
     TraceExecutingMethod();
     var toneSet = new NoteUtility(_toneProvider);
     Assert.AreEqual("D", toneSet.GetNoteElements(TestFrequency).Note);
     Assert.AreEqual(3, toneSet.GetNoteElements(TestFrequency).Octave);
 }
Example #8
0
 public void FrequencyDictionaryHas2OctavesOfNotes() {
     TraceExecutingMethod();
     var frequencyCount = new NoteUtility(_toneProvider).GetAllNotes().Count;
     Assert.AreEqual((12 * 2), frequencyCount);
 }