Solved

Audio problems

Posted on 2002-03-05
7
156 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 100 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
Independent Software Vendors: 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

Technology Partners: 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!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Android development question 2 113
swing controls 2 38
How does initial implicit objects  are set up in JSP? 7 41
How to access inner class in java (android)?? 13 22
Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
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 theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

710 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