• R/O
  • HTTP
  • SSH
  • HTTPS

cinnamon: Resumen Repositorio

Cinnamon audio library


Recent Commits RSS

Rev. Tiempo Autor Mensaje
bda8065 2021-07-25 06:38:35 AlaskanEmily devlist Add basic device enumeration API. This is kind of sub-op...
2601fb9 2021-07-25 05:44:29 AlaskanEmily master Update copyright date
9878d19 2020-05-03 06:21:58 AlaskanEmily Fix dumb typo in aucat that makes it crash if it can't op...
46f6635 2020-05-03 05:54:58 AlaskanEmily Fix compiling on OpenBSD for OSS rather than OpenAL
b3cf89a 2020-01-05 08:33:29 AlaskanEmily Add dummy implementation of OSS SoundGetVolume/SoundSetVo...
0ad75b1 2020-01-05 08:33:03 AlaskanEmily Fix formatting of OpenAL backend's implementation of Soun...
097ceff 2020-01-05 08:27:38 AlaskanEmily Add per-sound volume on Cin_Sound
e29fbea 2020-01-05 07:15:45 AlaskanEmily Update copyright years
a3f115b 2020-01-05 07:08:05 AlaskanEmily Add Cin_DriverSupports* API implementation for DirectSoun...
3f9332a 2019-11-15 17:19:52 AlaskanEmily Completed OSS backend

Branches

Nombre Rev. Tiempo Autor Mensaje
devlist bda8065 2021-07-25 06:38:35 AlaskanEmily Add basic device enumeratio...
master 2601fb9 2021-07-25 05:44:29 AlaskanEmily Update copyright date

readme.md

Cinnamon Audio Library

Cinnamon is a cross-platform, lightweight audio library for fully buffered audio. It currently wraps OpenAL and DirectSound, providing a simple interface to play audio with a minimum of external dependencies. Further backends are possible (there is a partial OSS backend).

Implementation Notes

Cinnamon is implemented in C for common code (soft loader, etc). Platforms usually either use C or the most native language for that platform. For instance, Java via JNI on Android, Objective C for OS X, or C++ on Windows.

Cinnamon does not contain any logic to load audio files. You might want to check out a library like libsndfile for a simple method to load a variety of audio formats.

License

Cinnamon is MPL 2.0 licensed, which means that any changes to existing files must be released under the MPL 2.0, but new files (for instance new platform backends) can use different licenses. Any pull requests containing new files will only be accepted if the code is licensed as MPL 2.0, zlib, or public domain.

The mixer code is licensed under the zlib license.

API Usage

You can check the sine_test.c source file for an example of playing audio using Cinnamon.

Most applications will do something similar to the following:

struct Cin_Driver *const driver = malloc(Cin_StructDriverSize());
if(driver == NULL || Cin_CreateDriver(driver) != Cin_eDriverSuccess){
    /* Handle error... */
    abort();
}

/* Load a sound into memory. Cinnamon doesn't provide this capability itself.
 * You can load the sound in parts, see below. */
unsigned sound_size;
const void *sound_data = LoadSound(&sound_size);

/* Create an audio Loader. This is used solely to load the sound, and then will
 * be used to create a playable sound. */
struct Cin_Loader *const loader = malloc(Cin_StructLoaderSize());
if(loader == NULL || Cin_CreateLoader(loader, driver, 44100, 2, Cin_eFormatS16) != Cin_eDriverSuccess){
    /* Handle error... */
    abort();
}

/* Load the sound. If the sound is loaded in parts (as is the case for manually
 * parsing some formats like Ogg) you can call this function multiple times to
 * append more data to the loader. */
Cin_LoaderPut(loader, sound_data, sound_size);

struct Cin_Sound *const sound = malloc(Cin_StructSoundSize());
if(sound == NULL || Cin_LoaderFinalize(loader, sound) != Cin_eLoaderSuccess){
    /* Handle error... */
    abort();
}

/* You can now play your sound. */
Cin_SoundPlay(sound);

/* Obviously Cin_SoundPlay doesn't block, so some other processing can occur
 * here... */

/* Clean up. It is safe to call Cin_SoundStop regardless of if the sound is
 * still playing or not. */
Cin_SoundStop(sound);

Cin_DestroySound(sound);
free(sound);
Cin_DestroyDriver(driver);
free(driver);
Show on old repository browser