 |
 |
|
 |
06-23-2009, 02:55 PM
|
#1 (permalink)
|
|
New Member
Join Date: Apr 2008
Location: Long Island, NY
Age: 19
Posts: 84
|
Combining Audio Files...Possible?
I'm looking for a way to combine separate audio files in one audio file. The starting separate files i can have are WAV or CAF (doesnt matter to me) and I would like to stitch them together into one file such as MIDI or anything other file type thats possible. I'm not sure if this is possible on iPhone but I would be able to make a mac desktop application to export to if needed to do the stitching together there. So pretty much what I'm asking is does anybody know of a not too complex (but share anyway even if insanely complex) way on iPhone OR OS X to combine separate audio files into one file. Thanks!
Nick
|
|
|
06-23-2009, 04:00 PM
|
#2 (permalink)
|
|
FasterThanMonkeys.com
iPhone Dev SDK Supporter
Join Date: Mar 2009
Location: Southern California
Posts: 517
|
There is a great audio editor that is free and is compatible with several platforms (Mac, Windows, Linux). It is called Audacity, and can be found here:
Audacity: Free Audio Editor and Recorder
It can do what you are asking, and a lot more.
|
|
|
06-23-2009, 04:04 PM
|
#3 (permalink)
|
|
New Member
Join Date: Apr 2008
Location: Long Island, NY
Age: 19
Posts: 84
|
Oh thanks for your help but I guess i didnt convey that I need to do this programmatically in my own app I am creating. I need a framework or some classes that can combine audio files. I need to create my own app that can combine audio files, not use one that already exists.
|
|
|
06-23-2009, 04:14 PM
|
#4 (permalink)
|
|
Magic Hands' Daddy
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 22
Posts: 1,245
|
Nitrex... havent seen you around here in a while... how's things been?
Anyways, I don't know about combining audio files of different types, but for same type audio files, same compression, same everything:
Could you just read in file1 using NSFileHandle's readData, write it out to another file, do the same for file2, just append it to the end of file 1. The only thing you need to determine is how many bytes are at the front of file2 that you can skip because they have unneeded file information that's not part of the audio.
|
|
|
06-23-2009, 04:18 PM
|
#5 (permalink)
|
|
FasterThanMonkeys.com
iPhone Dev SDK Supporter
Join Date: Mar 2009
Location: Southern California
Posts: 517
|
Ah... since you asked about OS X, I assumed you were just looking for a tool, not necessarily code.
I have seen some threads about using ffmpeg on the iphone. ffmpeg is generally used for Video, but works with audio as well. You might try searching on using ffmpeg on the iphone as the source code for that is freely available as well.
|
|
|
06-23-2009, 04:19 PM
|
#6 (permalink)
|
|
New Member
Join Date: Apr 2008
Location: Long Island, NY
Age: 19
Posts: 84
|
Quote:
Originally Posted by smithdale87
Nitrex... havent seen you around here in a while... how's things been?
Anyways, I don't know about combining audio files of different types, but for same type audio files, same compression, same everything:
Could you just read in file1 using NSFileHandle's readData, write it out to another file, do the same for file2, just append it to the end of file 1. The only thing you need to determine is how many bytes are at the front of file2 that you can skip because they have unneeded file information that's not part of the audio.
|
Yea i figured it was something like that except I don't know how to do that. Any advice on how you would go about it such as a class reference to look at or some methods you would be using. By the way all files would be of the same type, i just meant if WAV was not supported I can change all my files to CAF.
Thanks for the help.
Nick
|
|
|
06-23-2009, 04:22 PM
|
#7 (permalink)
|
|
New Member
Join Date: Apr 2008
Location: Long Island, NY
Age: 19
Posts: 84
|
Quote:
Originally Posted by ftm
Ah... since you asked about OS X, I assumed you were just looking for a tool, not necessarily code.
I have seen some threads about using ffmpeg on the iphone. ffmpeg is generally used for Video, but works with audio as well. You might try searching on using ffmpeg on the iphone as the source code for that is freely available as well.
|
Thanks for the info ill check that out. By asking about OS X i meant if there was no such technology on the iPhone I could make an OS X desktop application to handle this code and export data from the iPhone app to it.
Nick
|
|
|
06-23-2009, 04:56 PM
|
#8 (permalink)
|
|
Magic Hands' Daddy
Join Date: Aug 2008
Location: Memphis, TN, USA
Age: 22
Posts: 1,245
|
This should get you on the right track. Mix and match pseudo code
Code:
-(void) concatFiles( NSString* path1, NSString* path2, NSString* combinedPath )
{
NSFileHandle * f1Handle = [NSFileHandle fileHandleForReadingAtPath: path1];
NSFileHandle *f2Handle = [NSFileHandle fielHandleForReadingAtPath: path2];
//might need to check if file exists first, if not create it using NSFileManager's createFileAtPath
NSFileHandle * combinedHandle = [NSFileHandle fileHandleForWritingAtPath: combinedPath];
// read data in small chunks to avoid hogging memory.
NSData* read = [f1Handle readDataOfLength: CHUNK_SIZE] ;
while( length of read != 0 )
{
[combineHandle writeData: read];
read = [f1Handle readDataOfLength: CHUNK_SIZE] ;
}
[f1Handle close];
//now do the same for f2Handle
//might need to ignore a few bytes in the front of file2 that isnt audio
[f2Handle readDataOfLength: HEADER_LENGTH];
NSData* read = [f2Handle readDataOfLength: CHUNK_SIZE] ;
while (... )
{
}
[f2Handle close];
[combineHandle close];
}
|
|
|
06-23-2009, 08:14 PM
|
#9 (permalink)
|
|
New Member
Join Date: Apr 2008
Location: Long Island, NY
Age: 19
Posts: 84
|
Quote:
Originally Posted by smithdale87
This should get you on the right track. Mix and match pseudo code
Code:
-(void) concatFiles( NSString* path1, NSString* path2, NSString* combinedPath )
{
NSFileHandle * f1Handle = [NSFileHandle fileHandleForReadingAtPath: path1];
NSFileHandle *f2Handle = [NSFileHandle fielHandleForReadingAtPath: path2];
//might need to check if file exists first, if not create it using NSFileManager's createFileAtPath
NSFileHandle * combinedHandle = [NSFileHandle fileHandleForWritingAtPath: combinedPath];
// read data in small chunks to avoid hogging memory.
NSData* read = [f1Handle readDataOfLength: CHUNK_SIZE] ;
while( length of read != 0 )
{
[combineHandle writeData: read];
read = [f1Handle readDataOfLength: CHUNK_SIZE] ;
}
[f1Handle close];
//now do the same for f2Handle
//might need to ignore a few bytes in the front of file2 that isnt audio
[f2Handle readDataOfLength: HEADER_LENGTH];
NSData* read = [f2Handle readDataOfLength: CHUNK_SIZE] ;
while (... )
{
}
[f2Handle close];
[combineHandle close];
}
|
Wow thank you so much that will probably do it. That is so awesome! I haven't done anything with the NSFileHandle yet so I didn't know about it and it's methods. What do you recommend for the values of CHUNK_SIZE and HEADER_LENGTH?
Also in reference to me not being here for a while I have been very busy making tons of apps for the app store with various companies. I am also involved with the creation of highly developed new tutorial website that will be ready soon. Also busy finishing high school =P.
Nick
|
|
|
08-26-2009, 09:21 PM
|
#10 (permalink)
|
|
Registered Member
Join Date: Jan 2009
Location: Brooklyn, NY
Posts: 18
|
Very interesting. Hypothetically, if one file were video and one were audio, and both were mp4, do you think this would work?
|
|
|
 |
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
» Advertisements |
» Online Users: 487 |
| 62 members and 425 guests |
| activ8, Alexman, amiralic, amoll, angelFrog, bbc z, BillHerr79, bluemonkey, brianmethod, BrianSlick, Chonch, Corsu, CoxTral, craig.w, danbaumbach, dany88, dda, digidan, dre, Drudoo, eemceebee, eJohnny, Erle, fede, gjosef, healthyutech, imsatasia, Jeremy1026, JJGEight, johny_abo, KenPletzer, krisix, lanej, linuxgood, lws, MacSteve85, markbuchanan, mlfarrell, mlo, Mopedhead, Mr Jack, MrMattMac, nicholask, nonamelive, Nungster, P2k, pokypine, QAD, raees, redmouse, ryguy2503, scotopia, staticouture, TheAppByte, TheGiant, themathminister, tomoan74, Tuszy, xyster, zivido, ZunePod |
| Most users ever online was 779, 05-11-2009 at 10:55 AM. |
» Stats |
Members: 21,499
Threads: 35,780
Posts: 156,754
Top Poster: smasher (2,448)
|
| Welcome to our newest member, staticouture |
|