soundtouch分析:
1.main函数 RunParameters //获取参数,如输入输出文件名,pitchDelta等,将其保存在RunParameters类的成员变量 inFileName = (char*)paramStr[1]; outFileName = (char*)paramStr[2]; parseSwitchParam // interpret the switch name & operate accordingly checkLimits //判断有没有超出极限值
openFiles //打开输入输出文件, *inFile = new WavInFile(params->inFileName);//打开输入文件,并获取输入文件的音频参数 *outFile = new WavOutFile(stdout, samplerate, bits, channels);//打开输出文件,将输入文件的音频参数作为文件头 setup //Setup the 'SoundTouch' object for processing the sound //将音频参数和音频处理参数传给soundtouch,为处理做准备 pSoundTouch->setSampleRate(sampleRate); //采样率 channels = (int)inFile->getNumChannels(); //声道数 pSoundTouch->setSampleRate(sampleRate); //设置采样率 pSoundTouch->setChannels(channels); //设置声道数
pSoundTouch->setTempoChange(params->tempoDelta); pSoundTouch->setPitchSemiTones(params->pitchDelta);//设置音调参数 pSoundTouch->setRateChange(params->rateDelta);
pSoundTouch->setSetting(SETTING_USE_QUICKSEEK, params->quick); pSoundTouch->setSetting(SETTING_USE_AA_FILTER, !(params->noAntiAlias)); process //对音频处理过程 while (inFile->eof() == 0) // Process samples read from the input file { num = inFile->read(sampleBuffer, BUFF_SIZE); //从输入文件中读取一块样品,用于处理 nSamples = num / (int)inFile->getNumChannels();//计算一通道有多少数据 pSoundTouch->putSamples(sampleBuffer, nSamples); //将样品给soundtouch处理 do { //读取处理后的数据,处理后的数据可能比处理的数据还大,所以用do-while来处理 nSamples = pSoundTouch->receiveSamples(sampleBuffer, buffSizeSamples); outFile->write(sampleBuffer, nSamples * nChannels); } while (nSamples != 0); }
如果您感觉本篇博客对您有帮助,请打开支付宝,领个红包支持一下,祝您扫到99元,谢谢~~