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

Support triggering bar phase/clock every 4/8 bars #798

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

markterm
Copy link

@markterm markterm commented Feb 6, 2025

Support triggering bar phase/clock every 4 or 8 bars in the hosttime module by adding options to the right-click context menu.

(unforunately I don't have a Linux machine to build/test this)

@@ -165,11 +175,25 @@ struct HostTime : TerminalModule {
outputs[kHostTimeBeat].setVoltage(hasBeat ? 10.0f : 0.0f);
outputs[kHostTimeClock].setVoltage(hasClock ? 10.0f : 0.0f);
outputs[kHostTimeBarPhase].setVoltage(barPhase * 10.0f);
outputs[kHostTimeBeatPhase].setVoltage(beatPhase * 10.0f);
outputs[kHostTimeBeatPhase].setVoltage((tick / pcontext->ticksPerBeat) * 10.0f);
Copy link
Contributor

Choose a reason for hiding this comment

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

this seems like a leftover... please restore the original, otherwise for hosts that dont provide time info this results in a division by zero and crash

Copy link
Author

Choose a reason for hiding this comment

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

Good catch, have fixed it.

@@ -148,7 +157,8 @@ struct HostTime : TerminalModule {
? tick / pcontext->ticksPerBeat
: 0.0f;
const float barPhase = playingWithBBT && pcontext->beatsPerBar > 0
? ((float) (timeInfo.beat - 1) + beatPhase) / pcontext->beatsPerBar
? ((timeInfo.bar - 1) % barDivision) / (float) barDivision
Copy link
Contributor

Choose a reason for hiding this comment

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

this logic also seems wrong...

if we unfold the parenthesis we have

(
    (timeInfo.bar - 1) % barDivision
) / (float) barDivision
+
(
    (tick / pcontext->ticksPerBeat) / pcontext->beatsPerBar
)

this doesnt match the previous code and is likely to produce wrong results.

there is also another tick / pcontext->ticksPerBeat use that can just be beatPhase instead

Copy link
Author

Choose a reason for hiding this comment

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

Good point, updated calculation.

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.

2 participants