This is the xmplayer with sfx support. The music playing is still the same, but now we also have an array of sfx mixers (4 in this example, but you can change it by changing the define in sound.h). You have the following functions (protos in sound.h):
Code: Select all
extern void fill_buffer(int16_t *buffer);
extern uint8_t start_sfx(int8_t *data, uint16_t srate, uint32_t loop_length, uint32_t length, uint8_t volume, uint8_t pan);
extern void update_sfx(uint8_t mix, int32_t srate, int32_t volume, int32_t pan);
extern void stop_sfx(uint8_t mix);
extern uint8_t check_sfx(uint8_t mix);
In the example, press A to start the rain sfx, which loops forever. Press C to stop the rain sfx. Press B to start a punch sfx, which then does a "oof" sfx when the punch is done.
Remember that you can turn down the music volume by repeatedly pressing LEFT. You'll probably have to press it like 24 times to get the volume down low enough to hear the sfx well.
xmplayer-sfx.zip