Bookmark Topic Watch Topic
  • New Topic

HFJ BEAT BOX ISSUE  RSS feed

 
Ashish Dash
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Report post to moderator
I'm facing another problem with the HFJ code which i edited some what (as given HFJ) to make it work through command line

BeatBox using commandline.

Getting compiled but no sound coming..

package com.BB.getPlayer;
import javax.sound.midi.*;
public class MiniMusicAppCmd {

public static void main(String[] args) {
// TODO Auto-generated method stub

MiniMusicAppCmd mcd=new MiniMusicAppCmd();

if(args.length<2)
{
System.out.println("Hey you have to enter only the instrument & node You want To Play");

}
else
{
int instrument=Integer.parseInt(args[0]);

int note=Integer.parseInt(args[1]);
System.out.println(instrument+ " "+ note);
mcd.play(instrument,note);

}


}

public void play(int instru,int note)
{
try {
Sequencer player =MidiSystem.getSequencer();
player.open();
Sequence seq=new Sequence(Sequence.PPQ,4);

Track track=seq.createTrack();

//MidiEvent midi=null;

ShortMessage first=new ShortMessage();
first.setMessage(192,1,instru,0);
MidiEvent chngInstru=new MidiEvent(first, 1);
track.add(chngInstru);

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

ShortMessage b=new ShortMessage();
b.setMessage(128,1,note,100);
MidiEvent noteOff=new MidiEvent(b,1);
track.add(noteOff);
player.setSequence(seq);
player.start();

} catch (MidiUnavailableException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (InvalidMidiDataException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}


}

}


please help i'm running this code on eclipse.
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Report post to moderator
Please do not post the same question multiple times. Let us continue the discussion in your original topic http://www.coderanch.com/t/635459/java/java/sound-HFJ-Beatbox-app-solved
 
    Bookmark Topic Watch Topic
  • New Topic
Boost this thread!