diff options
author | Roland Reichwein <mail@reichwein.it> | 2025-01-04 18:27:21 +0100 |
---|---|---|
committer | Roland Reichwein <mail@reichwein.it> | 2025-01-04 18:27:21 +0100 |
commit | dbe72ddb8eb215de6d38cd01ed201704ab315a4f (patch) | |
tree | 8fda403192090d8560bca9fe5a2e9f9e4e1a7e41 /PCM.cpp | |
parent | 2e793141e5434043205763c70d3a597cf2d78eeb (diff) |
Compensate phase
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 |