-
December 18th, 2006, 10:49 AM
#1
How to append 2 wav file
Hi All,
I'm creating a midlet using j2me. I need to combine 2 wave file and save the newly created sound file on the phone. How do I go about combining (append, one after the other) 2 existing sound file?
Any suggestions?
Thanks
Last edited by bubblestar; December 18th, 2006 at 10:53 AM.
-
January 4th, 2007, 03:37 AM
#2
Re: How to append 2 wav file
So, is there any1 who can help?
Or maybe can teach me how do i do editing on the wav file itself?
-
January 5th, 2007, 02:25 PM
#3
Re: How to append 2 wav file
I've never tried that sort of thing, but have you tried messing around with simply reading the first file in as an array of bytes, writing it to a new file, then reading the 2nd file in as an array of bytes and appending it to the new file?
-
January 7th, 2007, 11:33 AM
#4
Re: How to append 2 wav file
Originally Posted by dmeikle
I've never tried that sort of thing, but have you tried messing around with simply reading the first file in as an array of bytes, writing it to a new file, then reading the 2nd file in as an array of bytes and appending it to the new file?
That won't work, since the header information is not updated. Generally, I suppose you will have to take a look at the wav header format (try a search, there are plenty tutorials on the net). To append 2 wav files you shoud:
1) Read the headers of the two wav files.
2) Read the audio data (that is actually an array of short int, or int, depending on the sample resolution), for both files.
3) IF the two signals have different sampling frequencies, then you will probably have to resample one of the two signals (in order to have 2 signals with the same sampling freq.).
4) Create a new wav file (binary):
4a) Firstly, write in that file a wav header which is the SAME as one of the two initial files EXEPT THAT you must have changed the chunkSize and Subchunk2Size, depending on the NEW data length (which is the sum of the lengths of the 2 signals). Also be sure that the sampling frequency field is the right one.
4b) After the wav header is written, then simply write in that file the audio data (stored in int arrays) of the 2 signals.
PS: The header fields (e.g. chunkSize) and generally the wav header is discribed in several tutorials and sites (here is an example).
-
January 10th, 2007, 01:26 AM
#5
Re: How to append 2 wav file
Originally Posted by yiannakop
That won't work, since the header information is not updated. Generally, I suppose you will have to take a look at the wav header format (try a search, there are plenty tutorials on the net). To append 2 wav files you shoud:
1) Read the headers of the two wav files.
2) Read the audio data (that is actually an array of short int, or int, depending on the sample resolution), for both files.
3) IF the two signals have different sampling frequencies, then you will probably have to resample one of the two signals (in order to have 2 signals with the same sampling freq.).
4) Create a new wav file (binary):
4a) Firstly, write in that file a wav header which is the SAME as one of the two initial files EXEPT THAT you must have changed the chunkSize and Subchunk2Size, depending on the NEW data length (which is the sum of the lengths of the 2 signals). Also be sure that the sampling frequency field is the right one.
4b) After the wav header is written, then simply write in that file the audio data (stored in int arrays) of the 2 signals.
PS: The header fields (e.g. chunkSize) and generally the wav header is discribed in several tutorials and sites ( here is an example).
hey thanks..
but how to i start reading the content of the wav file using j2me? any codes to guide me along?
-
January 12th, 2007, 11:52 AM
#6
Re: How to append 2 wav file
Originally Posted by bubblestar
hey thanks..
but how to i start reading the content of the wav file using j2me? any codes to guide me along?
Hi again. Sorry, I didn't notice you needed J2me functionality. Wel, I am not familiar with j2me, but there is an Api for using media resources, called Mobile Media API (link here).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|