Crates.io | open-sound-module |
lib.rs | open-sound-module |
version | 0.1.0 |
source | src |
created_at | 2019-09-28 14:25:19.043652 |
updated_at | 2019-09-28 14:25:19.043652 |
description | A crate providing a client for the Rebel Tech Open Sound Module |
homepage | |
repository | https://gitlab.com/taotetek/open-sound-module |
max_upload_size | |
id | 168443 |
size | 64,578 |
An unofficial library providing tools for working with Rebel Tech's Open Sound Module.
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(())
}
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(())
}
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(())
}
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(())
}