zoukankan      html  css  js  c++  java
  • 转:在ios中使用soundtouch库实现变声

    http://yarin.blog.51cto.com/1130898/640398

    首先下载soundtouch开源库,可以到官方网站去找了,http://www.surina.net/soundtouch/。

    下面我们要修改音频文件主要调整的几个函数如下了:

    1. mSoundTouch.setSampleRate(sampleRate);//设置声音的采样频率 
    2. mSoundTouch.setChannels(channels);//设置声音的声道 
    3. m_SoundTouch.setTempoChange(tempoDelta); //这个就是传说中的变速不变调 
    4. m_SoundTouch.setPitchSemiTones(pitchDelta);//设置声音的pitch 
    5. mSoundTouch.setRateChange(rateDelta);//设置声音的速率 
    6. // quick是一个bool变量,USE_QUICKSEEK具体有什么用我暂时也不太清楚。 
    7. mSoundTouch.setSetting(SETTING_USE_QUICKSEEK, quick); 
    8. // noAntiAlias是一个bool变量,USE_AA_FILTER具体有什么用我暂时也不太清楚。 
    9. mSoundTouch.setSetting(SETTING_USE_AA_FILTER, !(noAntiAlias));

    最后需要注意的两个问题:

    已开始我编译出来,声音很奇怪也有噪音很大,还是花了很多时间来找原因,但是都无果,突然想起前面我们说过,它同时支持32位浮点和16位定点,默 认时采用32位浮点的,我将其改为16位定点数的,哈哈,对了,效果很好,更改方式在STTypes.h文件中找到FLOAT_SAMPLES宏,注释 掉,并打开INTEGER_SAMPLES宏,如下:

    1. #if !(INTEGER_SAMPLES || FLOAT_SAMPLES) 
    2.     
    3.     /// Choose either 32bit floating point or 16bit integer sampletype 
    4.     /// by choosing one of the following defines, unless this selection  
    5.     /// has already been done in some other file. 
    6.     //// 
    7.     /// Notes: 
    8.     /// - In Windows environment, choose the sample format with the 
    9.     ///   following defines. 
    10.     /// - In GNU environment, the floating point samples are used by  
    11.     ///   default, but integer samples can be chosen by giving the  
    12.     ///   following switch to the configure script: 
    13.     ///       ./configure --enable-integer-samples 
    14.     ///   However, if you still prefer to select the sample format here  
    15.     ///   also in GNU environment, then please #undef the INTEGER_SAMPLE 
    16.     ///   and FLOAT_SAMPLE defines first as in comments above. 
    17.     #define INTEGER_SAMPLES     1    //< 16bit integer samples 
    18.     //#define FLOAT_SAMPLES       1    //< 32bit float samples 
    19.   
    20.  #endif 

    另外一个问题就是在模拟器上测试都完全无误了,这个时候放到真机设备上,直接报错,退出程序,又一个花了我不少时间的问题,最终发现,在真机上需要将声道改变为单声道,如下,在自己设置的时候使用:

    1. mSoundTouch.setChannels(2);//1则为单声道 

    大功告成,当然了如果你要继续了解soundtouch库,那么这里(http://blog.csdn.net/leilu2008/article/details/6540575)又一系列的参考资料。

  • 相关阅读:
    java读取properties 属性文件
    oracle中插入一条数据,id自动增长,插入之后怎么得到这个id(sequence的使用)
    Android布局实现圆角边框
    TabHost中使用startActivityForResult无法接收返回值的解决方案[转]
    ORA00937: not a singlegroup group function
    MVC与WebForm最大的区别
    使用SQL Server存储ASP.NET Session变量
    JS中的event 对象详解
    一列多行值合并成一个值(MS SQL SERVER 2008)
    c#如何共享程序集
  • 原文地址:https://www.cnblogs.com/li-baibo/p/3753699.html
Copyright © 2011-2022 走看看