.au sound format is not working

Hello everybody,
Infact this Alarm.java (attached) using sun proprietary API sun.audio classes, now these are deprecated so i want to replace it with java se 6 classes.
This Alarm.java is beeping the PC but not able to run alarm.au audio file and gives Following exception
Exception Occurred....java.lang.IllegalArgumentException: No line matching interface SourceDataLine supporting format ULAW 8000.0 Hz, 8 bit, mono, 1 bytes/frame, is supported.
Kindly help to make it work with alarm.au
NOTE: i hav commented all those sun proprietary API sun.audio code and tried with the alternate code in the same Alarm.java
Thanks
//Alarm.java
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.sound.sampled.*;
public class Alarm implements ActionListener
private static final int BEEP_INTERVAL = 1000;
private static javax.swing.Timer beepTimer = null;
private static Alarm theInstance = null;
private static boolean usePcSpeaker = false;
//old code
//private static sun.audio.ContinuousAudioDataStream soundClip = null;
//my code
private static AudioInputStream soundClip;
private static AudioFormat audioFormat;
private static SourceDataLine sourceDataLine;
//end my code
private static boolean isAlarmOn = false;
* Privately constructs a new Alarm. If useSpeaker is true, the method
* for sounding an alarm is to beep the pc speaker, otherwise we play
* a sound file.
private Alarm(boolean newUseSpeaker)
String alarmFilename = "Alarm.au";
usePcSpeaker = newUseSpeaker;
System.out.println("my code.. usePcSpeaker...."+usePcSpeaker);
if (!usePcSpeaker)
try
//my code
System.out.println("my code.. while usePcSpeaker..is false alarmFilename.."+alarmFilename);
               java.io.File file = new java.io.File(alarmFilename);
               soundClip = AudioSystem.getAudioInputStream(file);
               audioFormat = soundClip.getFormat();
               DataLine.Info dataLineInfo = new DataLine.Info(SourceDataLine.class,audioFormat);
               sourceDataLine = (SourceDataLine)AudioSystem.getLine(dataLineInfo);
//end my code
//old code
soundClip = new sun.audio.ContinuousAudioDataStream
new sun.audio.AudioStream
new java.io.FileInputStream(alarmFilename)
).getData()
catch (java.io.FileNotFoundException e)
System.out.println(alarmFilename + " not found");
     usePcSpeaker = true;
catch (java.io.IOException e)
System.out.println("Could not create audio stream");
     usePcSpeaker = true;
catch (java.lang.UnsatisfiedLinkError e)
System.out.println("Could not load audio driver");
     usePcSpeaker = true;
          catch (java.lang.Exception e)
System.out.println("Exception Occurred...."+e);
     usePcSpeaker = true;
if (usePcSpeaker)
beepTimer = new javax.swing.Timer(BEEP_INTERVAL, this);
beepTimer.setRepeats(true);
System.out.println("my code.. Using PC Speaker....");
* This method turns on the Alarm. By design the Alarm does not
* care who controls it or how. Controlled access to this object, if
* desired, must be handled outside this class. Excessive calls to
* this method when the Alarm is already on are simply ignored.
public void turnOn()
synchronized(theInstance)
System.out.println("my code.. in turnOn isAlarmOn..."+isAlarmOn+"...usePcSpeaker...."+usePcSpeaker);
if (isAlarmOn)
System.out.println("Alarm already on");
else
     if (usePcSpeaker)
beepTimer.start();
     else
//old code
     //sun.audio.AudioPlayer.player.start(soundClip);
//my code
                    try
                              sourceDataLine.open(audioFormat);
                              sourceDataLine.start();
                              int cnt;
                              byte tempBuffer[] = new byte[128000];
                              //Keep looping until the input read method
                              // returns -1 for empty stream
                              while((cnt = soundClip.read(tempBuffer,0,tempBuffer.length)) != -1 )
                                   if(cnt > 0)
                                        //Write data to the internal buffer of
                                        // the data line where it will be
                                        // delivered to the speaker.
                                        sourceDataLine.write(tempBuffer, 0, cnt);
                                   }//end if
                              }//end while
                              //Block and wait for internal buffer of the
                              // data line to empty.
                              sourceDataLine.drain();
                              sourceDataLine.close();
                    catch (java.lang.Exception e)
                         e.printStackTrace();
System.out.println(" < < < ALARM ON > > > Exception... "+e);
                         //usePcSpeaker = true;
