Code Monkey home page Code Monkey logo

blipkit's Introduction

BlipKit

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

Basic Example

This code demonstrates the basic steps to generate audio data of a square wave in the note A with enabled tremolo effect:

// Context object
BKContext ctx;

// Initialize context with 2 channels (stereo)
// and a sample rate of 44100 Hz
BKContextInit (& ctx, 2, 44100);

// Track object to generate the waveform
BKTrack track;

// Initialize track with square wave
// By default, the square wave has a duty cycle of 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 audio data buffer
// As there are 2 channels used, the buffer actually must be
// two times 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
// 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 ./autogen.sh

Next execute configure in the base directory:

./configure

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

make

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

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.

# in `examples`

make tone
make divider
make stereo
make scratch
make waveform
make envelope

Finally, run examples like this:

# in `examples`

./tone

License

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

blipkit's People

Contributors

detomon avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.