Erik de Castro Lopo | 1a7c3fa | 2014-11-27 13:03:13 +1100 | [diff] [blame] | 1 | #!/bin/sh -e |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 2 | |
| 3 | # FLAC - Free Lossless Audio Codec |
Erik de Castro Lopo | 39d9791 | 2014-11-25 20:02:22 +1100 | [diff] [blame] | 4 | # Copyright (C) 2012-2014 Xiph.Org Foundation |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 5 | # |
| 6 | # This file is part the FLAC project. FLAC is comprised of several |
Ulrich Klauer | cd4ddab | 2013-05-26 22:53:43 +0200 | [diff] [blame] | 7 | # components distributed under different licenses. The codec libraries |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 8 | # are distributed under Xiph.Org's BSD-like license (see the file |
| 9 | # COPYING.Xiph in this distribution). All other programs, libraries, and |
| 10 | # plugins are distributed under the GPL (see COPYING.GPL). The documentation |
| 11 | # is distributed under the Gnu FDL (see COPYING.FDL). Each file in the |
| 12 | # FLAC distribution contains at the top the terms under which it may be |
| 13 | # distributed. |
| 14 | # |
| 15 | # Since this particular file is relevant to all components of FLAC, |
| 16 | # it may be distributed under the Xiph.Org license, which is the least |
| 17 | # restrictive of those mentioned above. See the file COPYING.Xiph in this |
| 18 | # distribution. |
| 19 | |
Erik de Castro Lopo | 1a7c3fa | 2014-11-27 13:03:13 +1100 | [diff] [blame] | 20 | . ./common.sh |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 21 | |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 22 | PATH=`pwd`/../src/flac:$PATH |
| 23 | |
Erik de Castro Lopo | 0432b96 | 2013-03-04 21:24:51 +1100 | [diff] [blame] | 24 | echo "Using FLAC binary :" $(which flac) |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 25 | |
| 26 | date=`date "+%Y%m%dT%H%M%S"` |
| 27 | fname="comp${date}.flac" |
| 28 | |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 29 | last_k=0 |
Erik de Castro Lopo | 0432b96 | 2013-03-04 21:24:51 +1100 | [diff] [blame] | 30 | last_size=$(wc -c < noisy-sine.wav) |
| 31 | |
| 32 | echo "Original file size ${last_size} bytes." |
| 33 | |
Erik de Castro Lopo | f2e10fa | 2013-04-28 15:52:07 +1000 | [diff] [blame] | 34 | for k in 0 1 2 3 4 5 6 7 8 ; do |
Erik de Castro Lopo | a9712a2 | 2013-09-16 19:55:11 +1000 | [diff] [blame] | 35 | flac${EXE} -${k} --silent noisy-sine.wav -o ${fname} |
Erik de Castro Lopo | 0432b96 | 2013-03-04 21:24:51 +1100 | [diff] [blame] | 36 | size=$(wc -c < ${fname}) |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 37 | echo "Compression level ${k}, file size ${size} bytes." |
Erik de Castro Lopo | 0432b96 | 2013-03-04 21:24:51 +1100 | [diff] [blame] | 38 | if test ${last_size} -lt ${size} ; then |
Erik de Castro Lopo | b147b73 | 2014-11-26 16:20:06 +1100 | [diff] [blame] | 39 | echo "Error : Compression ${last_k} size ${last_size} >= compression ${k} size ${size}." |
Erik de Castro Lopo | 0432b96 | 2013-03-04 21:24:51 +1100 | [diff] [blame] | 40 | exit 1 |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 41 | fi |
Erik de Castro Lopo | 1a7c3fa | 2014-11-27 13:03:13 +1100 | [diff] [blame] | 42 | # Need this because OSX's 'wc -c' returns a number with leading whitespace. |
| 43 | last_size=$((${size}+10)) |
Erik de Castro Lopo | 0432b96 | 2013-03-04 21:24:51 +1100 | [diff] [blame] | 44 | last_k=${k} |
| 45 | rm -f ${fname} |
Erik de Castro Lopo | 1f0dacc | 2012-10-14 21:40:40 +1100 | [diff] [blame] | 46 | done |