3 basic oscillators

This commit is contained in:
2026-03-10 22:45:52 -04:00
commit 61747da879
5 changed files with 114 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
/target

86
Cargo.lock generated Normal file
View File

@@ -0,0 +1,86 @@
# This file is automatically @generated by Cargo.
# It is not intended for manual editing.
version = 4
[[package]]
name = "dasp"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7381b67da416b639690ac77c73b86a7b5e64a29e31d1f75fb3b1102301ef355a"
dependencies = [
"dasp_frame",
"dasp_sample",
"dasp_signal",
"dasp_window",
]
[[package]]
name = "dasp_frame"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b2a3937f5fe2135702897535c8d4a5553f8b116f76c1529088797f2eee7c5cd6"
dependencies = [
"dasp_sample",
]
[[package]]
name = "dasp_interpolate"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7fc975a6563bb7ca7ec0a6c784ead49983a21c24835b0bc96eea11ee407c7486"
dependencies = [
"dasp_frame",
"dasp_ring_buffer",
"dasp_sample",
]
[[package]]
name = "dasp_peak"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5cf88559d79c21f3d8523d91250c397f9a15b5fc72fbb3f87fdb0a37b79915bf"
dependencies = [
"dasp_frame",
"dasp_sample",
]
[[package]]
name = "dasp_ring_buffer"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "07d79e19b89618a543c4adec9c5a347fe378a19041699b3278e616e387511ea1"
[[package]]
name = "dasp_sample"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0c87e182de0887fd5361989c677c4e8f5000cd9491d6d563161a8f3a5519fc7f"
[[package]]
name = "dasp_signal"
version = "0.11.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "aa1ab7d01689c6ed4eae3d38fe1cea08cba761573fbd2d592528d55b421077e7"
dependencies = [
"dasp_frame",
"dasp_interpolate",
"dasp_peak",
"dasp_ring_buffer",
"dasp_sample",
]
[[package]]
name = "dasp_window"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99ded7b88821d2ce4e8b842c9f1c86ac911891ab89443cc1de750cae764c5076"
dependencies = [
"dasp_sample",
]
[[package]]
name = "synthesis"
version = "0.1.0"
dependencies = [
"dasp",
]

7
Cargo.toml Normal file
View File

@@ -0,0 +1,7 @@
[package]
name = "synthesis"
version = "0.1.0"
edition = "2024"
[dependencies]
dasp = { version = "0.11.0", default-features = false, features = ["signal", "window"] }

3
rust-toolchain.toml Normal file
View File

@@ -0,0 +1,3 @@
[toolchain]
channel = "nightly"

17
src/lib.rs Normal file
View File

@@ -0,0 +1,17 @@
#![no_std]
use dasp::signal::{self, ConstHz, Saw, Sine, Square};
pub fn square_oscillator(sample_rate: f64, freq: f64) -> Square<ConstHz> {
signal::rate(sample_rate).const_hz(freq).square()
}
pub fn sine_oscillator(sample_rate: f64, freq: f64) -> Sine<ConstHz> {
signal::rate(sample_rate).const_hz(freq).sine()
}
pub fn saw_oscillator(sample_rate: f64, freq: f64) -> Saw<ConstHz> {
signal::rate(sample_rate).const_hz(freq).saw()
}
// TODO: Custom triangle wave oscilator