#pragma once #include "config.h" #include "debug.h" #include "log.h" #include #include #include #include #include #include #include using namespace std::string_literals; class PCM { public: PCM(Config& config); ~PCM(); void click(std::chrono::duration offset); // generate 1 buffer size void generate(); int fd(); // write from buffer to ALSA PCM void write(); bool wait_for_event(); bool write_available(); private: Config& m_config; int err; snd_pcm_t *handle; int npfd; struct pollfd* pfd; std::vector m_data; int32_t m_phase; int16_t buffer[nframes]; };