Skip to content

Commit

Permalink
reset value for gui smooth is EPSILON
Browse files Browse the repository at this point in the history
  • Loading branch information
magnetophon committed Nov 16, 2024
1 parent 2e9e016 commit cbe032c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
7 changes: 4 additions & 3 deletions src/editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -472,6 +472,7 @@ impl DelayGraph {
params.map(move |params| {
let current_tap_value = params.current_tap.load(Ordering::SeqCst);
match current_tap_value {
// 0 => "tap a rhythm!".to_string(),
0 => String::new(),
1 => "1 tap".to_string(),
tap_nr => format!("{tap_nr} taps"),
Expand Down Expand Up @@ -508,10 +509,10 @@ impl DelayGraph {
}

/// Smoothly updates the value stored within an AtomicF32 based on a target value.
/// If the current value is f32::MIN, it initializes with the target value.
/// If the current value is f32::EPSILON, it initializes with the target value.
fn gui_smooth(target_value: f32, atomic_value: &AtomicF32) -> f32 {
// Check if current value is f32::MIN and initialize if necessary
if atomic_value.load(Ordering::SeqCst) == f32::MIN {
// Check if current value is f32::EPSILON and initialize if necessary
if atomic_value.load(Ordering::SeqCst) == f32::EPSILON {
atomic_value.store(target_value, Ordering::SeqCst);
}

Expand Down
12 changes: 6 additions & 6 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1260,17 +1260,17 @@ impl Del2 {

self.params
.previous_time_scaling_factor
.store(f32::MIN, Ordering::SeqCst);
.store(f32::EPSILON, Ordering::SeqCst);
self.params
.previous_first_note_height
.store(f32::MIN, Ordering::SeqCst);
.store(f32::EPSILON, Ordering::SeqCst);
self.params
.previous_panning_center_height
.store(f32::MIN, Ordering::SeqCst);
.store(f32::EPSILON, Ordering::SeqCst);
for i in 0..NUM_TAPS {
self.params.previous_note_heights[i].store(f32::MIN, Ordering::SeqCst);
self.params.previous_pan_foreground_lengths[i].store(f32::MIN, Ordering::SeqCst);
self.params.previous_pan_background_lengths[i].store(f32::MIN, Ordering::SeqCst);
self.params.previous_note_heights[i].store(f32::EPSILON, Ordering::SeqCst);
self.params.previous_pan_foreground_lengths[i].store(f32::EPSILON, Ordering::SeqCst);
self.params.previous_pan_background_lengths[i].store(f32::EPSILON, Ordering::SeqCst);
}

self.start_release_for_all_delay_taps(self.sample_rate);
Expand Down

0 comments on commit cbe032c

Please sign in to comment.