项目作者: detomon

项目描述 :
C library for creating the beautiful sound of old sound chips
高级语言: C
项目地址: git://github.com/detomon/BlipKit.git
创建时间: 2013-06-29T14:43:13Z
项目社区:https://github.com/detomon/BlipKit

开源协议:Other

下载


BlipKit

Build Status

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: http://blipkit.audio

🎹 Also consider to check out the 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:

  1. // The context object contains the audio buffers.
  2. BKContext ctx;
  3. // The track object generates the waveform.
  4. BKTrack track;
  5. // Initialize context with 2 channels (stereo).
  6. // and a sample rate of 44100 Hz.
  7. BKContextInit(&ctx, 2, 44100);
  8. // Initialize track with square wave.
  9. // By default, the square wave has a duty cycle of 4 (12.5%).
  10. BKTrackInit(&track, BK_SQUARE);
  11. // Set mix and note volume.
  12. BKSetAttr(&track, BK_MASTER_VOLUME, 0.15 * BK_MAX_VOLUME);
  13. BKSetAttr(&track, BK_VOLUME, 1.0 * BK_MAX_VOLUME);
  14. // Set note A in octave 3.
  15. BKSetAttr(&track, BK_NOTE, BK_A_3 * BK_FINT20_UNIT);
  16. // Enable tremolo effect.
  17. BKInt tremolo[2] = { 20, 0.66 * BK_MAX_VOLUME };
  18. BKTrackSetEffect(&track, BK_EFFECT_TREMOLO, tremolo, sizeof(tremolo));
  19. // Attach track to context.
  20. BKTrackAttach(&track, &ctx);
  21. // Define buffer to write audio data to.
  22. // As there are 2 channels used, the buffer must be
  23. // twice the size than number of frames are requested.
  24. BKFrame frames[512 * 2];
  25. // Generate 512 frames, e.g., as they would be requested by an audio output function (SDL).
  26. // Subsequent calls to this function generate the next requested number of frames.
  27. BKContextGenerate(&ctx, frames, 512);
  28. // The channels are interlaced into the buffer in the form: LRLR...
  29. // Which means that the first frame of the left channel is at frames[0],
  30. // 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:

  1. sh ./autogen.sh

Next execute configure in the base directory:

  1. ./configure

Use the --without-sdl option if you don’t want to link against SDL.

  1. ./configure --without-sdl

Then execute make to build libblipkit.a in the src directory:

  1. make

Optionally, you may want to execute to install the library and headers on your system:

  1. sudo make install

Building and Running Examples

All examples use SDL (http://www.libsdl.org) to output sound, so you have to install it first. Execute make examplename to build an example in the examples directory.

  1. # in `examples`
  2. make tone
  3. make divider
  4. make stereo
  5. make scratch
  6. make waveform
  7. make envelope

Finally, run examples like this:

  1. # in `examples`
  2. ./tone

License

This library is distributed under the MIT license. See LICENSE.