#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 maxfac) {c=true; maxfac=intfac; } static double minfa=0, maxfa=0; if(factor < minfa) {c=true; minfa=factor; } if(factor > maxfa) {c=true; maxfa=factor; } printf("min=%d max=%d orig min=%g max=%g\n", minfac,maxfac, minfa,maxfa); */ k[index-1] = factor; } if(m == 1) { //printf("gain=%g\n", gain); // process frame printf("%g\t", d[offset%P]); unsigned framemax = unsigned(frame_length/sampling_period); for(unsigned frame=0; frame < framemax; ++frame) { double w = count / double(1/sampling_period/F); double f = (-0.1 + drand48()*0.6)*0.1 + (1 - 2*(60.0 / ((w *30+20)*(w *40+3)))); //double point = frame / double(framemax); double tempk[P], tempgain; for(unsigned n=0; n= unsigned(1./sampling_period/F)) { count=0; } d[offset%P] = f; double sum = f; for(unsigned j=0; j< unsigned(Num); ++j) sum -= bp[ unsigned(offset-j-1)%P ] * tempk[j]; //sum=f;gain=1; //if(std::abs(sum) > 1e4) sum = 0; double r = bp[offset%P] = sum; data.push_back(r * std::sqrt(tempgain)); ++offset; } for(unsigned n=0; n