#pragma once #include "config.h" #include "debug.h" #include "log.h" #include <libreichwein/file.h> #include <alsa/asoundlib.h> #include <fmt/format.h> #include <iostream> #include <string> #include <vector> using namespace std::string_literals; class PCM { public: PCM(); ~PCM(); void click(); // generate 1 buffer size void generate(); int fd(); // write from buffer to ALSA PCM void write(); bool wait_for_event(); bool write_available(); private: int err; snd_pcm_t *handle; int npfd; struct pollfd* pfd; std::vector<uint16_t> m_data; int32_t m_phase; int16_t buffer[nframes]; };