Exemplo n.º 1
0
 /** Test of setPitch method, of class MidiNote. */
 @Test
 public void setPitch() {
   System.out.println("setPitch");
   int pitch = 50;
   MidiNote instance = new MidiNote();
   instance.setPitch(pitch);
   int result = instance.getPitch();
   assertEquals(pitch, result);
 }
Exemplo n.º 2
0
  @Test
  public void noteEventRefreshOnFieldChange() throws InvalidMidiDataException {
    System.out.println("noteEventRefreshOnFieldChange");
    MidiNote instance = new MidiNote();
    MidiEvent noteOnEvent = instance.getNoteOnEvent();
    MidiEvent noteOffEvent = instance.getNoteOffEvent();

    assertNoteEventEqual(
        noteOnEvent, 0, (byte) -112, (byte) 0, (byte) MidiNote.DEFAULT_VELOCITY, true);
    assertNoteEventEqual(noteOffEvent, 0, (byte) -128, (byte) 0, (byte) 0, true);

    instance.setPitch(92);
    noteOnEvent = instance.getNoteOnEvent();
    noteOffEvent = instance.getNoteOffEvent();
    assertNoteEventEqual(
        noteOnEvent, 0, (byte) -112, (byte) 92, (byte) MidiNote.DEFAULT_VELOCITY, true);
    assertNoteEventEqual(noteOffEvent, 0, (byte) -128, (byte) 92, (byte) 0, true);

    instance.setStartTime(16L);
    noteOnEvent = instance.getNoteOnEvent();
    noteOffEvent = instance.getNoteOffEvent();
    assertNoteEventEqual(
        noteOnEvent, 16, (byte) -112, (byte) 92, (byte) MidiNote.DEFAULT_VELOCITY, true);
    assertNoteEventEqual(noteOffEvent, 16, (byte) -128, (byte) 92, (byte) 0, true);

    instance.setDuration(8L);
    noteOnEvent = instance.getNoteOnEvent();
    noteOffEvent = instance.getNoteOffEvent();
    assertNoteEventEqual(
        noteOnEvent, 16, (byte) -112, (byte) 92, (byte) MidiNote.DEFAULT_VELOCITY, true);
    assertNoteEventEqual(noteOffEvent, 24, (byte) -128, (byte) 92, (byte) 0, true);

    instance.setVelocity(120);
    noteOnEvent = instance.getNoteOnEvent();
    noteOffEvent = instance.getNoteOffEvent();
    assertNoteEventEqual(noteOnEvent, 16, (byte) -112, (byte) 92, (byte) 120, true);
    assertNoteEventEqual(noteOffEvent, 24, (byte) -128, (byte) 92, (byte) 0, true);

    instance.setChannel(2);
    noteOnEvent = instance.getNoteOnEvent();
    noteOffEvent = instance.getNoteOffEvent();
    assertNoteEventEqual(noteOnEvent, 16, (byte) -110, (byte) 92, (byte) 120, true);
    assertNoteEventEqual(noteOffEvent, 24, (byte) -126, (byte) 92, (byte) 0, true);
  }