[PD] Pd + asterisk?

Chris lists at proquariat.de
Fri Dec 21 19:36:08 CET 2007

Russell Bryant wrote:
> Longer response ...
> In theory, any period size should work just fine.  I just happened to choose 160
> because I was thinking that it would be more efficient, since that was the
> period size of packets coming through Asterisk.  However, due to the way audio
> is passed between Asterisk and jack, it really shouldn't matter at all.  All of
> the raw audio goes through ringbuffers that have no concept of a period.  I will
> play around with different period sizes to see if I can cause a problem to occur.
I heard some klicking noise when I tried with 160 frames
> Also, I have all intentions to support more than 8 kHz mode for jack.  :)  The
> trick is, with 8 kHz, app_jack doesn't have to resample anything.  With any
> other sample rate, it does.  I have code that attempts to handle resampling the
> audio in both directions using libresample.  However, it currently makes the
> audio sound absolutely terrible.  I'll get it fixed, though ...
I tried it first with 48KHz and only got noise
> Would you mind sharing the Pd patch that you were using to test this out?
> The extreme echo is a good sign, I think.  I assume you mean you just heard your
> own voice coming back to you, with some delay.  Anything beyond that is probably
> acoustic echo with whatever phone you're using.  :)
> The reason that connecting Asterisk to itself works but not with anything else
> could have something to do with the way I did sample value normalization in
> Asterisk.  Asterisk uses a 16 bit integer representation per sample.  However, I
> had to convert it to float for jack.
> I wasn't sure of the right way to do it, so I simply scaled the values based on
> the maximum values of the type ...
> (f_buf is a buffer of floats, s_buf is a buffer of int16_t's)
> for (i = 0; i < f->samples; i++)
>      f_buf[i] = s_buf[i] * (FLT_MAX / SHRT_MAX);

A really long delay, but that may was because of my setup... (ISDN <->
Asterisk <-> IAX over Wlan <-> Asterisk with Jack) ;)

Pd patch was a really simple [adc~ 1] for audio input from the first
jack-channel, a [osc~ 440] for testing and a [dac~ 1] for audio output
to the first jack-channel

When I connected the osc~ with the dac~ I heard nothing at my phone,
when I connected the adc~ from asterisk to a dac~ patched to alsa I
neither heard a thing from the phone.
> what I want to do eventually is be able to send a message that you could receive
> in a Pd patch that a new pair of jack ports has become available.  But, that's
> not as important to me right now as getting the audio flow working properly.
> I don't know about adding an argument that says connect to PID X.  However,
> there appears to be an option in the jack C API which allows you to specify a
> server name to connect to.  That may do what is needed to connect to jackd
> running as a different user.
I don't know if you can patch two jack-channels together in pd, telling
app_jack to connect it's channel to a specific pd-channel would be
really easy, but having Pd handling it would be more flexible. Anyway,
sending something to pd, that there's a new caller definitely is a good
idea for various reasons.


More information about the Pd-list mailing list