Category Archives: Blog

Resolving M4A encoding problem

Background, usage of AAC

Hi-Q uses AAC audio encoding for M4A format. The AAC is the codec for encoding audio, and the M4A is the file extension for MPEG-4 container format.

In Android, there is a built-in encoder for AAC via the class MediaCodec. To start an AAC encoder, we call

MediaCodec.createEncoderByType("audio/mp4a-latm");

Then we need to call configure on the resulting object, providing it with a MediaFormat. We set up MediaFormat as follows:

format = MediaFormat.createAudioFormat("audio/mp4a-latm", 44100, 1);
format.setInteger(KEY_AAC_PROFILE, AACObjectHE);
format.setInteger(KEY_BIT_RATE, 64000);

Then after it is set, we sent the output of the codec to a MediaMuxer, which will format an MPEG-4 container with the AAC-encoded stream as the sole track.

Here is how we get the audio data encoded by the codec, simplified:

  1. We call codec.dequeueInputBuffer() to get an integer, that we pass to codec.getInputBuffer() to get a ByteBuffer.
  2. Put the raw audio data to the buffer.
  3. Call codec.queueInputBuffer(), passing the buffer with additional information such as the current time, size and offset in bytes, etc.
  4. Call codec.dequeueOutputBuffer() to get an integer, that we pass to codec.getOutputBuffer() to get a ByteBuffer.
  5. Read bytes from the buffer, and pass that to the muxer.

This works most of the time. Hi-Q users are able to enjoy a better audio quality and compression in m4a compared to mp3.

The random crash

However, since the first time we release this feature, there has been seemingly random crash as follows:

Fatal Exception: java.lang.IllegalStateException
       at android.media.MediaCodec.native_dequeueInputBuffer(MediaCodec.java)
       at android.media.MediaCodec.dequeueInputBuffer(MediaCodec.java:2635)
Fatal Exception: java.lang.IllegalStateException: Failed to stop the muxer
       at android.media.MediaMuxer.nativeStop(MediaMuxer.java)
       at android.media.MediaMuxer.stop(MediaMuxer.java:454)
Fatal Exception: java.lang.IllegalStateException
       at android.media.MediaCodec.native_dequeueOutputBuffer(MediaCodec.java)
       at android.media.MediaCodec.dequeueOutputBuffer(MediaCodec.java:2698)

The rate of this happening is ~800 users per month, out of more than 200K monthly users that we have.

Unfortunately we can’t find the reason of this happening, we tried multiple ways of reproducing and we never find any reliable way of triggering this error. We suspect that this was a faulty implementation of the codec, but this happened not only on a specific device model but arbitrarily.

Experiment to reliably reproduce crash

Only until one of our customer, Alex, told me that he often get a crash when he sets the Gain to the max while using the M4A format. This might explain the situation!

I tried to do the same myself, setting the gain to the max and recording using the M4A format. I tried it several times. Almost always Hi-Q crashed after several seconds, with similar stack trace as above. This was enlightening!

So we tried to reproduce the crash in a systematic manner. Instead of using audio data taken from real live, we generate the audio data in code:

for (int i = 0, len = block.len; i < len; i++) {
    final short[] data = block.data;
    if (i % 100 == 0) up = !up;
    if (up) {
        data[i] = (short) (32500 + i);
    } else {
        data[i] = (short) (-32500 - i);
    }
}

A block contains 4400 samples. The code above generates a sharp and loud audio signal, having amplitudes 32500~32599 out of max value of 32767. On the third block, the encoding process always crashes.

Hypothesis 1: The loud signals causes the codec to output a lot of data, so we need to repeatedly drain the output by calling dequeueOutputBuffer multiple times until BUFFER_FLAG_END_OF_STREAM is given. I was optimistic when I found that this was not currently done in the code.

This did not work. The same error still happened.

Hypothesis 2: We implemented waiting for the input buffer by calling dequeueInputBuffer with a wrong timeout.

To prevent deadlock, dequeueInputBuffer has a timeout parameter. Probably it was too short or too long. Unfortunately, there is no guideline or clear standard on the number we should put.

Hypothesis 3: We should have used the recommended asynchronous API instead of enqueueing and dequeueing the buffers ourselves.

Since Build.VERSION_CODES.LOLLIPOP, the preferred method is to process data asynchronously by setting a callback before calling configure.

In the asynchronous, we set a callback object to the codec that will receive input buffers to be filled in via onInputBufferAvailable, output buffers from where bytes are extracted via onOutputBufferAvailable, and errors via onError. No more calling dequeue methods, and no more timeout values to be specified!

