Results 1 to 1 of 1
  1. #1
    bs3ac is offline Member
    Join Date
    Oct 2009
    Posts
    10
    Rep Power
    0

    Cool MIDI - Music Player Help

    Hi,

    I have the following code which changes and plays an instrument (instruments are labeled from a list 1 - 127, using the default soundbank 1).

    Code:

    Java Code:
    public class MiniMiniMusicApp 
    {
        public static void main(String[] args)
        {
            MiniMiniMusicApp mini = new MiniMiniMusicApp();
            mini.play();
        } //close main
        
        public void play()
        {
            try
            {
            Sequencer player = MidiSystem.getSequencer();
            player.open(); 
            
            Sequence seq = new Sequence(Sequence.PPQ, 4);
            
            Track track = seq.createTrack();
            
            
            ShortMessage first = new ShortMessage();
            first.setMessage(192, 1, 120, 0);
            MidiEvent changeInstrument = new MidiEvent (first, 1);
            track.add(changeInstrument);
            
            ShortMessage a = new ShortMessage();
            a.setMessage(144, 1, 70, 100);
            MidiEvent noteOn = new MidiEvent (a, 3);
            track.add(noteOn);
            
            ShortMessage b = new ShortMessage();
            b.setMessage(128, 1, 70, 100);
            MidiEvent noteOff = new MidiEvent (b, 16);
            track.add(noteOff);
            
            player.setSequence(seq);
            player.start();
        }
        catch (Exception ex)
        {
            ex.printStackTrace();
        }
        }//close try
    
    }
    Now how can I set this code to use an instrument in a diffrent sound bank (for example instruments 1-127 from sound bank 2)?

    Thank

    s
    Last edited by Fubarable; 08-29-2010 at 02:19 AM. Reason: Moderator Edit: Color tags changed to Code tags

Similar Threads

  1. JMF player.setSource
    By lambi in forum Advanced Java
    Replies: 2
    Last Post: 02-22-2010, 02:09 PM
  2. Music player problem
    By abhinavhardikar in forum Advanced Java
    Replies: 2
    Last Post: 02-07-2010, 05:17 AM
  3. mp3 player applet
    By willemjav in forum Java Applets
    Replies: 0
    Last Post: 05-20-2008, 02:16 AM
  4. printing MIDI notes on a music staff
    By kbyrne in forum Advanced Java
    Replies: 0
    Last Post: 12-29-2007, 08:50 PM
  5. printing MIDI notes on a music staff
    By kbyrne in forum AWT / Swing
    Replies: 0
    Last Post: 12-29-2007, 06:30 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •