Commit c9f58e79 authored by Trisha Gee's avatar Trisha Gee
Browse files

[Ch13] Formatting and cleanup of MiniMusicCmdLine

parent d242c2e5
Loading
Loading
Loading
Loading
+7 −8
Changes for src/main/java/ch13/MiniMusicCmdLine.java: 7 added lines, 8 removed lines.
Original line number Diff line number Diff line
@@ -12,19 +12,15 @@ public class MiniMusicCmdLine {
      int note = Integer.parseInt(args[1]);
      mini.play(instrument, note);
    }
   } // close main
  }

  public void play(int instrument, int note) {

    try {
 
      Sequencer player = MidiSystem.getSequencer();
      player.open();
      Sequence seq = new Sequence(Sequence.PPQ, 4);
      Track track = seq.createTrack();

         MidiEvent event = null;

      ShortMessage first = new ShortMessage();
      first.setMessage(192, 1, instrument, 0);
      MidiEvent changeInstrument = new MidiEvent(first, 1);
@@ -39,9 +35,12 @@ public class MiniMusicCmdLine {
      b.setMessage(128, 1, note, 100);
      MidiEvent noteOff = new MidiEvent(b, 16);
      track.add(noteOff);

      player.setSequence(seq);
      player.start();

      } catch (Exception ex) {ex.printStackTrace();}
   } // close play
} // close class
 No newline at end of file
    } catch (Exception ex) {
      ex.printStackTrace();
    }
  }
}
 No newline at end of file