Sadly, the same error still happens, via onError. The error has code=1101, diagnostic info “android.media.MediaCodec.error_1101”, and isRecoverable=false.

In conclusion, we feel that it is quite likely that the error was not caused by dequeueing and enqueueing the input and output buffers at the wrong order.

Changes made

Hypothesis 4: The codec is configured in a way that does not allow encoding of audio signals outside of a certain limit.

We tried to see more carefully what parameters we passed to the codec, and we realized that we had this:

format.setInteger(KEY_AAC_PROFILE, AACObjectHE);

Then I thought: Why this has to be AACObjectHE? Could I change it to something else and maybe everything would work well? In online examples of encoding audio signals in AAC, people would use AACObjectLC (const value 2) or AACObjectHE (const value 5). I tried to change it to AACObjectLE and… voila! No more crashes.

This change is published starting in Hi-Q 2.8.0. I hope everything goes well and we have much more reliable M4A recording. We apologize for the earlier crashes. 🙇‍♂️

Regarding warnings from anti-virus software such as McAfee

It has come to our attention that certain anti-virus software on Android flag Hi-Q MP3 Voice Recorder, version 2.4 Beta 4, as harmful.

Please take note that other versions, including the most popular publicly available version 2.3.1, is not flagged as such by the anti-virus software.

We have also released 2.4 Beta 5 and 2.4 Beta 6 that is not detected as harmful.

The reason 2.4 Beta 4 was flagged is that we integrated the Tapcore SDK that shows advertisements to people using pirated copy of Hi-Q (e.g. not bought from Google Play). For more information about Tapcore, you can see the website https://tapcore.com/en. However, we found that this is problematic and we have removed completely all things related to Tapcore in our app.

We apologize for this careless integration of 3rd-party SDK into our app. We will be more careful in the future and try to bring you more requested features instead of adding useless things.

Version 2.2 released

It has been so long since we released an update to Hi-Q MP3 Voice Recorder — more than a year ago! We apologize for the lack of updates. Thank you for many feedback that we received via Play Store and help@hiqrecorder.com – we read them all but we could not implement all of them.

Major features of this release since 2.1:

  • Automatic upload to Google Drive
  • Seek back and forward 10s during playback
  • Playback in a loop or “A–B repeat”
  • Longer auto-stop timer up to 100 hours
  • More reliable Dropbox v2 API
  • Fine-grained adjustment of Gain
  • Smoother playback indicator
  • Individual VU-meter values in stereo recording
  • More compatibility when sharing files in Android Nougat

For detailed changes, please take a look at the Updates page.

Another fake Hi-Q MP3 Voice Recorder in the iOS App Store

Not long after we mentioned in our blog about the existence of a fake Hi-Q MP3 Voice Recorder app in the Apple (iOS) App Store, we saw another app that mimics our app.

The app is called “High Quality Audio Recorder Premium” and has the app id of “id1204257992”.

You may ask, “Isn’t it okay to use the phrase ‘High Quality’ as the app title, since it is just a general term?” Yes, it is okay to use that, but consider the description of their app, at the time of writing (July 5, 2017), which is as follows.

We hope you love our app as much as our community and our team do. Download it today and let us know what you think!

Record your conversations and easily listen to them again and again .

Are you looking for a simple application to easily record your conversations and your meetings? Hi-Q Audio Recorder Premium provides the solution through an elegant design and easy-to-use features.

The Hi-Q Audio Recorder takes mobile sound recording to the next level. Feature-packed and loaded with customization options, and with high-fidelity audio sampling, it’s miles ahead of any standard recording app.

Personal voice notes, group discussions, band practice, concerts, lectures, talks, sermons and so much more—if you can hear it, the app can record it

* Simple and Reliable.
Start the app and you are good to go! Press the striking Green button, and you’ll immediately start recording.

* MP3 clips.
Recordings are stored as MP3 files in real-time, which are compact enough and can be played everywhere.

* Keep Recordings Safe.
With automatic upload to Dropbox, your recordings are stored safely and you can free up more space on your device. Sync happens when the preferred connection is available (Wi-Fi only or Wi-Fi and mobile network).

* Manage Clips.
Share, sort, rename and delete recordings as you please.During playback you can move fast forward or fast backward at a selected period.

* During recording.
You can reject incoming calls while recording. Background recording is also supported.

With the Hi-Q Audio Recorder you won’t ever have to fuss with your phone to get the best recording quality. Record yourself and practice for a presentation, record song ideas and brainstorming sessions, record anything !

Buy now and you will get free upgrades with many new features!!!

