Skip to main content

mod_soundtouch

About

It's a module that uses the soundtouch library, which can do pitch shifting and other audio effects, so you can pipe the audio of a call(or any other channel audio) through this module and achieve those effects. You can specifically adjust pitch, rate, and tempo. Please note this documentation is only accurate for versions >= 1.0.2 or r9820 and greater.

Click here to expand Table of Contents

Configuring

  • Uncomment the build line in modules.conf for applications/mod_soundtouch and (re)compile/install
  • Add a line to your conf/modules.conf.xml to load the modules: <load module="mod_soundtouch"/>
  • Note: Under GCC >= 4.3, if your compile fails, in 'source/example/SoundStretch/WavFile.cpp' add '#include <cstdlib>' and '#include <cstring>' and try again.

Usage

Initial values and what leg to hook are specified in your dialplan, afterwards if you enable the DTMF hooking you will be able to interact with it through the keypad. The soundtouch module can only interact on one leg of a session at a time. By default it hooks the recv leg, which means that if you call someone else it will hook your side and modify your voice that they hear. It is important to keep in mind that during the initial specification you can specify the pitch either absolutely or by octaves or semitones. Each will override the other, so setting more than one is pointless.

You are now able to use mod_soundtouch. The API spec is:

[send_leg] [hook_dtmf] [-]<X>s [-]<X>o <X>p <X>r <X>t
  • send_leg - apply the filter to the send leg instead of the outgoing leg
  • hook_dtmf - If specified it will hook the DTMF tones and modify the pitch/rate/tempo per the DTMF codes at the bottom
  • s - Adjust the pitch in semitones, values should be between -14 and 14, default 0
  • o - Adjust the pitch in octaves, values should be between -1 and 1, default 0
  • p - Set the pitch directly, value should be > 0, default 1 (lower = lower tone)
  • r - Set the rate, value should be > 0, default 1 (lower = slower)
  • t - Set the tempo, value should be > 0, default 1 (lower = slower)

Dialplan Usage

One can use this in a dialplan before a bridge/etc by:

 <action application="soundtouch" data="hook_dtmf -0.3o 0.8r"/>

Api Usage

soundtouch <uuid> [start|stop] [send_leg] [hook_dtmf] [-]<X>s [-]<X>o <X>p <X>r <X>t

DTMF Interaction

Once the module has been activated on a session if you specify the hook_dtmf option it will also hook the DTMF's for whatever direction it applies to (ie if applies to send_leg it hooks the send's dtmf's.
The dtmf binds can then be used to interact with the application:

  • * - Do not intercept the next dtmf
  • 1 - pitch down 0.05
  • 2 - ptich = 1
  • 3 - ptich up 0.05
  • 4 - rate down 0.05
  • 5 rate = 1
  • 6 rate up 0.05
  • 7 temp down 0.05
  • 8 temp = 1
  • 9 tempo up 0.05
  • 0 log pitch,rate,temp at level INFO

Use in Lua

To start soundtouch in Lua use for example (this will lower the voice pitch by 0.2 octaves):

session:execute("soundtouch", "-0.2o") 

To reset the pitch to normal, this method will NOT work:

session:execute("soundtouch", "+0.2o") 

Even this will NOT work

session:execute("soundtouch", "0o") 

You will need to explicitly "stop" soundtouch by the following command

session:execute("soundtouch","stop")

You can subsequently do pitch/rate shifting again by issuing a fresh command e.g.

session:execute("soundtouch","0.8r") 

See Also