• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

Headfirst Book - No Output of this program

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
import javax.sound.midi.*;
public class MiniMiniMusicApp
{
public static void main (String [] args)
{
MiniMiniMusicApp mini = new MiniMiniMusicApp();
mini.play();
}
public void play()
{
try
{
Sequencer play = MidiSystem.getSequencer();
player.open();
Sequencer seq = new Sequence(Sequence.PPQ, 4);
Track track = seq.createTrack();

ShortMessage a = new ShortMessage();
a.setMessage(144, 1, 44, 100);
MidiEvent noteOn = new MidiEvent(a, 1);
track.add(noteOn);

ShortMessage b = new ShortMessage();
b.setMessage(128, 1, 44, 100);
MidiEvent noteOn = new MidiEvent(b,16);
track.add(noteOn);

player.setSequence(seq);
player.start();
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
}
 
Ranch Hand
Posts: 457
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
no audio output?
please use the CODE tags,
there's prob'ly a more appropriate forum,
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic