• Post Reply Bookmark Topic Watch Topic
  • New Topic

What's the use of MidiEvent event = null in the code below?  RSS feed

 
John McDowell
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As far as I know it is redundant and can be removed.But I just wanted to confirm because I found it in a book that's not known for making too many mistakes
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 changelnstrument. = new MidiEvent (first,
track.add(changelnstrument);
1) ;
ShortHessage a = new ShortMessage();
a.setMessage(144, 1, note, 100);
MidiEvent noteOn = new MidiEvent(a, 1);
track.add(noteOn);
ShortMessage b ~ new Shor~essage();
b.setMessage(12B, 1, note, 100);
MidiEvent noteOff = new MidiEvenc(b, 16);
track.add(noteOffl,
player.setSequence(seq);
player. start ();
I catch (ExCeption ex) (ex.printStackTrace();)
I / / close p lay
}// I cl ose clas s
 
Ulf Dittmer
Rancher
Posts: 42972
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
We can't say it's redundant, because we don't know how it gets used - no field called "event" is used anywhere in the code. This code wouldn't compile as is for multiple reasons, though, so maybe the usage somehow got lost during copy/paste?
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!