shithub: sox

Download patch

ref: a586ad952b11c3717d419ce9817391d21e10e045
parent: 7672dd349f386c937b4858a074fa830471dbf7ee
author: Ulrich Klauer <ulrich@chirlu.de>
date: Thu Jan 31 20:46:02 EST 2013

Apply new timespec syntax to documentation example

Update the "acpo" example script shown in the man page to take
advantage of the syntax features that were added recently (chained
time specifications, positions). All calculations that previously had
to be done in the shell can now be done in SoX directly, and values
like "1:03" instead of only sample numbers are allowed as parameters
to the script.

--- a/sox.1
+++ b/sox.1
@@ -3445,17 +3445,15 @@
 #!/bin/sh
 # Audio Copy and Paste Over
 # acpo infile copy-start copy-stop paste-over-start outfile
-# All times measured in samples.
-rate=\`soxi \-r "$1"\`
-e=\`expr $rate '*' 5 / 1000\`  # Using default excess
+# No chained time specifications allowed for the parameters
+# (i.e. such that contain +/\-).
+e=0.005                      # Using default excess
 l=$e                         # and leeway.
-sox "$1" piece.wav trim \`expr $2 \- $e \- $l\`s \\
-   \`expr $3 \- $2 + $e + $l + $e\`s
-sox "$1" part1.wav trim 0 \`expr $4 + $e\`s
-sox "$1" part2.wav trim \`expr $4 + $3 \- $2 \- $e \- $l\`s
-sox part1.wav piece.wav part2.wav "$5" splice \\
-   \`expr $4 + $e\`s \\
-   \`expr $4 + $e + $3 \- $2 + $e + $l + $e\`s
+sox "$1" piece.wav trim $2\-$e\-$l =$3+$e
+sox "$1" part1.wav trim 0 $4+$e
+sox "$1" part2.wav trim $4+$3\-$2\-$e\-$l
+sox part1.wav piece.wav part2.wav "$5" \\
+   splice $4+$e +$3\-$2+$e+$l+$e
 .EE
 In the above Bourne shell script,
 two splices are used to `copy and paste' audio.