Audio Capture and Play - Problem. can u help?

hello all
currently i am working in a project for which i need to capture sound and play that using headphone. for this i have implemented two classes those r CaptureSound.java and PlaySound.java. most of the cases these classes r working fine but some time these do not work perfectly. when i capture i think the recording part works fine but when i am going to play that recorded file then its playing some noisy sound though this sound file is playing perfectly if i use any audio player and i have seen that the file properties r same as which is playing with my PlaySound.java. i have tried to find - what is wrong but i can't
any one can help me for this problem?
the classes r :
import java.io.*;
import javax.sound.sampled.*;
import javax.sound.sampled.Port.*;
public class CaptureSound {
     private AudioFormat audioFormat;
private TargetDataLine targetDataLine;
AudioFormat recordingFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 11025.0F, 16, 2, 4, 11025.0F, false);
     public CaptureSound(String filePath) {
          AudioFileFormat.Type fileType = null;
          File audioFile = null;
          fileType = AudioFileFormat.Type.WAVE;
          File createDirectory = new File("C:\\Capture\\test");
          if(!createDirectory.exists()) {
               createDirectory.mkdirs();
          audioFile = new File(createDirectory + "\\1.wav");
          try {
               audioFormat = recordingFormat;
          DataLine.Info dataLineInfo = new DataLine.Info(TargetDataLine.class, audioFormat);
          targetDataLine = (TargetDataLine) AudioSystem.getLine(dataLineInfo);
          targetDataLine.open(audioFormat);
          targetDataLine.start();
          AudioSystem.write(new AudioInputStream(targetDataLine), fileType, audioFile);
          } catch (Exception e) {
          e.printStackTrace();
          System.out.println("File Not Found");
import java.io.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;
import javax.sound.sampled.*;
import java.net.URL;
import java.awt.*;
import java.net.URLConnection;
public class PlaySound {
private SourceDataLine sourcedataline;
private AudioInputStream ais = null;
private AudioFormat audioformat = null;
private FloatControl gainControl;
private InputStream inputStream = null;
private boolean isPlayEnd = false;
     public PlaySound(String sourceFile) {
          try {
               ais = AudioSystem.getAudioInputStream(new File("C:\\Capture\\test\1.wav"));
               audioformat = getAudioFormat(ais);
     DataLine.Info datalineinfo = new DataLine.Info(SourceDataLine.class,audioformat);
          if (AudioSystem.isLineSupported(datalineinfo)) {
     sourcedataline = (SourceDataLine) AudioSystem.getLine(datalineinfo);
          sourcedataline.open(audioformat);
          //Copy data from the input stream to the output data line
          int framesizeinbytes = audioformat.getFrameSize();
          int bufferlengthinframes = sourcedataline.getBufferSize() / 8;
          int bufferlengthinbytes = bufferlengthinframes *framesizeinbytes;
          byte[] sounddata = new byte[bufferlengthinbytes];
          int numberofbytesread = 0;
          while ( (numberofbytesread = ais.read(sounddata, 0, sounddata.length)) != -1) {
               if (!sourcedataline.isRunning()) {
                    sourcedataline.start();
          sourcedataline.write(sounddata, 0, numberofbytesread);
          isPlayEnd = false;
          isPlayEnd = true;
          } catch (LineUnavailableException lue) {
          } catch (IOException ioe) {
          } catch (NullPointerException npe) {
          } catch (ArrayIndexOutOfBoundsException npe) {
} catch (UnsupportedAudioFileException use) {
     private AudioFormat getAudioFormat(AudioInputStream ais) throws
          UnsupportedAudioFileException, IOException {
     AudioFormat audioFormat = null;
     try {
          audioFormat = ais.getFormat();
     AudioFormat newformat = new AudioFormat(
     AudioFormat.Encoding.PCM_SIGNED,
     audioFormat.getSampleRate(),
     16, //audioFormat.getSampleSizeInBits()
     audioFormat.getChannels(),
     audioFormat.getChannels() * 2,
     audioFormat.getSampleRate(),
     false);
     AudioInputStream newStream = AudioSystem.getAudioInputStream(
          newformat, ais);
     audioFormat = newformat;
     ais = newStream;
          } catch (Exception e) {
          System.err.println("Exception: " + e.getMessage());
     return audioFormat;
///////////////////////////////////////////////////////////////////////////////////////////////////

hello all
i have captured sound with the format : AudioFormat recordingFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 11025.0F, 16, 2, 4, 11025.0F, false); now i want to play this file. for that i have created AudioInputStream and then i have created AudioFormat like:
AudioInputStream audioInputStream = AudioSystem.getAudioInputStream(new File("C://Capture//test.wav"));
AudioFormat audioFormat = audioInputStream.getFormat();after this i have got the format like :
bigEndian: boolean = true
channels: int = 1
frameRate: float = -1.0
frameSize: int = -1
sampleRate: float = 48000.0
sampleSizeInBits: int = -1
here i have found different file format and it can't play. why this is happening? can any one help for this?
thanks
bashar

Similar Messages

  • Never in all my years have I seen this cut and paste problem - can anyone help?

    Hi all... I've been using Illustrator since v5, and never before has something foxed me as much as this...
    I have a document supplied from a customer to make up into packaging artwork. To start with, the file is 19MB which set the alarm bells ringing, as it has no images etc, and is fairly simply made up (it's a milk carton sleeve). However, when you copy any single element (even a simple shape) from the file and paste to a new doc it takes literally 2 mins to copy, and a minute or so to paste it into the new doc, and then comes in with nearly 100 colours - all called 'Deleted Global Color (1-100)'. You can delete these colours by selecting remove unused colours, but even then when you save the file down (an A4 page with a simple shape coloured in black), the file is 47MB!!! (which is obviously why I can't attach it)...
    I've looked in the appearances etc and nothing seems untoward - all masks have been disabled etc. As you can imagine, the file is very hard to work with, and even to deconstuct it is proving to be an impossible feat.
    If anyone has ever seen anything like this or if anyone knows what might be causing the problems or can suggest any way of tackling it, then I can be most grateful. I can supply a file if needed, but as mentioned, they are quite large!
    Thanks in anticipation, Karl

    Thanks Tom - I'm sure this is related to my problem in regards to the file having a severe 'lame ducks' problem. However, the answer in Teri Pettit's post (http://adobe.groupbrowser.com/t177412.html) is very specific to the user's problem she is addressing, so when I followed the instructions it didn't work for my file as I couldn't locate the offending string of text, as that must have been specific to the file that was being looked at.
    My file seems much worse! The file Teri was looking at was saving down at 6-8MB - mine saves down anything between 40-80MB. Though I'm sure it is the same problem.
    I could really do with getting in touch with Teri Petitt, but I am unsure as to how I can do this, as the adobe group browser doesn't let you reply to posts.
    Many thanks for pointing me in the right direction - I feel like I'm getting closer to a solution, just hope I can get in touch with Teri...
    Cheers, Karl

  • I am having problems using mov files imported into a project. I get the message "Not rendered" in the Canvas and clip won't play. Can anyone help?

    I am having problems using mov files imported into a project. I get the message "Not rendered" in the Canvas and clip won't play. Can anyone help?

    When clips won't play without rendering in the Timeline, it usually means that the clip's specs don't match the Sequence settings.
    A .mov file could be made from any number of codecs; the QuickTime Movie designation is merely a container for video files of all kinds.  Since FCE only works with the QuickTime DV codec and the Apple Intermediate Codec (AIC) natively, if your mov files aren't one of those two, you need to convert them PRIOR to importing into your FCE project.
    -DH

  • On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?

    On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?

    I have find the codec installed on my PC do you see an undesirable one I have highlighted the one that seems strange should I uninstall how can I do this safely
    Daniel
    Codecs audio
    Type
    Nom
    Format
    Binaire
    Version
    ACM
    Codec Microsoft IMA ADPCM
    0011
    ACM
    CODEC A-Law et u-Law Microsoft CCITT G.711
    0007
    ACM
    Codec audio Microsoft GSM 6.10
    0031
    ACM
    Codec Microsoft ADPCM
    0002
    ACM
    Fraunhofer IIS MPEG Layer-3 Codec (decode only)
    0055
    ACM
    Convertisseur PCM Microsoft
    0001
    DMO
    WMAudio Decoder DMO
    0160, 0161, 0162, 0163
    WMADMOD.DLL
    6.1.7601.17514
    DMO
    WMAPro over S/PDIF DMO
    0162
    WMADMOD.DLL
    6.1.7601.17514
    DMO
    WMSpeech Decoder DMO
    000A, 000B
    WMSPDMOD.DLL
    6.1.7601.17514
    DMO
    MP3 Decoder DMO
    0055
    mp3dmod.dll
    6.1.7600.16385
    Codecs vidéo
    Type
    Nom
    Format
    Binaire
    Version
    ICM
    Microsoft RLE
    MRLE
    msrle32.dll
    6.1.7601.17514
    ICM
    Microsoft Vidéo 1
    MSVC
    msvidc32.dll
    6.1.7601.17514
    ICM
    Microsoft YUV
    UYVY
    msyuv.dll
    6.1.7601.17514
    ICM
    Codec Intel IYUV
    IYUV
    iyuv_32.dll
    6.1.7601.17514
    ICM
    Toshiba YUV Codec
    Y411
    tsbyuv.dll
    6.1.7601.17514
    ICM
    Codec Cinepak de Radius
    cvid
    iccvid.dll
    1.10.0.13
    DMO
    Mpeg4s Decoder DMO
    mp4s, MP4S, m4s2, M4S2, MP4V, mp4v, XVID, xvid, DIVX, DX50
    mp4sdecd.dll
    6.1.7600.16385
    DMO
    WMV Screen decoder DMO
    MSS1, MSS2
    wmvsdecd.dll
    6.1.7601.17514
    DMO
    WMVideo Decoder DMO
    WMV1, WMV2, WMV3, WMVA, WVC1, WMVP, WVP2
    wmvdecod.dll
    6.1.7601.18221
    DMO
    Mpeg43 Decoder DMO
    mp43, MP43
    mp43decd.dll
    6.1.7600.16385
    DMO
    Mpeg4 Decoder DMO
    MPG4, mpg4, mp42, MP42
    mpg4decd.dll
    6.1.7600.16385
    De : sarika02 
    Envoyé : 17 juin 2014 19:26
    À : Daniel Cloutier
    Objet :  On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?
    On photoshop element 12 when I open a .MTS file I have the sound with a black screen if I open a .mov it work fine I have uninstall and reinstall I still have the same problem can you help?
    created by sarika02 <https://forums.adobe.com/people/sarika02>  in Photoshop Elements - View the full discussion <https://forums.adobe.com/message/6466796#6466796>

  • Gmail on iphone was working fine until yesterday when it prompted me with the message cannot get mail user name or password for gmail is incorrect, i have tried deleting the account and re-created a new account, same problem, can anyone help?

    gmail on iphone was working fine until yesterday when it prompted me with the message "cannot get mail user name or password for gmail is incorrect", i have tried deleting the account and re-created a new account, same problem, can anyone help?

    paulcb, you're a genius, it worked, thank you so much, you don't know how much stress you have taken off my shoulders, I am constantly on my email in my iphone everyday.  Thanks a million, take care. Robert.

  • I bought a new Epson printer WR-7620 on Saturday and the Air Printer is not working. I spoke to Epson and they said it is an Apple problem, can anyone help. Thanks Peter

    I bought a new Epson printer WR-7620 on Saturday and the Air Printer is not working. I spoke to Epson and they said it is an Apple problem, can anyone help. Thanks Peter

    Peter,
    deggie gave you that link so you'd know that airprint is a reduced-options print system, designed for mobile devices (not Macs), and you need to use the specific airprint driver on the Mac when adding the printer if you want Airprint, no-options printing. Otherwise, select the "non-airprint" driver when you add the printer.
    It may be helpful to Reset the Printing System to get OS X to find the right driver.
    Mac OS X: How to reset the printing system - Apple Support
    (And "not working" doesn't help us to help you - please give more detail next time)

  • HT4623 When I download an app from the App Store, it jus shows "waiting" and doesn't download as it used to do earlier... Then after a day or 2 the app is downloaded... I dunno wuz d problem, can someone help me :(

    When I download an app from the App Store, it jus shows "waiting" and doesn't download as it used to do earlier... Then after a day or 2 the app is downloaded... I dunno wuz d problem, can someone help me

    Make sure that you do not have a stalled download in iTunes - a song or podcast .... if you have a download in there that did not finish, complete that one first. Only one thing can download at a time on the iPad so that could be what is causing the problem.
    If that doesn't work - sign out of your account, restart the iPad and then sign in again.
    Settings>Store>Apple ID. Tap your ID and sign out. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button.
    Go back to Settings>Store>Sign in and then try to update again. Tap one waiting icon only if necessary to start the download stream.
    You can also try deleting the waiting icons - tap and hold down on an icon until it wiggles - the tap the X on the icon to delete it. Then try to download again.
    You can try resetting all settings. Settings>General>Reset>Reset All Settings. You will have to enter all of your app preferences and device settings again.

  • HT201317 Hi, i bought new pc and install win 7 , icloud . I turned on but doesn't have sync with photo stream to my pc. In the old pc i had no problem , can you help me?

    Hi, i bought new pc and install win 7 , icloud . I turned on but doesn't have sync with photo stream to my pc. In the old pc i had no problem , can you help me?

    I installed the new version of i cloud and its work ok

  • I was just listening to my iPod nano and it stopped working. I plugged it into the computer to sync it and it won't sync. The little light don't come on on my nano. I've turned it off and on, pushed the play/pause and nothing. Can anyone help me out here?

    I was just listening to my iPod shuffle and it stopped working. I plugged it into the computer to sync it and it won't sync. The little light don't come on on my nano. I've turned it off and on, pushed the play/pause and nothing. Can anyone help me out here?

    How long have you left the iPod to charge? It can take up to 30 minutes before it shows any signs of life. Did you use the instructions in this article to properly reset the Shuffle?
    Resetting iPod shuffle
    B-rock

  • PCI Express X-FI Xtreme Audio - Mic and mixer problems

    6PCI Express X-FI Xtreme Audio - Mic and mixer problems' Trouble started two days ago when I updated to the latest X-FI drivers. Now I have no mixer and I can't figure out how to get my mic to work. The only thing that has changed is the updating of drivers. I am using senheiser headphones with mic for use on ventrillo. In the old set up I could go into the mixer and tell the software that the Line-In was a mic and it would work perfectly. Now I can't get the mic to work at all since there is no creative mixer. The windows mixer doesn't allow you to do anything worth wild.
    I don't have the old software so I can't go back to the old setup. I am using Vista 64. What the heck am I doing wrong? Why won't the software now recognize that I am plugging in a mic!?!?!?
    BAH!!!!
    PLEASE HELP!

    Doesn't Vista have some sort of automatic checkpointing feature that gives you a way to back up to a point before you updated the drivers?
    -Dave
    ?[email protected]

  • HT5922 I do not see the air play icon, can someone help

    I do not see the air play icon, can someone help?

    I have the same problem on the Iphone 4S and Ipad 2, after upgrading to IOS7, someone solved the problem?

  • Audio capture and converting the audio data to .wav file

    hi,
    i am new to applet and javax.sound and trying to build online recorder SDK in applet. I could captured the audio data and play the sound from microphone and also store the audio data to .wav file successfully. But when try to play that file from Window Media Player, i got the message "Windows Media Player cannot play the file. The file is either corrupt or the Player does not support the format you are trying to play." I have tried it all in different way but it's not working for last 5-6 days. Is there anyone who could help me , my work is stocked b'coz of this.
    Thanks

    this is the thread in which i am storing the audio data from audio stream to .wav file
    class CaptureThread extends Thread{
                          public void run(){
                                      AudioFileFormat.Type fileType = AudioFileFormat.Type.WAVE;
                                      File audioFile = new File("junk.wav");
                                       try{
                                       final AudioFormat format = getFormat();
                                             line.open(format);
                                          line.start();
                                             AudioSystem.write(
                                              new AudioInputStream(line),
                                              fileType,audioFile);
                                        }catch (Exception e){
                                             e.printStackTrace();
                                          }//end catch
                                     }//end run
                        }//end inner class CaptureThread

  • Portal crashes and intermittant problems..urgent help needed.

    Portal Runtime Error
    An exception occurred while processing a request for :
    iView : pcd:portal_content/administrator/super_admin/super_admin_role/com.sap.portal.system_administration/com.sap.portal.system_admin_ws/com.sap.portal.themes/com.sap.portal.theme_editor/com.sap.portal.styleeditor
    Component Name : null
    Page could not create the iView.
    I briefly describe the system setup.
    sptltrex = central instance
    sptl1 = app1
    sptl2 = app2
    sptldb = database instance.
    sptltrex built with virtual name ourworld-0
    sptldb built with virtual name ourworld-db
    System setup with Oracle dataguard feature, so ourworld-0 and ourworld-db can fail over to disaster recovery systems sptldr and sptldevdb at another site. Although we installed using the SAPINST_USE_HOSTNAME for SCS/central instance the visual administrator and message server still pick
    up sptltrex. We though setting the SAPLOCALHOSTFULL to ourworld-0.sap.serco.com had fixed this issue, but this generated many iview errors that
    could not be found. When the SAPLOCALHOSTFULL was backed out everything
    began to display again. Although there is still intermittant errors of screens not acting as required.
    message server output
    http://sptltrex:8100/msgserver/text/logon
    version 1.0
    J2EE1666800
    J2EE sptl2.sap.serco.com 50000 LB=2
    J2EES sptl2.sap.serco.com 50001 LB=2
    P4 sptl2.sap.serco.com 50004 LB=2
    P4S sptl2.sap.serco.com 50006 LB=2
    J2EE13975600
    J2EE sptltrex.sap.serco.com 50100 LB=2
    J2EES sptltrex.sap.serco.com 50101 LB=2
    P4 sptltrex.sap.serco.com 50104 LB=2
    P4S sptltrex.sap.serco.com 50106 LB=2
    P4HTTP sptltrex.sap.serco.com 50105 LB=2
    JC_ourworld-0_PP1_01
    SDM ourworld-0 50118
    We have had numerous OSS messages for various continuing problems on the system. Today we have an complete up-to-date as possible patched system. SPS 9 with all the latest sub patches also. We have installed AIX TL 05 with service pack 2 so oslevel -s shows 5300-05-02 + a related db APAR, the IBM java JDK is SRS06. Full earlywatch go-live check parameters and options have been completed.
    But still we have problems.
    can anybody help......it's urgent....
    thanks
    saurabh

    hi!!
    We have a 3-server portal installation with one j2ee dispatcher and two
    j2ee servers on each server.
    We are experiencing major issues with the consistency or
    synchronisation between the servers and availability of portal applications.
    For example the themes editor is only available on sptl1 server0, so if
    you are lucky and log onto that server you can use this application.
    THIS IS ONE OF MANY examples of this type of issue. How can we ensure
    that the landscape is consistent? Screen shots from sptl1 showing the
    themes application being available and not available.
    A simple look at the filesystem reveals the following, and only the
    themes editor directory and contents are on sptl1.
    JSPM deployment finished successfully.
    sptl1:root:/ > find / -name "com.sap.portal.themes.editor" -print
    /usr/sap/PP1/J00/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/web-inf/portal/portalapps/com.sap.portal.themes.editor
    /usr/sap/PP1/J00/j2ee/cluster/server0/apps/sap.com/irj/servlet_jsp/irj/root/portalapps/com.sap.portal.themes.editor
    sptl1:root:/ > ssh sptl2 find / -name "com.sap.portal.themes.editor" -
    print
    sptl1:root:/ > ssh sptltrex find / -
    name "com.sap.portal.themes.editor" -pri>
    thanks
    saurabh

  • HT1351 the devices is not popping up in our itunes. is anyone else having this problem. can  you help me if you have

    the devices is not popping up in our itunes. is anyone else having this problem. can  you help me if you have the same problem

    Try rebooting the computer and restarting the device.
    Try a different cable.
    In rare cases fluff in the connector port can prevent proper contact with the connectors used to transfer data. An air duster or thin piece of card or plastic can be used to tease out debris if that is the problem.
    tt2

  • Hello, my ipod nano 6th generation is with the black screen, now restored, already pressed for 8 seconds and decrease volume botação start and not resolved, can someone help?

    Hello, my ipod nano 6th generation is with the black screen, now restored, already pressed for 8 seconds and decrease volume botação start and not resolved, can someone help?

    I am currently having this same problem. This nano lasted me less than 2 years.

Maybe you are looking for

  • Wired vs wireless Mighty Mouse tracking

    Has anyone else found that the wireless Mighty Mouse has different tracking or acceleration compared to the wired version? It feels as if it has some acceleration applied that I can't dial out using USB Overdrive, or that it has a slight dead zone or

  • Admin server looses managed servers

    we hava 2 clusters of 2 wls 6.1 sp2 instances each on 2 hpux 11 boxes. The wls console shows all the instances when booted up. But suddenly, after a period( and this random without a pattern), the admin seems to loose some of the managed servers. The

  • Workflow Jobs in SAP Identity Management

    Hello Experts, We have SAP Idm 7.1, Novell eDirectory and GRC AC 5.3 Installed successfully. Now, I have to create 2 workflow jobs in SAP IdM 7.1 for Novell eDirectory. 1- One job to query the Novell IDM Vault for any new identities and populate NW I

  • Problems with message delay property

    Hello, I am enqueueing messages in an oracle queue and i am specifying a message property delay. So, when the message is enqueued it stays in the 'WAIT' state. However, expired the delay the message does not come to the READY state (as I thought it w

  • Error at config stage of installation - files not exising

    Hi. Does anyone know anything about these errors? They occur on stage 6 of the installation. Before that, everything was going as planed according to the beginners guide. Thanks