//end my code
System.out.println(" < < < ALARM ON > > > while usePcSpeaker is flase and isAlarmOn is false");
     isAlarmOn = true;
* This method is called by the timer object when the timer fires.
* It simply calls a method to BEEP.
* @param evt the timer action event
public void actionPerformed(ActionEvent evt)
java.awt.Toolkit.getDefaultToolkit().beep();
* Test Main, not production code
public static void main(String[] args)
Alarm alarm = Alarm.getInstance(false);
System.out.println("test-main: turning alarm ON");
alarm.turnOn();
try
     System.out.println("test-main: with CPU burn activity in background");
double b = 12;
double a = 0;
for(int ii = 0; ii < 100000; ii++)
// garbage formula to do busy work
a = Math.sqrt(1234.4567 * b) / ( (a+ii) / b) + ii;
b += 1;
     java.lang.Thread.sleep(5000);
catch (Exception e)
     e.printStackTrace();
System.out.println("test-main: turning alarm OFF");
try
     System.out.println("test-main: sleeping 3 seconds");
     java.lang.Thread.sleep(3000);
catch (Exception e)
     e.printStackTrace();
System.out.println("test-main: turning alarm ON");
alarm.turnOn();
try
     System.out.println("test-main: sleeping 5 seconds");
     java.lang.Thread.sleep(5000);
catch (Exception e)
     e.printStackTrace();
System.out.println("PROGRAM EXITING");
// The Unit Test program will run forever if we dont kill it
// this way (because the timer/awt dispatch thread is still running)
System.exit(1);
}

