Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open

Clock module #28

wants to merge 5 commits into from

Conversation

jacobh
Copy link
Collaborator

@jacobh jacobh commented Apr 9, 2020

No description provided.

@jacobh jacobh marked this pull request as ready for review April 9, 2020 12:58
@jacobh jacobh requested a review from haileys April 9, 2020 12:58
@@ -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> {
Copy link
Collaborator Author

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

Copy link
Owner

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

Comment on lines +22 to +26
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
}
Copy link
Collaborator Author

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

Copy link
Collaborator

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 🥁

Copy link
Owner

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

Copy link
Owner

@haileys haileys left a 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"
Copy link
Owner

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> {
Copy link
Owner

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 {
Copy link
Owner

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?

src/module/clock.rs Outdated Show resolved Hide resolved
Comment on lines +22 to +26
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
}
Copy link
Owner

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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants