2013년 11월 1일 금요일

SoX Library 컴파일하기(for OS X)

./osxbuild 실행

오류
$ ruby -e "$(curl -fsSL https://raw.github.com/mxcl/homebrew/go)"
$ brew install automake

재시도

$ ./osxbuild
configure.ac:21: installing './compile'
configure.ac:10: installing './config.guess'
configure.ac:10: installing './config.sub'
configure.ac:12: installing './install-sh'
configure.ac:12: installing './missing'
libgsm/Makefile.am:35: error: Libtool library used but 'LIBTOOL' is undefined
libgsm/Makefile.am:35:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
libgsm/Makefile.am:35:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
libgsm/Makefile.am:35:   If 'LT_INIT' is in 'configure.ac', make sure
libgsm/Makefile.am:35:   its definition is in aclocal's search path.
libgsm/Makefile.am: installing './depcomp'
lpc10/Makefile.am:8: error: Libtool library used but 'LIBTOOL' is undefined
lpc10/Makefile.am:8:   The usual way to define 'LIBTOOL' is to add 'LT_INIT'
lpc10/Makefile.am:8:   to 'configure.ac' and run 'aclocal' and 'autoconf' again.
lpc10/Makefile.am:8:   If 'LT_INIT' is in 'configure.ac', make sure
lpc10/Makefile.am:8:   its definition is in aclocal's search path.
autoreconf: automake failed with exit status: 1
configure: WARNING: unrecognized options: --disable-shared
checking build system type... x86_64-apple-darwin13.0.0
checking host system type... x86_64-apple-darwin13.0.0
checking target system type... x86_64-apple-darwin13.0.0
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... no
configure: error: in `/Users/spectrum/Documents/c/sox':
configure: error: C compiler cannot create executables
See `config.log' for more details
make: *** No rule to make target `all'.  Stop.


음. 기분이 나쁘군. 레퍼런스를 보고 하자.


mp3 까지 지원된다면 감사감사.
sox-14.4.1, lame-3.99.5, libmad-0.15.1b.  3종을 먼저 받으라고 하는데 libmad는 안쓰면 안되나? lame만 쓰고 싶은데 라이센스 문제도 싫고.

lame 해보자 lame

./configure CFLAGS="-m32 -arch i386" LDFLAGS="-arch i386" --enable-shared --disable-static
sudo make
sudo make install

별 탈 없이 잘된다.
$ lame --help
LAME 32bits version 3.99.5 (http://lame.sf.net)

usage: lame [options] <infile> [outfile]

    <infile> and/or <outfile> can be "-", which means stdin/stdout.

RECOMMENDED:
    lame -V2 input.wav output.mp3

OPTIONS:
    -b bitrate      set the bitrate, default 128 kbps
    -h              higher quality, but a little slower.  Recommended.
    -f              fast mode (lower quality)
    -V n            quality setting for VBR.  default n=4
                    0=high quality,bigger files. 9=smaller files
    --preset type   type must be "medium", "standard", "extreme", "insane",
                    or a value for an average desired bitrate and depending
                    on the value specified, appropriate quality settings will
                    be used.
                    "--preset help" gives more info on these

    --help id3      ID3 tagging related options

    --longhelp      full list of options

    --license       print License information

다행이야 다행.
친절하게 testcase.wav랑 mp3도 있네
testcase.mp3는 지우고 

$ lame testcase.wav
LAME 3.99.5 32bits (http://lame.sf.net)
Using polyphase lowpass filter, transition band: 16538 Hz - 17071 Hz
Encoding testcase.wav to testcase.mp3
Encoding as 44.1 kHz j-stereo MPEG-1 Layer III (11x) 128 kbps qval=3
    Frame          |  CPU time/estim | REAL time/estim | play/CPU |    ETA 
    23/23    (100%)|    0:00/    0:00|    0:00/    0:00|   9.7248x|    0:00 
-----------------------------------------------------------------------------------------------
   kbps        LR    MS  %     long switch short %
  128.0       95.7   4.3        78.3  13.0   8.7
Writing LAME Tag...done
ReplayGain: -1.6dB

잘됨. 만족

libmad도 해본다.
./configure CFLAGS="-m32 -arch i386" LDFLAGS="-arch i386" --enable-shared --disable-static
sudo make
sudo make install

이건 실행파일은 아니니까 존재유무만 확인하자.
$ ls /usr/local/lib/libmad*
/usr/local/lib/libmad.0.2.1.dylib /usr/local/lib/libmad.dylib
/usr/local/lib/libmad.0.dylib     /usr/local/lib/libmad.la

좋아. 이상없음.

./configure CFLAGS="-m32 -arch i386" LDFLAGS="-arch i386" --with-mad --with-lame

돌리다가
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
checking whether ln -s works... yes
./configure: line 4327: syntax error near unexpected token `dlopen'
./configure: line 4327: `LT_INIT(dlopen win32-dll)'

오류. win32-dll? 안쓸거니까 막자. # 붙여서 주석처리.
......
그래도 안된다.

이럴땐 다른 걸 받아보자.
에서 다시 받아서 재시도.

BUILD OPTIONS
Debugging build............no
Distro name ...............not specified!
Dynamic loading support....no
Pkg-config location........$(libdir)/pkgconfig
Play and rec symlinks......yes
Symlinks enabled...........yes

OPTIONAL DEVICE DRIVERS
ao (Xiph)..................no
alsa (Linux)...............no
coreaudio (Mac OS X).......yes
sndio (OpenBSD)............no
oss........................no
pulseaudio.................no
sunaudio...................no
waveaudio (MS-Windows).....no

OPTIONAL FILE FORMATS
amrnb......................no
amrwb......................no
ffmpeg.....................no
flac.......................no
gsm........................yes (in-tree)
lpc10......................yes (in-tree)
mp2/mp3....................yes
 id3tag....................no
 lame......................yes
 lame id3tag...............yes
 dlopen lame...............no
 mad.......................yes
 dlopen mad................no
 twolame...................no
oggvorbis..................no
sndfile....................no
wavpack....................no

OTHER OPTIONS
ladspa effects.............no
magic support..............no
png support................no
GOMP support...............no

Configure finished.  Do 'make -s && make install' to compile and install SoX.

성공인 느낌.
sudo make -s
엄청난 양의 warning; 하지만 에러는 없네.

$ sudo make install
Making install in lpc10
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
Making install in libgsm
make[2]: Nothing to be done for `install-exec-am'.
make[2]: Nothing to be done for `install-data-am'.
Making install in src
 .././install-sh -c -d '/usr/local/lib'
 /bin/sh ../libtool --silent  --silent --mode=install /usr/bin/install -c   libsox.la '/usr/local/lib'
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ranlib: file: /usr/local/lib/libsox.a(libsox_la-ladspa.o) has no symbols
 .././install-sh -c -d '/usr/local/bin'
  /bin/sh ../libtool --silent  --silent --mode=install /usr/bin/install -c sox '/usr/local/bin'
/Applications/Xcode.app/Contents/Developer/usr/bin/make  install-exec-hook
if test "yes" = "yes"; then \
cd /usr/local/bin; rm -f  play rec; ln -s sox play; ln -s sox rec; \
fi
if test "yes" = "yes"; then \
cd /usr/local/bin; rm -f  soxi; ln -s sox soxi; \
fi
 .././install-sh -c -d '/usr/local/include'
 /usr/bin/install -c -m 644 sox.h '/usr/local/include'
make[2]: Nothing to be done for `install-exec-am'.
 ./install-sh -c -d '/usr/local/share/man/man1'
 /usr/bin/install -c -m 644 sox.1 soxi.1 '/usr/local/share/man/man1'
 ./install-sh -c -d '/usr/local/share/man/man3'
 /usr/bin/install -c -m 644 libsox.3 '/usr/local/share/man/man3'
 ./install-sh -c -d '/usr/local/share/man/man7'
 /usr/bin/install -c -m 644 soxformat.7 '/usr/local/share/man/man7'
 ./install-sh -c -d '/usr/local/lib/pkgconfig'
 /usr/bin/install -c -m 644 sox.pc '/usr/local/lib/pkgconfig'
