#audio #network #eurorack

bin+lib open-sound-module

A crate providing a client for the Rebel Tech Open Sound Module

1 unstable release

0.1.0 Sep 28, 2019

#258 in #network

MPL-2.0 license

34KB
707 lines

open-sound-module

An unofficial library providing tools for working with Rebel Tech's Open Sound Module.

cv

The cv module provides types for creating and working with control voltage messages.

extern crate open_sound_module;

use std::io::Read;
use open_sound_module::{CvMessage, CvAddress};
  
fn main() -> Result<(), failure::Error> {
    let mut msg = CvMessage::new(CvAddress::A, -0.3);
    let bytes = msg.to_vec();
    let mut buf: [u8; 1024] = [0; 1024];
    let n = msg.read(&mut buf)?;
    assert!(n == 20);
    Ok(())  
}

trigger

The trigger module provides types for creating and working with trigger messages.

extern crate open_sound_module;

use std::io::Read;
use open_sound_module::{TriggerMessage, TriggerAddress};
  
fn main() -> Result<(), failure::Error> {
    let mut msg = TriggerMessage::new(TriggerAddress::B, 1);
    let bytes = msg.to_vec();
    let mut buf: [u8; 1024] = [0; 1024];
    let n = msg.read(&mut buf)?;
    assert!(n == 20);
    Ok(())  
}

sequencer

The sequencer module provides an OscMessageSequencer trait built on Iterator, that can be used to send a series of control voltage and trigger messages. It also includes several impementations using sample::signal that represent some useful waveforms.

extern crate open_sound_module;

use open_sound_module::OscMessageSequence;
use open_sound_module::SineSequence;
use open_sound_module::CvAddress;
use std::time;

fn main() -> Result<(), failure::Error> {
    let rate = 4.0;
    let hz = 1.0;
    let seconds = time::Duration::from_secs(30);
    let mut noise = SineSequence::new(CvAddress::A, rate, hz, seconds);
    let _msg = noise.next();
    let _delay = noise.delay();
    Ok(())  
}

client

The client module provides a Client type to simplify sending cv and trigger messages over UDP in Open Sound Control protocol.

extern crate open_sound_module;

use open_sound_module::Client;
use open_sound_module::CvAddress;
use open_sound_module::OscMessage;
use open_sound_module::NoiseSequence;
use std::time;

fn main() -> Result<(), failure::Error> {
  let client = Client::new("127.0.0.1:8888".to_string())?;

  let msg = CvMessage::new(CvAddress::B, -1.0);
  client.send_osc_message(OscMessage::CvMessage(msg))?;

  let seed = 0;
  let rate = 4.0;
  let seconds = time::Duration::from_secs(1);
  let mut noise = NoiseSequence::new(CvAddress::A, seed, rate, seconds);
  client.send_sequence(&mut noise)?;
  Ok(())
}

Dependencies

~4MB
~70K SLoC