The siraph
crate is a node-based digital signal processing crate.
Features
-
nodes: Adds the
nodes
module that contains a couple of basic useful nodes asMap
orConst
. This feature is enabled by default. -
math: Adds the
nodes::math
module that contains useful nodes related to mathematics asAdd
orOscillator
. This feature depends on thenum-traits
crate and thenodes
feature. -
random: Adds the
nodes::random
module that contains useful nodes related to random number generators asSampleAndHold
. This feature depends on therand
crate and thenodes
feature.
Example
// Using the `nodes` feature
use Graph;
use ;
let mut graph = new;
// First, we can insert nodes into the graph.
// This node just takes the values given by an iterator
// and send them into its output.
let from_iter = graph.insert;
// This node infinitly outputs 4 `false` then 1 `true`.
let pulse = graph.insert;
// This one wait for a pulse and holds the value its has in its input
// until a new pulse.
let hold = graph.insert;
// Simply uses the given function to maps its input to its output.
let map = graph.insert;
// Then, we can plug them together.
graph.plug.unwrap;
graph.plug.unwrap;
graph.plug.unwrap;
// Once our graph is done, we can retreive values from it using a sink.
let mut sink = graph.sink.unwrap;
// Here is a simple schem of what we have so far
/*
+------------------------+
| from_iter output i32 >----+ +------------------------------+
+------------------------+ +---> input | +----------------------+
| hold output i32 >--> input map output > sink
+---> resample | +----------------------+
+---------------------+ | +------------------------------+
| pulse output bool >-------+
+---------------------+
*/
// Values can be retreived with the `next` function on the sink
// Once again, the `()` is the context provided to the nodes.
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
assert_eq!;
// The sink is an iterator
for in sink.take.enumerate
Create your own nodes
You can create your own nodes using the Node
trait.
use ;
// Our node will take an input and smooth it using a basic interpolation function.
Todo List
- Load VSTs as nodes