We have a branded music and try to use it as music on hold in asterisk. But while playing music, it interrupts with a loud noise. Codec used is alaw. The formats for moh file I tried are wav, ulaw, alaw and GSM (I have converted the music into alaw and ulaw with sox utility). Only GSM plays normally, but it’s quality is too low. I have tried to decreace volume by 12 Db, but without result. Obviously, the reason is specific sounds located in our branded music (we had the same problem when tried to make music on hold in Panasonic PBX). The sounds seems to be hard to encode with VoIP formats. But there must be a method to convert music into VoIP oriented sound without using GSM with so lossy quality. Does anybody know such method?
SOX will convert music into low bit rate formats.
The only thing I can think of is that the sound has a lot of energy above 4kHz and there isn’t enough anti-aliasing being done in the conversion tool.
I would suggest using the rate operation in SOX explicitly, with a rate of 8000. Given that telephone audio only goes to about 3.4kHz, I’d suggest that you try bandwidths of 85% and 90%, although you might want to play with the other options, as well.
As a lot of people use mobile phones these days, you might want to consider choosing music that tolerates vocoder codecs better, although that may be difficult. It certainly sounds as though your music was not designed to render well in telephone bandwidths.
Note, this is support question, so should have been on Asterisk Support.
Thank you for answer. I use a pcm wav file with 8KHz sampling frequency as source for MOH. So it cannot have a frequencies above 4KHz. I thought that maybe it has ones at ~4Khz which are hard to render. So I edited the file and cut hi frequency. But it had no results. It’s strange.
I can’t really help then. At the least one would need to hear the distortion and a clean verision, to try and understand what was going on at a technical level.
Just a reminder though, Asterisk only accepts two .wav formats natively. .wav is 8kHz, 16 bit, signed, linear, mono, and .WAV is GSM encoded. Most other formats are bare media, with no meta data.
make sure your PCM Wave at 8k is also MONO not stereo
This works for me when converting audio/music to alaw:
Then to tidy the filenames if you want to:
Let me know if that works for you!
sox should automatically apply an anti-aliasing filter when you do a rate conversion, but, if you are going to use an explicit filter, I would think you would want it rather more than 6dB down a the Nyquist frequency. You only need to pass up to 3400Hz, although you probably want the 6dB point to higher than that.
Companding should only be necessary for wide dynamic range, classical, music.
David, I am so glad you saw this post! Finally someone you might know how compand works! I understand the basics of compression (as in, audio, not file), normalization, db, frequency, bandwidth, clipping, high and low-pass and so on, and I can quite happily produce reasonable sounding audio in Audacity using the plugins.
But I have to admit at being totally lost with the sox compand argument
Yup, I read the sox docs - “Compand (compress or expand) the dynamic range of the audio”.
But after that, I’m afraid I am lost - I read things like this below, and I just glaze. I don’t consider myself terminally moronic, but…
Nope! But all of that said, I have found various compand examples, and this sounds by far the best. The thing is, I’ve tried low and highpass filters to reflect exactly the G711 alaw range, and they sounded far “thinner” on the phone. While it does occasionally warn of a few sample clips, the string above gives a sound almost identical in quality to, say, the extra-sounds moh and speech included with Asterisk.
But if anyone knows a way of making something in a GUI like Audacity for example, and then exporting the arguments as something that can be used in sox, I’m all ears, so to speak!
I haven’t used compand in sox, but as examples of the basic principle, and assuming that broadcasters in your country do the same as in the UK. I’ll also use the term dynamic range reduction, which I think is more accurate.
Commercial breaks on TV sound louder than the programmes, not because they have a greater maximum loudness, but because their dynamic range has been reduced to make the difference between the soft and loud sounds less.
Analogue TV sound will probably have more dynamic range compression than digital.
Classical music sent over AM radio will usually have its dynamic range greatly reduced, but over FM or digital you are likely to get closer to the full dynamic range.
Most modern pop music doesn’t have a lot of dynamic range to start with, but may have it deliberately reduced, to make it sound louder.
G.711 has companding in a more general sense, but that is undone at the receiving end.
Sorry for so late response.
I installed Asterisk 13 in order to get ARI functional. And I was glad to hear our branded music in wav format without any noises! So my problem was solved by itself.
Than you for your replies!