AudioSink::AudioSink(long const srate, int const latency, int const periods) : rbuf_(nearestPowerOf2(srate * latency / ((periods + 1) * 1000)) * periods * 2) , rateEst_(srate, rbuf_.size() / periods) , mut_(SDL_CreateMutex()) , bufReadyCond_(SDL_CreateCond()) , failed_(openAudio(srate, rbuf_.size() / 2 / periods, fillBuffer, this) < 0) { rbuf_.fill(0); }
int GData::getAnalysisStepSize(int rate) { //int stepSize = settings.getInt("Analysis", "stepSizeValue"); int stepSize = qsettings->value("Analysis/stepSizeValue", 24).toInt(); //QString stepSizeUnit = settings.getString("Analysis", "stepSizeUnit"); QString stepSizeUnit = qsettings->value("Analysis/stepSizeUnit", "milli-seconds").toString(); if(stepSizeUnit.lower() == "milli-seconds") { //convert to samples stepSize = int(double(stepSize) * double(rate) / 1000.0); } //if(settings.getBool("Analysis", "stepSizeRound")) { if(qsettings->value("Analysis/stepSizeRound", true).toBool()) { stepSize = toInt(nearestPowerOf2(stepSize)); } return stepSize; }
int GData::getAnalysisBufferSize(int rate) { //int windowSize = settings.getInt("Analysis", "bufferSizeValue"); int windowSize = qsettings->value("Analysis/bufferSizeValue", 48).toInt(); //QString windowSizeUnit = settings.getString("Analysis", "bufferSizeUnit"); QString windowSizeUnit = qsettings->value("Analysis/bufferSizeUnit", "milli-seconds").toString(); if(windowSizeUnit.lower() == "milli-seconds") { //convert to samples windowSize = int(double(windowSize) * double(rate) / 1000.0); } //if(settings.getBool("Analysis", "bufferSizeRound")) { if(qsettings->value("Analysis/bufferSizeRound", true).toBool()) { windowSize = toInt(nearestPowerOf2(windowSize)); } return windowSize; }
static unsigned int prescale(unsigned int n) { if(n <= 4095) { return 0; } n = (n * 16)/65536; if (!isPowerOfTwo(n)) { n = nearestPowerOf2(n); } return (Log2n(n) + 1); }