- BPM display use BPM calculation from LFO
- LFO: fixed S&H waveforms git-svn-id: http://moon:8086/svn/software/trunk/projects/JaySynth@737 b431acfa-c32f-4a4a-93f1-934dc6c82436
This commit is contained in:
+8
-18
@@ -129,8 +129,6 @@ JaySynth::JaySynth (int num_voices, String pathToWaves)
|
||||
}
|
||||
|
||||
m_clock_cnt_bar = 0;
|
||||
m_lastTime_ms = 0;
|
||||
m_estimatedTime_ms = 0;
|
||||
m_numMidiClocksPerBeat = 1;
|
||||
m_numMidiClocksPerBar = 1;
|
||||
m_isMidiClockStarted = false;
|
||||
@@ -1132,7 +1130,6 @@ void JaySynth::handleMidiEvent (const MidiMessage& m)
|
||||
SynthDebug("SongPositionPointer\n");
|
||||
m_clock_cnt_bar = (6 * m.getSongPositionPointerMidiBeat()) % m_numMidiClocksPerBar;
|
||||
SynthDebug("getSongPositionPointerMidiBeat(): %u -> %u clocks\n", m.getSongPositionPointerMidiBeat(), m_clock_cnt_bar);
|
||||
m_lastTime_ms = 0;
|
||||
}
|
||||
if (m.isQuarterFrame())
|
||||
{
|
||||
@@ -1150,30 +1147,20 @@ void JaySynth::handleMidiEvent (const MidiMessage& m)
|
||||
}
|
||||
if (m.isMidiClock())
|
||||
{
|
||||
const double alpha_1 = 2.0/m_numMidiclocksPerQuarterNote;
|
||||
const double currTime_ms = juce::Time::getMillisecondCounterHiRes();
|
||||
|
||||
// BPM Estimation
|
||||
double deltaTime_ms = currTime_ms - m_lastTime_ms;
|
||||
if (m_lastTime_ms > 0.0)
|
||||
{
|
||||
m_estimatedTime_ms = (1.0-alpha_1)*m_estimatedTime_ms + alpha_1*deltaTime_ms;
|
||||
}
|
||||
m_lastTime_ms = currTime_ms;
|
||||
|
||||
// Quarter clock generation
|
||||
m_clock_cnt_bar = m_clock_cnt_bar % m_numMidiClocksPerBar;
|
||||
if (m_isMidiClockStarted)
|
||||
{
|
||||
#if WITH_DEV_SYNCED_LFO
|
||||
voiceSetMidiBeat(m_clock_cnt_bar);
|
||||
// Sync LFO and BPM Estimation
|
||||
synth_float_t bpm = voiceSetMidiBeat(m_clock_cnt_bar);
|
||||
#endif
|
||||
if (m_clock_cnt_bar % m_numMidiClocksPerBeat == 0)
|
||||
{
|
||||
// Send quarter pulse with current BPM estimation
|
||||
midi_quarter_clock_info_t info;
|
||||
|
||||
info.bpm = (uint32_t)(m_numMidiclocksPerQuarterNote*m_estimatedTime_ms + 0.5);
|
||||
info.bpm = (uint32_t)(bpm + 0.5);
|
||||
info.type = 1;
|
||||
if (m_clock_cnt_bar == 0)
|
||||
{
|
||||
@@ -1186,13 +1173,14 @@ void JaySynth::handleMidiEvent (const MidiMessage& m)
|
||||
}
|
||||
}
|
||||
|
||||
void JaySynth::voiceSetMidiBeat(int barBeatCount)
|
||||
synth_float_t JaySynth::voiceSetMidiBeat(int barBeatCount)
|
||||
{
|
||||
synth_float_t bpm = 0;
|
||||
for (int i=0; i < VOICE_NUM_LFO; i++)
|
||||
{
|
||||
lfo_t *pLfo = &m_pVoices[0].pCom->glfo[i];
|
||||
synth_float_t phase = Sync_mod((synth_float_t)barBeatCount/m_numMidiClocksPerBar);
|
||||
LFO_sync(pLfo, phase);
|
||||
bpm += LFO_sync(pLfo, phase)/VOICE_NUM_LFO;
|
||||
}
|
||||
|
||||
for (int i=0; i < max_num_voices; i++)
|
||||
@@ -1200,6 +1188,8 @@ void JaySynth::voiceSetMidiBeat(int barBeatCount)
|
||||
JaySynthVoice* const voice = voices.getUnchecked (i);
|
||||
voice->setMidiBeat(barBeatCount);
|
||||
}
|
||||
|
||||
return bpm;
|
||||
}
|
||||
|
||||
//==============================================================================
|
||||
|
||||
Reference in New Issue
Block a user