Results 1 to 8 of 8

Thread: Split wav file

  1. #1
    evan_earnest is offline Member
    Join Date
    Jan 2010
    Posts
    8
    Rep Power
    0

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    Read that data in up to wherever you want to stop, writing it out to a new file. Then continue reading to where you want the next bit to stop, writing that out to a file. Repeat to fade.

  3. #3
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Do you want the wav chunks you create (by splitting) to be playable outside of your program? Doesn't a wav file have a header? In which case, you'd need to repackage the data into new files complete with appropriate headers... Tolls method will def. split the file, but the resulting files might not be playable without re-assembly.

  4. #4
    evan_earnest is offline Member
    Join Date
    Jan 2010
    Posts
    8
    Rep Power
    0

    Default

    I have a wave file which is record from the program that i have already created. The file obtained from my program is playing in a player perfectly. I want to split this wav file into two. How can i split this file into two wav files. Please explain me this through a sample code.. thanks
    Last edited by evan_earnest; 01-21-2010 at 05:54 AM.

  5. #5
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,086
    Rep Power
    20

    Default

    :)
    I didn't expect mine to produce a useable wav file, it has to be said.

  6. #6
    senorbum is offline Member
    Join Date
    Aug 2009
    Posts
    76
    Rep Power
    0

    Default

    Quote Originally Posted by evan_earnest View Post
    Please explain me this through a sample code.. thanks
    So you want somebody else to do it for you for free?

  7. #7
    evan_earnest is offline Member
    Join Date
    Jan 2010
    Posts
    8
    Rep Power
    0

    Default

    No, i need a tutorial, or some sample code.
    Last edited by evan_earnest; 08-30-2010 at 09:34 AM.

  8. #8
    quad64bit's Avatar
    quad64bit is offline Moderator
    Join Date
    Jul 2009
    Location
    VA
    Posts
    1,323
    Rep Power
    7

    Default

    Java Code:
    private void move(File f, File dest) {
            try {
                loading = "Moving: " + f.getName();
                File tmp = new File(dest.getPath() + System.getProperty("file.separator") + f.getName());
                RandomAccessFile out = new RandomAccessFile(tmp, "rw");
                RandomAccessFile in = new RandomAccessFile(f, "rw");
                byte[] buf = new byte[8182];
                int read = 0;
                while (true) {
                    read = in.read(buf);
                    if (read == -1) {
                        break;
                    }
                    out.write(buf, 0, read);
                }
                out.close();
                in.close();
            } catch (FileNotFoundException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            } catch (IOException ex) {
                Logger.getLogger(Main.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
    Ok, so this is a method I wrote some years ago for reading a file from one place and writing it to another. It would be trivial to modify this to write only half a file and then write the second half to another file.

Similar Threads

  1. How to split a file into 2?
    By syntrax in forum New To Java
    Replies: 3
    Last Post: 09-26-2009, 06:28 AM
  2. How to split a String using split function
    By Java Tip in forum java.lang
    Replies: 4
    Last Post: 04-17-2009, 08:27 PM
  3. split Keyword
    By santhoshrao in forum New To Java
    Replies: 4
    Last Post: 08-13-2008, 10:28 AM
  4. how to split a file
    By nagaraaju in forum New To Java
    Replies: 0
    Last Post: 03-14-2008, 08:45 AM
  5. How to split a String using split function
    By JavaBean in forum Java Tip
    Replies: 0
    Last Post: 10-04-2007, 09:32 PM

Posting Permissions

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