Sponsors: Michael Fertik - Best JAVA Web hosting Company & 30% off


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-20-2010, 09:33 AM
Member
 
Join Date: Jan 2010
Posts: 7
Rep Power: 0
evan_earnest is on a distinguished road
Default Split wav file
Help me to split a wav files into pieces
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 01-20-2010, 09:46 AM
Senior Member
 
Join Date: Apr 2009
Posts: 2,111
Rep Power: 4
Tolls is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-20-2010, 06:00 PM
quad64bit's Avatar
Senior Member
 
Join Date: Jul 2009
Location: MD
Posts: 272
Rep Power: 2
quad64bit is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-20-2010, 06:11 PM
Member
 
Join Date: Jan 2010
Posts: 7
Rep Power: 0
evan_earnest is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-21-2010, 09:11 AM
Senior Member
 
Join Date: Apr 2009
Posts: 2,111
Rep Power: 4
Tolls is on a distinguished road
Default

I didn't expect mine to produce a useable wav file, it has to be said.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-21-2010, 10:34 PM
Member
 
Join Date: Aug 2009
Posts: 76
Rep Power: 0
senorbum is on a distinguished road
Default
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?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 01-22-2010, 02:16 PM
Member
 
Join Date: Jan 2010
Posts: 7
Rep Power: 0
evan_earnest is on a distinguished road
Default
No, i need a tutorial, or some sample code.

Last edited by evan_earnest; 08-30-2010 at 09:34 AM.
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 01-24-2010, 05:32 AM
quad64bit's Avatar
Senior Member
 
Join Date: Jul 2009
Location: MD
Posts: 272
Rep Power: 2
quad64bit is on a distinguished road
Default
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.
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to split a file into 2? syntrax New To Java 3 09-26-2009 06:28 AM
How to split a String using split function Java Tip java.lang 2 12-21-2008 09:27 AM
split Keyword santhoshrao New To Java 4 08-13-2008 10:28 AM
how to split a file nagaraaju New To Java 0 03-14-2008 08:45 AM
How to split a String using split function JavaBean Java Tips 0 10-04-2007 09:32 PM


Java Forums is supported by the best jsp hosting.

All times are GMT +2. The time now is 05:39 AM.



VBulletin, Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org