Sampleplayer in C API not playing MP3's

Hi there,

I'm running the C API on Windows, building with nmake, and having issues/confusion with the sampleplayer API.

SamplePlayer *sp = pd->sound->sampleplayer->newPlayer();
AudioSample *test = pd->sound->sample->load("sounds/Intro.mp3");
pd->sound->sampleplayer->setSample(sp, test);

Get this error in the log:
SamplePlayer_setSample: non-NULL value required for argument 's'

I'm sure the path is correct, and the following works fine using the FilePlayer.

FilePlayer *fp = pd->sound->fileplayer->newPlayer();
pd->sound->fileplayer->loadIntoPlayer(fp, "sounds/Intro.mp3");
pd->sound->fileplayer->play(fp, 0);

May have to do with me not understanding the purpose / difference between FilePlayer and SamplePlayer. The latter I want to use so I can preload all my sounds into AudioSources at startup rather than loading them within update().

Sorry for the false alarm, I've found my answers are stated clearly in the Lua documentation, but the C docs are quite sparse :smiling_face_with_tear:

2 Likes

I can't believe C is just a skeleton with no notes redirecting to Lua. Thank you for sharing!

1 Like