Results 1 to 3 of 3
  1. #1
    phil128 is offline Member
    Join Date
    Sep 2008
    Posts
    40
    Rep Power
    0

    Default Handling multiple WAV files and saving them into ONE

    Helllo. Does anyone know if its possible to handle multiple WAV files and save them into one single WAV file.

    I.e:

    Combined = wav1 + wav2 + wav3 + wav4 etc etc

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    I assume that you've Googled about the WAV file format and understand its structure, including this article:

    WAVE File Format

    and are using this information in your program, correct?

  3. #3
    phil128 is offline Member
    Join Date
    Sep 2008
    Posts
    40
    Rep Power
    0

    Default

    I read into the wave file format the other day. I understand about having to correct the headers etc.

    I seen this code one a website:

    import java.io.File;
    import java.io.IOException;
    import java.io.SequenceInputStream;
    import javax.sound.sampled.AudioFileFormat;
    import javax.sound.sampled.AudioInputStream;
    import javax.sound.sampled.AudioSystem;

    public class WavAppender {
    public static void main(String[] args) {
    String wavFile1 = "D:\\wav1.wav";
    String wavFile2 = "D:\\wav2.wav";

    try {
    AudioInputStream clip1 = AudioSystem.getAudioInputStream(new File(wavFile1));
    AudioInputStream clip2 = AudioSystem.getAudioInputStream(new File(wavFile2));

    AudioInputStream appendedFiles =
    new AudioInputStream(
    new SequenceInputStream(clip1, clip2),
    clip1.getFormat(),
    clip1.getFrameLength() + clip2.getFrameLength());

    AudioSystem.write(appendedFiles,
    AudioFileFormat.Type.WAVE,
    new File("D:\\wavAppended.wav"));
    } catch (Exception e) {
    e.printStackTrace();
    }
    }
    }


    Now I understand how this joins two clips together, but I'm not too sure how/if I can alter this code to join 2 or more wave files.

    Thanks for your help

Similar Threads

  1. regarding saving files or objects in database
    By sandeepsai39 in forum New To Java
    Replies: 10
    Last Post: 08-28-2010, 06:09 AM
  2. Issue with saving multiple times to a variable
    By sidd0123 in forum New To Java
    Replies: 3
    Last Post: 06-06-2010, 02:02 AM
  3. Compiling Multiple Files
    By Chasingxsuns in forum New To Java
    Replies: 4
    Last Post: 02-12-2010, 01:22 PM
  4. Replies: 0
    Last Post: 02-26-2009, 03:13 AM
  5. multiple class files
    By nemesys571 in forum Eclipse
    Replies: 0
    Last Post: 06-26-2008, 01:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •