Changeset 5613

Add a script to do mixing and use it by default to mix monitor files

Modern versions of sox have options rather than a separate soxmix
program.
Modern versions of sox can either combine inputs onto different channels
of a stereo file or mix them into a single channel.
Many people would like to normalize the volume of the channels.

Committed by:  mjagdis
Date:  Feb 05 2010 * 00:42 (6 months ago)

Affected files:

callweaver/trunk/res/Makefile.am (unified diff)

r5590r5613
2121 res_monitor_la_SOURCES = res_monitor.c
2222 res_monitor_la_LDFLAGS = -module -avoid-version @NO_UNDEFINED@
2323 res_monitor_la_LIBADD = @CALLWEAVER_LIB@
24 res_monitor_la_CFLAGS = $(AM_CFLAGS) -DCW_UTILSDIR="$(cwutilsdir)"
2425
2526 res_ogi_la_SOURCES = res_ogi.c
2627 res_ogi_la_LDFLAGS = -module -avoid-version @NO_UNDEFINED@

callweaver/trunk/res/res_monitor.c (unified diff)

r5594r5613
265265 }
266266
267267 if (chan->monitor->joinfiles && !cw_strlen_zero(chan->monitor->filename_base)) {
268 char tmp[1024];
269 char tmp2[1024];
268 struct cw_dynstr *cmd = NULL;
269 /* This mapping is because that's what corelib/file.c does when asked to write wav49 */
270270 const char *format = (strcasecmp(chan->monitor->format, "wav49") == 0) ? "WAV" : chan->monitor->format;
271271 char *name = chan->monitor->filename_base;
272272 int directory = strchr(name, '/') ? 1 : 0;
------
277277 execute = pbx_builtin_getvar_helper(chan, CW_KEYWORD_MONITOR_EXEC, "MONITOR_EXEC");
278278 execute_args = pbx_builtin_getvar_helper(chan, CW_KEYWORD_MONITOR_EXEC_ARGS, "MONITOR_EXEC_ARGS");
279279
280 snprintf(tmp, sizeof(tmp), "%s \"%s/%s-in.%s\" \"%s/%s-out.%s\" %s%s \"%s/%s.%s\" %s &",
281 (execute ? execute->value : "nice -n 19 soxmix"),
282 dir, name, format, dir, name, format,
283 (execute ? "" : "-t "),
284 (execute ? "" : format),
280 cw_dynstr_printf(&cmd,
281 "%s '%s/%s-in.%s' '%s/%s-out.%s' '%s/%s.%s' %s > /dev/null 2>&1 &",
282 (execute ? execute->value : "nice -n 19 " CW_CPP_DO(CW_CPP_MKSTR, CW_UTILSDIR) "/cw_mixer"),
285283 dir, name, format,
286 (execute_args ? execute_args->value : ""));
284 dir, name, format,
285 dir, name, format,
286 (execute_args ? execute_args->value : "")
287 );
287288
288289 if (execute_args)
289290 cw_object_put(execute_args);
291
290292 if (execute)
291293 cw_object_put(execute);
292 else {
293 /* Remove legs when done mixing */
294 snprintf(tmp2, sizeof(tmp2), "( %s& rm -f \"%s/%s-\"* ) &", tmp, dir ,name);
295 cw_copy_string(tmp, tmp2, sizeof(tmp));
296 }
297 cw_log(CW_LOG_DEBUG,"monitor executing %s\n", tmp);
298 if (cw_safe_system(tmp) == -1)
299 cw_log(CW_LOG_WARNING, "Execute of %s failed.\n", tmp);
294
295 if (cmd && !cmd->error) {
296 cw_log(CW_LOG_DEBUG,"Executing: %s\n", cmd->data);
297 if (cw_safe_system(cmd->data) == -1)
298 cw_log(CW_LOG_WARNING, "Failed to execute: %s failed.\n", cmd->data);
299 } else
300 cw_log(CW_LOG_ERROR, "Out of memory!\n");
301
302 if (cmd)
303 cw_dynstr_free(cmd);
300304 }
301305
302306 free(chan->monitor->format);

callweaver/trunk/utils/Makefile.am (unified diff)

r5564r5613
66 noinst_SCRIPTS = cc
77 noinst_PROGRAMS = genkeywords
88 cwutils_PROGRAMS = streamplayer # check_expr
9 cwutils_SCRIPTS = cw_mixer
910
1011 streamplayer_SOURCES = streamplayer.c ${top_srcdir}/corelib/strcompat.c
1112
------
2930 smsq_SOURCES = smsq.c
3031 smsq_LDADD = -lpopt
3132 endif WANT_SMSQ
33
34
35 install-data-hook:
36 cfgdir=/etc/sysconfig; \
37 test -d $$cfgdir || cfgdir=/etc/default; \
38 test -f $(DESTDIR)$$cfgdir/cw_mixer \
39 || $(INSTALL) -m 0644 $(srcdir)/cw_mixer.conf.sample $(DESTDIR)$$cfgdir/cw_mixer