Hi Ulrich,

Thanks for that. All working now.

Cheers

Stephen Paterson
Developer   |  SYNETY
www.synety.com

ddi:    01134 166029
main: 0330 335 0000
 
SMARTER COMMUNICATIONS
Confidentiality: This e-mail transmission, including any attachments, is 
intended only for the named recipient(s) and may contain information that is 
privileged, confidential and/or exempt from disclosure under applicable law. If 
you have received this transmission in error, or are not the named 
recipient(s), please notify the sender immediately by return e-mail and 
permanently delete this transmission, including any attachments.

Security: This e-mail and any attachments are believed to be free from any 
virus but it is the responsibility of the recipient to ensure this is so. 
E-mail is not a 100% secure communications medium. We recommend you observe 
this when e-mailing us.


-----Original Message-----
From: Ulrich Klauer [mailto:ulr...@chirlu.de] 
Sent: 10 April 2013 16:48
To: sox-devel@lists.sourceforge.net
Subject: Re: [SoX-devel] Half length output with libsox for stereo -> mono

Stephen Paterson wrote:

> I can't get it to work with libsox. I've made a tiny modification to 
> example3.c that should do the same but no matter what I try I always 
> end up with a file that is exactly half the length of the one I get 
> from sox (or some crazy audio).

example3 is buggy. It doesn't take into account that sox_add_effect() modifies 
the "in" signalinfo, which is why it isn't a good idea to pass it a signalinfo 
that is still in use elsewhere, or to call
sox_add_effect() with identical in and out signalinfos.

What is happening here is that in->signal.length, after the sox_open_read(), 
contains some value like 882000, for a 10-second stereo 44100 Hz input file. 
After adding "rate", the value will have changed to 160000, and after 
"channels", to 80000. Because it is the same memory location all the time, the 
input format handler (from
sox_open_read()) will see this value as well and think that its file is only 
80000 samples long. It will therefore stop reading after 80000 samples (/2 
channels, /44100 Hz = 0.907 seconds), and that is all that is processed by the 
effects chain.

See the attached diff for how to use a copy of the signalinfo instead.

Ulrich
------------------------------------------------------------------------------
Precog is a next-generation analytics platform capable of advanced
analytics on semi-structured data. The platform includes APIs for building
apps and a phenomenal toolset for data science. Developers can use
our toolset for easy data analysis & visualization. Get a free account!
http://www2.precog.com/precogplatform/slashdotnewsletter
_______________________________________________
SoX-devel mailing list
SoX-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sox-devel

Reply via email to