Skip to content

Commit 5591e03

Browse files
committed
Fixes #12 and #11
1 parent 0d48520 commit 5591e03

File tree

1 file changed

+45
-10
lines changed

1 file changed

+45
-10
lines changed

src/lib.rs

Lines changed: 45 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ impl Plugin for Gain {
240240

241241
let sync_response = ui.checkbox(&mut sync_var.lock(), "Sync").on_hover_text("Lock drawing to timing");
242242
let alt_sync = ui.checkbox(&mut alt_sync.lock(), "Alt. Sync").on_hover_text("Try this if Sync doesn't work");
243-
let timing = ui.add(widgets::ParamSlider::for_param(&params.sync_timing, setter).with_width(60.0));
243+
let timing = ui.add(widgets::ParamSlider::for_param(&params.sync_timing, setter).with_width(60.0)).on_hover_text("Refresh interval when sync enabled");
244244

245245
let dir_response = ui.checkbox(&mut dir_var.lock(), "Flip").on_hover_text("Flip direction of oscilloscope");
246246

@@ -250,6 +250,17 @@ impl Plugin for Gain {
250250
// Reset our line on change
251251
if sync_response.clicked() || dir_response.clicked() || alt_sync.clicked() || timing.changed()
252252
{
253+
// Keep same direction when syncing (Issue #12)
254+
if sync_response.clicked(){
255+
// If flip selected already, it should be deselected on this click
256+
if *dir_var.lock() {
257+
*dir_var.lock() = false;
258+
}
259+
// If flip not selected, it should now be selected
260+
else {
261+
*dir_var.lock() = true;
262+
}
263+
}
253264
sum_line = Line::new(PlotPoints::default());
254265
aux_line = Line::new(PlotPoints::default());
255266
line = Line::new(PlotPoints::default());
@@ -394,19 +405,43 @@ impl Plugin for Gain {
394405
// This should still play well with other DAWs using this timing
395406
current_beat = ((current_beat + 0.036) * 100.0 as f64).round() / 100.0 as f64;
396407
let current_bar = current_beat as i64;
397-
// Tracks based off beat number for other daws - this is a mutex instead of atomic for locking
398-
if *self.alt_sync_beat.lock() != current_bar {
399-
self.in_place_index = Arc::new(AtomicI32::new(0));
400-
self.skip_counter = 0;
401-
*self.alt_sync_beat.lock() = current_bar;
408+
// Added in Issue #11
409+
match self.params.sync_timing.value() {
410+
BeatSync::Bar => {
411+
// Tracks based off beat number for other daws - this is a mutex instead of atomic for locking
412+
if *self.alt_sync_beat.lock() != current_bar && current_bar % 4 == 0 {
413+
self.in_place_index = Arc::new(AtomicI32::new(0));
414+
self.skip_counter = 0;
415+
*self.alt_sync_beat.lock() = current_bar;
416+
}
417+
},
418+
BeatSync::Beat => {
419+
// Tracks based off beat number for other daws - this is a mutex instead of atomic for locking
420+
if *self.alt_sync_beat.lock() != current_bar {
421+
self.in_place_index = Arc::new(AtomicI32::new(0));
422+
self.skip_counter = 0;
423+
*self.alt_sync_beat.lock() = current_bar;
424+
}
425+
},
402426
}
403427
} else {
404428
// Works in FL Studio but not other daws, hence the previous couple of lines
405429
current_beat = (current_beat * 10000.0 as f64).round() / 10000.0 as f64;
406-
if current_beat % 1.0 == 0.0 {
407-
// Reset our index to the sample vecdeques
408-
self.in_place_index = Arc::new(AtomicI32::new(0));
409-
self.skip_counter = 0;
430+
match self.params.sync_timing.value() {
431+
BeatSync::Bar => {
432+
if current_beat % 4.0 == 0.0 {
433+
// Reset our index to the sample vecdeques
434+
self.in_place_index = Arc::new(AtomicI32::new(0));
435+
self.skip_counter = 0;
436+
}
437+
},
438+
BeatSync::Beat => {
439+
if current_beat % 1.0 == 0.0 {
440+
// Reset our index to the sample vecdeques
441+
self.in_place_index = Arc::new(AtomicI32::new(0));
442+
self.skip_counter = 0;
443+
}
444+
},
410445
}
411446
}
412447
}

0 commit comments

Comments
 (0)