Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: build

on: [push, pull_request]
on: [push, pull_request, workflow_dispatch]

env:
CACHE_VERSION: 15
Expand Down
12 changes: 8 additions & 4 deletions plugins/Cardinal/src/HostTime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ struct HostTime : TerminalModule {

enum BarDivisions {
Bars1 = 1,
Bars2 = 2,
Bars4 = 4,
Bars8 = 8
};
Expand Down Expand Up @@ -158,9 +159,11 @@ struct HostTime : TerminalModule {
? tick / pcontext->ticksPerBeat
: 0.0f;
const float barPhase = playingWithBBT && pcontext->beatsPerBar > 0
? ((float)((timeInfo.bar - 1) % barDivision) + (timeInfo.beat - 1) + beatPhase)
/ (pcontext->beatsPerBar * barDivision)
: 0.0f;
? fmod(
(timeInfo.bar - 1) + ((timeInfo.beat - 1) + beatPhase) / (float)pcontext->beatsPerBar,
(float)barDivision
) / (float)barDivision
: 0.0f;

lights[kHostTimeRolling].setBrightness(playing ? 1.0f : 0.0f);
lights[kHostTimeReset].setBrightnessSmooth(hasReset ? 1.0f : 0.0f, args.sampleTime * 0.5f);
Expand Down Expand Up @@ -192,7 +195,7 @@ struct HostTime : TerminalModule {
void dataFromJson(json_t* rootJ) override {
if (json_t* bdJ = json_object_get(rootJ, "barDivision")) {
int value = json_integer_value(bdJ);
if (value == Bars1 || value == Bars4 || value == Bars8)
if (value == Bars1 || value == Bars2 || value == Bars4 || value == Bars8)
barDivision = static_cast<BarDivisions>(value);
}
}
Expand Down Expand Up @@ -327,6 +330,7 @@ struct HostTimeWidget : ModuleWidgetWith8HP {
menu->addChild(new MenuSeparator);
menu->addChild(construct<MenuLabel>(&MenuLabel::text, "Bar Division"));
menu->addChild(construct<BarDivisionItem>(&BarDivisionItem::text, "Bars/1", &BarDivisionItem::module, module, &BarDivisionItem::value, HostTime::Bars1));
menu->addChild(construct<BarDivisionItem>(&BarDivisionItem::text, "Bars/2", &BarDivisionItem::module, module, &BarDivisionItem::value, HostTime::Bars2));
menu->addChild(construct<BarDivisionItem>(&BarDivisionItem::text, "Bars/4", &BarDivisionItem::module, module, &BarDivisionItem::value, HostTime::Bars4));
menu->addChild(construct<BarDivisionItem>(&BarDivisionItem::text, "Bars/8", &BarDivisionItem::module, module, &BarDivisionItem::value, HostTime::Bars8));
}
Expand Down