default progress bar behaviour

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

default progress bar behaviour

Jan Stary
By default, SoX displays the progress bar
when playing to or recording from an audio device.

Would make more sense to display the progress bar only if,
moreover, the output goes to a terminal?

For example, this is what a play(1) cronjob produces now:

> > Your "at" job on lenovo.stare.cz
> > "/var/cron/atjobs/1385486400.c"
> >
> > produced the following output:
> >
> >
> >   Encoding: n/a          
> >   Channels: 1 @ 32-bit  
> > Samplerate: 48000Hz      
> > Replaygain: off        
> >   Duration: unknown      
> >
> >
In:0.00% 00:00:00.00 [00:00:00.00] Out:0     [      |      ]        Clip:0    
In:0.00% 00:00:00.34 [00:00:00.00] Out:16.4k [ =====|===== ]        Clip:0    
In:0.00% 00:00:00.51 [00:00:00.00] Out:19.2k [ =====|===== ]        Clip:0    
> > Done.

Imagine what the output would look like when playing something longer.
I think it would be better if this was (textually) silent.

The diff below changes the default behaviour.
Note that the progress bar goes to stderr, not stdout,
so we check whether isatty(STDERR_FILENO), not STDOUT_FILENO.

        Jan

--- sox.c Sun Jan 13 20:57:39 2013
+++ /home/hans/src/sox-14.4.1/src/sox.c Tue Nov 26 21:14:44 2013
@@ -1568,7 +1568,8 @@ static void open_output_file(void)
    * device: */
   if (show_progress == sox_option_default)
     show_progress = (ofile->ft->handler.flags & SOX_FILE_DEVICE) != 0 &&
-                    (ofile->ft->handler.flags & SOX_FILE_PHONY) == 0;
+                    (ofile->ft->handler.flags & SOX_FILE_PHONY) == 0  &&
+    isatty(STDERR_FILENO);
 
   report_file_info(ofile);
 }
@@ -2953,7 +2954,8 @@ int main(int argc, char **argv)
       exit(2);
     if (show_progress == sox_option_default &&
         (files[j]->ft->handler.flags & SOX_FILE_DEVICE) != 0 &&
-        (files[j]->ft->handler.flags & SOX_FILE_PHONY) == 0)
+        (files[j]->ft->handler.flags & SOX_FILE_PHONY) == 0  &&
+ isatty(STDERR_FILENO))
       show_progress = sox_option_yes;
   }
 

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: default progress bar behaviour

René Bastian
Le Wed, 27 Nov 2013 09:04:21 +0100,
Jan Stary <[hidden email]> a écrit :

> By default, SoX displays the progress bar
> when playing to or recording from an audio device.
>
> Would make more sense to display the progress bar only if,
> moreover, the output goes to a terminal?
>
The -q option (quiet) exists for performance needs.
The default -S is clever during tests etc.

rb

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: default progress bar behaviour

Jan Stary
On Nov 27 10:00:44, [hidden email] wrote:

> Le Wed, 27 Nov 2013 09:04:21 +0100,
> Jan Stary <[hidden email]> a écrit :
>
> > By default, SoX displays the progress bar
> > when playing to or recording from an audio device.
> >
> > Would make more sense to display the progress bar only if,
> > moreover, the output goes to a terminal?
> >
> The -q option (quiet) exists for performance needs.
> The default -S is clever during tests etc.

The proposed change is exactly about the _default_ behaviour,
i.e. (not) displaying the progress bar unless on a terminal.

What do you mean by "clever during tests"?



------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users
Reply | Threaded
Open this post in threaded view
|

Re: default progress bar behaviour

Eric Wong
In reply to this post by Jan Stary
Jan Stary <[hidden email]> wrote:
> The diff below changes the default behaviour.
> Note that the progress bar goes to stderr, not stdout,
> so we check whether isatty(STDERR_FILENO), not STDOUT_FILENO.

Your change looks good to me.  I agree it should be default behavior.
Thanks.

------------------------------------------------------------------------------
Rapidly troubleshoot problems before they affect your business. Most IT
organizations don't have a clear picture of how application performance
affects their revenue. With AppDynamics, you get 100% visibility into your
Java,.NET, & PHP application. Start your 15-day FREE TRIAL of AppDynamics Pro!
http://pubads.g.doubleclick.net/gampad/clk?id=84349351&iu=/4140/ostg.clktrk
_______________________________________________
Sox-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/sox-users