From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS3561 216.34.176.0/20 X-Spam-Status: No, score=-2.4 required=3.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,RCVD_IN_DNSWL_HI,RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL,RCVD_IN_SORBS_SPAM,RP_MATCHES_RCVD,SPF_HELO_PASS,SPF_PASS, T_DKIM_INVALID shortcircuit=no autolearn=no autolearn_force=no version=3.4.0 Received: from lists.sourceforge.net (lists.sourceforge.net [216.34.181.88]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 8980B20A10 for ; Mon, 6 Nov 2017 21:47:38 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=sfs-ml-3.v29.ch3.sourceforge.com) by sfs-ml-3.v29.ch3.sourceforge.com with esmtp (Exim 4.89) (envelope-from ) id 1eBpF3-00032e-5j; Mon, 06 Nov 2017 21:47:37 +0000 Received: from sfi-mx-3.v28.ch3.sourceforge.com ([172.29.28.193] helo=mx.sourceforge.net) by sfs-ml-3.v29.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.89) (envelope-from ) id 1eBpF1-00032W-KL for sox-users@lists.sourceforge.net; Mon, 06 Nov 2017 21:47:35 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Type:To:Subject:Message-ID:Date:From: References:In-Reply-To:MIME-Version:Sender:Reply-To:Cc: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=tMTvDDt0pzkNFJsb9M5xQ4LmJTuhkWVU/VCtxRTV6IE=; b=F4X3hfZ9YFrDUBye4xS7jx5GG yw1ePtZ2THDicQ3IYenjeql4yzLwryE+pN/q1+LaD54ETFi6qridLPUJqmy1tugqxNMgXKoXSdmpB BgjZ6Uq+a4qHwYijZi189p5aFguVAft4nMyoBPJnu6Y/fbiZ/E+0whMwIK2Os8uue8CMo=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Type:To:Subject:Message-ID:Date:From:References:In-Reply-To: MIME-Version:Sender:Reply-To:Cc:Content-Transfer-Encoding:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tMTvDDt0pzkNFJsb9M5xQ4LmJTuhkWVU/VCtxRTV6IE=; b=G/3pJPOBIywuS6/fQI1TS9Htrs 8IknmJGgrzWp8pkl8BTtln1sTZTggIjRKoCR+QYOElXVw8EiS6AUgO1x78YudgfDLlOJjJpYSEpaq u29cgV48nN1v5OQHKMFSkQvDChu0DZKAI55HvxNCp+M2x3+INOD6IR6GArWEy3yMm1Sk=; Received: from mail-oi0-f49.google.com ([209.85.218.49]) by sfi-mx-3.v28.ch3.sourceforge.com with esmtps (TLSv1.2:ECDHE-RSA-AES128-GCM-SHA256:128) (Exim 4.89) id 1eBpF0-00073E-LB for sox-users@lists.sourceforge.net; Mon, 06 Nov 2017 21:47:35 +0000 Received: by mail-oi0-f49.google.com with SMTP id q4so8658136oic.7 for ; Mon, 06 Nov 2017 13:47:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to; bh=tMTvDDt0pzkNFJsb9M5xQ4LmJTuhkWVU/VCtxRTV6IE=; b=d3fZ02hgyb9gq0ZyXzNvK61H+ozFKl5LHnVPEYP2nYwAMWWWB/TwtaIi6GQf8SvNhZ /ekvClveAeCBIHwWY171+f/wp9NmX1A/FHNHtJBjnoNVUkgMn+ud2J4skon/Wiz5Vdmk yVDbjgS5xvqJRY/eVi43zuWL6QHbFk2JJiXLSzf/zlVaD4JmVgWQA2+yHzznsC0vFChB unqDZJWEm0ZGqPSuizD2+Yk6bcTXE341DLiAO+TLH/O7WAdpZJ+ylFQv0vm4YLqep5bi +eE54hjq8frYpMt9CBp1cGegvLAOJBU0JoQ/XXjwvW94VQ0ebbBjKrKf3xl3ATEaA5Lm 17Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to; bh=tMTvDDt0pzkNFJsb9M5xQ4LmJTuhkWVU/VCtxRTV6IE=; b=bbSSbyEclu5NIylMF3WESgwKWKw2SjZs0ncTLx32IV5UGkPmf9nQWP+ZptLGhlMRsT W67mVBQuFv7z7IGIaPM7JjcDeHjoJRwraFN6p8Rbm2N+xOAOJUq2/0I/xm2qPSFotHNn HvQtkr9hbqAv3Ph5Lq/U4Ty0+OKKamg+4IC7WqZufCCmUCyaa1UU/i/4wHDyjWSkcARg nyG3jH+OIfP6BgNMxgPcC7xsyn2jbgfNOCC7uuT/YhXvcgCd4oT2WQF4Q/+PPqcLVXVV cSC2RwPCj5upyXGgea1nFVC3fgz3+NJ6//wPK5sHOWDtWhUNOOjsbJi004fyJSuysSUC O0Yg== X-Gm-Message-State: AMCzsaU6fPF9nYl9BhzxGSiD28r0aszNdKkgzaWcPLOX5Og7Y0eIXpSY NTUEHPkcaczgenRZfmok3qWzfA4TQibYBsMrLgM= X-Google-Smtp-Source: ABhQp+Tp4aw3xivkA4izm2XiF3M6hJrNpynXcAychDLy91kOafhqws9LpzfeCsVCfMMDkS0IUpLMVEf7xUfm5ISFkwM= X-Received: by 10.202.7.69 with SMTP id 66mr10222270oih.404.1510004848970; Mon, 06 Nov 2017 13:47:28 -0800 (PST) MIME-Version: 1.0 Received: by 10.74.162.36 with HTTP; Mon, 6 Nov 2017 13:47:28 -0800 (PST) In-Reply-To: <20171106210932.GA41280@www.stare.cz> References: <20171106111001.GA80730@www.stare.cz> <20171106190645.GA61378@www.stare.cz> <20171106210932.GA41280@www.stare.cz> From: Dan Hitt Date: Mon, 6 Nov 2017 13:47:28 -0800 Message-ID: To: sox-users@lists.sourceforge.net X-Headers-End: 1eBpF0-00073E-LB Subject: Re: how to interpret tell_off, and the right way to use sox_seek X-BeenThere: sox-users@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: sox-users@lists.sourceforge.net Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: sox-users-bounces@lists.sourceforge.net Hi Jan! Thanks for your mail. On Mon, Nov 6, 2017 at 1:09 PM, Jan Stary wrote: > On Nov 06 12:14:59, dan.hitt@gmail.com wrote: ....... (cut) >> >> #include >> #include >> #include >> >> int main( int argc, char** argv ) { >> if ( argc < 2 ) { >> fprintf(stderr,"Call with one arg, the name of a sound file.\n" ); >> exit(1); >> } >> int istat = sox_init(); >> if (istat != SOX_SUCCESS ) { >> fprintf(stderr, "Failed to initialize sox, error %d.\n", istat); >> exit(1); >> } >> char* infile = argv[1]; >> sox_format_t* s = sox_open_read( infile, 0, 0, 0 ); >> if ( ! s ) { >> fprintf(stderr,"Failed to open `%s' .\n", infile); >> exit(1); >> } >> int buf[1024]; >> int count = 0; >> while ( 1 ) { >> int rcnt = sox_read( s, buf, 1024 ); >> if ( rcnt <= 0 ) { >> printf( "Failed on read, attempt %d\n", count ); >> exit( 0 ); >> } >> int status = sox_seek( s, 0, SOX_SEEK_SET ); >> if ( status ) { >> fprintf(stderr,"Failed on seek.\n" ); >> exit(1); >> } >> count++; >> } >> return 0; // not reached >> } >> .... (cut) > If I am reading your code right, it does not seek at all. It's in a loop. First, it reads (which presumably moves the file pointer forwards), then it seeks back to where it was. I've verified in gdb that it actually does call sox_seek() (again and again and again, but not forever). I have also verified in gdb that it is reading the same samples. So sox_seek() is definitely being called, and definitely working. But nevertheless, the reading done after the seeking eventually fails. Certainly if you do analogous coding with calls to fread() and fseek(), it would not terminate. > > I still suspect that it is first of all unnecessary to read the input > again and again while seeking back again and again; but I can't be sure, > because I still have no idea about what you are doing. What i'm trying to do now is to determine the correct way to use sox_seek() if i am using it incorrectly. If i'm using it correctly, then i would like confirmation of my characterization (that it has some internal counter which is decremented until it hits zero). (I did have a signal processing problem that i was considering earlier, but that's not relevant now because i avoided the sox_seek issue by rearranging the computation. So i can do my dsp, but i do wonder about correct usage of sox_seek.) Anyhow, i do appreciate your investigation of this!!! :) :) dan ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ Sox-users mailing list Sox-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/sox-users