기본 콘텐츠로 건너뛰기

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로 올려봐야지.

댓글

이 블로그의 인기 게시물

cURL로 cookie를 다루는 법

http://stackoverflow.com/questions/22252226/passport-local-strategy-and-curl 레거시 소스를 보다보면 인증 관련해서 cookie를 사용하는 경우가 있는데 가령 REST 서버인 경우 curl -H "Content-Type: application/json" -X POST -d '{"email": "aaa@bbb.com", "pw": "cccc"}' "http://localhost/login" 이렇게 로그인이 성공이 했더라도 curl -H "Content-Type: application/json" -X GET -d '' "http://localhost/accounts/" 이런 식으로 했을 때 쿠키를 사용한다면 당연히 인증 오류가 날 것이다. curl의 --cookie-jar 와 --cookie 옵션을 사용해서 cookie를 저장하고 꺼내쓰자. 각각 옵션 뒤엔 저장하고 꺼내쓸 파일이름을 임의로 지정하면 된다. 위의 과정을 다시 수정해서 적용하면 curl -H --cookie-jar jarfile "Content-Type: application/json" -X POST -d '{"email": "aaa@bbb.com", "pw": "cccc"}' "http://localhost/login" curl -H --cookie jarfile "Content-Type: application/json" -X GET -d '' "http://localhost/accounts/" 이렇게 사용하면

MQTT Broker Mosquitto 설치 후 설정

우분투 기준 $ sudo apt-add-repository ppa:mosquitto-dev/mosquitto-ppa $ sudo apt-get update 하고 $ sudo apt-get install mosquitto 으로 설치하면 서비스까지 착실하게 올라간다. 설치는 간단한데 사용자를 만들어야한다. /etc/mosquitto/mosquitto.conf 파일에서 권한 설정을 변경하자. allow_anonymous false 를 추가해서 아무나 못들어오게 하자. $ service mosquitto restart 서비스를 재시작. 이제 사용자를 추가하자. mosquitto_passwd <암호파일 경로명> <사용자명> 하면 쉽게 만들 수 있다. # mosquitto_passwd /etc/mosquitto/passwd admin Password:  Reenter password:  암호 넣어준다. 두번 넣어준다. 이제 MQTT 약을 열심히 팔아서 Broker 사글세방 임대업을 하자.

MQTT 접속해제 - LWT(Last will and testament)

통신에서 중요하지만 구현이 까다로운 문제로 "상대방이 예상치 못한 상황으로 인하여 접속이 끊어졌을때"의 처리가 있다. 이것이 까다로운 이유는 상대방이 의도적으로 접속을 종료한 경우는 접속 종료 직전에 자신의 종료 여부를 알리고 나갈 수 있지만 프로그램 오류/네트웍 연결 강제 종료와 같은 의도치 않은 상황에선 자신의 종료를 알릴 수 있는 방법 자체가 없기 때문이다. 그래서 전통적 방식으로는 자신의 생존 여부를 계속 ping을 통해 서버가 물어보고 timeout 시간안에 pong이 안올 경우 서버에서 접속 종료를 인식하는 번거로운 방식을 취하는데 MQTT의 경우 subscribe 시점에서 자신이 접속 종료가 되었을 때 특정 topic으로 지정한 메시지를 보내도록 미리 설정할 수 있다. 이를 LWT(Last will and testament) 라고 한다. 선언을 먼저하고 브로커가 처리하게 하는 방식인 것이다. Last Will And Testament 라는 말 자체도 흥미롭다. 법률용어인데  http://www.investopedia.com/terms/l/last-will-and-testament.asp 대략 내가 죽으면 뒷산 xx평은 작은 아들에게 물려주고 어쩌고 하는 상속 문서 같은 내용이다. 즉, 내가 죽었을(연결이 끊어졌을) 때에 변호사(MQTT Broker - ex. mosquitto/mosca/rabbitMQ등)로 하여금 나의 유언(메시지)를 상속자(해당 토픽에 가입한 subscriber)에게 전달한다라는 의미가 된다. MQTT Client 가 있다면 한번 실습해보자. 여러가지가 있겠지만 다른 글에서처럼  https://www.npmjs.com/package/mqtt  을 사용하도록 한다. npm install mqtt --save 로 설치해도 되고 내 경우는 자주 사용하는 편이어서 npm install -g mqtt 로 전역설치를 했다. 호스트는 무료 제공하고 있는 test.mosquitto.org 를