/Applications/Xcode.app/Contents/Developer/usr/bin/make  install-data-hook
cd /usr/local/share/man/man1 && rm -f play.1 && ln -s sox.1 play.1
cd /usr/local/share/man/man1 && rm -f rec.1 && ln -s sox.1 rec.1
cd /usr/local/share/man/man7 && rm -f soxeffect.7 && ln -s ../man1/sox.1 soxeffect.7

어? 생각보다 어렵지 않게 잘 됨.
원래 잘 되는거구나;
확인.

$ sox
sox:      SoX v14.4.1

sox FAIL sox: Not enough input filenames specified

Usage summary: [gopts] [[fopts] infile]... [fopts] outfile [effect [effopt]]...

SPECIAL FILENAMES (infile, outfile):
-                        Pipe/redirect input/output (stdin/stdout); may need -t
-d, --default-device     Use the default audio device (where available)
-n, --null               Use the `null' file handler; e.g. with synth effect
-p, --sox-pipe           Alias for `-t sox -'

SPECIAL FILENAMES (infile only):
"|program [options] ..." Pipe input from external program (where supported)
http://server/file       Use the given URL as input file (where supported)

GLOBAL OPTIONS (gopts) (can be specified at any point before the first effect):
--buffer BYTES           Set the size of all processing buffers (default 8192)
--clobber                Don't prompt to overwrite output file (default)
--combine concatenate    Concatenate all input files (default for sox, rec)
--combine sequence       Sequence all input files (default for play)
-D, --no-dither          Don't dither automatically
--effects-file FILENAME  File containing effects and options
-G, --guard              Use temporary files to guard against clipping
-h, --help               Display version number and usage information
--help-effect NAME       Show usage of effect NAME, or NAME=all for all
--help-format NAME       Show info on format NAME, or NAME=all for all
--i, --info              Behave as soxi(1)
--input-buffer BYTES     Override the input buffer size (default: as --buffer)
--no-clobber             Prompt to overwrite output file
-m, --combine mix        Mix multiple input files (instead of concatenating)
--combine mix-power      Mix to equal power (instead of concatenating)
-M, --combine merge      Merge multiple input files (instead of concatenating)
--norm                   Guard (see --guard) & normalise
--play-rate-arg ARG      Default `rate' argument for auto-resample with `play'
--plot gnuplot|octave    Generate script to plot response of filter effect
-q, --no-show-progress   Run in quiet mode; opposite of -S
--replay-gain track|album|off  Default: off (sox, rec), track (play)
-R                       Use default random numbers (same on each run of SoX)
-S, --show-progress      Display progress while processing audio data
--single-threaded        Disable parallel effects channels processing
--temp DIRECTORY         Specify the directory to use for temporary files
-T, --combine multiply   Multiply samples of corresponding channels from all
                         input files (instead of concatenating)
--version                Display version number of SoX and exit
-V[LEVEL]                Increment or set verbosity level (default 2); levels:
                           1: failure messages
                           2: warnings
                           3: details of processing
                           4-6: increasing levels of debug messages
FORMAT OPTIONS (fopts):
Input file format options need only be supplied for files that are headerless.
Output files will have the same format as the input file where possible and not
overriden by any of various means including providing output format options.

-v|--volume FACTOR       Input file volume adjustment factor (real number)
--ignore-length          Ignore input file length given in header; read to EOF
-t|--type FILETYPE       File type of audio
-e|--encoding ENCODING   Set encoding (ENCODING may be one of signed-integer,
                         unsigned-integer, floating-point, mu-law, a-law,
                         ima-adpcm, ms-adpcm, gsm-full-rate)
-b|--bits BITS           Encoded sample size in bits
-N|--reverse-nibbles     Encoded nibble-order
-X|--reverse-bits        Encoded bit-order
--endian little|big|swap Encoded byte-order; swap means opposite to default
-L/-B/-x                 Short options for the above
-c|--channels CHANNELS   Number of channels of audio data; e.g. 2 = stereo
-r|--rate RATE           Sample rate of audio
-C|--compression FACTOR  Compression factor for output format
--add-comment TEXT       Append output file comment
--comment TEXT           Specify comment text for the output file
--comment-file FILENAME  File containing comment text for the output file
--no-glob                Don't `glob' wildcard match the following filename

AUDIO FILE FORMATS: 8svx aif aifc aiff aiffc al amb au avr cdda cdr cvs cvsd cvu dat dvms f32 f4 f64 f8 fssd gsm gsrt hcom htk ima ircam la lpc lpc10 lu maud mp2 mp3 nist prc raw s1 s16 s2 s24 s3 s32 s4 s8 sb sf sl sln smp snd sndr sndt sou sox sph sw txw u1 u16 u2 u24 u3 u32 u4 u8 ub ul uw vms voc vox wav wavpcm wve xa
PLAYLIST FORMATS: m3u pls
AUDIO DEVICE DRIVERS: coreaudio

EFFECTS: allpass band bandpass bandreject bass bend biquad chorus channels compand contrast dcshift deemph delay dither divide+ downsample earwax echo echos equalizer fade fir firfit+ flanger gain highpass hilbert input# loudness lowpass mcompand mixer* noiseprof noisered norm oops output# overdrive pad phaser pitch rate remix repeat reverb reverse riaa silence sinc speed splice stat stats stretch swap synth tempo treble tremolo trim upsample vad vol
  * Deprecated effect    + Experimental effect    # LibSoX-only effect
EFFECT OPTIONS (effopts): effect dependent; see --help-effect

멋있게 잘 나오네.
그럼 이제 이걸 crossbridge로 올려봐야지.