MOH issue with WAV file

We’re having an issue with asterisk not playing our MOH files. The MOH files are supposed to be in WAV format and we confirmed with sox (see below), but we receive the following in the asterisk console:

-- Started music on hold, class 'Test', on SIP/trunk-00009283 [2013-06-17 10:19:34] WARNING[3128]: format_wav.c:92 check_header_fmt: Not a wav file 7 [2013-06-17 10:19:34] WARNING[3128]: file.c:376 fn_wrapper: Unable to open format wav [2013-06-17 10:19:34] WARNING[3128]: res_musiconhold.c:327 ast_moh_files_next: Unable to open file '/var/lib/asterisk/moh/Test//wav_test': No such file or directory -- Stopped music on hold on SIP/trunk-00009283

Sox output:

sox: Detected file format type: wav

sox: WAV Chunk fmt
sox: WAV Chunk fact
sox: WAV Chunk data
sox: Reading Wave file: Microsoft U-law format, 1 channel, 16000 samp/sec
sox: 16000 byte/sec, 1 block align, 8 bits/samp, 2678827 data bytes
sox: 2678827 Samps/chans
sox: Input file test_moh.wav: using sample rate 16000
size bytes, encoding u-law, 1 channel
sox: Output file 001.raw: using sample rate 8000
size shorts, encoding u-law, 1 channel
sox: Output file: comment “Processed by SoX”

sox: resample opts: Kaiser window, cutoff 0.800000, beta 16.000000

sox: Error writing: Do not support this encoding for this data size
sox: Error writing: Do not support this encoding for this data size

Interstingly, the same file plays without issue if used in the IVR module (as the announcement).

Any suggestions?

In further testing, I downloaded one of our working IVR recordings and found that Audacity reports the file to be 32-bit float, but 8000 Hz. I made sure the MOH file matched these settings, without success. Running moh reload each time to make sure it’s loading the correct file. Also only leaving one file in the directory.

– Started music on hold, class ‘test’, on SIP/trunk-00009452
[2013-06-17 11:05:02] WARNING[3770]: format_wav.c:110 check_header_fmt: Unexpected frequency mismatch 16000 (expecting 8000)
[2013-06-17 11:05:02] WARNING[3770]: file.c:376 fn_wrapper: Unable to open format wav
[2013-06-17 11:05:02] WARNING[3770]: res_musiconhold.c:327 ast_moh_files_next: Unable to open file ‘/var/lib/asterisk/moh/test//test5’: No such file or directory
– Stopped music on hold on SIP/trunk-00009452

Upon further review, the source WAV file had a sample format of 32-bit float rather than 16-bit PCM. I exported as 16-bit PCM but no change.

The original frequency was 16,000. Noticing the warning about frequency mismatch, I tried 8,000 and also 44,100.

This is Asterisk 1.8.7.1.

[*CLI> [0K -- Started music on hold, class 'Test', on SIP/trunk-0000935e

[*CLI>
[0K[2013-06-17 10:46:11] [1;31mWARNING[0m[3405]: [1;37mformat_wav.c[0m:[1;37m110[0m [1;37mcheck_header_fmt[0m: Unexpected frequency mismatch 16000 (expecting 8000)

[*CLI>
[0K[2013-06-17 10:46:11] [1;31mWARNING[0m[3405]: [1;37mfile.c[0m:[1;37m376[0m [1;37mfn_wrapper[0m: Unable to open format wav

[*CLI>
[0K[2013-06-17 10:46:11] [1;31mWARNING[0m[3405]: [1;37mres_musiconhold.c[0m:[1;37m327[0m [1;37mast_moh_files_next[0m: Unable to open file ‘/var/lib/asterisk/moh/Test//testPCM3’: No such file or directory
– Stopped music on hold on SIP/trunk-0000935e

Apparently when we re-sampled our files to 8000 Hz, they were not saving properly. Once the sampling rate was correctly applied at 8000 Hz, MOH began working.