This example shows how to cross fade two streams.
#include <stdio.h>
#ifdef _WIN32
#include <windows.h>
#define sleep(sec) Sleep((sec)*1000)
#else
#include <unistd.h>
#endif
#define SOURCE_LIMIT 0
#define STREAM_LIMIT 2
#define MUSIC_SI SOURCE_LIMIT
void music_crossfade(const char* streamPath)
{
static int current = 0;
current ^= 1;
if (streamPath) {
faun_playStream(MUSIC_SI + current, streamPath, 0, 0,
}
}
int main()
{
static const char* trackList[] = {
"data/gate_open.ogg",
"data/townes.ogg",
"data/gate_open.ogg",
NULL
};
const char* err = faun_startup(0, SOURCE_LIMIT, STREAM_LIMIT, 0, "Faun Example");
if (err) {
printf("%s\n", err);
return 1;
}
for (const char** track = trackList; *track; ++track) {
music_crossfade(*track);
sleep(4);
}
music_crossfade(NULL);
sleep(2);
faun_shutdown();
return 0;
}
The Faun programmer interface.
@ FAUN_FADE_PERIOD
Duration in seconds for fading in & out.
Definition faun.h:87
@ FC_FADE_OUT
Fade volume to zero from the current play position over the FAUN_FADE_PERIOD.
Definition faun.h:27
@ FAUN_PLAY_ONCE
Used to initiate playback of a source or stream a single time.
Definition faun.h:71
@ FAUN_PLAY_FADE_IN
Increase gain from 0.0 gradually when playing begins.
Definition faun.h:73