asterisk + mpg123 packages

Tzafrir Cohen tzafrir.cohen@xorcom.com
Tue, 14 Jun 2005 18:17:36 +0300


On Sun, Jun 12, 2005 at 01:37:51AM +0300, Tzafrir Cohen wrote:
> But I
> figure I'll try to work around the extra CPU load of that MOH decoding
> anyway.

Here is some work-in-progress. In musiconhold.conf:
---------------------------
[classes]
default=>custom:/usr/share/asterisk/mohwav,/usr/local/bin/wavplayer
---------------------------

/usr/local/bin/wavplayer is:
---------------------------
#! /bin/sh
exec /usr/bin/sox -t wav "$@" -t raw -
---------------------------

And /usr/share/asterisk/mohwav is automatically generated from mohmp3.
Recall that the music-on-hold code looks for *.mp3 files, and thus the
renaming. 
/usr/share/asterisk/mohwav/Makefile:
---------------------------
MOH:=$(shell ls ../mohmp3 2>/dev/null| grep '\.mp3$$' |sed -e 's/.mp3$$/.new&/')

all: $(MOH)

test:
	echo $(MOH)

# mpg123 here can probably be mpg321 or whatever mp3->wav convertor you
# want. Maybe some minor adaptations of the command-line will be
# required.
%.big.wav: ../mohmp3/%.mp3
	mpg123 --wav "$@" "$<"

%.new.wav: %.big.wav
	sox "$<" -c1 -t wav -r 8000 "$@" resample -q

# TODO: get rid of the '.new' . Don't simply throw it, or you'll have a
# make loop. We'll probably need here a rule of the sort:
# $(TARGET_MP3S): %.mp3: %.wav
%.new.mp3: %.new.wav
	mv "$<" "$@"
---------------------------
And the result: I don't think we lost any quality that can be heard
through a phone line. Change of disk space:

$ ls -l /usr/share/asterisk/moh*
/usr/share/asterisk/mohmp3:
total 6600
-rw-r--r--  1 root root 1939812 2005-02-27 11:23 fpm-calm-river.mp3
-rw-r--r--  1 root root 2582496 2005-02-27 11:23 fpm-sunshine.mp3
-rw-r--r--  1 root root 2217563 2005-02-27 11:23 fpm-world-mix.mp3

/usr/share/asterisk/mohwav:
total 6604
-rw-r--r--  1 root root 1939794 2005-06-14 04:58 fpm-calm-river.new.mp3
-rw-r--r--  1 root root 2582198 2005-06-14 04:59 fpm-sunshine.new.mp3
-rw-r--r--  1 root root 2217318 2005-06-14 04:59 fpm-world-mix.new.mp3
-rw-r--r--  1 root root     448 2005-06-14 04:58 Makefile

-- 
Tzafrir Cohen     icq#16849755  +972-50-7952406
tzafrir.cohen@xorcom.com  http://www.xorcom.com