android - audio capture - please help!

I’ve got some code that performs an audio capture to a file, test.raw

It then attempts to check the file size of the capture and report the size screen.

It works fine on the simulator and iOS , but Android is giving strange results.

For example if I record test.raw (or test.pcm) for 4 secs I should get a file size of 352,844 bytes

iOS reports 352,844 Bytes (correct)
simulator reports 352,844 Bytes (correct)
Android reports 7371 Bytes (incorrect)

What am I doing wrong ? Android is v2.2 and running on HTC Desire

Corona is 2011.591 (2011.8.2)
[import]uid: 97524 topic_id: 19556 reply_id: 319556[/import]

Corona for Android always records audio to the 3GP audio format, regardless of the extension that you give the file. Based on my testing, 3GP is the default audio recording format for the Android OS. The Corona audio APIs are unable to play the 3GP file format. The only work-around at the moment is to use the Corona media API to play the 3GP file, which does the playback via the Android OS instead of OpenAL. [import]uid: 32256 topic_id: 19556 reply_id: 75576[/import]

thanks for the reply Joshua - this was my suspicion.

Can I put a request in for Corona staff to change this, so raw is recorded in raw format ? Surely that’s not too hard to implement? For example, a lot of people don’t simply want to play the capture back - they want to perform post processing on the capture, for various audio applications?

Could I also make a couple of other important suggestions ?

  1. Perhaps change the Corona docs on audio capture to say at present only 3gp is captured (it mentions raw too but clearly thats NOT supported)?

Even the simple audio recorder template shows audio being captured in .pcm so it’s confusing for the developer.

  1. Add a note on audio capture that Android buils require a “build settings” file allowing permission to record audio. I had no idea this was needed initally so wasted valuable time wondering why my app was suddenly freezing on the Android phone ?
    [import]uid: 97524 topic_id: 19556 reply_id: 75609[/import]

Joshua, can this be used with Corona ?
http://ffmpeg.org/about.html [import]uid: 97524 topic_id: 19556 reply_id: 75618[/import]

I’m going to have to decode a 5 second long 3gp file into raw - can the above do it, or is there any published methods for doing it manually ?

Joshua can you tell me any additional info that would help regarding the 3gp format Corona captures audio in on Android ? For example is it AAC audio format, and what spec ? [import]uid: 97524 topic_id: 19556 reply_id: 75619[/import]

Hello dax,

Sorry for the late reply. I was out for the holidays.

I’ve corrected our audio recording API documentation. The required Android permission was already documented, but not on all API pages.
http://developer.anscamobile.com/reference/index/medianewrecording

We already have a feature request for having Android record to an uncompressed WAV file. It’s on our wish-list. Unfortunately, it cannot be easily done on Android; meaning it is not a quick fix on our end. We’re also already aware that the included sample app has problems and fails to play back the recorded audio file. I don’t like releasing a broken sample app, but the audio recording feature was so little used by our customers, that fixing it became a very low priority compared to everything else we’re doing on Android (such as in-app purchases).

Regarding ffmpeg, you cannot use external libraries with Corona.

Regarding the 3GP format, none of us here at Ansca know that audio format; otherwise our audio API would have supported it. So, unfortunately, it is up to you to figure out how to decode it.

Would you mind telling me what you are trying to do with the audio recording? Perhaps I can provide an alternate solution for you.
[import]uid: 32256 topic_id: 19556 reply_id: 77070[/import]

Joshua

Thanks for your comprehensive reply.

Fortuntely Corona’s iPhone implementation offers me the raw audio capture i need. I perform a particular kind of processing on the data, which requires raw data to work

I guess i’ll just have to be patient and wait for Corona to implement RAW or WAV audio capture. In the meantime, i’ll finish the iOS version.

Thanjs again Joshua [import]uid: 97524 topic_id: 19556 reply_id: 77077[/import]

I’m glad you are happy with our iOS implementation… and I apologize for whatever frustration our Android implementation has caused you. Hopefully we’ll have time to update the Android side to better match iOS by the next release. [import]uid: 32256 topic_id: 19556 reply_id: 77100[/import]