Wassup JUCE Community,
I have a question regarding to drawing syncronized waveforms by bars into my GUI. Drawing the waveform of the current signal is no problem at all. I checked some LFO plugins and they display the waveform perfectly syncronized to the bar in strict time so I was wondering if anyone has an idea of how to implement it? I already implemented a Ring Buffer which is supposed to hold one quarter note lenths of the signal. I am pretty sure I have to calculate some kind of a factor of the CurrentPositionInfo. So i tried to calculate Samples per Bar but it does not really work and my bars also get inaccurate over time.
const double bpm = info.bpm; const double timeInSeconds = info.timeInSeconds; const double sampleRate = processor.getSampleRate(); const int samplesPerBlock = processor.getBlockSize(); const int64 timeInSamples = info.timeInSamples; const double bps = bpm / 60.00; double barDouble = timeInSeconds * bps / 4.0; double barDoubleRounded = roundf(barDouble * 100000) / 100000; const int bar = (int) barDoubleRounded + 1; // calc with not rounded values const int subBar = (int)(fmod(barDoubleRounded, 1.0) * 4.0 + 1.0); double barsPerSecond = 1.0 / (bps / 4.0); const int samplesPerBar = sampleRate / barsPerSecond;
Has anyone done something similar and can help me out?