This discussion is archived
4 Replies Latest reply: Aug 3, 2010 11:51 PM by 843802 RSS

urgent Help me please

843802 Newbie
Currently Being Moderated
i've got a small app which processes audio data

i'm reading the audio data from a WAV in small chunks of about 8000 bytes, using a loop with the audioInputStream.read() method to read each chunk of data into a byte array. the app then processes the data in the byte array, then repeats the loop for each consecutive chunk of data.

i need to save the data to a new WAV file. ideally i'd like to stream the data out in a similar way as it's streaming in, so at the end of each iteration i can write the modified byte array out to the new file, and discard the data. i cannot seem to find ANY way of doing this at all.

really what i need is a version of the AudioInputStream class that allows me to write to it rather than read from it (AudioOutputStream anyone?). then i could use this to write a new WAV file chunk by chunk as i need to.

I have tried to save first chunk of byte[] that I have read in the first iteration in:
ByteArrayInputStream tt=new ByteArrayInputStream(byte[] audioBytes);

and then save this ByteArrayInputStream in audioInputStream to write it in the file
audioInputStream=AudioSystem.getAudioInputStream(tt);

but in this way I will only write the first bytes from the first iteration only since that I don't know how to read another chuck of data and concatenating it to the previous one and then when I finish write all of then to a file


please help me it is urgent
  • 1. Re: urgent Help me please
    843802 Newbie
    Currently Being Moderated
    pleaaaaaaaase anyyyyyyyyyone heeeeeeeeelp

    it is for my MSc project and I am stuck in this problem for days
  • 2. Re: urgent Help me please
    843802 Newbie
    Currently Being Moderated
    Sounds to me like you need to create an InputStream that merges many other InputStreams. I would expect it to have a method to append() an InputStream and exhaust that before processing the next InputStream. Obviously you should not allow the end-of-stream to propagate though and you would need to have a method to indicate when no more appends() are allowed and an end-of-stream can be reported.

    15 minutes work!

    P.S. Your urgency is your problem and by marking a post as urgent you are more likely to have the opposite effect to the one you desired.
  • 3. Re: urgent Help me please
    captfoss Pro
    Currently Being Moderated
    please help me it is urgent
    I guess if it's urgent then you probably don't need any help at this point, so I'll be vague since I'm probably wasting my time answering your question anyway...

    Rather than using a ByteArrayInputStream, you should use a PipedInputStream connected to a PipedOutputStream. You can use the PIS to build your AIS, and you can write directly into the POS and have it write automatically to the PIS which will write automatically to the AIS.
  • 4. Re: urgent Help me please
    843802 Newbie
    Currently Being Moderated
    [ugg boots|http://outlet-ugg-boots.com] [hair straighteners|http://chi-ghd-hair-straighteners.com] [nfl jerseys |http://cheap-nfl-jerseys-store.com] [Christian Louboutin |http://www.cheap-louboutin-shoes.com] [vibram five fingers|http://vibram-store.com] Standard vibram five fingers digital audio file format Christian Louboutin used for storing waveform nfl jerseys data; allows audio recordings to be saved with different sampling rates and bitrates; often saved in a 44.1 KHz, 16-bit, stereo format, which is the standard format used for CD audio.
    WAV is short for "Waveform Audio File Format," and is pronounced "wave;" WAV files are similar to .AIF files, but they are based on the Resource Interchange File Format (RIFF), rather than the Audio Interchange File Format (AIFF); WAV files are most ugg boots often seen on Windows-based computers, while AIF files are more common on Macintosh systems.hair straighteners

    Edited by: xiaoyu2010 on Aug 3, 2010 11:49 PM