-
-
Notifications
You must be signed in to change notification settings - Fork 160
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
base: main
Are you sure you want to change the base?
Conversation
plugins/Cardinal/src/HostTime.cpp
Outdated
@@ -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); |
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.
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
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.
Good catch, have fixed it.
plugins/Cardinal/src/HostTime.cpp
Outdated
@@ -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 |
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.
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
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.
Good point, updated calculation.
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)