• 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:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

No sound in HFJ Beatbox app (?solved)

 
Greenhorn
Posts: 9
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Hi I have started working on the app "BEATBOX" and i implemented its first phase thats given in Exception Handling chapter,but i couldn't hear any sound ,the app get complied fine but no sound.

Please help or suggest .
code:






....I found the mistake .....
 
Marshal
Posts: 80269
430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch

What was the mistake? If you tell us the thread will be useful for future generations of HFJ readers.
I have added code tags to your code, and also got rid of some of the empty lines (too many empty lines make the code harder to read) and doesn't it look better.
This appears to be a new question so it merits a thread of its own.
 
Ashish Dash
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanxx for showing the concern to go through once my code..

The problem was that the in a.setMessage(* , , , ) & b.setMessage(*, , , ) first arguement(*) is set to 128 & that's why no sound was coming...

correct one:
a.setMessage(144,1,27,100)

But now I'm facing another problem with the same code which i edited some what (as given HFJ) to make it work through command line

Getting compiled but no sound coming..

package com.BB.getPlayer;

import javax.sound.midi.*;

public class MiniMusicAppCmd {

/**
* @param args
*/


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.
 
Ashish Dash
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
!!!Please help or assist me so that I can make the above code work!!!
 
Ashish Dash
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm sorry for again posting the same question but it had been three to 4 days i didn't got any reply ..... i'll keep in mind that not to post the same stuff again... but please someone answer my query.....
 
Ranch Hand
Posts: 607
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Ashish Dash wrote:I'm sorry for again posting the same question but it had been three to 4 days i didn't got any reply ..... i'll keep in mind that not to post the same stuff again... but please someone answer my query.....


ehy,
do you receive at least the output:
Hey you have to enter only the instrument & node You want To Play

when you launch the program?

 
Ashish Dash
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yeah i did that ofcourse. Passing those arguements "instru" & "note" no sound even the program gets compiled..
 
Giovanni Montano
Ranch Hand
Posts: 607
11
Android Python Open BSD VI Editor Slackware
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, i pass the arguments clicking on proprieties from the project folder and then going to the argument tab from the multi tab menu( is not immediate), usually when there is not sound is because the second argument is really low as number so trying different parameters work ed for me
 
Ashish Dash
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanxx it worked...
 
Campbell Ritchie
Marshal
Posts: 80269
430
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please spell all words correctly. Thanks not thanxx.
 
Power corrupts. Absolute power xxxxxxxxxxxxxxxx is kinda neat.
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic