pcm-flow

A library for building big synthesizers and effects from small modules. You can write structs implementing the Processor Trait and chain them together in a flexible way. This library is still in early development and it is not advised to use it yet

Usage

Add pcm-flow to your Cargo.toml [dependencies] pcm-flow = "0.3.1"

A simple Program using pcm-flow

This program shows how to use pcm-flow in a very useless but simple way. We define a struct implementing the Processor trait which just takes an input and passes it to its output. Then we make two instances of this struct and chain them together.

``` rust extern crate pcm_flow;

use pcmflow::graph::Graph; use pcmflow::processor::Processor;

fn main() { // create a new graph Struct, it is the main container for our Processors let mut graph = Graph::new(1); // Add two PassThrough structs to the graph and store their IDs in variables let passthrough1 = graph.addprocessor(Box::new(PassThrough{})); let passthrough2 = graph.addprocessor(Box::new(PassThrough{})); // connect the two processors graph.addconnection(&(passthrough1, 0), &(passthrough2, 0)).unwrap(); // add an input to the graph graph.setinputamt(1); // add an output to the graph graph.setoutputamt(1); // connect the input to the first Processor graph.connectinput(0, (passthrough1, 0)).unwrap(); // connect the second Processor to the Output graph.connectoutput(0, (pass_through2, 0)).unwrap(); }

// The struct we define here, takes one input and passes the signal to the output struct PassThrough {}

impl Processor<[f32; 2]> for PassThrough { fn process(&mut self, inputs: &Vecamt(&self) -> usize { 1 } fn outputsamt(&self) -> usize { 1 } } ```