#![no_std]
#![forbid(unsafe_code)]
#![doc = include_str!("../README.md")]
mod sine;
mod tuning;
pub mod bytecode;
pub mod midi;
pub mod polyphony;
pub use bytecode::Op;
pub use sine::sine_q15;
pub use tuning::Tuning;
pub trait Dsp<S> {
fn gain(&mut self, input: &[S], level: u8, output: &mut [S]);
fn mix(&mut self, left: &[S], right: &[S], output: &mut [S]);
}
pub trait Process<M = (), S = f32> {
fn inlets(&self) -> &[Port];
fn outlets(&self) -> &[Port];
fn process(&mut self, cx: &mut ProcessContext<'_, '_, M, S>);
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Port {
Message,
Signal,
}
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub struct Event<M> {
pub frame: usize,
pub port: usize,
pub message: M,
}
#[allow(
missing_debug_implementations,
reason = "The event sink is an opaque callback."
)]
pub struct ProcessContext<'call, 'output, M = (), S = f32> {
pub frames: usize,
pub inputs: &'call [&'call [S]],
pub outputs: &'call mut [&'output mut [S]],
pub events: &'call [Event<M>],
pub emit: &'call mut dyn FnMut(Event<M>) -> Result<(), Event<M>>,
}