From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: sudha krishna Newsgroups: gmane.comp.audio.sox.devel Subject: Issue with using sox resample library apis, to downsample audio from input rate(44.1Khz, 2 channel, 16 bit), to output rate(16Khz, 1 channel, 16 bit). Date: Thu, 24 Jul 2014 10:56:45 -0700 Message-ID: <1406224605.53438.YahooMailNeo@web121205.mail.ne1.yahoo.com> Reply-To: sudha krishna , sox-devel@lists.sourceforge.net NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============8398527070589266067==" X-Trace: ger.gmane.org 1406224628 28698 80.91.229.3 (24 Jul 2014 17:57:08 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 24 Jul 2014 17:57:08 +0000 (UTC) To: "sox-devel@lists.sourceforge.net" Original-X-From: sox-devel-bounces@lists.sourceforge.net Thu Jul 24 19:57:01 2014 Return-path: Envelope-to: gcasd-sox-devel@m.gmane.org Received-SPF: pass (sog-mx-1.v43.ch3.sourceforge.com: domain of yahoo.com designates 98.138.91.210 as permitted sender) client-ip=98.138.91.210; envelope-from=sudha_k1975@yahoo.com; helo=nm22-vm2.bullet.mail.ne1.yahoo.com; X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 806759.82075.bm@omp1053.mail.ne1.yahoo.com X-YMail-OSG: glSsJj0VM1mRZXRr32TmmWug0.Mt8df2S3Hx7E.zaPHr4ob bCLpH5J46.e9r9At9pZnDWClgDGoaUx58.s3rue9LEbAn9RldzgEBsnBswCd rgnXI75y.PGjMmvgb4WQLksU.zx3b1rZEU8oKXOLaBOERJTSPbbyhGT2qTwv 2aAwTFe.gMDVINFQxYPdquc1jjp2IxQTXy_NamVYlzFt3UYTAtoCU76Yb.m0 mGxY45MOg9SpVd7bO9rCDyd9U5zLvTCPNHY8oNJyReldhT4EVhQleFEN59V1 ncq_3HNzXDSWo6rRYCXAF22HC3RZTCpi2cLVKPoZVEVVUdcKx7DdQTReTG5n iGP.VSYWEVk8RUBWCMD.XPeQSrcFjqwTlWINUXjEgFOLZKffnDHddXES3O3t NEniHRiEPONIrnN84FPCdpJgti9HPjO1fzG5mh4y3_a3_fcqpKTZMQmQU9hD c7RAfAoiBk5DJa6MwuC0wyd59yMUCFxd.G23EnuU917SANfDvZrG9BOmX3md lAgnqiqW1AftZDhNIpUobnkEz9LzI_RV27pmBT2JJLeWYf0x4ugKr174- X-Rocket-MIMEInfo: 002.001, SGkgU294LWdyb3VwLAoKT2JqZWN0aXZlOiBJIGFtIHRyeWluZyB0byB1c2Ugc294LXJlc2FtcGxlIGxpYnJhcnksIHRvIGRvd25zYW1wbGUgZnJvbSBpbnB1dCByYXRlKDQ0LjFLaHosIDIgY2hhbm5lbCwgMTYgYml0KSwKdG8gb3V0cHV0IHJhdGUoMTZLaHosIDEgY2hhbm5lbCwgMTYgYml0KS4gSXMgaXQgcG9zc2libGUgdG8gdXNlIHNveC1yZXNhbXBsZSBsaWJyYXJ5IGZvciB0aGlzIHByb2Nlc3MuCgpJIHRyaWVkIHNveHJfb25lc2hvdCB0aGlzIGFwaSwgYW5kIHRoZSBvdXRwdXQgcHJvZHVjZWQsIGRvZXMBMAEBAQE- X-Mailer: YahooMailWebService/0.8.196.685 X-Spam-Score: -0.1 (/) X-Spam-Report: Spam Filtering performed by mx.sourceforge.net. See http://spamassassin.org/tag/ for more details. -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [98.138.91.210 listed in list.dnswl.org] -1.5 SPF_CHECK_PASS SPF reports sender host as permitted sender for sender-domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (sudha_k1975[at]yahoo.com) -0.0 SPF_PASS SPF: sender matches SPF record 0.2 FREEMAIL_REPLYTO_END_DIGIT Reply-To freemail username ends in digit (sudha krishna ) -0.0 RP_MATCHES_RCVD Envelope sender domain matches handover relay domain 0.2 FREEMAIL_ENVFROM_END_DIGIT Envelope-from freemail username ends in digit (sudha_k1975[at]yahoo.com) 1.0 HTML_MESSAGE BODY: HTML included in message -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature X-Headers-End: 1XANG7-0003td-9k X-BeenThere: sox-devel@lists.sourceforge.net X-Mailman-Version: 2.1.9 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: sox-devel-bounces@lists.sourceforge.net Xref: news.gmane.org gmane.comp.audio.sox.devel:371 Archived-At: Received: from lists.sourceforge.net ([216.34.181.88]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1XANGE-000561-IB for gcasd-sox-devel@m.gmane.org; Thu, 24 Jul 2014 19:56:58 +0200 Received: from localhost ([127.0.0.1] helo=sfs-ml-2.v29.ch3.sourceforge.com) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XANGA-0007Hm-RV; Thu, 24 Jul 2014 17:56:54 +0000 Received: from sog-mx-1.v43.ch3.sourceforge.com ([172.29.43.191] helo=mx.sourceforge.net) by sfs-ml-2.v29.ch3.sourceforge.com with esmtp (Exim 4.76) (envelope-from ) id 1XANG9-0007Gv-07 for sox-devel@lists.sourceforge.net; Thu, 24 Jul 2014 17:56:53 +0000 Received: from nm22-vm2.bullet.mail.ne1.yahoo.com ([98.138.91.210]) by sog-mx-1.v43.ch3.sourceforge.com with esmtps (TLSv1:AES256-SHA:256) (Exim 4.76) id 1XANG7-0003td-9k for sox-devel@lists.sourceforge.net; Thu, 24 Jul 2014 17:56:52 +0000 Received: from [98.138.100.116] by nm22.bullet.mail.ne1.yahoo.com with NNFMP; 24 Jul 2014 17:56:45 -0000 Received: from [98.138.89.195] by tm107.bullet.mail.ne1.yahoo.com with NNFMP; 24 Jul 2014 17:56:45 -0000 Received: from [127.0.0.1] by omp1053.mail.ne1.yahoo.com with NNFMP; 24 Jul 2014 17:56:45 -0000 Received: (qmail 98386 invoked by uid 60001); 24 Jul 2014 17:56:45 -0000 Received: from [192.55.54.36] by web121205.mail.ne1.yahoo.com via HTTP; Thu, 24 Jul 2014 10:56:45 PDT --===============8398527070589266067== Content-Type: multipart/alternative; boundary="1078491548-1922696268-1406224605=:53438" --1078491548-1922696268-1406224605=:53438 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi Sox-group,=0A=0AObjective: I am trying to use sox-resample library, to d= ownsample from input rate(44.1Khz, 2 channel, 16 bit),=0Ato output rate(16K= hz, 1 channel, 16 bit). Is it possible to use sox-resample library for this= process.=0A=0AI tried soxr_oneshot this api, and the output produced, does= not have the original voice of the input buffer,=A0=0Ait has a weird sound= ing voice output, far from the original voice input.=0A=0AAlso tried the so= xr_create and soxr_process apis, and did not get correct output.=0A=0AI am = not sure, if these apis(soxr_oneshot, soxr_create, and soxr_process) have a= n option,=0Ato downgrade number of channels, and whether we can specify 16 = bit or 8 bit.=0A=0AAlso not sure, if I should be using LibSox apis, such as= sox_create_effect/sox_add_effect, and whether that is a better option.=0A= =0AHere is sample code using, soxr_oneshot, please let me know, what could = be wrong, or if you have any suggestions.=0A=0A#define INPUT_RATE(44100)=0A= #define OUTPUT_RATE(16000)=0A#define INPUT_NUM_CHANNELS (2)=0A#define OUTPU= T_NUM_CHANNELS (1)=0A=0A#define OUTPUT_BLOCK_ALIGN (2)=0A=0A/*=0Aibuf - poi= nter to input buffer.=0Alength - length of input buffer.=0Ablock_align - sa= mple size of input rate.=0A*/=0Astatic int sox_test_function(void *ibuf, UI= NT32 length, UINT32 block_align)=0A{=0A=0Asize_t olen =3D (size_t)((length = * OUTPUT_RATE * OUTPUT_NUM_CHANNELS)/ (INPUT_RATE * OUTPUT_NUM_CHANNELS)); = =A0=A0=0Afloat * obuf =3D (float *)malloc(OUTPUT_BLOCK_ALIGN * olen);=0Amem= set(obuf, 0, (OUTPUT_BLOCK_ALIGN * olen));=0Asize_t odone;=0A=A0 =A0 FILE *= ofile;=0A=A0 =A0 UINT32 written =3D 0;=0A=0A//SKR: Need to find out, if we = can downgrade # of channels..can we do that..??=0A//also not sure..how to s= pecify 16 bit/8 bit..etc..=0Asoxr_error_t err =3D soxr_oneshot(=0A=A0 =A0 I= NPUT_RATE,=0A=A0 =A0 OUTPUT_RATE,=0A=A0 =A0 1,=0A=A0 =A0 ibuf , length/bloc= k_align, NULL,=0A=A0 =A0 obuf, olen/OUTPUT_BLOCK_ALIGN, &odone,=0A=A0 =A0 N= ULL,=0A=A0 =A0 NULL,=0A=A0 =A0 NULL);=0A=0A=A0 =A0 ofile =3D fopen("nwave_f= ile_16k_pcm.raw", "wb");=0A=A0 =A0=A0=0Aif (ofile =3D=3D NULL) {=0A=A0 =A0 = =A0 =A0 perror("Invalid file specified.");=0A=A0 =A0 =A0 =A0 exit(-1);=0A= =A0 =A0 }=0A=0A=A0 =A0 written =3D fwrite(obuf, OUTPUT_BLOCK_ALIGN, odone, = ofile); // Consume output.=0A=0A=A0 =A0return 0;=0A=0A}=0A=0APlease let me = know, what could be wrong, or if you have any suggestions.=0A=0A=0AThanks,= =0A=0AKrishna --1078491548-1922696268-1406224605=:53438 Content-Type: text/html; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable
Hi Sox-group,

