Files
osc/src/main.cpp
T

65 lines
1.5 KiB
C++
Raw Normal View History

#include <iostream>
#include <stdexcept>
2026-11-13 18:31:07 +06:00
#include <thread>
#include <atomic>
#include "../include/synth.hpp"
#include "../include/audio_engine.hpp"
2026-11-13 18:31:07 +06:00
#include "../include/spsc_queue.hpp"
#include "../include/command.hpp"
2026-11-13 18:31:07 +06:00
void producer(SpscQueue& queue, std::atomic<bool>& producer_done){
/*
* формирует последовательность команд;
записывает их через queue.push();
повторяет попытку, если очередь заполнена;
после успешной отправки последней команды устанавливает producer_done = true.
*/
}
void consumer(SpscQueue& queue, std::atomic<bool>& producer_done){
}
int main(){
std::cout << "110.гц\n";
2026-11-12 20:58:48 +06:00
std::string a = "";
Synth synth;
2026-11-13 18:31:07 +06:00
SpscQueue queue;
2026-11-13 18:31:07 +06:00
std::atomic<bool> producer_done;
2026-11-13 18:31:07 +06:00
// std::thread producer();
// std::thread consumer();
synth.set_frequency(110);
synth.set_amplitude(0.5);
try{
AudioEngine audio_engine(synth);
audio_engine.start();
2026-11-12 20:58:48 +06:00
while (true){
2026-11-13 18:31:07 +06:00
std::cout << std::boolalpha
<< "Lock-free: " << std::atomic<Command>{}.is_lock_free()
<< '\n';
2026-11-12 20:58:48 +06:00
std::cin >> a;
if (a == "start"){
synth.note_on();
2026-11-12 20:58:48 +06:00
}
else synth.note_off();
2026-11-12 20:58:48 +06:00
}
// audio_engine.stop();
}
catch (const std::exception& error){
std::cerr << error.what() << "\n";
return 1;
}
return 0;
}