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

Loudness related thing support #60

Closed
wants to merge 3 commits into from

Conversation

apple502j
Copy link
Contributor

This adds LoudnessHandler, which is mostly copy-paste from scratch-audio. Also, adds Project.fireGreaterThanTrigger and Trigger.getOption/Trigger.castOption as well as Trigger.executed. In terms of blocks, it adds loudness and when () > () trigger.

@PullJosh
Copy link
Collaborator

I see you've updated this so it can be merged! I'm excited to take a close look at this PR soon. :)

Copy link
Collaborator

@adroitwhiz adroitwhiz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a few questions about the implementation, particularly the way that "greater than" triggers are implemented.

rms = Math.max(rms, this._lastValue * 0.6);
}
this._lastValue = rms;
rms *= 1.63;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be missing a lot of explanatory comments from Scratch's implementation.

this.fireGreatherThanTrigger(Trigger.LOUDNESS_GREATER_THAN);
}
this._prevLoudness = this.loudnessHandler.loudness;
this.fireGreatherThanTrigger(Trigger.TIMER_GREATER_THAN);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Scratch seems to implement "edge-activated hats" (what we call "greater-than triggers" here) a bit differently--every step, it evaluates the predicate of the hat (e.g. "is loudness greater than N? is timer greater than N?") which returns either a true or false value. It fires those hat blocks if the predicate evaluates to true and it evaluated to false on the previous step (the predicate is on a rising edge).

This seems like it'd require less per-trigger logic, and the predicate logic can be encapsulated more cleanly. Would that be worth doing?

@@ -305,6 +304,10 @@ class SpriteBase {
get answer() {
return this._project.answer;
}

async loudness() {
return this._project.loudnessHandler.getLoudness();
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

None yet

3 participants