Go: Use the SoundTouch Library in iOS to make a voice changer

Source: Internet
Author: User

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

First download SoundTouch open Source Library, you can go to the official website to find, http://www.surina.net/soundtouch/.

Here are a few of the main adjustments we want to make to modify the audio file:

  
 
  1. msoundtouch.setsamplerate (samplerate); //Set the sampling frequency of the sound  
  2. Msoundtouch.setchannels (Channels); //Set the sound channel  
  3. M_soundtouch.settempochange (Tempodelta); //This is the legendary change of speed does not change the tone  
  4. M_soundtouch.setpitchsemitones (Pitchdelta); //Set pitch of sound  
  5. Msoundtouch.setratechange (Ratedelta); //Set the rate of sound  
  6. //Quick is a bool variable, use_quickseek specific what to use I am not very clear for the time being.  
  7. Msoundtouch.setsetting (Setting_use_quickseek, quick);
  8. //Noantialias is a bool variable, use_aa_filter specific what to use I'm not quite sure yet.  
  9. Msoundtouch.setsetting (Setting_use_aa_filter,!) ( Noantialias));

The last two issues to note:

Has started my compilation, the sound is very strange also has the noise very big, still spent a lot of time to find the reason, but all did not have the result, suddenly remembered that we said, it also supports 32-bit floating point and 16-bit fixed point, by default, 32-bit floating point, I will change it to 16-bit fixed point number, haha Change the way you find the Float_samples macro in the STTypes.h file, comment it out, and open the Integer_samples macro, as follows:

  
 
  1. #if! (Integer_samples | | Float_samples)
  2. // Choose either 32bit floating point or 16bit integer sampletype  
  3. /// by choosing one of the following defines, unless this selection  
  4. //has already been do in some other file.  
  5. ////  
  6. //Notes:  
  7. //-in Windows environment, choose the sample format with the  
  8. /// following defines.  
  9. //-in GNU environment, the floating point samples is used by  
  10. /// default, but integer samples can is chosen by giving the  
  11. //Following switch to the Configure script:  
  12. /// ./configure--enable-integer-samples  
  13. /// However, if you still prefer to select the sample format here  
  14. // also in GNU environment, then #undef the Integer_sample  
  15. ///Float_sample defines first as in comments above.  
  16. #define Integer_samples 1//< 16bit INTEGER SAMPLES  
  17. //#define Float_samples 1//< 32bit FLOAT SAMPLES  
  18. #endif  

Another problem is that the test on the simulator is completely correct, this time put on the real machine equipment, direct error, quit the program, another time spent me a lot of problems, and finally found that in the real machine needs to change the channel to Mono, as below, in their own settings when used:

 
   
  
  1. Msoundtouch.setchannels (2); //1 is mono  

It's done, of course. If you want to continue to understand the SoundTouch library, then here (http://blog.csdn.net/leilu2008/article/details/6540575) a series of reference materials.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.