Playing a WAVE file after making a phone call.

Hi everyone..
I'm trying to play a wav file after making a phone call. I was able to make the call. But I get an exception when i try to paly a wav file..
Can any one tell me where I've gone wrong..
This is the code which plays the audio file..(I downloaded it by the way.. and it's working fine when used as a seperate program)
import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.DataLine;
import javax.sound.sampled.FloatControl;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.UnsupportedAudioFileException;
public class PlayWave extends Thread {
     private String filename;
     private Position curPosition;
//30000000(7324.21 kb)
     private final int EXTERNAL_BUFFER_SIZE = 524288; // 128Kb
     enum Position {
          LEFT, RIGHT, NORMAL
     public PlayWave(String wavfile) {
          filename = wavfile;
          curPosition = Position.NORMAL;
     public PlayWave(String wavfile, Position p) {
          filename = wavfile;
          curPosition = p;
     public void run() {
          File soundFile = new File(filename);
          if (!soundFile.exists()) {
               System.err.println("Wave file not found: " + filename);
               return;
          AudioInputStream audioInputStream = null;
          try {
               audioInputStream = AudioSystem.getAudioInputStream(soundFile);
          } catch (UnsupportedAudioFileException e1) {
               e1.printStackTrace();
               return;
          } catch (IOException e1) {
               e1.printStackTrace();
               return;
          AudioFormat format = audioInputStream.getFormat();
          SourceDataLine auline = null;
          DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);
          try {
               auline = (SourceDataLine) AudioSystem.getLine(info);
               auline.open(format);
          } catch (LineUnavailableException e) {
               e.printStackTrace();
               return;
          } catch (Exception e) {
               e.printStackTrace();
               return;
          if (auline.isControlSupported(FloatControl.Type.PAN)) {
     FloatControl pan = (FloatControl) auline.getControl(FloatControl.Type.PAN);
               if (curPosition == Position.RIGHT)
                    pan.setValue(1.0f);
               else if (curPosition == Position.LEFT)
                    pan.setValue(-1.0f);
          auline.start();
          int nBytesRead = 0;
          byte[] abData = new byte[EXTERNAL_BUFFER_SIZE];
          try {
               while (nBytesRead != -1) {
          nBytesRead = audioInputStream.read(abData, 0, abData.length);
          if (nBytesRead >= 0)
               auline.write(abData, 0, nBytesRead);
          } catch (IOException e) {
               e.printStackTrace();
               return;
          } finally {
               auline.drain();
               auline.close();
     }I inserted
new PlayWave("greeting.wav").start();In to a method an called this method in the program where i send commands to the modem.
These are my modem commands
send("ATZ");
    expect("OK");
//Enable voice mode
    send("AT+FCLASS=8");
    expect("OK");
//Dial the number
    send("ATDT"+number);
    expect("OK");
//Choose encoding method //This is the default
    send("AT+VSM=140,8000,0,0");
    expect("OK");
// start sending audio data
    send("AT+VTX");
    expect("OK");
PlayAudio();
send("ATH");The size of my audio file is 100 kb.I'm using a 56 K intel externel voice modem connected to a serial port.I wonder if it's because the buffer is too big. If anyone tried this and succeded please correct me.
Thankyou in advance
goodnews

Hi goodnews!
Did I understand well? Can You record the speech? This is what I want!
Can you help me and send me sample code?
This would be a big help for me!
Thank You!
rflair

Similar Messages

  • After making a phone call, I went to make another and all my contacts were gone. How can i get them back?

    I made one phone call this morning and after hanging up i went to the contacts library and all my contacts were gone. I have unfortunately not got a backup (this isn't my phone its for a friend) and so I have no backup of my contacts. I have already tried importing contacts from the sim but only a very small few contacts are on the sim so im still missing over 90% of my contacts. How can i fix this? This phone is an iphone 4s running ios 7

    nope just set it to do so for future purposes but i have no recorded backup of any contacts

  • IPhone is frozen after making a phone call. Does not respond to any command. Does not turn off.

    Also iTunes freezes when iPhone is connected to laptop.

    Press and hold down the home button and the power button at the top of the phone both at the same time until you see the apple logo appear - this is a reset of the phone and is a good fix for most problems.  Its a mini computer and every now and then it needs a reset. - hope this helps - let me know

  • Playing a wav file (byte array) using JMF

    Hi,
    I want to play a wav file in form of a byte array using JMF. I have 2 classes, MyDataSource and MyPullBufferStream. MyDataSource class is inherited from PullStreamDataSource, and MyPullBufferStream is derived from PullBufferStream. When I run the following piece of code, I got an error saying "EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x7c9108b2, pid=3800, tid=1111". Any idea what might be the problem? Thanks.
    File file = new File(filename);
    byte[] data = FileUtils.readFileToByteArray(file);
    MyDataSource ds = new MyDataSource(data);
    ds.connect();
    try
        player = Manager.createPlayer(ds);
    catch (NoPlayerException e)
        e.printStackTrace();
    if (player != null)
         this.filename = filename;
         JMFrame jmframe = new JMFrame(player, filename);
        desktop.add(jmframe);
    import java.io.IOException;
    import javax.media.Time;
    import javax.media.protocol.PullBufferDataSource;
    import javax.media.protocol.PullBufferStream;
    public class MyDataSource extends PullBufferDataSource
        protected Object[] controls = new Object[0];
        protected boolean started = false;
        protected String contentType = "raw";
        protected boolean connected = false;
        protected Time duration = DURATION_UNKNOWN;
        protected PullBufferStream[] streams = null;
        protected PullBufferStream stream = null;
        protected final byte[] data;
        public MyDataSource(final byte[] data)
            this.data = data;
        public String getContentType()
            if (!connected)
                System.err.println("Error: DataSource not connected");
                return null;
            return contentType;
        public void connect() throws IOException
            if (connected)
                return;
            stream = new MyPullBufferStream(data);
            streams = new MyPullBufferStream[1];
            streams[0] = this.stream;
            connected = true;
        public void disconnect()
            try
                if (started)
                    stop();
            catch (IOException e)
            connected = false;
        public void start() throws IOException
            // we need to throw error if connect() has not been called
            if (!connected)
                throw new java.lang.Error(
                        "DataSource must be connected before it can be started");
            if (started)
                return;
            started = true;
        public void stop() throws IOException
            if (!connected || !started)
                return;
            started = false;
        public Object[] getControls()
            return controls;
        public Object getControl(String controlType)
            try
                Class cls = Class.forName(controlType);
                Object cs[] = getControls();
                for (int i = 0; i < cs.length; i++)
                    if (cls.isInstance(cs))
    return cs[i];
    return null;
    catch (Exception e)
    // no such controlType or such control
    return null;
    public Time getDuration()
    return duration;
    public PullBufferStream[] getStreams()
    if (streams == null)
    streams = new MyPullBufferStream[1];
    stream = streams[0] = new MyPullBufferStream(data);
    return streams;
    import java.io.ByteArrayInputStream;
    import java.io.IOException;
    import javax.media.Buffer;
    import javax.media.Control;
    import javax.media.Format;
    import javax.media.format.AudioFormat;
    import javax.media.protocol.ContentDescriptor;
    import javax.media.protocol.PullBufferStream;
    public class MyPullBufferStream implements PullBufferStream
    private static final int BLOCK_SIZE = 500;
    protected final ContentDescriptor cd = new ContentDescriptor(ContentDescriptor.RAW);
    protected AudioFormat audioFormat = new AudioFormat(AudioFormat.GSM_MS, 8000.0, 8, 1,
    Format.NOT_SPECIFIED, AudioFormat.SIGNED, 8, Format.NOT_SPECIFIED,
    Format.byteArray);
    private int seqNo = 0;
    private final byte[] data;
    private final ByteArrayInputStream bais;
    protected Control[] controls = new Control[0];
    public MyPullBufferStream(final byte[] data)
    this.data = data;
    bais = new ByteArrayInputStream(data);
    public Format getFormat()
    return audioFormat;
    public void read(Buffer buffer) throws IOException
    synchronized (this)
    Object outdata = buffer.getData();
    if (outdata == null || !(outdata.getClass() == Format.byteArray)
    || ((byte[]) outdata).length < BLOCK_SIZE)
    outdata = new byte[BLOCK_SIZE];
    buffer.setData(outdata);
    byte[] data = (byte[])buffer.getData();
    int bytes = bais.read(data);
    buffer.setData(data);
    buffer.setFormat(audioFormat);
    buffer.setTimeStamp(System.currentTimeMillis());
    buffer.setSequenceNumber(seqNo);
    buffer.setLength(BLOCK_SIZE);
    buffer.setFlags(0);
    buffer.setHeader(null);
    seqNo++;
    public boolean willReadBlock()
    return bais.available() > 0;
    public boolean endOfStream()
    return willReadBlock();
    public ContentDescriptor getContentDescriptor()
    return cd;
    public long getContentLength()
    return (long)data.length;
    public Object getControl(String controlType)
    try
    Class cls = Class.forName(controlType);
    Object cs[] = getControls();
    for (int i = 0; i < cs.length; i++)
    if (cls.isInstance(cs[i]))
    return cs[i];
    return null;
    catch (Exception e)
    // no such controlType or such control
    return null;
    public Object[] getControls()
    return controls;

    Here's some additional information. After making the following changes to MyPullBufferStream class, I can play a wav file with gsm-ms encoding with one issue: the wav file is played many times faster.
    protected AudioFormat audioFormat = new AudioFormat(AudioFormat.GSM, 8000.0, 8, 1,
                Format.NOT_SPECIFIED, AudioFormat.SIGNED, 8, Format.NOT_SPECIFIED,
                Format.byteArray);
    // put the entire byte array into the buffer in one shot instead of
    // giving a portion of it multiple times
    public void read(Buffer buffer) throws IOException
            synchronized (this)
                Object outdata = buffer.getData();
                if (outdata == null || !(outdata.getClass() == Format.byteArray)
                        || ((byte[]) outdata).length < BLOCK_SIZE)
                    outdata = new byte[BLOCK_SIZE];
                    buffer.setData(outdata);
                buffer.setLength(this.data.length);
                buffer.setOffset(0);
                buffer.setFormat(audioFormat);
                buffer.setData(this.data);
                seqNo++;
        }

  • Playing a .wav file from email attachment

    I am trying to play a .wav file that is attached to an email, and i get "The document conversion failed". Am I missing something? What do I need to do to be able to play .wav files that are sent to me via email?

    I have the same request.
    We have a new Panasonic phone system that sends out .wav voicemail files.
    Our company's Curve's play the wav fine.
    Our company's BOLDs ... DO NOT.

  • How do I play the .wav file google mail sends me on my Iphone 5?

    I have cable phone service that sends out a .wav file of any voicemails I recieve to my e-mail account.  I use google mail on my Iphone, and cannot play the .wav file that is attached to that e-mail.  When I click on the "audio message box", it brings up a circle containing a south-west facing arrow which has a slash through it. 

    I have the latest software (6.1.4) and I can play the attachment if I go through "Mail" instead of "GMail".  I am still not certain why I have a widget called "Mail". 
    Inside the "Mail" app, there are it's own Inbox, VIP, Flagged, etc which are all in color.  Further down the list is my GMail boxes and sub-boxes.  They are all grayed out, but still funtional.
    Do I have something set up wrong causing me to be unable to play the .wav files that come to me through gmail?

  • How to play a wave file through the DAQ board?

    Hi there,
    we want to play a wave file that is saved on the harddrive via the DAQ board. Means we want to connect a amp to the analog output of the DAQ to amplify the sound and play it through a speaker.
    We couldn't find any VI that does that. Can anybody tell us how to play a wave file, or perhaps even send us a VI that can do that?
    Thanks a lot for your help
    Martin - Physical Optics Corporation

    Hi Martin,
    The only example that I could find on how to do this was using our
    older Traditional DAQ drivers version 6.9.3.  If you're using Traditional
    DAQ drivers, the vi can be found here. 
    The example reads a 8-bit mono .wav file (an example .wav file is included in the .zip file) and writes it to the analog out of your DAQ card.  I've updated the
    example to work with our newer DAQmx drivers and attached it here.  
    I hope this helps,
    Paul C.
    Message Edited by Paul C. on 08-14-2007 05:47 PM
    Attachments:
    daqmx_wav_file_to_ao_output.zip ‏27 KB

  • Why cant I play embeded wave files in firefox but I can in explorer?

    I just embedded a wave file (Godsmack Voodoo) for my website & saved it but when I goto run teh intro no sound, But explorer plays it no problems? What is wrong with Firefox 9.01 & playing the embedded sounds?

    Can you post a link to a public page?
    Which code are you using to play that WAV file?

  • Why can't I open/play my movie files after I have downloaded them from my camera? Pictures open fine.

    Why can't I open/play my movie files after I have downloaded them from my camera? Pictures open fine.

    What system and iPhoto version are you running and do you have Qjuicktime Player 7 installed. It would be in the Applications or Applications/Utilities folder.
    OT

  • Subsequent play of WAV files from HTTP

    Hi,
    I have to subsequently play many WAV files from HTTP in a nokia series 60 emulator.
    Everything is ok for the first two files, but at the third I catch an exception:
    "java.io.IOException: exceeded the configured maximum number of connections"
    I tried two ways to load the files from HTTP:
    Manager.CreatePlayer(InputStream...)
    Manager.CreatePlayer("http:\\...")
    Below there is the code of the two methods I use. Please note that I try in every way to close the connection before open a new one!!!
    public void Method_1(String src, String type){
    int iLen=0;
    is = null;
    httpCon = null;
    byte[] bBuf;
    try {
    if (p != null) {
    if (p.getState() == Player.STARTED) {
    p.stop();
    p.removePlayerListener(this);
    p.deallocate();
    p.close();
    p=null;
    if (is!=null){
    is.close();
    is=null;
    if (httpCon!=null){
    httpCon.close();
    httpCon=null;
    httpCon = (HttpConnection) Connector.open(src);
    if (httpCon.getResponseCode() != HttpConnection.HTTP_OK) {
    System.out.println("Bad response code");
    return;
    System.out.println("Connection OK! (audio)");
    iLen = (int) httpCon.getLength();
    System.out.println("audio file length : " + iLen);
    is = httpCon.openInputStream();
    p = Manager.createPlayer(is, type);
    p.addPlayerListener(this);
    p.setLoopCount(1);
    p.prefetch();
    p.start();
    vc = (VolumeControl)p.getControl("VolumeControl");
    catch (MediaException ex) {
    ex.printStackTrace();
    catch (IOException ex) {
    ex.printStackTrace();
    public void Method_2(String src){
    try {
    if (p!=null){
    if (p.getState() == Player.STARTED)
    p.stop();
    p.deallocate();
    p.close();
    p=null;
    p = Manager.createPlayer(src);
    p.addPlayerListener(this);
    p.setLoopCount(1);
    p.start();
    vc = (VolumeControl)p.getControl("VolumeControl");
    catch (java.io.IOException e) {
    e.printStackTrace();
    catch (MediaException e) {
    e.printStackTrace();

    My question is:
    how can I load (from a HTTP server) and play more than two WAV files without crashing?
    Do I have to close the connection in a better way in order to re-open it without problems (and more than two times)?
    It is simply an emulator bug?
    Thanks.

  • Play a wav file once

    how do I play a wav file just once using the play sound
    file.vi. i keep getting it to repeat over and over
    thanks

    First may I recommend some reading here. This is not meant to be cocky just to help you.  
    Getting Started with NI LabVIEW Student Training
    LabVIEW101
    Second I have included sort of template. Notice the wire that ends in the while loop. This will ensure that the wav is played before the loop starts.
    Good luck with your Labview labwork
    Besides which, my opinion is that Express VIs Carthage must be destroyed deleted
    (Sorry no Labview "brag list" so far)
    Attachments:
    play wav file[2].vi ‏9 KB

  • How to play a wav file to LINE_OUT with javax.sound.sampled

    Hello all,
    I need to play a wav file to LINE_OUT port, but not to the SPEAKER. I am trying to do this under window NT. For some reason I get false for isLineSupported(Port.Info.LINE_OUT). I am new to javax.sound so I might be doing something wrong. Here is the code that I am using to iterate through all availible mixers and check if LINE_OUT is supported by any of them:
    Mixer.Info[] mixers = AudioSystem.getMixerInfo();
    for(int i = 0; i < mixers.length; i++){
    Mixer mixer = AudioSystem.getMixer(mixers);
    if (mixer.isLineSupported(Port.Info.LINE_OUT)) {
    System.out.println("the port is supported");
    try {
    Port line = (Port) AudioSystem.getLine(
    Port.Info.LINE_OUT);
    catch(Exception ex){
    ex.printStackTrace();
    else{
    System.out.println("the port is not supported");
    Please help

    The new bugID of the request to implement Ports is: 4558938.
    (If you voted for the old bug id: 4504642, be sure to change your votes to this new bug report since the old one was closed as a duplicate of the new one.)

  • Play a .wav file fractional

    hi,
    i´m looking for a solution to play a .wav file.
    the special what i need is, that i want to jump to concrete points on the timeline.
    or can i seperate the timeline of a .wav file?
    martin

    Hi Martin
    this could help you starting. For the case you can't open LV 8.2- VIs, i attach the BD- picture.
    greets, Dave
    Message Edited by daveTW on 06-14-2007 10:26 AM
    Greets, Dave
    Attachments:
    play sound part_FP.png ‏10 KB
    play sound part.vi ‏50 KB

  • Need Help playing a wav file on PDA

    Does anyone have a SIMPLE example of playing a wav file on a PDA using LabView PDA. The only working example I can find from NI "Advance Sound Example for LabVIEW PDA for Pocket PC" is a jumbled of confusing functionality. I'm mainly looking for a simple "play" example, but a simple "record" example would be helpful also.
    Thanks - Bruce

    Hello,
    Well, I looked through the example code I tried to break it down to the point where you could create a simple Play VI. Unfortunately, I don't have the PDA target, so I'm uncertain if the little example that I have attached will run or not. If not, I also took a screen shot so you can see what VIs I used. I'm pretty sure I only used VI's that I found on the example itself.
    Good luck.
    Attachments:
    Play_Wav_PDA.vi ‏55 KB
    Play_Wav_PDA.bmp ‏1029 KB

  • Screen stays on when making a phone call

    I am wondering if there is a setting for making the screen go black when making a phone call. I have done some research and it seems there should be a proximity sensor that makes the screen turn off when the sensor is activated. If there is no setting for this sensor then I have to believe that the phone is defective and must be returned - I just wanted to be sure that a setting doesn't exist to correct the problem before doing that. It is a Droid X2. Thank you in advance for any help provided! 

    Yes, there is a small "proximity sensor" in the upper left corner next to the ear piece.  When you "cover" it after making a call, the screen should go blank. If it is staying on when you cover that (with your face/ear or even your hand) if sounds like it is defective. There are no Settings that I am aware of that makes the screen stay "always on".  At least on my Droid X.
    Have you tried running in SAFE MODE just to make sure it's not some 3rd party app causing the problem?
    - Power Off
    - Press & hold the MENU button (far left button)
    - Power up phone, but continue to HOLD the MENU button for like 1-2 mins.
    Phone should come up saying "SAFE MODE" in lower left side.
    Test you issue.
    To get out of SAFE MODE, just power off & on as usual.

Maybe you are looking for

  • Unable to delete a podcast from my ipod touch

    I deleted the problem podcast from itunes and then unscribed from that podcast but when I sync my ipod this podcast pops up again in my ipod. I did a soft reset to no avail. Thank You John

  • Issue HR_KR_XSTRING_TO_STRING

    Hi Guys, we have problem to upload a flat file using the function HR_KR_XSTRING_TO_STRING. I think this only support 10000(field in_xstring in characters?). Because it only upload a part of the flat file. Please I f you can help me with this. Regards

  • Hpvpldrv09

    HI, I have a problem which seems to be unknown here. After installing a Officejet 8600 pro on an XP Pro SP3 maschine it is not possible to print or even look at the printer settings from other software. OO 3.3 crashes when printing and the document n

  • SAP PI client change

    how to change the default client for PI template based configuration in SAP PI 7.0

  • Itunes showing up in german

    itunes store and ministore both are showing headers in german. i thought it was just a bug with the version so i downloaded the newest version and now not only are the headers in german, but it seems the music is showing up for germany (not american