Record your world with Hi-Q Audio Recorder Premium !
Thank you about using the app.
Good luck !

Our original Hi-Q MP3 Voice Recorder description says:

The Hi-Q MP3 Voice Recorder takes mobile sound recording to the next level. Feature-packed and loaded with customization options, and with high-fidelity 44 kHz audio sampling, it’s miles ahead of any standard recording app.

Personal voice notes, group discussions, band practice, concerts, lectures, talks, sermons and so much more—if you can hear it, the app can record it.

Simple and Reliable. Start the app and you are good to go! Press the striking Red button, and you’ll immediately start recording.

MP3 clips. Recordings are stored as MP3 files in real-time, which are compact enough and can be played almost everywhere.

Keep Recordings Safe. With automatic upload to Dropbox, your recordings are stored safely and you can free up more space on your device. Sync happens when the preferred connection is available (Wi-Fi only or Wi-Fi and mobile network).

Home Screen Widgets. Start, pause and resume recording in a flash with home screen widget.

Quality Settings. Customize audio quality with changeable bit rate up to 320 kbps. You can also record in WAV, OGG, M4A, and FLAC (experimental) formats.

Input Selection. Select the more sensitive front microphone, or the clearer back microphone as you wish (depending on individual device).

Shhh! Switch the recording icon for discretion.

Manage Clips. Share, sort, rename and delete recordings as you please.

Wi-Fi Transfer. Transfer recordings to your PC wirelessly with the built-in Wi-Fi Transfer, utilizing your home Wi-Fi or your device’s Wi-Fi Hotspot capability.

Gain. Specify input gain settings in real-time for optimum recording in various noise levels.

With the Hi-Q MP3 Voice Recorder you won’t ever have to fuss with your phone to get the best recording quality. Record yourself and practice for a presentation, record song ideas and brainstorming sessions, record anything!

I have highlighted the copied text in orange. You can easily notice that they are copycat of our app. Full diff can be seen on this PDF report.

You may notice several things:

  • They use the name “Hi-Q Audio Recorder”, which is actually the name of our app that we publish in the Amazon Appstore.
  • They use “Hi-Q” even though the name of their app is not “Hi-Q”. I think this is such that a search on “Hi-Q” on the Apple App Store results in their app.
  • They changed the phrase “press the striking Red button” to “press the striking Green button”. It’s funny how lazy they are to make their own app description.

As an Android developer, I thought the quality of applications in iTunes App Store is much better because of their strict approval process. I was wrong. This is the 3rd time a copycat of our app has appeared in App Store, and I will file a complaint again to Apple. We do not have any Hi-Q Recorder apps on the App Store. Please be careful and do not get deceived.

Beware of fake “Hi-Q MP3 Voice Recorder” on iTunes/iOS App Store

It has come to our attention that there is a fake and unauthorized Hi-Q MP3 Voice Recorder on the iOS platform on the following Apple App Store page:

https://itunes.apple.com/us/app/hi-q-mp3-voice-recorder-pro/id1149183454?mt=8

As of November 2, 2016, the page looks like this:

As you can notice from the screenshots above:

  • The name of the app is taken from ours: Hi-Q MP3 Voice Recorder Pro.
  • The icon is exactly the same as ours.
  • The publisher is “heon Song Seung”, a name of a Korean actor.
  • The UI is completely different than ours and very simplistic.

We have contacted Apple for removal of the aforementioned app since it infringes our trademark and copyright.

Please contact Apple if you have bought that app from the iTunes Store for cancellation or refund.

The official Hi-Q MP3 Voice Recorder can be obtained only for Android at the following links: Free trial version, Pro version.

Note: It is disappointing to know that Apple App Store approval process did not filter out such submission. This is the second time this happened. The first one happened on Aug 2016 when the same fake app appeared (same name, icon, and screenshots) and published by “Prisma bible Nguyen”, Apple ID of the app “1120553159”.

Version 2.1.0: Upload to Dropbox becomes much easier.

Dear readers,

We are glad to announce that Hi-Q MP3 Voice Recorder version 2.1.0 has been released! One major improvement that we want to highlight is the ability of Dropbox auto-upload.

Now you may already know that you can share your recordings to Dropbox from the share menu. But there is no way to automatically do it every time you create a recording. With this new auto-upload ability, you don’t need to worry if some time later you lose your phone or the storage media fails, because you will have a backup of your recordings in Dropbox! It also means that you can get rid of chunks of bulky recordings in your phone and free up the device storage because Hi-Q MP3 Voice Recorder will indicate which recordings have been safely uploaded.

