Skip to content

Commit

Permalink
Merge pull request #1011 from quartiq/sweptsine-state
Browse files Browse the repository at this point in the history
sweptsine: set state directly
  • Loading branch information
jordens authored Feb 4, 2025
2 parents 616042a + 7d495a0 commit e0d9c10
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/hardware/signal_generator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ pub struct Config {
/// Number of half periods (periodic) or samples (sweep and noise), 0 for infinte
length: Leaf<u32>,

/// Sweep: Number of cycles for the first octave
cycles: Leaf<i32>,
/// Sweep: initial state
state: Leaf<i64>,

/// Sweep: Sweep rate
rate: Leaf<i32>,
Expand All @@ -76,7 +76,7 @@ impl Default for Config {
amplitude: Leaf(0.0),
phase: Leaf(0.0),
offset: Leaf(0.0),
cycles: Leaf(1),
state: Leaf(0),
rate: Leaf(0),
length: Leaf(0),
}
Expand Down Expand Up @@ -228,11 +228,8 @@ impl Config {
}
}
Signal::SweptSine => Source::SweptSine {
sweep: AccuOsc::new(Sweep::new(
*self.rate,
((*self.rate * *self.cycles) as i64) << 32,
))
.take(*self.length as _),
sweep: AccuOsc::new(Sweep::new(*self.rate, *self.state))
.take(*self.length as _),
amp,
},
Signal::WhiteNoise => Source::WhiteNoise {
Expand Down

0 comments on commit e0d9c10

Please sign in to comment.