Code Monkey home page Code Monkey logo

ogaboga's Introduction

OgaBoga

license Build Status

Ogaboga is a syntheziser library written in rust based on the audio output library cpal, it's very dumb and you shouldn't really use it if you don't like to do fun stuff that's not terribly optimized.

It consists of a pulse modulator that takes an envelope and a waveform and can ouput a pulse based on that envelope.

The waveform is simply a function that takes a clock that will be the deltatime modulus the common period 2ฯ€ and outputs a waveform accordingly, some examples like square, triangle and sawtooth are included.

A single voice will run in its own thread, so you'll need a voice pool to handle the communication between threads.

Examples

See the examples/ directory in the source.

To run the examples, just check out the source and execute cargo run --example in the root directory:

$ git clone https://github.com/isidornygren/ogaboga.git
$ cd ogaboga
$ cargo run --example random

Basic project example

Basic project that initiates a voice pool, and starts a loop that will pulse a random tone every second.

extern crate noise;
extern crate ogaboga;
extern crate rand;

use ogaboga::{Envelope, Voice, VoiceEvent, VoicePoolBuilder};
use rand::Rng;
use std::{thread, time};

fn main() {
    // Initiate the voice pool that we will initiate voices in
    let mut voice_pool = VoicePoolBuilder::new()
        .with_voice(Voice::new(&f32::sin, Envelope::new(0.5, 0.5, 0.5, 0.5)))
        .build();

    loop {
        let sleep_time = time::Duration::from_millis(1000);
        thread::sleep(sleep_time);
        voice_pool
            .send(
                VoiceEvent::ChangeFreq(440.0 + rand::thread_rng().gen::<f32>() * 220.0),
                0,
            )
            .unwrap();
        voice_pool.send(VoiceEvent::Pulse, 0).unwrap();
    }
}

TODO

  • Remove sample rate dependency on voice creation, as the format is deduced during thread creation.
  • Tests
  • Integrate Travis
  • Periodic 1D noice function (kinda done)
  • Rethink abstractions and fix library linking
  • Example(s)
  • Documentation

ogaboga's People

Contributors

isidornygren avatar

Watchers

 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.