#include #include #include #include #include #include #include using namespace std; int main() { audio_object* ao; ao=create_audio_device_object(0, "teller", ""); if(!ao) { cerr<<"Unable to open audio file "< counter; auto player = [&]() { vector data; int ourcounter=0; data.reserve(44100); while(counter >= 0) { data.clear(); if(ourcounter < counter) { for(int n=0; n < 250; ++n) { int16_t val = 20000 * sin((n/44100.0) * 500 * 2 * M_PI); data.push_back(val); } ourcounter++; } else { for(int n=0; n < 150; ++n) { data.push_back(0); } } audio_object_write(ao, &data[0], data.size() * sizeof(decltype(data)::value_type)); // audio_object_flush(ao); } }; std::thread athread(player); string line; while(getline(cin, line)) { counter++; } counter = -1; athread.join(); sleep(1); }