-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clock module #28
base: master
Are you sure you want to change the base?
Clock module #28
Conversation
@@ -43,3 +44,10 @@ pub fn clamp<T: PartialOrd>(min: T, max: T, val: T) -> T { | |||
val | |||
} | |||
} | |||
|
|||
pub fn extract_callback_float_value(event: ChangeData) -> Option<f64> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
happy for suggestions on name/implementation of this
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on pulling this one out to utils
pub type SampleSeq = u64; | ||
pub type Ms = f64; | ||
pub fn sample_seq_duration_ms(sample_rate: usize, first: SampleSeq, last: SampleSeq) -> Ms { | ||
(last - first) as f64 / sample_rate as f64 * 1000.0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also interested in any feedback here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you have to put the output into the input if you want feedback 🥁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of changing this function to return a value in seconds? Mixlab mostly uses seconds or samples as timing units, and I notice that in Clock we're dividing this value by 1000.0 before using it anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Few things, but otherwise good to go
html! { | ||
<> | ||
<label for={&bpm_id}>{"BPM"}</label> | ||
<input type="number" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bjeanes taught me today that inputs don't actually need ids to be used with labels. We can actually wrap the <label>
tag around <input>
. I haven't updated the rest of the code yet, but we can start doing that here?
@@ -43,3 +44,10 @@ pub fn clamp<T: PartialOrd>(min: T, max: T, val: T) -> T { | |||
val | |||
} | |||
} | |||
|
|||
pub fn extract_callback_float_value(event: ChangeData) -> Option<f64> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 on pulling this one out to utils
let current_beat_elapsed_percent = 1.0 / beats_per_second * current_beat_elapsed_seconds; | ||
|
||
// For the first 25% of the beat, output high, otherwise, output low | ||
if current_beat_elapsed_percent < 0.25 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you call this frac
or something rather than percent
?
pub type SampleSeq = u64; | ||
pub type Ms = f64; | ||
pub fn sample_seq_duration_ms(sample_rate: usize, first: SampleSeq, last: SampleSeq) -> Ms { | ||
(last - first) as f64 / sample_rate as f64 * 1000.0 | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you think of changing this function to return a value in seconds? Mixlab mostly uses seconds or samples as timing units, and I notice that in Clock we're dividing this value by 1000.0 before using it anyway
Co-Authored-By: Charlie Somerville <[email protected]>
No description provided.