1
0
Fork
You've already forked faun
0
A high-level C audio library. https://wickedsmoke.codeberg.page/faun_doc/
C 90.5%
Objective-C 3.6%
Shell 3.3%
Brainfuck 1.7%
Makefile 0.9%
Find a file
2025年11月01日 18:16:44 -04:00
.supplement Initial import. 2022年04月01日 10:06:30 -04:00
dist cbuild: Use make-deb 1.1 for Debian build. 2025年11月01日 18:16:44 -04:00
example Add crossfade example. 2024年12月01日 14:07:56 -05:00
jni Bump version to 0.2.3. 2025年05月08日 11:26:05 -04:00
support Update foxenflac to the latest version (now licensed as LGPLv2.1+). 2025年03月29日 21:47:46 -04:00
test Fix FLAC reader segfault with 22KHz sample rates. 2025年10月07日 01:22:47 -04:00
.gitignore Initial import. 2022年04月01日 10:06:30 -04:00
configure Update foxenflac to the latest version (now licensed as LGPLv2.1+). 2025年03月29日 21:47:46 -04:00
faun.c Add FC_PAUSE command. Change FC_STOP to deactivate source. 2025年10月19日 00:16:08 -04:00
faun.def Add faun_idleSource(). 2024年12月06日 14:58:50 -05:00
faun.h Add FC_PAUSE command. Change FC_STOP to deactivate source. 2025年10月19日 00:16:08 -04:00
faun_test.c Add FC_PAUSE command. Change FC_STOP to deactivate source. 2025年10月19日 00:16:08 -04:00
fcode.b Replace opcodes FO_STREAM_ONCE & FO_STREAM_LOOP with FO_START_STREAM. 2024年11月24日 15:46:49 -05:00
FlacReader.c Fix FLAC reader segfault with 22KHz sample rates. 2025年10月07日 01:22:47 -04:00
internal.h Add AAudio system interface. 2022年07月20日 19:40:35 -04:00
LICENSE Use MIT license. 2024年11月29日 18:01:48 -05:00
Makefile Add android build script. 2025年07月09日 16:26:00 -04:00
project.b Bump version to 0.2.3. 2025年05月08日 11:26:05 -04:00
README.md Read FLAC with libFLAC. 2024年11月29日 17:54:39 -05:00
sys_aaudio.c Add AAudio system interface. 2022年07月20日 19:40:35 -04:00
sys_dsound.c Add sys_ prefix to system interface files. 2022年07月01日 22:13:37 -04:00
sys_pulseaudio.c sys_pulseaudio.c: Use PulseAudio Asynchronous API. 2023年06月13日 11:02:36 -04:00
sys_wasapi.c sys_wasapi.c: Add LAG_ADJUST to increase buffer size. 2025年05月08日 11:26:05 -04:00
write_test.c sys_wasapi.c: Attempt to fix sound break-up on a Windows 10 system. 2025年01月04日 11:31:40 -05:00

Faun Audio Library

Faun is a high-level C API for playback of sound & music in games & demos. It is a modestly sized library designed to use pre-packaged audio and is not intended for synthesizer or audio manipulation applications. The shared library is about half the size the SDL 2 & Allegro 5 mixer libraries.

The following audio formats can be played:

  • FLAC
  • Ogg Vorbis
  • rFX (sfxr synthesizer)
  • WAVE

The following operating systems are supported:

  • Android (via AAudio)
  • Linux (via PulseAudio)
  • Windows (via Windows Audio Session)

Features include:

  • Support for audio embedded in larger files.
  • Playback of stream fragments.
  • Fading volume in & out.
  • Source playback from a queue of buffers.
  • Signaling when a sound is finished playing.
  • A bytecode language for running simple playback sequences.

At this time the library does not support:

  • Sample rates other than 44100 & 22050 Hz.
  • More than two channels.
  • 3D audio.

NOTE: This library is under development and the API is subject to change.

Example usage:

#include <faun.h>
int main() {
 FaunSignal sig;
 faun_startup(64, 8, 2, 0, "Faun Test");
 // Start some music.
 faun_playStream(8, "path/to/music.ogg", 0, 0,
 FAUN_PLAY_ONCE | FAUN_SIGNAL_DONE);
 // Load and play a sound.
 faun_loadBuffer(0, "path/to/sound.flac", 0, 0);
 faun_playSource(0, 0, FAUN_PLAY_ONCE);
 // Wait for music to finish.
 faun_waitSignal(&sig);
 faun_shutdown();
}

Resource Management

Sources are used to play audio samples completely stored in memory buffers. Streams are used to play longer sounds by continually decoding small parts of the file into memory. While the stream implemention uses sources & buffers internally, for the API user streams are treated as separate resources.

The maximum number of source buffers, sources, & streams that can be used by a program is set once using faun_startup(). This reserves slots which are specified by index (zero to limit-1) which may be used as desired.

Sources and Buffers

Before a source can play, buffers must be loaded using faun_loadBuffer(). The faun_playSource() function can then be used to play 1-3 buffers in series as a single sound.

Streams

The faun_playStream() & faun_playStreamPart() functions are used to play streams.

NOTE: Currently only Ogg Vorbis files can be streamed.

Build Instructions

Linux Dependencies

The FLAC, Vorbis and PulseAudio libraries (with headers) must be installed.

Fedora:

sudo dnf install flac-devel libvorbis-devel pulseaudio-libs-devel

Debian & Ubuntu:

sudo apt install libflac-dev libvorbis-dev libpulse-dev

Build for Linux

The following commands will build and install the shared Faun library. Use the --static configure option to build a static library.

./configure --prefix /usr
make
sudo make install