Does the LibSpotify on android gives PCM in different format than Linux

561 views Asked by At

I am trying to integrate libspotify on Android. It looks like the raw PCM data I obtained from android is different from the raw PCM I obtained on ubuntu.

For testing purposes I tried to store the PCM file and played it using audacity. In Ubuntu it is perfect, but in Android the play is choppy and slow.

I tried printing the first 10 int16_t of the data, it looks completely different:

Android - -457 463 62 635 492 742 968 246 909 179

Ubuntu - -944 960 128 1318 1020 1538 2008 510 1885 353

Rough analysis shows each int16_t value is 2.7 times more than what I get in Android.

My question is how to obtain the same PCM data that I obtain in Ubuntu in Android also.

1

There are 1 answers

2
iKenndac On

You're never guaranteed the same PCM data, especially across platforms.

  • libspotify may be using different bitrate settings. Sometimes if it has a high quality version cached it might use that even if the bitrate setting is lower.

  • libspotify uses different decoders across platforms for performance reasons.

  • libspotify may be performing normalisation on the audio, and normalisation is only available on some platforms for performance reasons.

If you require exact PCM matching across sessions, libspotify is not the solution for you - it's designed as a consumer music service rather than a professional audio provider.