Working base

This commit is contained in:
2026-03-13 21:57:10 +01:00
parent 092fb0191f
commit 866a5dd501
23 changed files with 1050 additions and 321 deletions

7
oxydsp-dsp/Cargo.toml Normal file
View File

@ -0,0 +1,7 @@
[package]
name = "oxydsp-dsp"
version = "0.1.0"
edition = "2024"
[dependencies]
oxydsp-flowgraph = {path = "../oxydsp-flowgraph/"}

2
oxydsp-dsp/src/blocks.rs Normal file
View File

@ -0,0 +1,2 @@
pub mod math;
pub mod utilities;

View File

@ -0,0 +1 @@
pub mod basic;

View File

@ -0,0 +1,61 @@
use std::ops::Add;
use oxydsp_flowgraph::{
BlockIO,
block::{Block, BlockResult},
edge::{In, Out, PopIterable, stream},
};
#[derive(BlockIO)]
pub struct Adder<Ia, Ib, O>
where
Ia: Add<Ib, Output = O> + 'static,
Ib: 'static,
O: 'static,
{
#[input]
input_a: In<Ia>,
#[input]
input_b: In<Ib>,
#[output]
output: Out<O>,
}
impl<Ia, Ib, O> Adder<Ia, Ib, O>
where
Ia: Add<Ib, Output = O> + 'static,
Ib: 'static,
O: 'static,
{
pub fn new(input_a: In<Ia>, input_b: In<Ib>) -> (Self, In<O>)
{
let (output, added) = stream();
(
Self {
input_a,
input_b,
output,
},
added,
)
}
}
impl<Ia, Ib, O> Block for Adder<Ia, Ib, O>
where
Ia: Add<Ib, Output = O> + 'static,
Ib: 'static,
O: 'static,
{
fn work(&mut self) -> BlockResult
{
self.output.push_iter(
(&mut self.input_a, &mut self.input_b)
.pop_iter()
.map(|(a, b)| a + b),
);
BlockResult::Ok
}
}

View File

@ -0,0 +1 @@
pub mod iter;

View File

@ -0,0 +1,46 @@
use oxydsp_flowgraph::{
BlockIO,
block::{Block, BlockResult},
edge::{In, Out, stream},
};
#[derive(BlockIO)]
pub struct IterSource<I: Iterator>
where
I::Item: 'static,
{
iter: I,
#[output]
output: Out<I::Item>,
}
impl<I> IterSource<I>
where
I: Iterator,
I::Item: 'static,
{
pub fn new(iter: I) -> (Self, In<I::Item>)
{
let (output, items) = stream();
(Self { iter, output }, items)
}
}
impl<I> Block for IterSource<I>
where
I: Iterator,
I::Item: 'static,
{
fn work(&mut self) -> oxydsp_flowgraph::block::BlockResult
{
if self.output.push_iter(&mut self.iter)
{
BlockResult::Ok
}
else
{
BlockResult::Terminated
}
}
}

1
oxydsp-dsp/src/lib.rs Normal file
View File

@ -0,0 +1 @@
pub mod blocks;

1
oxydsp-dsp/src/main.rs Normal file
View File

@ -0,0 +1 @@
fn main() {}