forked from chirlu/sox
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL
350 lines (249 loc) · 12.5 KB
/
INSTALL
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
SoX Installation
----------------
SoX should compile and run on any POSIX compatible system (Linux, BSD,
Solaris, Xcode on Mac OS X, Cygwin on MS-Windows, etc.). Some
non-POSIX compilers (such as MSVC) are supported via the `CMake' build
utility. For other compilers/systems, it is often possible to
manually construct a custom `soxconfig.h' and `Makefile' for that
system (the minimum requirements are 32-bit CPU, 64-bit FPU, C89
compiler).
Note that the `play', `rec', and `soxi' programs are in fact just
copies-of or links-to (depending on OS) `sox'.
SoX optionally makes use of some external libraries to obtain support
for additional file formats and/or effects. Optional libraries should
be installed before compiling SoX. The current list of supported
libraries, where to get them (if not from your OS distribution), and
their licence types, is as follows:
OpencoreAMR-NB/WB http://sourceforge.net/projects/opencore-amr Apache
AMR-NB/WB http://www.penguin.cz/~utx/amr See library web page
AO http://xiph.org/ao GPL
FLAC http://flac.sourceforge.net BSD
LADSPA http://www.ladspa.org LGPL + plugins' licence
Lame MP3 encoder http://lame.sourceforge.net LGPL
Twolame MP2 enc. http://www.twolame.org LGPL
libltdl http://www.gnu.org/software/libtool LGPL
MAD MP3 decoder http://www.underbit.com/products/mad GPL
MP3 ID3 tags http://www.underbit.com/products/mad GPL
Magic http://www.darwinsys.com/file BSD
Ogg Vorbis http://www.vorbis.com BSD
Opus http://www.opus-codec.org/ BSD
PNG http://www.libpng.org/pub/png zlib (BSD-like)
Sndfile http://www.mega-nerd.com/libsndfile LGPL
WavPack http://www.wavpack.com BSD
Compiling and installing on a POSIX system
------------------------------------------
First install any optional libraries that you need for SoX. Some
libraries may require pkg-config to be installed to be properly
detected by SoX.
[Only if you're compiling the git sources, first make sure you have
the GNU autotools installed (automake >= 1.9, autoconf >= 2.62) and
run
autoreconf -i
]
To compile and install SoX (executables, libraries, manual pages) with
a default configuration for your platform, run the following commands:
./configure
make -s
make install
There should be no errors and few, if any, warnings during the `make
-s' stage. Any warnings about pointer mismatch or conversion should
be treated with deep suspicion.
The `make install' command may require `root' priviliges; for example,
on some systems, the following modification to the command is needed:
sudo make install
To run a selection of tests on the installed sox executable:
make installcheck
Optionally, HTML & PDF versions of the manual pages can be built and
installed as follows:
make html
make install-html
make pdf
make install-pdf
Again, `root' priviliges may be needed at the install stages.
Custom build options on a POSIX system
--------------------------------------
Selection of optional libraries and of other build options can be made
by adding parameters to the `./configure' command line (above). Run
./configure --help
for a complete list of options.
Each optional file-format may be configured to be loaded statically
(the default) or dynamically. The dynamic option may be useful for
distribution packaging reasons -- for example, to keep separate `free'
and `non-free' software.
If you are building SoX for a `distribution' (i.e. the build will be
used by others), please use --with-distro to identify the distribution
as this information is useful in helping to diagnose SoX bug reports.
For example,
./configure --with-distro='Super Linux OS 6.1'
If any libraries are installed in a non-standard locations in your
system then you can use the CPPFLAGS and LDFLAGS variables to allow
configure to find them. For example:
./configure CPPFLAGS="-I/home/sox/include -I/usr/local/multimedia/include" LDFLAGS="-L/home/sox/lib -L/usr/local/multimedia/lib"
If you are compiling under cygwin and would like to create a static
sox.exe using mingw libraries then you can use the following:
./configure CC="gcc -mno-cygwin" --disable-shared
The next cygwin example is used to build the cygwin version of SoX that is
distributed by the project. It tells gcc to prefer static libraries
over dynamic ones and to use some static libraries compiled manually
and installed under /usr/local.
./configure LDFLAGS="-static -L/usr/local/lib" CPPFLAGS=-I/usr/local/include
You can run "cygcheck.exe src/sox.exe" after compiling to see which
dynamic DLL's will be required to be distributed with the cygwin
executable.
Alternatively, you can make use of the "cygbuild" script distributed
with SoX source that is used to automate all steps of building
a win32 package. "osxbuild" script is used to automate all steps
of building a MacOS X package.
Newer versions of SoX include support for loading libraries for
file formats at runtime. The main usage of this feature is to
allow shipping SoX without dependencies on external libraries
that are not globally used or have redistribution restrictions.
If you experience problems with this then you may wish to disable
this feature:
./configure --without-libltdl
Also, the default behavior even when libltdl is used is to link
all file format handlers into libsox as there is a performance
hit when dynamically loading external libraries. To force a format
handler to be built as a dynamically loaded module, pass "dyn" to
its --with-* option. For example, to build pulseaudio handler as
an external dynamic library:
./configure --with-pulseaudio=dyn
A subset of external libraries can be configured to be dlopen()'ed
at run time instead of being linked in. This will allow one to
distribute a binary with optional features that only require
a user to install the missing libraries into their system. This
can be enabled using:
--enable-dl-lame
--enable-dl-mad
--enable-dl-sndfile
--enable-dl-amrnb
--enable-dl-amrwb
Testing
-------
N.B.: If SoX is configured and compiled to load some file-formats
dynamically, then it will not be able to load them when running SoX
executables from within the source file directory until after SoX has
been installed (temporarily configuring with --without-libltdl removes
this restriction).
After successfully compiling SoX, try translating a sound file. You
should also playback the new file to make sure it sounds like the
original. You can either use an external program or SoX itself
if compiled with playback support.
To work with widest range of playback programs, you should chose a
format that is native to your OS; such as .wav for Windows or .aiff for
MacOS. In the following example, we'll use .xxx as the extension of
your preferred format.
cd src
./sox monkey.wav monkey.xxx
You may have to give the word size and rate for the file. For example,
this command will make a sound file with a data rate of 12,500 samples
per second and the data formatted as 2-byte (16-bit) signed integers:
./sox monkey.wav -r 12500 -2 -s monkey.xxx
If playback support was compiled in then it can be played like this:
./play monkey.xxx
or, equivalently:
./sox monkey.xxx -d
If monkey.xxx plays properly (it's a very short monkey screech),
congratulations! SoX works.
If you're adding new features to SoX or want to perform advance tests
on a new platform then you can use the scripts "tests.sh" and
"testall.sh" to stress SoX.
Compiling using Microsoft's Visual C
------------------------------------
To compile a full-featured build of SoX with Visual Studio 2008 (msvc9),
Visual Studio 2010 (msvc10), or the Windows SDK 7.1, you may be able to use the
preconfigured solution found in the sox\msvc9 (VS2008) or sox\msvc10 (VS2010 or
Windows SDK 7.1) folder. See sox\msvc9\readme.txt or sox\msvc10\readme.txt for
details on building using the corresponding Microsoft C compiler. If the
preconfigured solution doesn't work for you, build with CMake as follows:
o Install cmake (http://www.cmake.org/HTML/Download.html)
o Install any optional libraries to use with SoX
o Unpack the SoX sources (...tar.gz) to say c:\sox
o Type cd c:\sox
o Type cmake -G "compiler" . (type cmake --help for list of compilers)
This should generate project build files for use with Visual C.
Appendix: How To Compile SoX with MP3 Support on Win32
------------------------------------------------------
The solution files in msvc9 and msvc10 will build SoX to dynamically load
libmad.dll and libmp3lame.dll at runtime.
The following text, untested by the SoX team, was originally written
by `Enter AG' and released to the public domain. It includes instructions for
building SoX with MP3 support linked directly into the SoX executable.
= How To Compile Sox with MP3 Support =
== Requirements ==
The following requirements have been tested. Nevertheless, other
versions may work as well.
o Microsoft Windows (Win32, Win2000, XP, Win2003, Vista, etc.).
o CMake (Cross Platform Make) version 2.4
available on [http://www.cmake.org]
o Microsoft Visual Stuio 2008 (earlier versions should also work).
o SoX source distribution version 14.0.1
available on [http://sox.sourceforge.net]
o LAME source distribution version 3.97. LAME 3.98 is required for full ID3 tag
support. Available on [http://lame.sourceforge.net]
o MAD source distribution version 0.15.1b
available on [http://www.underbit.com/products/mad/]
== Compilation Procedure ==
=== Compilation of the LAME libraries ===
o Extract the LAME source distribution and open it as a Visual Studio project
using the VS file in the top directory.
o Set the ''libmp3lame'' "Configuration Properties -> C/C++ -> Code Generation
-> Runtime Library" to Multi-threaded DLL (/MD).
o Do the same for ''mpglib'' .
o Build ''libmp3lame'' and ''mpglib.''
o Rename the static library libmp3lame.lib to mp3lame.lib.
o Create a folder somewhere with an arbitrary name. We used the name
"lameforsox". Create in this folder a new folder called "lame" and copy the
lame.h header file into it. Copy mp3lame.lib and mpglib.lib in the lameforsox
folder. Now you should have prepared the lame components for further use like
this:
...\[somewhere]\lameforsox\
mp3lame.lib
mpglib.lib
\lame\
lame.h
=== Compilation of the MAD library ===
o Compile ''libmad'' with the same "Runtime Library" settings as described for
LAME (previous section Compilation of the LAME libraries).
o Rename the static library libmad.lib to mad.lib.
=== Compilation of SoX with the LAME and MAD libraries ===
o Open Visual Studio and add in "Tools -> Options -> Projects and Solutions ->
VC++ Directories" in the "Include Directories" collection the folder
containing the MAD header file mad.h and the folder containing lame/lame.h
(...\[somewhere]\lameforsox). Add in the "Library files" collection the
folder containing mad.lib and the folder containing the lame libraries
mp3lame.lib and mpglib.lib (...\[somewhere]\lameforsox).
o Edit the CMakeLists.txt in the SoX top directory:
Add
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} mpglib)
after some blank lines beneath the statement
if(NEED_LIBM)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} -lm)
endif(NEED_LIBM)
o Open the windows command line console and change into the SoX top directory.
o Execute cmake like this:
cmake.exe ./ -G "Visual Studio 9 2008"
o If the Visual Studio settings are done as described above the following cmake
output should appear:
...
include files HAVE_MAD_H1 - found
mad_stream_buffer in madmad_stream_buffer in mad - found
...
include files HAVE_LAME_LAME_H1 - found
lame_init in mp3lamelame_init in mp3lame - found
...
o If not check CMakeFiles\CMakeError.log.
o Open Visual Studio and open the SoX solution file in the SoX top directory
(sox.sln).
o Rebuild "ALL_BUILD" and confirm all "File Modification Detected" dialogs
with "Reload".
o Add in the libsox "Preprocessor Definitions" (right click on libsox ->
Properties -> Configuration Properties -> C/C++ -> Preprocessor) HAVE_STRING_H
before the first line. Set the "Runtime Library" to Multi-threaded DLL (/MD)
as described above.
o Do the same for sox and add in the "Additional Dependencies" (Linker -> Input)
after the last line mpglib.lib.
o Now build libsox
o and then sox.
o Sox now prompts "mp3, mp2" in the usage output in the section "SUPPORTED FILE
FORMATS".