zoukankan      html  css  js  c++  java
  • soundtouch源码分析__based on csdn :

    1. soundtouch介绍和相关资源

    The SoundTouch Library Copyright © Olli Parviainen 2001-2014

    SoundTouch is an open-source audio processing library for changing the Tempo, Pitch and Playback Rates of audio streams or audio files

    • Tempo (time stretch): Changes the sound to play at faster or slower tempo than originally without affecting the sound pitch.
    • Pitch (key) : Changes the sound pitch or key while keeping the original tempo (speed).
    • Playback Rate : Changes both tempo and pitch together as if a vinyl disc was played at different RPM rate.

    The SoundTouch library is intended  for application developers writing sound processing tools that require tempo/pitch control functionality, or just for playing around with the sound effects.

    resource:

    1.soundtouch官网:http://www.surina.net/soundtouch/。这上面有soundtouch的介绍、源码,封装好的dll文件、使用方法、以及一些demo。这上面demo做的不好。

    2.一个利用java的jni调用soundtouch非常短小精悍的java swing界面小程序:http://www.aplu.ch/home/apluhomex.jsp?site=44

    3.csdn suhetao做的soundtouch源码分析:http://blog.csdn.net/suhetao/article/details/5843480

    4.关于声音处理的一个理论网页:http://www.surina.net/article/time-and-pitch-scaling.html

    5.其他资料:http://baosu.iteye.com/blog/1840054

          http://baosu.iteye.com/blog/1843031

          http://blog.csdn.net/leilu2008/article/details/6724354

    2.对于soundtouch源码的最简明的解释(参考)

    1. 音频采集

       这点主要是通过Android设备的麦克风实时采集音频,由于Android平台的MediaRecorder类录制音频到文件,虽然可以通过空设备回调获得实时的音频流,不过为了降低开发者的难度,Android开发网推荐使用正统的AudioRecord和AudioTrack,首先我们仍然需要加入android.permission.RECORD_AUDIO这个权限。

      

    android.media.AudioRecord类的read方法主要有3种重载形式:
    
    int  read(short[] audioData, int offsetInShorts, int sizeInShorts)   //short在java中占用两个字节
    int  read(byte[] audioData, int offsetInBytes, int sizeInBytes)  //byte在java中占用一个字节
    int  read(ByteBuffer audioBuffer, int sizeInBytes)  //基于NIO的ByteBuffer类型
    

      

      我们可以看到从麦克风中获取的音频无需经过文件系统直接通过AudioRecord类的read方法读入到我们预定的缓冲区中,这里需要注意的是采样率的大小必须有足够的缓冲区空间处理

      2. 变声处理

      这点需要一些基本的音频处理方式,比如移调、变速,Android开发网推荐大家参考Adobe Audition的早期Cool Editi泄露的代码,当然音频处理算法比较多,大家可以自己实现。

      3. 播放原始音频流

      同样,处理完后考虑到效率我们仍然直接从内存流中播放,最简单的就是AudioTrack类,通过android.media.AudioTrack类的write方法,让Android声卡播放原始音频流。两种重载方法如下

    int  write(short[] audioData, int offsetInShorts, int sizeInShorts) 
    int  write(byte[] audioData, int offsetInBytes, int sizeInBytes) 
    

      

    3.soundtouch的代码结构

     

  • 相关阅读:
    如何在vim中同时编辑多个文件
    Windows操作系统架构
    驱动中PAGED_CODE的作用
    Process Hacker源码中的用户态hook的做法
    IO Processing
    Device Drivers
    Windows IO System
    how to catch error in make error message
    分析/proc/[pid]/maps中的各个内存区域的大小
    boost::shared_ptr
  • 原文地址:https://www.cnblogs.com/haore147/p/3662518.html
Copyright © 2011-2022 走看看