https://github.com/detomon/blipkit
C library for creating the beautiful sound of old sound chips
https://github.com/detomon/blipkit
audio c chiptune library music sdl sound sound-chips tremolo waveform waveforms
Last synced: 6 months ago
JSON representation
C library for creating the beautiful sound of old sound chips
- Host: GitHub
- URL: https://github.com/detomon/blipkit
- Owner: detomon
- License: other
- Created: 2013-06-29T14:43:13.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2025-05-07T16:05:20.000Z (9 months ago)
- Last Synced: 2025-05-31T11:35:22.457Z (8 months ago)
- Topics: audio, c, chiptune, library, music, sdl, sound, sound-chips, tremolo, waveform, waveforms
- Language: C
- Homepage: https://blipkit.audio
- Size: 1.26 MB
- Stars: 38
- Watchers: 5
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: ChangeLog
- License: LICENSE
Awesome Lists containing this project
README
BlipKit
=======
[](https://github.com/detomon/BlipKit/actions/workflows/c.yml)
BlipKit is a C library for creating the beautiful sound of old sound chips.
- Generate waveforms: square, triangle, noise, sawtooth, sine and custom waveforms
- Use an unlimited number of individual tracks
- Use stereo output or up to 8 channels
- Define instruments to create envelopes and other interesting effects
- Use effects: portamento, tremolo, vibrato and some more
- Load multi-channel samples and play them at different pitches
📖 Manual:
🎹 Also consider to check out the [bliplay](https://github.com/detomon/bliplay) project
Basic Example
-------------
This code demonstrates the basic steps to generate audio data of a square wave in the note A with enabled tremolo effect:
```c
// The context object contains the audio buffers.
BKContext ctx;
// The track object generates the waveform.
BKTrack track;
// Initialize context with 2 channels (stereo).
// and a sample rate of 44100 Hz.
BKContextInit(&ctx, 2, 44100);
// Initialize track with square wave.
// By default, the square wave has a duty cycle of 4 (12.5%).
BKTrackInit(&track, BK_SQUARE);
// Set mix and note volume.
BKSetAttr(&track, BK_MASTER_VOLUME, 0.15 * BK_MAX_VOLUME);
BKSetAttr(&track, BK_VOLUME, 1.0 * BK_MAX_VOLUME);
// Set note A in octave 3.
BKSetAttr(&track, BK_NOTE, BK_A_3 * BK_FINT20_UNIT);
// Enable tremolo effect.
BKInt tremolo[2] = { 20, 0.66 * BK_MAX_VOLUME };
BKTrackSetEffect(&track, BK_EFFECT_TREMOLO, tremolo, sizeof(tremolo));
// Attach track to context.
BKTrackAttach(&track, &ctx);
// Define buffer to write audio data to.
// As there are 2 channels used, the buffer must be
// twice the size than number of frames are requested.
BKFrame frames[512 * 2];
// Generate 512 frames, e.g., as they would be requested by an audio output function (SDL).
// Subsequent calls to this function generate the next requested number of frames.
BKContextGenerate(&ctx, frames, 512);
// The channels are interlaced into the buffer in the form: LRLR...
// Which means that the first frame of the left channel is at frames[0],
// the first frame of the right channel at frames[1] and so on...
```
Building the Library
--------------------
First execute `autogen.sh` in the base directory to generate the build system:
```sh
sh ./autogen.sh
```
Next execute `configure` in the base directory:
```sh
./configure
```
Use the `--without-sdl` option if you don't want to link against SDL.
```sh
./configure --without-sdl
```
Then execute `make` to build `libblipkit.a` in the `src` directory:
```sh
make
```
Optionally, you may want to execute to install the library and headers on your system:
```sh
sudo make install
```
Building and Running Examples
-----------------------------
All examples use SDL () to output sound, so you have to install it first. Execute `make examplename` to build an example in the `examples` directory.
```sh
# in `examples`
make tone
make divider
make stereo
make scratch
make waveform
make envelope
```
Finally, run examples like this:
```sh
# in `examples`
./tone
```
License
-------
This library is distributed under the MIT license. See `LICENSE`.