pub mod metronome;
pub mod nodes;
pub mod notation;
mod parse;
pub mod pitch;
pub mod stream;
mod sync;
pub mod time;
use std::fmt::Debug;
use std::sync::Arc;
pub use stream::Stream;
pub type Error = Box<dyn std::error::Error + Send + Sync>;
pub type Result<T> = std::result::Result<T, Error>;
pub trait Node: Debug + Send + Sync {
fn process<'a, 'b, 'c>(
&'a self,
inputs: &'b [Stream],
outputs: &'c mut Vec<Stream>,
) -> Result<()>;
}
pub trait FrequencyNode: Node + DynNode {
fn get_frequency(&self) -> Result<f64>;
fn set_frequency(&self, frequency: f64) -> Result<()>;
}
pub trait DynNode {
fn node(self: Arc<Self>) -> Arc<dyn Node>;
}
impl<T> DynNode for T
where
T: 'static + Node,
{
fn node(self: Arc<Self>) -> Arc<dyn Node> {
self
}
}
pub trait DynFrequencyNode {
fn frequency_node(self: Arc<Self>) -> Arc<dyn FrequencyNode>;
}
impl<T> DynFrequencyNode for T
where
T: 'static + FrequencyNode,
{
fn frequency_node(self: Arc<Self>) -> Arc<dyn FrequencyNode> {
self
}
}