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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

HFJ BEAT BOX ISSUE

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 11497
19
Android Google Web Toolkit Mac Eclipse IDE Ubuntu Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Please do not post the same question multiple times. Let us continue the discussion in your original topic https://coderanch.com/t/635459/java/java/sound-HFJ-Beatbox-app-solved
 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic