commit 14e1034b8846d3d34b8ece96cbcf7895f0838143
parent 142a89813203c191b777d505d5108660f7c79693
Author: dsp56300 <dsp56300@users.noreply.github.com>
Date: Tue, 20 Jul 2021 21:04:26 +0200
report internal device latency to host, too
Diffstat:
4 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/source/synthLib/device.cpp b/source/synthLib/device.cpp
@@ -76,6 +76,11 @@ namespace synthLib
LOG("Latency set to " << m_latency << " samples at " << getSamplerate() << " Hz");
}
+ uint32_t Device::getInternalLatencySamples() const
+ {
+ return 260; // hard to belive but this is what I figured out by measuring with the init patch
+ }
+
void Device::startDSPThread()
{
m_dspThread.reset(new DSPThread(*m_dsp));
diff --git a/source/synthLib/device.h b/source/synthLib/device.h
@@ -18,6 +18,7 @@ namespace synthLib
virtual void process(float** _inputs, float** _outputs, size_t _size, const std::vector<SMidiEvent>& _midiIn, std::vector<SMidiEvent>& _midiOut);
void setLatencySamples(uint32_t _size);
uint32_t getLatencySamples() const { return m_latency; }
+ uint32_t getInternalLatencySamples() const;
void startDSPThread();
diff --git a/source/synthLib/plugin.cpp b/source/synthLib/plugin.cpp
@@ -237,6 +237,8 @@ namespace synthLib
const auto latency = static_cast<uint32_t>(std::ceil(static_cast<float>(m_blockSize) * m_device->getSamplerate() * m_hostSamplerateInv));
m_device->setLatencySamples(latency);
+
+ m_deviceLatency = m_device->getInternalLatencySamples() * m_hostSamplerate / m_device->getSamplerate();
}
void Plugin::setBlockSize(const uint32_t _blockSize)
@@ -249,6 +251,6 @@ namespace synthLib
uint32_t Plugin::getLatencySamples() const
{
std::lock_guard lock(m_lock);
- return m_blockSize;
+ return m_blockSize + m_deviceLatency;
}
}
diff --git a/source/synthLib/plugin.h b/source/synthLib/plugin.h
@@ -53,6 +53,8 @@ namespace synthLib
uint32_t m_blockSize = 0;
+ uint32_t m_deviceLatency;
+
// MIDI Clock
bool m_isPlaying = false;
uint32_t m_lastKnownBeat = 0;