You can try to convert alarm.au to a supported format.
Here is an example how to find available converters:
import javax.sound.sampled.*;
import java.io.File;
public class ShowConverters {
    public static void main(String[] args) {
        AudioFormat format = null;
        try {
            AudioInputStream in =
                AudioSystem.getAudioInputStream(new File("alarm.au"));
            format = in.getFormat();
        } catch (Exception e) {
            e.printStackTrace();
        AudioFormat.Encoding[] encodings =
            AudioSystem.getTargetEncodings(format.getEncoding());
        if (encodings.length == 0) {
            System.out.println("No available format converters.");
            return;
        for (AudioFormat.Encoding encoding : encodings) {
            AudioFormat[] formats =
                AudioSystem.getTargetFormats(encoding, format);
            for (AudioFormat toFormat : formats) {
                System.out.println("--> " + toFormat);
}Good luck.

Similar Messages

  • SB04100 Sound Blaster Card not working after computer rebuild

    =SB0400 Sound Blaster Card not working after computer rebuildZ I did a full disk format and reinstall for a friend on a Dimension 3000, running XP SP3. There is no sound at all. Speakers are good, tested on another system. Model number on the back of the sound card is SB0400, so I assume this is an older 24 bit PCI SoundBlaster card. Although I reinstalled all drivers from Dell, I found no drivers for this. The Creative site has no listing for this model.
    Computer does not seem to recognize the card. Have not opened the box yet but I assume if I were to remove and then reinstall the card it would be recognized (?) I then have to find an SB0400 driver.
    Does anyone know where I can find an SB0400 driver ? Does the strategy of pulling and reinstalling the card make sense ? (I have really avoided tampering with any of the hardware on this box -- since it is not mine.)

    Re: SB0400 Sound Blaster Card not working after computer rebuild? Thanks much for your response. Problem solved for now. I removed the board and then reinserted it, after which I was able to download the drivers directly. Some of my difficulty with this whole process has been ) I didn't know there was no working speaker in the computer and 2) I apparently misunderstood the BIOS settings for this. I re-set it up as an add-on board during the troubleshooting process. After loading the driver, I went back to the original setting (don't recall what it was but it was for integrated sound). The setting for integrated sound works fine, with external speakers and the new 24 bit driver. Still some noise (popping and static) but this board shares the bus with 2 other cards one of which is a wireless network card. May be a PCI latency issue but I'm reluctant to change that because the network card is a bit shaky anyway.
    Everything works for now -- I'll be glad to get this particular computer out of my house !

  • Satellite U400-17R - Sound device is not working after installing XP

    Hi there,
    I purchased a U400-17R Model with Vista Home. i Formatted it and installed Windows XP Professional downloading the XP drivers from Toshiba site.
    Everything works but my Sound Device is not working. when i check in the Device Manager the Sound Drivers are there and it says working properly.
    I am Lost...Can anyone please help?

    Hi!
    On Windows XP you have to install two patches from the Microsoft Knowledge Base for high definition audio cards. If you only have SP1 or SP2 you need the patches but if you have SP3 you dont need it because they are a part of SP3.
    Both patches or SP3 must be installed *first* and then the sound driver. So if you have installed the sound driver first you must remove it and then install the patches again. After this it should work with the sound:
    http://support.microsoft.com/kb/835221
    http://support.microsoft.com/kb/888111
    Bye

  • Sound system is not working. Stand option no more available.

    I have HP pavillion dv 1000. After formatting the laptop, sound system is not working. I can't hear any video sound; stand by and hibernate options are no more available. Please help me.
    This question was solved.
    View Solution.

    Nazia2011 wrote:
    I have HP pavillion dv 1000. After formatting the laptop, sound system is not working. I can't hear any video sound; stand by and hibernate options are no more available. Please help me.
    Well actually, if you really performed the impossible as you stated "formatted the laptop" how could anything work?
    One can format and partition a hard disk which is a component of a laptop. Without reinstallation of an OS how can anything work?
    Please restate in clearer terms what you did to which component to achieve nothing working.
    Identify your notebook in more concise terms than just the series number from the front. Turn your notebook over and look at the tag. Post all but the serial number from the barcoded tag.
    Best regards,
    erico
    ****Please click on Accept As Solution if a suggestion solves your problem. It helps others facing the same problem to find a solution easily****
    2015 Microsoft MVP - Windows Experience Consumer

  • My sound system does not work AFTER installing pc to tv wireless connection

    my sound system does not work after installing hp pc to tv wireles device when I am using lap top for other purposes.

    Hi,
    You don’t install VS2010 on the client PC, then where did the Form Invoice not work? When you run it from another version of VS? Or when you run the application with application.exe?
    Based on your description, one form works well, another form does not. I assume that two forms are in two different projects, then please check the .Net Framework used by the two projects. If they are different, you can use the
    one used by the Form contact for Form Invoice.
    Because this issue is a project issue, I recommend you to consult it on some application forum such as Windows Forms General forum for better support.
    VS General Question forum mainly discusses
    the usage of Visual Studio IDE such as
    WPF & SL designer, Visual Studio Guidance Automation Toolkit, Developer Documentation and Help
    System and Visual Studio Editor.
    Thanks,
    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click
    HERE to participate the survey.

  • My sound system is not working after my last updates on my imac,what shall i do to get fixed?

    Hello any body who can help me out here?
    My sound system is not working on my imac after the last updates,
    WHAT SHALL I DO FOR????

    apollos211,
    You marked this as solved, so chances are no one else will respond.
    You can try going Applications>utilities>audio MIDI set up, output tab and check to see if built in is selected.
    Also check in system preferences>sound >output and see what is selected there.
    If you look in the headphone port and see a red light (this means it is in digital mode), try taking a set off headphones and plugging them in and out several times also wiggle them around gently. There is a micro switch that sometimes gets stuck.
    Hope this helps, if still no joy try reposting so that more contributers might check it, as once checked as solved it reduces the number of people checking.
    All the best

  • Iphone 5.1 update messed up sound. Audio not working in youtube, music and video apps. Phone is not muted! nor is volume turned down

    Iphone 5.1 update messed up sound. Audio not working in youtube, music and video apps. Phone is not muted! nor is volume turned down

    Basics from the User Guide are restart, reset, restore from backup, restore as NEW.  Unless you've tried ALL of these, you're not done troubleshooting.

  • External sound system is not working

    Hi, the sound system is not working for my MacBook. It is working perfectly for my PC, however, when I plug it into my mac, every sound playing is being paused (e.g. iTunes are being paused on the second playing). What could be the issue?

    That is what I am asking. It just does not make since that the Macbooks audio out/headphone plug works on some systems and not on that particular system.
    If the system you are trying to use does not plug into the AC wall socket to get power then that could be one of the problems. But I believe you have try to tell us that is does plug into the AC wall plug and then plugs into the Macbooks headphone plug.
    Is it possible that the Jack on the sound system you are experiencing problems with is bad?
    Does the sound actually pause or just cut sound in/out similar to how a loose speaker wire might sound like?
    Have you tried using this sound system on a different computer to see if the problem still exist?

  • I cannot get any sound..it says my sound card is not working properly...how do i fix this.

    HP PC 2000 notebook, windows 7 operating system
    can't get any sound..says the sound card is not working..how can i fix this...

    You need to contact Adobe for you billing problem this is a user four not adobe customer support.
    For your Photoshop Problems this user community may be helpful. 
    Supply pertinent information for quicker answers
    The more information you supply about your situation, the better equipped other community members will be to answer. Consider including the following in your question:
    Adobe product and version number
    Operating system and version number
    The full text of any error message(s)
    What you were doing when the problem occurred
    Screenshots of the problem
    Computer hardware, such as CPU; GPU; amount of RAM; etc.

  • I have hp laptop from last 2 days sound system is not working

    hi my laptop sound system is not working i cant hear the music

    Go to the link below.Enter your Product Number as listed on Service Tag attached to bottom of notebook (may be under battery). You can also get the Product Number by pressing Fn + Esc key. After entering PN, click Next ,then choose Software & Drivers.On the next page use the dropdown to select your OS (probably Windows 7 64bit). A list will populate with drivers. Download & install the latest Audio driver.
    http://h10025.www1.hp.com/ewfrf/wc/siteHome?cc=us&​lc=en
    ```````````````````````````````````````
    If still no sound,try a hard reset, works sometimes.Disconnect all external devices first.
    1-remove power cord and battery
    2-press power button for 30 seconds
    3-reinstall only power cord for first startup.
    4-power on
    ******Clicking the Thumbs-Up button is a way to say -Thanks!.******
    **Click Accept as Solution on a Reply that solves your issue to help others**

  • HT4085 My sound effects is not working

    My sound effects is not working can help me ?

    (A) Reset iPad
    Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears
    Note: Data will not be affected.
    (B) Make sure sound is not muted.
    http://i1224.photobucket.com/albums/ee374/Diavonex/ac7f6dc314aca5d618ac2f55616be 20e_zpsa92a3ebd.jpg

  • TS1574 optic digital port can't be shut off and the sound of speakers not working! what to do?

    optic digital port can't be shut off and the sound of speakers not working! what to do?
    this happened after taking out the head-phones. Now even after pressing CMD+ALT+P+R when booting - the sound of booting appeares BUT after the desktop is ready the sound doesn't work and sound buttons show the sign "circle with crossed line"

    If there is a red light visible in the audio output port, the switch id stuck.  Insert the earphone jack a few times.  If that fails to trip the switch, try a toothpick or similar device and jiggle it inside the port.  If that fails, try a shot or two of compressed air.  If still no success, go to a repair facility.
    Ciao.

  • Siri, sounds, video, alarm not working. Need help with backing up my iPad so I can do a factory reset....need help doing that also.

    Siri,sounds,alarm, videos not working. How do I back up my iPad and how do I do a factory reset?

    Try this:
    Make sure IOS is updated to latest version
    (How to update your iOS device
    http://support.apple.com/kb/HT4623)
    Reboot device by pressing both the home button and sleep/wake (power) buttons at the same time for 10-15 seconds until the apple logo appears on the screen, then let go.
    If that doesn't work then reset the device by going to settings/general/reset/reset all settings  (or for network connection issues 'reset network settings').
    (no media or data will be deleted from the device, this will only take a minute).
    If that doesn't work then backup and then restore the device as new first (to isolate cause of the issue). Then from backup if necessary.
    How to back up and restore (iCloud and iTunes) 
    http://support.apple.com/kb/HT1766

  • Sound Recorder is not working

    My sound recorder is not working!
    I already saw all of topics about sound recording problem in hp support forum but it did not slove yet.
    Now what should i do?

    Try running audio recorder troubleshooter fixit from below link and check if your issue is resolved
    https://support.microsoft.com/en-us/mats/audiorecording

  • Sound.length is not working for Flex Mobile Project

    Hi
    i am working on Flash builder 4.6. I see sount.length is returning zero verytime. other sound object is working but sound.length is not working.
    Any one facing such type of problem for sound file in Flash builder 4.6.
    Thanks
    Brij Kishor
    Flash Builder App developer

    Thanks for the response. I am using spark TextInput components as you can see in the code above. I've used these conrtols in other apps in FB 4.5 and have had no problems so it seems like something may be different in 4.6, or it's a bug.

Maybe you are looking for