=
Objective: I am t= rying to use sox-resample library, to downsample from input rate(44.1Khz, 2= channel, 16 bit),
to output rate(16Khz, 1 = channel, 16 bit). Is it possible to use sox-resample library for this proce= ss.

I tried soxr_oneshot this api, and the output produced, does not have the original= voice of the input buffer, 
it has a = weird sounding voice output, far from the original voice input.

Also tried the soxr_create and soxr_process apis, and did not get cor= rect output.

I am not sure, if these apis(soxr_oneshot, sox= r_create, and soxr_process) have an option,
to downgrade number of channels, and whether we can specify 16 bit or 8 bi= t.

Also not sure, if I should be using LibSox apis, such as= sox_create_effect/sox_add_effect, and whether that is a better option.

Here is sample code using, soxr_oneshot, please let me know, what could be wrong, or if you have any = suggestions.

#define INPUT_RATE=09(44100)
#define OU= TPUT_RATE=09(16000)
=
#define INPUT_NUM_CHANNELS (2)
#define OUTPUT_NUM_CHANNELS (1)

#define OU= TPUT_BLOCK_ALIGN (2)

/*
i= buf - pointer to input buffer.
length - len= gth of input buffer.
block_align - sample s= ize of input rate.
*/
static int sox_test_function(void *ibuf, UINT32 length, UINT32 block_align)
{

=09size_t olen =3D (size_t)((length= * OUTPUT_RATE * OUTPUT_NUM_CHANNELS)/ (INPUT_RATE * OUTPUT_NUM_CHANNELS));=   
=09float * obuf =3D (float *)malloc(OUTPUT_BLOCK_ALIGN= * olen);
=09memset(obuf, 0, (OUTPUT_BLOCK_ALIGN * olen));
=09size_t odone;
    FILE *ofile;
    UINT32 written =3D 0;

=09//SKR: Need to= find out, if we can downgrade # of channels..can we do that..??
=09//also not sure..how to specify 16 bit/8 bit..etc..
=09soxr_error_t= err =3D soxr_oneshot(
    INPUT_= RATE,
    OUTPUT_RATE,
    1,
&nbs= p;   ibuf , length/block_align, NULL,
=     obuf, olen/OUTPUT_BLOCK_ALIGN, &odone,
    NULL,
  &n= bsp; NULL,
    NULL);

    ofile =3D fopen("nwave_file_16k_pcm.raw", "wb");
<= div class=3D"" style=3D"">    
=09if (ofile =3D=3D NU= LL) {
        perror("Inva= lid file specified.");
     =   exit(-1);
    }

    written =3D fwrite(obuf, OUTPUT_BLOCK_ALIGN, odone, of= ile); // Consume output.

   return 0;

}

Please let me know, = what could be wrong, or if you have any suggestions.

Thanks,
Krish= na

=

--1078491548-1922696268-1406224605=:53438-- --===============8398527070589266067== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline ------------------------------------------------------------------------------ Want fast and easy access to all the code in your enterprise? Index and search up to 200,000 lines of code with a free copy of Black Duck Code Sight - the same software that powers the world's largest code search on Ohloh, the Black Duck Open Hub! Try it now. http://p.sf.net/sfu/bds --===============8398527070589266067== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ SoX-devel mailing list SoX-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sox-devel --===============8398527070589266067==--