Degrading calls: connecting Asterisk through JACK with Puredata
Dennis GuseSometimes it is necessary to get access to the audio of a VoIP telephony connection (more precisely SIP/RTP). My reason for this is quite simple: for laboratory studies on subjective quality of telephony, I need be able to introduce degradations like noise and speaker echo.
This is a short howto (for Ubuntu 14.04) to let Asterisk run in proxy mode (directmedia=no), route the audio via JACK to Puredata and back. In Puredata then audio can be modified as needed.
-
Install software:
-
Setup realtime for group audio (optional)
If you need realtime for JACK, then enable it.
-
Configure Asterisk
Configure one extension (phone number) that:
- answers the call
- enables JACK for the caller to callee channel,
- then dials the callee,
- and on answering enables JACK for the callee to caller channel using a post dial macro.
The i(…) and o(…) tell asterisk to connect directly to the defined JACK ports - thus PD should already be running.
Reload the configuration:
ATTENTION: If JACK is not running and the asterisk JACK application is thus failing to connect, it fail silently by just emitting a warning and audio is passed on directly.
-
Start JACK and Puredata
All applications connecting to a JACK server running as user X need also to run as X. As Asterisk is running as user asterisk simply start JACK and Puredata as user asterisk.
###JACK Start JACK either directly or using qjackctl as user asterisk. If you need realtime, enable it properly.
Dummy is used as backend as I do not need local sound output from JACK - if you want it use Alsa instead.
###Puredata Start Puredata as user asterisk and connect to JACK.
Then just enable DSP or do automatically.
Puredata version before 0.46 Overwriting the HOME-variable is necessary for Puredata version less than version 0.46, which will be included in Ubuntu 15.04. Otherwise the UI is not loaded as reading the config-files fails and the UI process stops.
Have fun.
Known issues:
- Asterisk Version prior 13 are limited to 8000Hz for interaction with JACK - see here.
- If JACK is not running Asterisk just ignores it and the call continues without.
- Due to the large numbers of buffers involved a relatively high delay is to be expected - a guess is ~80-100ms.