alexa/avs-device-sdk

Poor music quality using AVS on Android, suggest floating point PCM output

Closed this issue · 5 comments

Briefly summarize your issue:

The music quality from Amazon music is very poor when playing on android.

What is the expected behavior?

I would expect crisp, audio quality when playing back music.

What behavior are you observing?

The audio sounds scratchy and definitely degraded. Looking at the media player, I'd suggest playing with floating point PCM output (available to OpenSL ES via SLAndroidDataFormat_PCM_EX source with SL_ANDROID_PCM_REPRESENTATION_FLOAT representation).

Provide the steps to reproduce the issue, if applicable:

Trigger alexa to listen, ask to play a song/artist, and listen to the quality.

Tell us about your environment:

avs 1.9.0, running on android

Tell us what hardware you're using:

  • Desktop / Laptop
  • Raspberry Pi
  • [ x] Other - tell us more: Arm7 based platform

Tell us about your OS (Type & version):

  • [x ] Linux
  • MacOS
  • Raspbian Stretch
  • Raspbian Jessy
  • Other - tell us more:

Hi @wjennings,

Thanks for raising the issue. We already have this on our backlog.

Thanks,
Benny

@bennyAv10,
Turns out, while going floating point may improve it, the real issue is in FFmpegDecoder::readData(), where the function av_samples_get_buffer_size is being called with align 0 (NO_FLAGS), where it should be called with 1. From the ffmpeg documentation:
align buffer size alignment (0 = default, 1 = no alignment)

This causes the number of bytes to be returned to be too large. For example, with nb_samples = 1114, 2 channels, 16-bit format, the size in bytes should be 4456, but the value being returned is 4480, which is 32 byte aligned.

This causes there to be empty samples played, which causes bad quality sound.

Hi @wjennings, thanks for the finding! We have opened an internal ticket to do more investigation and verification with your suggestion. Thank you so much again!

Hello wjennings,

Release 1.10 includes a change to AndroidSLESMediaPlayer/src/FFmpegDecoder.cpp that is intended to fix this problem. If you can, please let us know if it works for you.

Thank you,
-SWH

I am closing this issue due to inactivity. Please feel free to re-open it if it has been closed in error.