0

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.

Community
  • 1
  • 1
Karthik
  • 2,282
  • 2
  • 22
  • 23

1 Answers1

1

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.

iKenndac
  • 18,730
  • 3
  • 35
  • 51
  • Thanks for the response, as far as the bitrate and format is concerned, Spotify says it uses 16 Bit LPCM LE , and am receiving same bitrate in both the platforms that is 44100 with 2 channels. I need to find a way to obtain a correct PCM , without any choppy or slow pace. – Karthik Dec 16 '13 at 16:30
  • I mean the bitrate of the source material - see sp_session_preferred_bitrate(). Also, libspotify doesn't deliver "choppy" or "slow" PCM data - once enough has been downloaded to start playing the song, data delivery will start and the data you get is fully formed. If your sound is choppy, your problem is elsewhere - check your sound driver code. – iKenndac Dec 16 '13 at 16:49