0

I'm using libspotify and I spent a lot of time searching in google and in the documentation about the callback method :

music_delivery(sp_session *session, const sp_audioformat *format, const void *frames, int num_frames).

I'm trying to print the content of each frame but the printed values are not really correct (only nan or big negative values).

It seems I don't understand how it works...

Is someone able to help me ?

Thanks a lot !

Sébastien.

Sébastien
  • 321
  • 2
  • 10

1 Answers1

1

The format tells you how the audio is formatted: sp_audioformat

I think the only current format is 16-bit signed pcm samples. There might be one or two channels. So if there are two channels, each frame consists of two consecutive 16-bit signed integers. The frames pointer points to the start of a contiguous array of such frames, with a number of elements equal to num_frames. I don't know how you're getting NaN - only floating point types can be NaN, and you shouldn't have floating point types involved here at all.

You can see an example of implementing the music_delivery callback in jukebox.c.

Weeble
  • 17,058
  • 3
  • 60
  • 75
  • Hi Weeble, thank you for your answer, other times when I was getting pcm frames, I got one float for the left channel and one other for the right one (if there is two channels), so I was trying to cast the void * into a float *, but yep, I try with SInt16 and it seems it works :-) – Sébastien Jul 12 '13 at 07:57