Ejemplo n.º 1
0
        public void Constructor_SingleNotePassed_ReportsSingleNote_Test()
        {
            // Act
            var sut = new MidiInputTrigger(Pitch.A0);

            // Assert
            Assert.IsTrue(sut.IsSingleNote);
            Assert.IsFalse(sut.IsChord);
        }
Ejemplo n.º 2
0
        public void Constructur_MultipleNotesPassed_ReportsChord_Test()
        {
            // Arrange
            var pitchArray = new[] { Pitch.A0, Pitch.A1 };

            // Act
            var sut = new MidiInputTrigger(pitchArray);

            // Assert
            Assert.IsFalse(sut.IsSingleNote);
            Assert.IsTrue(sut.IsChord);
        }
Ejemplo n.º 3
0
        public void Constructor_SingleNoteArrayPassed_ReportsSingleNote_Test()
        {
            // Arrange
            var pitchArray = new[] { Pitch.A0 };

            // Act
            var sut = new MidiInputTrigger(pitchArray);

            // Assert
            Assert.IsTrue(sut.IsSingleNote);
            Assert.IsFalse(sut.IsChord);
        }
        public void SetMappingRecord(MidiMappingRecord record)
        {
            LoadActions();

            if (record != null)
            {
                inputTrigger = record.Trigger;
                action = record.Action;

                RefreshActionSelection();
                RefreshMidiInputText();
                RefreshParameterText();
            }
        }
Ejemplo n.º 5
0
        private void WaitAndFinalizeChord()
        {
            // Allow to store other chord notes in the buffer.
            Thread.Sleep(chordWaitTime);
            StopReceivingMidi();

            // Process collected events.
            var bufferedEvents = eventBuffer.Flush();
            var inputTrigger = new MidiInputTrigger(bufferedEvents.Select(e => e.Pitch).OrderBy(p => p).ToArray());

            // Reset the buffer to return to normal mode.
            Interlocked.CompareExchange(ref eventBuffer, null, eventBuffer);

            var oldTargetControl = midiInputLearnTargetControl;
            midiInputLearnTargetControl = null;

            Invoke(new Action(() => oldTargetControl.TeachMidiInput(inputTrigger)));
        }
 public void TeachMidiInput(MidiInputTrigger trigger)
 {
     inputTrigger = trigger;
     txtInputTrigger.BackColor = inputNormalColor;
     RefreshMidiInputText();
 }
Ejemplo n.º 7
0
        public void ToString_SingleNote_ReturnsStringWithoutSeparators_Test()
        {
            // Arrange
            var sut = new MidiInputTrigger(Pitch.A0);

            // Act
            var triggerString = sut.ToString();

            // Assert
            Assert.AreEqual("A0", triggerString);
        }
Ejemplo n.º 8
0
        public void ToString_MultipleNotes_ReturnsStringWithSeparators_Test()
        {
            // Arrange
            var sut = new MidiInputTrigger(new [] { Pitch.C0, Pitch.CSharp0 });

            // Act
            var triggerString = sut.ToString();

            // Assert
            Assert.AreEqual("C0,C#0", triggerString);
        }