Common sound file format for different device types

I can understand why you choose to use .aif as the preferred file type for iOS devices, and .3gp for android, after all there are licensing issues with mp3. The way you are currently doing it provides a compressed file format, and keeps apps smaller than using something like .wav

However, I really need a file type that is common to both types of device in order to make it possible to transfer sound files from an iPod to a Galaxy and vice versa. Only having the ability to record a memo in one filetype is preventing this.

Is there any way to make it possible for a user to transfer files by converting an existing file (.aif or .3gp) to a common format like wav? Is it possible to do this in pure lua code, and if so what would happen when the code was compiled into  an app?

Have you tried just using .mp3? I know it’s not in the documents but I’ve worked with games for both iPhone and Android using mp3 on both OS and everything played back fine.

Same works for recording.

    local filePath = system.pathForFile( ‘audioFile.mp3’, system.DocumentsDirectory )
    
    local r = media.newRecording( filePath )

An mp3 file gets created and plays back fine on both Android and iOS.

iOS and Android do not support recording to MP3.  Just because you record to a file with an mp3 extension does not mean that the platform will record with that format.  We document the supported formats here…

   http://docs.coronalabs.com/daily/api/library/media/newRecording.html#path-optional

Unfortunately, there isn’t a common audio recording format that you can use between platforms… nor a means of converting the recordings to a different format.  This is a limitation between iOS and Android, and there isn’t enough demand for us to allocate time/resources to override audio recording and record to a common format ourselves, which is what it would take to do this.

Thanks for the answers guys. 

@Red Piston - like Joshua said, using the mp3 extension doesn’t mean the sound is recorded in that format, the docs say only .3gp on android and .aif on iOS. Besides using mp3 brings licensing issues, it isn’t in the public domain, and you can be made to pay royalties if sales of your app exceed a certain level.

@Joshua. I guess the only way round is file conversion after the recording is made. Something that would occur when the user wants to export a recording to another device. I’ll have a look on the net for Lua code that can do something like this. If (for example) I use Lua’s file IO, tables, and string manipulation routines to load a file, change the header and data blocks to the right format and then write the data out to a new file; will Corona choke on any of that when the app is compiled? I wouldn’t have thought so, I guess I just have to “Suck it and see” for myself huh? This could take some time!! I can see why you didn’t want to go there :slight_smile:

Yeah, converting the audio file to a different audio format would work, but might prove difficult.  Lua isn’t great at working with binary data since you don’t have byte/integer data types (Lua numbers are really double floats) and the ability to do bitwise operations.  The closest thing to a byte type in Lua is the string type, which is internally implemented as a byte array/buffer.  But hey, if you can find a Lua library that does exactly this, then I say go for it.  Converting to an uncompressed wav file is probably the way to go.

Have you tried just using .mp3? I know it’s not in the documents but I’ve worked with games for both iPhone and Android using mp3 on both OS and everything played back fine.

Same works for recording.

    local filePath = system.pathForFile( ‘audioFile.mp3’, system.DocumentsDirectory )
    
    local r = media.newRecording( filePath )

An mp3 file gets created and plays back fine on both Android and iOS.

iOS and Android do not support recording to MP3.  Just because you record to a file with an mp3 extension does not mean that the platform will record with that format.  We document the supported formats here…

   http://docs.coronalabs.com/daily/api/library/media/newRecording.html#path-optional

Unfortunately, there isn’t a common audio recording format that you can use between platforms… nor a means of converting the recordings to a different format.  This is a limitation between iOS and Android, and there isn’t enough demand for us to allocate time/resources to override audio recording and record to a common format ourselves, which is what it would take to do this.

Thanks for the answers guys. 

@Red Piston - like Joshua said, using the mp3 extension doesn’t mean the sound is recorded in that format, the docs say only .3gp on android and .aif on iOS. Besides using mp3 brings licensing issues, it isn’t in the public domain, and you can be made to pay royalties if sales of your app exceed a certain level.

@Joshua. I guess the only way round is file conversion after the recording is made. Something that would occur when the user wants to export a recording to another device. I’ll have a look on the net for Lua code that can do something like this. If (for example) I use Lua’s file IO, tables, and string manipulation routines to load a file, change the header and data blocks to the right format and then write the data out to a new file; will Corona choke on any of that when the app is compiled? I wouldn’t have thought so, I guess I just have to “Suck it and see” for myself huh? This could take some time!! I can see why you didn’t want to go there :slight_smile:

Yeah, converting the audio file to a different audio format would work, but might prove difficult.  Lua isn’t great at working with binary data since you don’t have byte/integer data types (Lua numbers are really double floats) and the ability to do bitwise operations.  The closest thing to a byte type in Lua is the string type, which is internally implemented as a byte array/buffer.  But hey, if you can find a Lua library that does exactly this, then I say go for it.  Converting to an uncompressed wav file is probably the way to go.