Weird problem with audio playback on Android devices

Hi all,

 

I’ve moved this thread as I originally put it off the back of another, which didn’t make any sense…

 

Basically, my app records to WAV format on all devices and this seems to work fine. The app then allows users to upload that audio via a web service I’ve created and download it on another device for playback (audio share functionality).

 

Because Android and iOS both support WAV format, in theory, the audio recording on an Android devices should play on an iOS device and vice versa.

 

However, and this is where it gets weird…

 

  • The WAV files recorded on iOS or the simulator on my Mac play on other iOS devices after uploading and downloading them so the transfer process is fine. They also play on my Mac.

  • The WAV files recorded on Android devices play on all other Android devices (tested between Kindle and a generic cheap Android machine)

  • The WAV files recorded on Android devices play on iOS devices and on my Mac in the simulator fine.

  • The WAV files recorded on iOS or in the simulator on my Mac do NOT play on Android devices.

 

So, any audio recorded on an iOS device or Mac, uploaded to the server via my web service and then downloaded onto an Android device will  not  play. I get the following debug trace when running on the device:

 

Using the Media library:

I/Corona  ( 6770): PATH IS: /data/data/uk.co.mycompany.myapp/app\_data/clip-1.wav E/MediaPlayer( 6770): Unable to to create media player

Using the Audio library:

I/Corona  (29516): PATH IS: /data/data/uk.co.mycompany.myapp/app\_data/clip-2.wav I/SoundDecoder\_SetError(29516): WAV: Not a RIFF file. I/SoundDecoder(29516): MPG123: Accepting data stream. I/SoundDecoder\_SetError(29516): MPG123: Message: Prepare for a changed audio format (query the new one)!

I have checked the files recorded from both device types and they seem to be identical. If I download them via FTP from the server where they were saved during the upload process, they both play on my Mac and can be opened in my audio editor and appear to have the same properties.

 

They are both WAV files, both 16 bit, both 44.1k. I can see no difference. And yet one plays and one doesn’t from within my app on every Android device I’ve tested on, so there must be something different about them.

 

I’ve run another test where I push an audio file (recorded on my Mac using Audacity) onto the device via Eclipse and that plays fine too.

 

So it’s just audio clips recorded on iOS or on my Mac via the app that won’t play on Android devices.

I’ve checked and I’ve not double up on the extensions (so I don’t have clip-1.wav.wav) or leaving them off (so no clip-1 with no extension). Everything seems to be in order but it’s as if the actual “type” of wav file is different… is that possible? Can there be different types of WAV file recorded by different devices?

 

Any help would be much appreciated - is this a bug or am I doing something wrong??

 

Thanks in advance.

 

Ian

I think the answer lies in that wav is a general file format with a header describing the content. E.g. it supports a range of different compression formats.

For IOS the standard compression is AAC (Advanced Audio Coding) which is what you get. So even with a wav file on IOS it will only be a wav with a header describing that it contains AAC encoded data. That plays fine on other Apple devices, but not on Android.

Android on the other way does not always encode AAC (its a device dependent issue). I am not shure what type of compression those devices give you (RAW, losseless or lossy), but Iphone supports wav in general so it may play most of them.

Now, since the audio is recorded in a file, you can read it byte by byte and decode the data. I havent found any lua-based deconversion tool for AAC, but it would be possible. If you want to go down that line, try to stick to the BitOP plugin tool as it will speed up bitwise math considerably…

As a starting point you could check out: http://libzplay.sourceforge.net/

Its a library for playing AAC (and other files). I havent looked into it, but you can download its sourcecode in C if you want to try and translate it.

I havent found any lua-based deconversion tool for AAC, but it would be possible (and probably alot of work…)

If it’s being uploaded to a server, there could be some PHP tools or something like that which could do it. Although that means putting the workload for all users onto the 1 server, rather than spreading it across all devices.

Yea, that would probably be alot easier than translating a AAC decoder written in C.

The web service is written in VB.Net so I’ll look into whether there is any way of decoding from AAC in VB.Net.

Thanks for the replies - very helpful.

Massively frustrating situation - I could just about get away with telling iOS users that they couldn’t share with Android devices but I’d really rather find a solution.

Will post my findings here once I’ve done some more research.

Thanks.

I found this - https://naudio.codeplex.com/documentation

Could work server side to do the conversion. Way out of my comfort zone though…

I would far rather find a Corona based solution but am I right in thinking that Corona can’t record from iOS to any other formats other than aif and this weird form of wav that isn’t actually a wav?

If anyone from Corona could come back on this and let me know what’s happening under the hood when iOS records to this odd WAV format it would be a massive help - I’m pretty stuck at the moment.

Thanks,

Ian

I think the answer lies in that wav is a general file format with a header describing the content. E.g. it supports a range of different compression formats.

For IOS the standard compression is AAC (Advanced Audio Coding) which is what you get. So even with a wav file on IOS it will only be a wav with a header describing that it contains AAC encoded data. That plays fine on other Apple devices, but not on Android.

Android on the other way does not always encode AAC (its a device dependent issue). I am not shure what type of compression those devices give you (RAW, losseless or lossy), but Iphone supports wav in general so it may play most of them.

Now, since the audio is recorded in a file, you can read it byte by byte and decode the data. I havent found any lua-based deconversion tool for AAC, but it would be possible. If you want to go down that line, try to stick to the BitOP plugin tool as it will speed up bitwise math considerably…

As a starting point you could check out: http://libzplay.sourceforge.net/

Its a library for playing AAC (and other files). I havent looked into it, but you can download its sourcecode in C if you want to try and translate it.

I havent found any lua-based deconversion tool for AAC, but it would be possible (and probably alot of work…)

If it’s being uploaded to a server, there could be some PHP tools or something like that which could do it. Although that means putting the workload for all users onto the 1 server, rather than spreading it across all devices.

Yea, that would probably be alot easier than translating a AAC decoder written in C.

The web service is written in VB.Net so I’ll look into whether there is any way of decoding from AAC in VB.Net.

Thanks for the replies - very helpful.

Massively frustrating situation - I could just about get away with telling iOS users that they couldn’t share with Android devices but I’d really rather find a solution.

Will post my findings here once I’ve done some more research.

Thanks.

I found this - https://naudio.codeplex.com/documentation

Could work server side to do the conversion. Way out of my comfort zone though…

I would far rather find a Corona based solution but am I right in thinking that Corona can’t record from iOS to any other formats other than aif and this weird form of wav that isn’t actually a wav?

If anyone from Corona could come back on this and let me know what’s happening under the hood when iOS records to this odd WAV format it would be a massive help - I’m pretty stuck at the moment.

Thanks,

Ian