forked from RustAudio/dasp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This adds a new crate for working with dynamic audio graphs. From the new docs: > `dasp_graph` is targeted towards users who require an efficient yet > flexible and dynamically configurable audio graph. Use cases might > include virtual mixers, digital audio workstations, game audio systems, > virtual modular synthesizers and related usecases. This work has been a long-time coming and is the result of many discussions in the rust audio community and many lessons learned over the last few years of working with rust and audio. In particular: - the development of and reflection on [dsp-chain](https://crates.io/crates/dsp-chain) and its shortcomings. - The (reasonable) limitations of [dasp_signal](https://crates.io/crates/dasp_signal) when dynamically configuring graphs. - Discussion on the design of audio graphs with @raphlinus at RustAudio/dsp-chain#141. - The development of the [spatial audio server](https://github.com/museumsvictoria/spatial_audio_server). - A recent email discussion with Sami Perttu on DASP and audio graphs. `dasp_graph` is of course not a one-size-fits-all solution. Instead, it is designed specifically to work well alongside (and fill a gap within) the rest of the `dasp` crate ecosystem. Please refer to the "Comparing `dasp_signal`" section of the `dasp_graph` root documentation for a more detailed overview of the design choices between the two, what applications each are best suited toward and how the two best interoperate together. A small suite of node implementations are provided out of the box including a `Delay`, `Sum`, `Pass`, `GraphNode` and `BoxedNode`, all of which can be enabled/disabled via their associated features. Following this, I have some ideas for adding an optional `sync` module to the crate, aimed at controlling and monitoring a dasp graph and it's nodes from a separate thread (i.e. for convenient use alongside a GUI) in a non-dynamically-allocating, non-blocking manner. The work so far has been performed with these plans in mind. The ideas are for the most part based on the discussion at RustAudio/dsp-chain#141. Also, `no_std` support for `dasp_graph` is currently blocked on petgraph support for `no_std`. A PR is open for adding `no_std` support at petgraph/petgraph#238. In the meantime, the `std` feature must be enabled to use the new `dasp::graph` module. This is also noted in the updated docs. For more information about the crate and inner workings feel free to read through the new `dasp_graph` docs. I'm yet to add examples, but hopefully the added tests can give a good idea of how to use the crate in the meantime.
- Loading branch information
1 parent
16f7498
commit 5853e5f
Showing
16 changed files
with
1,167 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[package] | ||
name = "dasp_graph" | ||
description = "A digital audio signal processing graph." | ||
version = "0.11.0" | ||
authors = ["mitchmindtree <[email protected]>"] | ||
readme = "../README.md" | ||
keywords = ["dsp", "audio", "graph", "pcm", "audio"] | ||
license = "MIT OR Apache-2.0" | ||
repository = "https://github.com/rustaudio/dasp.git" | ||
homepage = "https://github.com/rustaudio/dasp" | ||
edition = "2018" | ||
|
||
[features] | ||
default = ["all-nodes"] | ||
all-nodes = ["node-boxed", "node-delay", "node-graph", "node-pass", "node-signal", "node-sum"] | ||
node-boxed = [] | ||
node-delay = ["dasp_ring_buffer"] | ||
node-graph = [] | ||
node-pass = [] | ||
node-signal = ["dasp_frame", "dasp_signal"] | ||
node-sum = ["dasp_slice"] | ||
|
||
[dependencies] | ||
dasp_frame = { version = "0.11", default-features = false, features = ["std"], optional = true } | ||
dasp_ring_buffer = { version = "0.11", default-features = false, features = ["std"], optional = true } | ||
dasp_signal = { version = "0.11", default-features = false, features = ["std"], optional = true } | ||
dasp_slice = { version = "0.11", default-features = false, features = ["std"], optional = true } | ||
petgraph = { version = "0.5", default-features = false } | ||
|
||
[dev-dependencies] | ||
petgraph = { version = "0.5", features = ["stable_graph"] } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
use core::fmt; | ||
use core::ops::{Deref, DerefMut}; | ||
|
||
/// The fixed-size buffer used for processing the graph. | ||
#[derive(Clone)] | ||
pub struct Buffer { | ||
data: [f32; Self::LEN], | ||
} | ||
|
||
impl Buffer { | ||
/// The fixed length of the **Buffer** type. | ||
pub const LEN: usize = 64; | ||
/// A silent **Buffer**. | ||
pub const SILENT: Self = Buffer { | ||
data: [0.0; Self::LEN], | ||
}; | ||
|
||
/// Short-hand for writing silence to the whole buffer. | ||
pub fn silence(&mut self) { | ||
self.data.copy_from_slice(&Self::SILENT) | ||
} | ||
} | ||
|
||
impl Default for Buffer { | ||
fn default() -> Self { | ||
Self::SILENT | ||
} | ||
} | ||
|
||
impl From<[f32; Self::LEN]> for Buffer { | ||
fn from(data: [f32; Self::LEN]) -> Self { | ||
Buffer { data } | ||
} | ||
} | ||
|
||
impl fmt::Debug for Buffer { | ||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { | ||
fmt::Debug::fmt(&self.data[..], f) | ||
} | ||
} | ||
|
||
impl PartialEq for Buffer { | ||
fn eq(&self, other: &Self) -> bool { | ||
&self[..] == &other[..] | ||
} | ||
} | ||
|
||
impl Deref for Buffer { | ||
type Target = [f32]; | ||
fn deref(&self) -> &Self::Target { | ||
&self.data[..] | ||
} | ||
} | ||
|
||
impl DerefMut for Buffer { | ||
fn deref_mut(&mut self) -> &mut Self::Target { | ||
&mut self.data[..] | ||
} | ||
} |
Oops, something went wrong.