#include #include #include #include #include std::vector data; struct MyAudioDriver { SDL_AudioSpec spec {}; MyAudioDriver(unsigned rate) { spec.freq = rate; spec.format = AUDIO_F32SYS; spec.channels = 1; spec.samples = 4096; spec.userdata = this; spec.callback = [](void* param, Uint8* stream, int len) { ((MyAudioDriver*)param)->callback((float*)stream, len/sizeof(float)); }; auto dev = SDL_OpenAudioDevice(nullptr, 0, &spec, &spec, 0); SDL_PauseAudioDevice(dev, 0); } std::size_t pos = 0; void callback(float* target, int num_samples) { for(int n=0; n= unsigned(1./sampling_period/voice_pitch)) { count=0; } d[offset%P] = f; double sum = f; for(unsigned j=0; j