Skip to content

Commit 4d131d1

Browse files
committed
Add seeded super saw init
1 parent 388d739 commit 4d131d1

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

modules/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "caw_modules"
3-
version = "0.3.0"
3+
version = "0.3.1"
44
description = "Collection of synthesizer modules for the caw synthesizer framework"
55
authors = ["Stephen Sherratt <[email protected]>"]
66
license = "MIT"

modules/src/super_saw.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ use wide::f32x8;
77
#[derive(Debug, Clone, Copy)]
88
pub enum SuperSawInit {
99
Random,
10+
RandomWithSeed(u64),
1011
Const(f32),
1112
}
1213

@@ -124,6 +125,13 @@ where
124125
*x *= mask;
125126
}
126127
}
128+
SuperSawInit::RandomWithSeed(seed) => {
129+
let mut rng = StdRng::seed_from_u64(seed);
130+
for (x, mask) in state_01.iter_mut().zip(mask.iter()) {
131+
*x = rng.gen::<[f32; 8]>().into();
132+
*x *= mask;
133+
}
134+
}
127135
}
128136
Sig(Self {
129137
freq_hz,

0 commit comments

Comments
 (0)