Let's say that I would like to have the best possible sound quality in an Asterisk-based IVR system. What audio format (gsm, ulaw, etc.) should I use? What sampling rate and sample size?
I always used 8000 Hz and 16 bit amplitude, but this was on non-VoIP Dialogic boards. I assumed that 8 KHz was the maximum that the POTS system could handle, but then I found in the Windows Sound Recorder a mode called "Telephone Quality" which uses 11.025 KHz and 8 bits only.
real telco digital data uses 8000 8-bit samples/sec. (64kbit/sec.)
There's some (but not a whole lot) excuse for going higher sampling and/or higher bit depth, so as to avoid 'off by one' errors, due to slight timing and/or quantization differences between your gear, and the telco's.
For "best quality", use an uncompressed audio format. For voice, there is _very_little_ "noticable" loss, using a 'lossy' compression format at 32-kbit/sec.
No. They sample at 8 KHz, but use a dynamic range compression called A-law (or uLaw, if in rightopondia. Very similar, but not exactly like.). The sampling needs to be at 13-14 bits, and it is advantagous to oversample by one bit. The result transmitted over the wire is a stream of 8-bit semilogarithmic values.
GSM samples at the same frequency and at 13 bits, and applies a compression algorithm to the data, yielding a data stream of packets; nominally at 12 kilobits. It sounds "mobile phone".
These encodings are reasonably good at handling small amounts of data loss.
iLBC and G.729 (proprietary) use similar principles as GSM, but are not as bandwidth-constraimed, at various points in the 20-40 kilobit range. iLBC uses a lot, G.729 a great deal of processing power in both ends, but sound pretty good.
ADPCM and G.726 use adaptive PCM encodings, taking the idea of dynamic compression in A-Law even further. They are not as processing-intensive, but sound "blander" than G.729 and iLBC.
G.723.1 is the last one I'll cover; a pure vocoder, representing coded phonemes instead of voice. Extremely good at getting sort of intelligable speech through at 5.3 kilobits; but sounds VERY much like D.Duck. Also proprietary.
If you are using asterisk throughout, have a good network (but not unlimited bandwidth) and have fast servers for asterisk I would go for iLBC.
If you have a rotten network use GSM and large jitter buffers.
If you have unlimited bandwidth use G.711. (Alaw or uLaw depending on continent).
Some phones and adapters may lead you to use G.726 or Speex.