Question

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.

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top