soundtouch分析

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元,谢谢~~

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值