11/*
22 * DISTRHO Cardinal Plugin
3- * Copyright (C) 2021-2024 Filipe Coelho <falktx@falktx.com>
3+ * Copyright (C) 2021-2026 Filipe Coelho <falktx@falktx.com>
44 *
55 * This program is free software; you can redistribute it and/or
66 * modify it under the terms of the GNU General Public License as
@@ -37,6 +37,7 @@ struct HostTime : TerminalModule {
3737 kHostTimeClock ,
3838 kHostTimeBarPhase ,
3939 kHostTimeBeatPhase ,
40+ kHostTimeBPM ,
4041 kHostTimeCount
4142 };
4243
@@ -160,7 +161,7 @@ struct HostTime : TerminalModule {
160161 ? ((float )((timeInfo.bar - 1 ) % barDivision) + (timeInfo.beat - 1 ) + beatPhase)
161162 / (pcontext->beatsPerBar * barDivision)
162163 : 0 .0f ;
163-
164+
164165 lights[kHostTimeRolling ].setBrightness (playing ? 1 .0f : 0 .0f );
165166 lights[kHostTimeReset ].setBrightnessSmooth (hasReset ? 1 .0f : 0 .0f , args.sampleTime * 0 .5f );
166167 lights[kHostTimeBar ].setBrightnessSmooth (hasBar ? 1 .0f : 0 .0f , args.sampleTime * 0 .5f );
@@ -176,6 +177,7 @@ struct HostTime : TerminalModule {
176177 outputs[kHostTimeClock ].setVoltage (hasClock ? 10 .0f : 0 .0f );
177178 outputs[kHostTimeBarPhase ].setVoltage (barPhase * 10 .0f );
178179 outputs[kHostTimeBeatPhase ].setVoltage (beatPhase * 10 .0f );
180+ outputs[kHostTimeBPM ].setVoltage (playingWithBBT ? std::log2 (pcontext->beatsPerMinute / 120.0 ) : 0.0 );
179181 }
180182
181183 void processTerminalOutput (const ProcessArgs&) override
@@ -224,6 +226,7 @@ struct HostTimeWidget : ModuleWidgetWith8HP {
224226 addOutput (createOutput<PJ301MPort>(Vec (startX, startY_cv + 4 * padding), m, HostTime::kHostTimeClock ));
225227 addOutput (createOutput<PJ301MPort>(Vec (startX, startY_cv + 5 * padding), m, HostTime::kHostTimeBarPhase ));
226228 addOutput (createOutput<PJ301MPort>(Vec (startX, startY_cv + 6 * padding), m, HostTime::kHostTimeBeatPhase ));
229+ addOutput (createOutput<PJ301MPort>(Vec (startX, startY_cv + 7 * padding), m, HostTime::kHostTimeBPM ));
227230
228231 const float x = startX + 28 ;
229232 addChild (createLightCentered<SmallLight<GreenLight>> (Vec (x, startY_cv + 0 * padding + 12 ), m, HostTime::kHostTimeRolling ));
@@ -263,6 +266,7 @@ struct HostTimeWidget : ModuleWidgetWith8HP {
263266 nvgFontSize (args.vg , 11 );
264267 drawOutputLine (args.vg , 5 , " Bar Phase" );
265268 drawOutputLine (args.vg , 6 , " Beat Phase" );
269+ drawOutputLine (args.vg , 7 , " BPM" );
266270
267271 nvgBeginPath (args.vg );
268272 nvgRoundedRect (args.vg , startX - 1 .0f , startY_top, 98 .0f , 38 .0f , 4 ); // 98
0 commit comments