Solved

Audio problems

Posted on 2002-03-05
7
153 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
  • 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
JDeveloper 12c for 32 bit 4 84
thymeleaf natural templating vs JSP 2 98
Java Options in Zimbra Server 2 53
Facing this issue for maven proxy setting 2 10
INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
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 …
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

773 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