Initial implementation for host tempo module: play, bar and beat

This commit is contained in:
falkTX 2021-10-29 02:40:57 +01:00
parent 4cabc3690c
commit 24ad763bc8
6 changed files with 388 additions and 31 deletions

View file

@ -815,6 +815,21 @@ protected:
std::memset(outputs[1], 0, sizeof(float)*frames);
}
{
const TimePosition& timePos(getTimePosition());
context->playing = timePos.playing;
context->frameZero = timePos.frame == 0;
if (timePos.bbt.valid)
{
context->bar = timePos.bbt.bar;
context->beat = timePos.bbt.beat;
context->beatsPerBar = timePos.bbt.beatsPerBar;
context->tick = timePos.bbt.tick;
context->ticksPerBeat = timePos.bbt.ticksPerBeat;
context->ticksPerFrame = 1.0 / (60.0 * getSampleRate() / timePos.bbt.beatsPerMinute / timePos.bbt.ticksPerBeat);
}
}
std::memset(fAudioBufferOut, 0, sizeof(float)*frames*DISTRHO_PLUGIN_NUM_OUTPUTS);
for (CardinalMidiInputDevice* dev : fMidiInputs)

View file

@ -40,6 +40,9 @@ struct CardinalPluginContext : rack::Context {
uint32_t bufferSize;
double sampleRate;
float parameters[kModuleParameters];
bool playing, frameZero;
int32_t bar, beat, beatsPerBar;
double tick, ticksPerBeat, ticksPerFrame;
Mutex mutex;
Plugin* const plugin;
@ -47,6 +50,13 @@ struct CardinalPluginContext : rack::Context {
CardinalPluginContext(Plugin* const p)
: bufferSize(p->getBufferSize()),
sampleRate(p->getSampleRate()),
playing(false),
frameZero(false),
bar(0),
beat(0),
beatsPerBar(0),
tick(0.0),
ticksPerBeat(0.0),
plugin(p)
{
std::memset(parameters, 0, sizeof(parameters));