diff options
Diffstat (limited to 'PCM.cpp')
-rw-r--r-- | PCM.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
@@ -59,13 +59,20 @@ PCM::~PCM() free(pfd); } -void PCM::click(int64_t offset_us) +// offset > 0: play earlier +// offset < 0: play later +void PCM::click(std::chrono::duration<double> offset) { snd_pcm_sframes_t delay; if (0 > snd_pcm_delay(handle, &delay)) { } - m_phase = - click_latency_frames + delay + offset_us; + int64_t offset_frames{static_cast<int64_t>(offset.count() * f_sample)}; + m_phase = - click_latency_frames + delay + offset_frames; + + if (m_phase > 0) { + log_cout << fmt::format("phase = {}", m_phase) << std::endl; + } } // generate 1 buffer size |