Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Audio problems

Posted on 2002-03-05
7
Medium Priority
?
159 Views
Last Modified: 2010-03-31
My problem really is adding some sound to my piece of code. What i really want to know is how do I record my voice to a file i can use on my piece of code that will execute at a given time.Example: when the an applet color changes from blue to pink, my recorded voice should shout "Pink" as it corresponds to the change of colors.

Oh! and by the way, I am using Visual J++ as my compiler..
Thanx!!
0
Comment
Question by:q_bic
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 2

Accepted Solution

by:
mzimmer74 earned 400 total points
ID: 6842217
   try
    {
      URL file = new URL(filename);
      AudioClip clip = Applet.newAudioClip(file);
      clip.play();
    }
    catch (MalformedURLException mue)
    {
    }
0
 
LVL 2

Expert Comment

by:mzimmer74
ID: 6842219
That's how you play a clip.  Of course, you'll have to call it as appropriate.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6843727
> Oh! and by the way, I am using Visual J++ as my compiler..

in JDK1.1 you need

AudioClip clip = applet.getAudioClip(url);
clip.play();
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:q_bic
ID: 6846748
Yeah, but how do i change existing sound files to .au files so that they can be recognised by java coz i failed to find any .au files in my system.
How do i make my own .au files that i can use on my code
mzimmer74?
thanx...
0
 
LVL 2

Expert Comment

by:mzimmer74
ID: 6847149
That I don't know...I supose there are some programs out there that will convert files to .au type.  However, if you want to use .midi or .wav files you can play them in this manner:

private void playMidi()
{
  try
  {
    File file = new File("soundOne.mid");
    // OR:
    // File file = new File("sounDTwo.wav");
    currentSound = MidiSystem.getSequence(file);
    player = MidiSystem.getSequencer();
    player.open();
    player.setSequence(currentSound);
    player.start();
    while (player.isRunning())
    {
      System.out.print(". ");
    }
    player.close();
  }
  catch (Exception ex)
  {
    ex.printStackTrace();
  }
}


I don't remember all the info about this method (ie, what is player) as I don't use it anymore in some code I've written.  However, I do remember that it worked.

You might look at
http://java.sun.com/products/java-media/sound/
for some examples of this.  Hope that helps.
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 6850010
q_bic:

what is the target Java version ?
0
 

Author Comment

by:q_bic
ID: 6855689
Thanx mzimmer74, finally it worked!!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn about the third conditional statement “else if” and use it in an example program. Then additional information about conditional statements is provided, covering the topic thoroughly. Viewers learn about the third conditional statement …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

721 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question