Open Hi-Q MP3 Voice Recorder and go to settings > Dropbox. First you will need to log in to your Dropbox account to activate the feature. After that you can always toggle on/off or totally log off from your account by tapping the “Account” entry.

dropbox1

After you log in, a folder will automatically be created at Dropbox > Apps > Hi-Q Recordings and all the uploaded recordings will be stored there.

With the “upload new recordings” option turned on, the app will automatically upload new recordings to Dropbox.

Choose to upload whenever there is wi-fi and mobile network or via wi-fi only to conserve your mobile data usage.

You can also check the Status to see how many uploads are pending or in progress, or whether it is idle.

In the recording list, you can see little Dropbox icons indicating whether the recordings are “uploaded”, “currently uploading”, “pending upload”, or “error”.

layar

ic_dropboxhiq

From left: “uploaded”, “currently uploading”, “pending upload”, “error”

Errors may happen when connection is lost in the middle of uploading (it will automatically retry) or when the Hi-Q Recordings folder in your Dropbox is missing.

You can also upload your existing recordings to Dropbox by tapping them and choose “Upload to Dropbox”.

uploadtodropbox

Please note that this is not a Dropbox two-way synchronisation. After the app finishes uploading the recordings, you can edit/rename/delete the files in your Dropbox and Hi-Q MP3 Voice Recorder will not do anything about them.

Hopefully you will enjoy this new feature. Update your app here:

https://play.google.com/store/apps/details?id=com.hiqrecorder.full

Unleash the power of Quick Settings

On the latest update of Hi-Q MP3 Voice Recorder, we introduced new UI element in the recording page that we called “Quick settings”. We thank for your feedbacks, as this feature has been suggested by some of you and we think this is going to be very useful for recording. The Quick settings gives you ability to modify the recording directly in the recording page even while the recording is ongoing.

depanhiq

There are 4 elements we add Quick Settings:

1. Recording format

Choose which recording format (MP3/WAV/M4A/OGG/FLAC). You can’t change the format while recording.

2. Quality

Set the recording quality. Note that WAV and FLAC don’t have this option. You can’t change the quality while recording is ongoing.

3. Gain

Adjust recording gain. The best part is you are able to adjust gain while recording. So if recording is too loud or too soft, you can easily change gain and adjust it directly in the same screen. Note that if you adjust gain while recording, you are adjusting the “current recording gain” which is specifically for that recording, meaning the gain setting will not be saved for the next recording. Meanwhile, adjusting gain while you are not in recording session will change the “default gain”.

4. Timer

Add timer and the app will automatically stop the recording after the specified time. You can adjust the timer even while recording is already ongoing. Note that timer option is only in Quick setting.

If you haven’t update the app, you can update the app through Google Play.

We hope this feature will be useful for you.

 

You Don’t Have To Purchase Again (Part 2)

After some discussion within our team, we come out with what we think as the best move:

1. Hi-Q MP3 Voice Recorder by Audiophile will be the app that is available in Google Play. Hi-Q MP3 Voice Recorder by Yuku will not be visible to any users. This is important to avoid confusion why there are 2 similar apps on Play Store.

2.  However, if you had bought the app previously (the Yuku version), you can go to this link to download the Yuku version to download the full version freely, if any case you switch phone. Therefore you don’t have to purchase the same app twice.

3. Hi-Q MP3 Voice Recorder by Yuku will be updated to be the same (latest) version as Audiophile version.

We truly hope this is the best solution for everyone. Should you have any questions, do not hesitate to contact us.

You Don’t Have To Purchase Again (Part 1)

Good news!

As some of you have known, Google suspended our dev account (Yuku), resulting the change of ownership of Hi-Q MP3 Voice Recorder to Audiophile and we will reimburse you for your second purchase via Paypal.

But a few weeks ago, a kind Google employee actually contacted us and we explained our situation to her. After a while, Google finally retrieve our account back with our apps ratings, statistics, comments are still preserved like the same as before our account were closed (Thank you, Google!).

We decided to re-activate Yuku’s Hi-Q MP3 Voice Recorder because there are still so many users using it. Therefore if you are existing user of Yuku, you don’t have to purchase Audiophile’s Hi-Q MP3 Voice Recorder if you want to install the app on another devices, as what it should be in the first place.

On the other side, there are now two similar Hi-Q MP3 Voice Recorder apps on Google Play (plus one free version), with both of the apps has quite amount of users using it. We don’t want to confuse you guys of which app you should download. Currently Audiophile’s has the latest version (1.21) and Yuku’s is still version 1.19.3. We will decide what should be done the best, so stay tuned for the next updates!