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

Repair stepOffset in sync.flash #88

Merged
merged 1 commit into from
Apr 8, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion renin/src/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@ export class Sync {
this.music = music;
}

/**
* Outputs a number between 0 and 1, signifying the progress between two "flashes", synced to the music.
* "stepStride" denotes the number of steps (subdivisions of a beat) between each flash
* "stepOffset" offsets the flashes from the start of a beat.
*/
flash(frame: number, stepStride: number, stepOffset: number = 0) {
const step = this.stepForFrame(frame);
const startStep = (((step - stepOffset) / stepStride) | 0) * stepStride;
const startStep = (((step - stepOffset) / stepStride) | 0) * stepStride + stepOffset;
const startFrame = this.frameForStep(startStep);
const endFrame = this.frameForStep(startStep + stepStride);
return (frame - startFrame) / (endFrame - startFrame);
Expand Down