From: William M. <wm...@ke...> - 2011-11-01 20:32:52
|
I am using libsox to process voice files that are usually mono but occasionally are in 2 channel stereo format. I am creating a chain and, if the input signal has 2 channels, I am adding the "channels" effect with the option of "1". // ensure number of channels is 1 if (in->signal.channels != 1) { signalinfo.length = in->signal.length / in->signal.channels; fprintf(stderr, "Input file has %d Channels. Must only have 1!\n", (int) in->signal.channels); args[0] = "1"; fprintf (stderr, "Change Channels to %s\n", args[0]); e = sox_create_effect(sox_find_effect("channels")); assert(sox_effect_options(e, 1, args) == SOX_SUCCESS); assert(sox_add_effect(chain, e, &in->signal, &signalinfo) == SOX_SUCCESS); } Signal info is identical to in->signal except for length and number of channels. When the input signal has 1 channel, of course this effect is not added, so all is well. However, if it is 2 channels, the resulting output file is 1/2 the length. What am I missing here? William C. Mortimore Keystone Insights, LLC S76W13054 Cambridge Ct. W. Muskego, WI 53150 414-841-6067 Fax:414-425-9155 www.keystoneinsights.com |