-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from mitchmindtree/graph
Add a `dasp_graph` crate.
- Loading branch information
Showing
18 changed files
with
1,174 additions
and
2 deletions.
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
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.