Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pitch causing problems on exoplayer #2751

Closed
blennerSilva opened this issue Apr 28, 2017 · 18 comments
Closed

Pitch causing problems on exoplayer #2751

blennerSilva opened this issue Apr 28, 2017 · 18 comments

Comments

@blennerSilva
Copy link

Guys first of all thank you for adding the PlaybackParameters function to exoplayer.

but the pitch variable is causing some problems on Exoplayer when im setting different speeds
in different phones and android versions.

on a motorola g1 android 5.1 i set the speed at 1.5x and pitch to one and the audio gets all distorted
on a samsung s4 android 4.4 i set the speed at 2x and pitch at one and the same happens

can you guys give me a clue of what to do?

thanks

@andrewlewis
Copy link
Collaborator

Are you building a release version of your APK? If not, the audio playback may not be smooth (see #26 (comment)).

If you see this problem with a release version of your APK, please provide all the information requested in the issue template so we can investigate further.

@clauskrogholm
Copy link

I am having the exact same problem. For me it can be reproduced by adding an MP3 file as an asset in the demo app, and then setting PlaybackParameters with speed 1.25 and pitch 1.

@clauskrogholm
Copy link

The problem is the same on a release APK for my own app.

@andrewlewis
Copy link
Collaborator

@clauskrogholm Testing on a Samsung Galaxy S4 running Android 4.2.2, a 44.1 kHz stereo MP3 played back fine at 1.25 speed. This was on a debuggable (non-release) build in the demo app. Please could you provide a link to the stream you're trying to play so I can try to reproduce the issue you're seeing?

@clauskrogholm
Copy link

@andrewlewis First of all, thank you for taking such quick action! The file I tested in the demo app can be found here: https://www.dropbox.com/s/7ctbo1rxud0wlpj/02%20Amore%20E%20Musica.mp3?dl=0

I have tested on a handful of different files too, with the same result. And all of them play back flawlessly on speed 1.0.

@andrewlewis
Copy link
Collaborator

Thanks. I can reproduce the issue with that file.

@clauskrogholm
Copy link

@andrewlewis That is good to know - after all, a reproducible error is so much more fixable than an unknown error :-)

Thanks again for the swift reply!

@blennerSilva
Copy link
Author

on my app it worked on release mode

@andrewlewis
Copy link
Collaborator

@clauskrogholm I'm afraid I spoke too soon -- although playback is not smooth with that file on a debuggable APK on my test device, it plays fine if I use a signed, release APK.

  • Please could you double check that the APK you're testing with is a signed, release APK not a debuggable one? aapt dump xmltree demo.apk AndroidManifest.xml | grep debuggable should have no output if it's not debuggable.
  • Note that some distortion is expected due to the way the speed adjustment implementation works, but audio should not cut out or stutter. (If it's not clear whether the behavior is a bug or expected, please attached a video recording.)
  • It would be useful to have the output of adb bugreport to check if there's anything else going on and find out exactly what build the device is running. Thanks.

@clauskrogholm
Copy link

@andrewlewis I will check as soon as possible, and revert.

@clauskrogholm
Copy link

clauskrogholm commented May 2, 2017

@andrewlewis I just tested that the APK was a signed release APK (yielding no output from the aapt command). Also - to be absolutely sure - I generated a new signed APK and transferred it to my device via Android File Transfer, and installed it from there.

What I find quite strange is that the high level of distortion that I am experiencing is neither better nor worse when I am explicitly using a debug build... The playback sounds exactly the same.

The following is a link to a bug report generated via the developer options on my device:
https://www.dropbox.com/sh/bojyr8kunjcvdc9/AACa_tLVzGpTGCCh02sH2Em5a?dl=0

Thanks for your time in examining this, and please let me know if I can provide anything else to shed light on the subject!

@andrewlewis
Copy link
Collaborator

@clauskrogholm Could you also describe what the distortion sounds like or attach a video of the problem?

We've found an issue with using extensions and variable playback speed, where the byte buffer endianness is set incorrectly. This can result in very noisy sound, rather than the stuttering playback experienced when using a debuggable APK. It's probably unrelated to your issue unless you're using the FFmpeg extension to play your MP3.

@clauskrogholm
Copy link

@andrewlewis It is a bit difficult to describe - my main impression is that the background music sounds "wobbly" (as if played under water, if that makes any sense). There are no stutters as such, and I have noticed that the lyrics themselves actually sound quite decent. I don't know if it could be because the Sonic framework is more geared towards speech?

I haven't done anything special regarding extensions - simply added the MP3 file as an asset in your demo app, and set the PlaybackParameters to the increased speed.

Not sure if I mentioned it earlier, but I am testing on a Samsung Galaxy S8, running Android 7.0.

Even though, by your previous directions, I feel confident to have verified that I am actually using a release build, I find it weird that there doesn't seem to be any quality difference between a debug build and a release build - but that is perhaps because I am on API 23?

@andrewlewis
Copy link
Collaborator

@clauskrogholm I think you might be right that the distortion is expected with Sonic. One way to verify that this isn't the same performance issue would be to run on the most powerful device you can find running Android Nougat and check whether you hear the same thing.

There is a quality/performance trade-off, and if you can find another suitable speed/pitch adjustment library that gives output that sounds better when processing music we could investigate integrating it as an alternative. Thanks!

@clauskrogholm
Copy link

@andrewlewis I guess it would be difficult finding a more powerful device than the Galaxy S8 right now, so performance definitely shouldn't be an issue.

I have been looking towards the Superpowered library, but so far have found it too cumbersome to integrate into my own app - I am really looking for something that is as approachable as ExoPlayer...

I will try to make a recording of the sound both with speed 1.00 and 1.25, in the hope that you could tell if the quality difference is expected or caused by something else.

Thanks for your continued support!

@ojw28
Copy link
Contributor

ojw28 commented May 5, 2017

One other thing that's worth trying is to use Android's regular MediaPlayer API to play the sample at 1.25x, which is supported on more recent API levels. IIRC MediaPlayer also uses Sonic internally. If you experience the same distortion using that approach then it's probably expected with Sonic. If MediaPlayer is distortion free then that would point more toward an ExoPlayer issue.

@clauskrogholm
Copy link

clauskrogholm commented May 5, 2017

@ojw28 Thank you for the suggestion. I already tried the MediaPlayer API in order to have a reference, and it exhibits the same level of distortion. So I think you're right that it points to a Sonic issue rather than an ExoPlayer issue (I was not aware until now that MediaPlayer is also based on Sonic).

@ojw28
Copy link
Contributor

ojw28 commented May 8, 2017

In that case it sounds like things are working as intended.

@andrewlewis did find some incorrect rate/pitch adjustment logic in the Sonic library, which we've fixed in 631cce9. Apparently it does sound a little better with the fix, so give that a try and see if it helps! The fix has also been merged into Sonic, and should be merged into Android O as well.

@ojw28 ojw28 closed this as completed May 8, 2017
@google google locked and limited conversation to collaborators Sep 6, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants