Mercurial > hg > sv-dependency-builds
comparison src/libsndfile-1.0.27/doc/FAQ.html @ 125:cd6cdf86811e
Current libsndfile source
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 18 Oct 2016 13:22:47 +0100 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
124:e3d5853d5918 | 125:cd6cdf86811e |
---|---|
1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> | |
2 <HTML> | |
3 | |
4 <HEAD> | |
5 <TITLE> | |
6 libsndfile : Frequently Asked Questions. | |
7 </TITLE> | |
8 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)"> | |
9 <META NAME="Description" CONTENT="The libsndfile FAQ."> | |
10 <META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux"> | |
11 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all"> | |
12 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print"> | |
13 </HEAD> | |
14 | |
15 <BODY> | |
16 | |
17 <H1><B>libsndfile : Frequently Asked Questions.</B></H1> | |
18 <P> | |
19 <A HREF="#Q001">Q1 : Do you plan to support XYZ codec in libsndfile?</A><BR/> | |
20 <A HREF="#Q002">Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field | |
21 but version 1 does not. Why?</A><BR/> | |
22 <A HREF="#Q003">Q3 : Compiling is really slow on MacOS X. Why?</A><BR/> | |
23 <A HREF="#Q004">Q4 : When trying to compile libsndfile on Solaris I get a "bad | |
24 substitution" error during linking. What can I do to fix this?</A><BR/> | |
25 <A HREF="#Q005">Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</A><BR/> | |
26 <A HREF="#Q006">Q6 : What's the best format for storing temporary files?</A><BR/> | |
27 <A HREF="#Q007">Q7 : On Linux/Unix/MacOS X, what's the best way of detecting the | |
28 presence of libsndfile?</A><BR/> | |
29 <A HREF="#Q008">Q8 : I have libsndfile installed and now I want to use it. I | |
30 just want a simple Makefile! What do I do?</A><BR/> | |
31 <A HREF="#Q009">Q9 : How about adding the ability to write/read sound files to/from | |
32 memory buffers?</A><BR/> | |
33 <A HREF="#Q010">Q10 : Reading a 16 bit PCM file as normalised floats and then | |
34 writing them back changes some sample values. Why?</A><BR/> | |
35 <A HREF="#Q011">Q11 : I'm having problems with u-law encoded WAV files generated by | |
36 libsndfile in Winamp. Why?</A><BR/> | |
37 <A HREF="#Q012">Q12 : I'm looking at sf_read*. What are items? What are frames?</A><BR/> | |
38 <A HREF="#Q013">Q13 : Why can't libsndfile open this Sound Designer II (SD2) | |
39 file?</A><BR/> | |
40 <A HREF="#Q014">Q14 : I'd like to statically link libsndfile to my closed source | |
41 application. Can I buy a license so that this is possible?</A><BR/> | |
42 <A HREF="#Q015">Q15 : My program is crashing during a call to a function in libsndfile. | |
43 Is this a bug in libsndfile?</A><BR/> | |
44 <A HREF="#Q016">Q16 : Will you accept a fix for compiling libsndfile with compiler X? | |
45 </A><BR/> | |
46 <A HREF="#Q017">Q17 : Can libsndfile read/write files from/to UNIX pipes? | |
47 </A><BR/> | |
48 <A HREF="#Q018">Q18 : Is it possible to build a Universal Binary on Mac OS X? | |
49 </A><BR/> | |
50 <A HREF="#Q019">Q19 : I have project files for Visual Studio / XCode / Whatever. Why | |
51 don't you distribute them with libsndfile? | |
52 </A><BR/> | |
53 <A HREF="#Q020">Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source | |
54 projects support it! | |
55 </A><BR/> | |
56 <A HREF="#Q021">Q21 : How do I use libsndfile in a closed source or commercial program | |
57 and comply with the license? | |
58 </A><BR/> | |
59 <A HREF="#Q022">Q22 : What versions of windows does libsndfile work on? | |
60 </A><BR/> | |
61 <A HREF="#Q023">Q23 : I'm cross compiling libsndfile for another platform. How can I | |
62 run the test suite? | |
63 </A><BR/> | |
64 <HR> | |
65 | |
66 <!-- ========================================================================= --> | |
67 <A NAME="Q001"></A> | |
68 <H2><BR/><B>Q1 : Do you plan to support XYZ codec in libsndfile?</B></H2> | |
69 <P> | |
70 If source code for XYZ codec is available under a suitable license (LGPL, BSD, | |
71 MIT etc) then yes, I'd like to add it. | |
72 </P> | |
73 <P> | |
74 If suitable documentation is available on how to decode and encode the format | |
75 then maybe, depending on how much work is involved. | |
76 </P> | |
77 <P> | |
78 If XYZ is some proprietary codec where no source code or documentation is | |
79 available then no. | |
80 </P> | |
81 <P> | |
82 So if you want support for XYZ codec, first find existing source code or | |
83 documentation. | |
84 If you can't find either then the answer is no. | |
85 </P> | |
86 <!-- ========================================================================= --> | |
87 <A NAME="Q002"></A> | |
88 <H2><BR/><B>Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field | |
89 but version 1 does not. Why?</B></H2> | |
90 <P> | |
91 This was dropped for a number of reasons: | |
92 </P> | |
93 <UL> | |
94 <LI> pcmbitwidth makes little sense on compressed or floating point formats | |
95 <LI> with the new API you really don't need to know it | |
96 </UL> | |
97 <P> | |
98 As documented | |
99 <A HREF="api.html#note1">here</A> | |
100 there is now a well defined behaviour which ensures that no matter what the | |
101 bit width of the source file, the scaling always does something sensible. | |
102 This makes it safe to read 8, 16, 24 and 32 bit PCM files using sf_read_short() | |
103 and always have the optimal behaviour. | |
104 </P> | |
105 | |
106 <!-- ========================================================================= --> | |
107 <A NAME="Q003"></A> | |
108 <H2><BR/><B>Q3 : Compiling is really slow on MacOS X. Why?</B></H2> | |
109 <P> | |
110 When you configure and compile libsndfile, it uses the /bin/sh shell for a number | |
111 of tasks (ie configure script and libtool). | |
112 Older versions of OS X (10.2?) shipped a really crappy Bourne shell as /bin/sh | |
113 which resulted in <b>really</b> slow compiles. | |
114 Newer version of OS X ship GNU Bash as /bin/sh and this answer doesn't apply in that | |
115 case. | |
116 </P> | |
117 <P> | |
118 To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to | |
119 /bin/sh.old and make a symlink from /bin/sh to the bash shell. | |
120 Bash is designed to behave as a Bourne shell when is is called as /bin/sh. | |
121 </P> | |
122 <P> | |
123 When I did this on my iBook running MacOS X, compile times dropped from 13 minutes | |
124 to 3 minutes. | |
125 </P> | |
126 | |
127 <!-- ========================================================================= --> | |
128 <A NAME="Q004"></A> | |
129 <H2><BR/><B>Q4 : When trying to compile libsndfile on Solaris I get a "bad | |
130 substitution" error on linking. Why?</B></H2> | |
131 <P> | |
132 It seems that the Solaris Bourne shell disagrees with GNU libtool. | |
133 </P> | |
134 <P> | |
135 To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to | |
136 /bin/sh.old and make a symlink from /bin/sh to the bash shell. | |
137 Bash is designed to behave as a Bourne shell when is is called as /bin/sh. | |
138 </P> | |
139 | |
140 <!-- ========================================================================= --> | |
141 <A NAME="Q005"></A> | |
142 <H2><BR/><B>Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</B></H2> | |
143 <P> | |
144 This problem is bigger than it may seem at first. | |
145 </P> | |
146 <P> | |
147 For a stereo file, it is a pretty safe bet that a simple interleaving/de-interleaving | |
148 could satisfy most users. | |
149 However, for files with more than 2 channels this is unlikely to be the case. | |
150 If the user has a 4 channel file and want to play that file on a stereo output | |
151 sound card they either want the first 2 channels or they want some mixed combination | |
152 of the 4 channels. | |
153 </P> | |
154 <P> | |
155 When you add more channels, the combinations grow exponentially and it becomes | |
156 increasingly difficult to cover even a sensible subset of the possible combinations. | |
157 On top of that, coding any one style of interleaver/de-interleaver is trivial, while | |
158 coding one that can cover all combinations is far from trivial. | |
159 This means that this feature will not be added any time soon. | |
160 </P> | |
161 | |
162 <!-- ========================================================================= --> | |
163 <A NAME="Q006"></A> | |
164 <H2><BR/><B>Q6 : What's the best format for storing temporary files?</B></H2> | |
165 | |
166 <P> | |
167 When you want to store temporary data there are a number of requirements; | |
168 </P> | |
169 <UL> | |
170 <LI> A simple, easy to parse header. | |
171 <LI> The format must provide the fastest possible read and write rates (ie | |
172 avoid conversions and encoding/decoding). | |
173 <LI> The file format must be reasonably common and playable by most players. | |
174 <LI> Able to store data in either endian-ness. | |
175 </UL> | |
176 <P> | |
177 The format which best meets these requirements is AU, which allows data to be | |
178 stored in any one of short, int, float and double (among others) formats. | |
179 </P> | |
180 <P> | |
181 For instance, if an application uses float data internally, its temporary files | |
182 should use a format of (SF_ENDIAN_CPU | SF_FORMAT_AU | SF_FORMAT_FLOAT) which | |
183 will store big endian float data in big endian CPUs and little endian float data | |
184 on little endian CPUs. | |
185 Reading and writing this format will not require any conversions or byte swapping | |
186 regardless of the host CPU. | |
187 </P> | |
188 | |
189 <!-- ========================================================================= --> | |
190 | |
191 <A NAME="Q007"></A> | |
192 <H2><BR/><B>Q7 : On Linux/Unix/MaxOS X, what's the best way of detecting the presence | |
193 of libsndfile using autoconf?</B></H2> | |
194 | |
195 <P> | |
196 libsndfile uses the pkg-config (man pkg-config) method of registering itself with the | |
197 host system. | |
198 The best way of detecting its presence is using something like this in configure.ac | |
199 (or configure.in): | |
200 </P> | |
201 <PRE> | |
202 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.2, ac_cv_sndfile=1, ac_cv_sndfile=0) | |
203 | |
204 AC_DEFINE_UNQUOTED([HAVE_SNDFILE],${ac_cv_sndfile}, | |
205 [Set to 1 if you have libsndfile.]) | |
206 | |
207 AC_SUBST(SNDFILE_CFLAGS) | |
208 AC_SUBST(SNDFILE_LIBS) | |
209 </PRE> | |
210 <P> | |
211 This will automatically set the <B>SNDFILE_CFLAGS</B> and <B>SNDFILE_LIBS</B> | |
212 variables which can be used in Makefile.am like this: | |
213 </P> | |
214 <PRE> | |
215 SNDFILE_CFLAGS = @SNDFILE_CFLAGS@ | |
216 SNDFILE_LIBS = @SNDFILE_LIBS@ | |
217 </PRE> | |
218 <P> | |
219 If you install libsndfile from source, you will probably need to set the | |
220 <B>PKG_CONFIG_PATH</B> environment variable as suggested at the end of the | |
221 libsndfile configure process. For instance on my system I get this: | |
222 </P> | |
223 <PRE> | |
224 -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=- | |
225 | |
226 Configuration summary : | |
227 | |
228 Version : ..................... 1.0.5 | |
229 Experimental code : ........... no | |
230 | |
231 Tools : | |
232 | |
233 Compiler is GCC : ............. yes | |
234 GCC major version : ........... 3 | |
235 | |
236 Installation directories : | |
237 | |
238 Library directory : ........... /usr/local/lib | |
239 Program directory : ........... /usr/local/bin | |
240 Pkgconfig directory : ......... /usr/local/lib/pkgconfig | |
241 | |
242 Compiling some other packages against libsndfile may require | |
243 the addition of "/usr/local/lib/pkgconfig" to the | |
244 PKG_CONFIG_PATH environment variable. | |
245 </PRE> | |
246 | |
247 <!-- ========================================================================= --> | |
248 | |
249 <A NAME="Q008"></A> | |
250 <H2><BR/><B>Q8 : I have libsndfile installed and now I want to use it. I just want | |
251 a simple Makefile! What do I do?</B></H2> | |
252 | |
253 <P> | |
254 The <B>pkg-config</B> program makes finding the correct compiler flag values and | |
255 library location far easier. | |
256 During the installation of libsndfile, a file named <B>sndfile.pc</B> is installed | |
257 in the directory <B>${libdir}/pkgconfig</B> (ie if libsndfile is installed in | |
258 <B>/usr/local/lib</B>, <B>sndfile.pc</B> will be installed in | |
259 <B>/usr/local/lib/pkgconfig/</B>). | |
260 </P> | |
261 <P> | |
262 In order for pkg-config to find sndfile.pc it may be necessary to point the | |
263 environment variable <B>PKG_CONFIG_PATH</B> in the right direction. | |
264 </P> | |
265 <PRE> | |
266 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig | |
267 </PRE> | |
268 | |
269 <P> | |
270 Then, to compile a C file into an object file, the command would be: | |
271 </P> | |
272 <PRE> | |
273 gcc `pkg-config --cflags sndfile` -c somefile.c | |
274 </PRE> | |
275 <P> | |
276 and to link a number of objects into an executable that links against libsndfile, | |
277 the command would be: | |
278 </P> | |
279 <PRE> | |
280 gcc `pkg-config --libs sndfile` obj1.o obj2.o -o program | |
281 </PRE> | |
282 | |
283 <!-- ========================================================================= --> | |
284 | |
285 <A NAME="Q009"></A> | |
286 <H2><BR/><B>Q9 : How about adding the ability to write/read sound files to/from | |
287 memory buffers?</B></H2> | |
288 | |
289 <P> | |
290 This has been added for version 1.0.13. | |
291 </P> | |
292 | |
293 <!-- ========================================================================= --> | |
294 | |
295 <A NAME="Q010"></A> | |
296 <H2><BR/><B>Q10 : Reading a 16 bit PCM file as normalised floats and then | |
297 writing them back changes some sample values. Why?</B></H2> | |
298 | |
299 <P> | |
300 This is caused by the fact that the conversion from 16 bit short to float is | |
301 done by dividing by 32768 (0x8000 in hexadecimal) while the conversion from | |
302 float to 16 bit short is done by multiplying by 32767 (0x7FFF in hex). | |
303 So for instance, a value in a 16 bit PCM file of 20000 gets read as a floating | |
304 point number of 0.6103515625 (20000.0 / 0x8000). | |
305 Converting that back to a 16 bit short results in a value of 19999.3896484375 | |
306 (0.6103515625 * 0x7FFF) which then gets rounded down to 19999. | |
307 </P> | |
308 <P> | |
309 You will notice that for this particular case, the error is 1 in 20000 or | |
310 0.005%. | |
311 Interestingly, for values of less than 16369, dividing by 0x8000 followed | |
312 by multiplying by 0x7FFF and then rounding the result, gives back the | |
313 original value. | |
314 It turns out that as long as the host operating system supplies the 1999 ISO | |
315 C Standard functions <B>lrintf</B> and <B>lrint</B> (or a replacement has | |
316 been supplied) then the maximum possible error is 1 in 16369 or about 0.006%. | |
317 </P> | |
318 <P> | |
319 Regardless of the size of the error, the reason why this is done is rather | |
320 subtle. | |
321 </P> | |
322 <P> | |
323 In a file containing 16 bit PCM samples, the values are restricted to the range | |
324 [-32768, 32767] while we want floating point values in the range [-1.0, 1.0]. | |
325 The only way to do this conversion is to do a floating point division by a value | |
326 of 0x8000. | |
327 Converting the other way, the only way to ensure that floating point values in | |
328 the range [-1.0, 1.0] are within the valid range allowed by a 16 bit short is | |
329 to multiply by 0x7FFF. | |
330 </P> | |
331 <P> | |
332 Some people would say that this is a severe short-coming of libsndfile. | |
333 I would counter that anybody who is constantly converting back and forth | |
334 between 16 bit shorts and normalised floats is going to suffer other losses | |
335 in audio quality that they should also be concerned about. | |
336 </P> | |
337 <P> | |
338 Since this problem only occurs when converting between integer data on disk and | |
339 normalized floats in the application, it can be avoided by using something | |
340 other than normalized floats in the application. | |
341 Alternatives to normalized floats are the <b>short</b> and <b>int</b> data | |
342 types (ie using sf_read_short or sf_read_int) or using un-normalized floats | |
343 (see | |
344 <a href="command.html#SFC_SET_NORM_FLOAT"> | |
345 SFC_SET_NORM_FLOAT</a>). | |
346 </P> | |
347 <P> | |
348 Another way to deal with this problem is to consider 16 bit short data as a | |
349 final destination format only, not as an intermediate storage format. | |
350 All intermediate data (ie which is going to be processed further) should be | |
351 stored in floating point format which is supported by all of the most common | |
352 file formats. | |
353 If floating point files are considered too large (2 times the size of a 16 bit | |
354 PCM file), it would also be possible to use 24 bit PCM as an intermediate | |
355 storage format (and which is also supported by most common file types). | |
356 </P> | |
357 | |
358 <!-- ========================================================================= --> | |
359 | |
360 <A NAME="Q011"></A> | |
361 <H2><BR/><B>Q11 : I'm having problems with u-law encoded WAV files generated by | |
362 libsndfile in Winamp. Why? | |
363 </B></H2> | |
364 | |
365 <P> | |
366 This is actually a Winamp problem. | |
367 The official Microsoft spec suggests that the 'fmt ' chunk should be 18 bytes. | |
368 Unfortunately at least one of Microsoft's own applications (Sound Recorder on | |
369 Win98 I believe) did not accept 18 bytes 'fmt ' chunks. | |
370 </P> | |
371 <P> | |
372 Michael Lee did some experimenting and found that: | |
373 </P> | |
374 <PRE> | |
375 I have checked that Windows Media Player 9, QuickTime Player 6.4, | |
376 RealOne Player 2.0 and GoldWave 5.06 can all play u-law files with | |
377 16-byte or 18-byte 'fmt ' chunk. Only Winamp (2.91) and foobar2000 | |
378 are unable to play u-law files with 16-byte 'fmt ' chunk. | |
379 </PRE> | |
380 | |
381 <P> | |
382 Even this is a very small sampling of all the players out there. | |
383 For that reason it is probably not a good idea to change this now because there | |
384 is the risk of breaking something that currently works. | |
385 </P> | |
386 | |
387 <!-- ========================================================================= --> | |
388 | |
389 <A NAME="Q012"></A> | |
390 <H2><BR/><B>Q12 : I'm looking at sf_read*. What are items? What are frames? | |
391 </B></H2> | |
392 | |
393 <P> | |
394 An <tt>item</tt> is a single sample of the data type you are reading; ie a | |
395 single <tt>short</tt> value for <tt>sf_read_short</tt> or a single <tt>float</tt> | |
396 for <tt>sf_read_float</tt>. | |
397 </P> | |
398 | |
399 <P> | |
400 For a sound file with only one channel, a frame is the same as a item (ie a | |
401 single sample) while for multi channel sound files, a single frame contains a | |
402 single item for each channel. | |
403 </P> | |
404 | |
405 <P> | |
406 Here are two simple, correct examples, both of which are assumed to be working | |
407 on a stereo file, first using items: | |
408 </P> | |
409 | |
410 <PRE> | |
411 #define CHANNELS 2 | |
412 short data [CHANNELS * 100] ; | |
413 sf_count items_read = sf_read_short (file, data, 200) ; | |
414 assert (items_read == 200) ; | |
415 </PRE> | |
416 | |
417 <P> | |
418 and now reading the exact same amount of data using frames: | |
419 </P> | |
420 | |
421 <PRE> | |
422 #define CHANNELS 2 | |
423 short data [CHANNELS * 100] ; | |
424 sf_count frames_read = sf_readf_short (file, data, 100) ; | |
425 assert (frames_read == 100) ; | |
426 </PRE> | |
427 | |
428 <!-- ========================================================================= --> | |
429 | |
430 <A NAME="Q013"></A> | |
431 <H2><BR/><B>Q13 : Why can't libsndfile open this Sound Designer II (SD2) file? | |
432 </B></H2> | |
433 | |
434 <P> | |
435 This is somewhat complicated. | |
436 First some background. | |
437 </P> | |
438 | |
439 <P> | |
440 SD2 files are native to the Apple Macintosh platform and use features of | |
441 the Mac filesystem (file resource forks) to store the file's sample rate, | |
442 number of channels, sample width and more. | |
443 When you look at a file and its resource fork on Mac OS X it looks like | |
444 this: | |
445 </P> | |
446 | |
447 <PRE> | |
448 -rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2 | |
449 -rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 file.sd2/rsrc | |
450 </PRE> | |
451 | |
452 <P> | |
453 Notice how the file itself looks like a directory containing a single file | |
454 named <B>rsrc</B>. | |
455 When libsndfile is compiled for MacOS X, it should open (for write and read) | |
456 SD2 file with resource forks like this without any problems. | |
457 It will also handle files with the resource fork in a separate file as | |
458 described below. | |
459 </P> | |
460 | |
461 <P> | |
462 When SD2 files are moved to other platforms, the resource fork of the file | |
463 can sometimes be dropped altogether. | |
464 All that remains is the raw audio data and no information about the number | |
465 of channels, sample rate or bit width which makes it a little difficult for | |
466 libsndfile to open the file. | |
467 </P> | |
468 | |
469 <P> | |
470 However, it is possible to safely move an SD2 file to a Linux or Windows | |
471 machine. | |
472 For instance, when an SD2 file is copied from inside MacOS X to a windows | |
473 shared directory or a Samba share (ie Linux), MacOS X is clever enough to | |
474 store the resource fork of the file in a separate hidden file in the | |
475 same directory like this: | |
476 </P> | |
477 <PRE> | |
478 -rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 ._file.sd2 | |
479 -rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2 | |
480 </PRE> | |
481 | |
482 <P> | |
483 Regardless of what platform it is running on, when libsndfile is asked to | |
484 open a file named <B>"foo"</B> and it can't recognize the file type from | |
485 the data in the file, it will attempt to open the resource fork and if | |
486 that fails, it then tries to open a file named <B>"._foo"</B> to see if | |
487 the file has a valid resource fork. | |
488 This is the same regardless of whether the file is being opened for read | |
489 or write. | |
490 </P> | |
491 | |
492 <P> | |
493 In short, libsndfile should open SD2 files with a valid resource fork on | |
494 all of the platforms that libsndfile supports. | |
495 If a file has lost its resource fork, the only option is the open the file | |
496 using the SF_FORMAT_RAW option and guessing its sample rate, channel count | |
497 and bit width. | |
498 </P> | |
499 | |
500 <P> | |
501 Occasionally, when SD2 files are moved to other systems, the file is | |
502 <A HREF="http://www.macdisk.com/binhexen.php3">BinHexed</A> | |
503 which wraps the resource fork and the data fork together. | |
504 For these files, it would be possible to write a BinHex parser but | |
505 there is not a lot to gain considering how rare these BinHexed SD2 | |
506 files are. | |
507 </P> | |
508 | |
509 <!-- ========================================================================= --> | |
510 <A NAME="Q014"></A> | |
511 <H2><BR/><B>Q14 : I'd like to statically link libsndfile to my closed source | |
512 application. Can I buy a license so that this is possible? | |
513 </B></H2> | |
514 | |
515 <P> | |
516 Unfortunately no. | |
517 libsndfile contains code written by other people who have agreed that their | |
518 code be used under the GNU LGPL but no more. | |
519 Even if they were to agree, there would be significant difficulties in | |
520 dividing up the payments fairly. | |
521 </P> | |
522 | |
523 <P> | |
524 The <B>only</B> way you can legally use libsndfile as a statically linked | |
525 library is if your application is released under the GNU GPL or LGPL. | |
526 </P> | |
527 | |
528 <!-- ========================================================================= --> | |
529 <A NAME="Q015"></A> | |
530 <H2><BR/><B>Q15 : My program is crashing during a call to a function in libsndfile. | |
531 Is this a bug in libsndfile? | |
532 </B></H2> | |
533 | |
534 <P> | |
535 libsndfile is being used by large numbers of people all over the world | |
536 without any problems like this. That means that it is much more likely | |
537 that your code has a bug than libsndfile. However, it is still possible | |
538 that there is a bug in libsndfile. | |
539 </P> | |
540 <P> | |
541 To figure out whether it is your code or libsndfile you should do the | |
542 following: | |
543 </P> | |
544 <UL> | |
545 <LI>Make sure you are compiling your code with warnings switched on and | |
546 that you fix as many warnings as possible. | |
547 With the GNU compiler (gcc) I would recommend at least | |
548 <B>-W -Wall -Werror</B> which will force you to fix all warnings | |
549 before you can run the code. | |
550 <LI>Try using a memory debugger. | |
551 <A HREF="http://valgrind.kde.org/">Valgrind</A> on x86 Linux is excellent. | |
552 <A HREF="http://www.ibm.com/software/awdtools/purify/">Purify</A> also | |
553 has a good reputation. | |
554 <LI>If the code is clean after the above two steps and you still get | |
555 a crash in libsndfile, then send me a small snippet of code (no | |
556 more than 30-40 lines) which includes the call to sf_open() and | |
557 also shows how all variables passed to/returned from sf_open() | |
558 are defined. | |
559 </UL> | |
560 | |
561 <!-- ========================================================================= --> | |
562 <A NAME="Q016"></A> | |
563 <H2><BR/><B>Q16 : Will you accept a fix for compiling libsndfile with compiler X? | |
564 </B></H2> | |
565 | |
566 <P> | |
567 If compiler X is a C++ compiler then no. | |
568 C and C++ are different enough to make writing code that compiles as valid C | |
569 and valid C++ too difficult. | |
570 I would rather spend my time fixing bugs and adding features. | |
571 </P> | |
572 | |
573 <P> | |
574 If compiler X is a C compiler then I will do what I can as long as that does | |
575 not hamper the correctness, portability and maintainability of the existing | |
576 code. | |
577 It should be noted however that libsndfile uses features specified by the 1999 | |
578 ISO C Standard. | |
579 This can make compiling libsndfile with some older compilers difficult. | |
580 </P> | |
581 | |
582 <!-- ========================================================================= --> | |
583 <A NAME="Q017"></A> | |
584 <H2><BR/><B>Q17 : Can libsndfile read/write files from/to UNIX pipes? | |
585 </B></H2> | |
586 | |
587 <P> | |
588 Yes, libsndfile can read files from pipes. | |
589 Unfortunately, the write case is much more complicated. | |
590 </P> | |
591 | |
592 <P> | |
593 File formats like AIFF and WAV have information at the start of the file (the | |
594 file header) which states the length of the file, the number of sample frames | |
595 etc. | |
596 This information must be filled in correctly when the file header is written, | |
597 but this information is not reliably known until the file is closed. | |
598 This means that libsndfile cannot write AIFF, WAV and many other file types | |
599 to a pipe. | |
600 </P> | |
601 | |
602 <P> | |
603 However, there is at least one file format (AU) which is specifically designed | |
604 to be written to a pipe. | |
605 Like AIFF and WAV, AU has a header with a sample frames field, but it is | |
606 specifically allowable to set that frames field to 0x7FFFFFFF if the file | |
607 length is not known when the header is written. | |
608 The AU file format can also hold data in many of the standard formats (ie | |
609 SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_FLOAT etc) as well as allowing | |
610 data in both big and little endian format. | |
611 </P> | |
612 | |
613 <P> | |
614 See also <A HREF="#Q006">FAQ Q6</A>. | |
615 </P> | |
616 | |
617 <!-- ========================================================================= --> | |
618 <A NAME="Q018"></A> | |
619 <H2><BR/><B>Q18 : Is it possible to build a Universal Binary on Mac OS X? | |
620 </B></H2> | |
621 | |
622 <P> | |
623 Yes, but you must do two separate configure/build/test runs; one on PowerPC | |
624 and one on Intel. | |
625 It is then possible to merge the binaries into a single universal binary using | |
626 one of the programs in the Apple tool chain. | |
627 </P> | |
628 | |
629 <P> | |
630 It is <b>not</b> possible to build a working universal binary via a single | |
631 compile/build run on a single CPU. | |
632 </P> | |
633 | |
634 <P> | |
635 The problem is that the libsndfile build process detects features of the CPU its | |
636 being built for during the configure process and when building a universal binary, | |
637 configure is only run once and that data is then used for both CPUs. | |
638 That configure data will be wrong for one of those CPUs. | |
639 You will still be able to compile libsndfile, and the test suite will pass on | |
640 the machine you compiled it on. | |
641 However, if you take the universal binary test suite programs compiled on one | |
642 CPU and run them on the other, the test suite will fail. | |
643 </P> | |
644 | |
645 <P> | |
646 Part of the problem is that the CPU endian-ness is detected at configure time. | |
647 Yes, I know the Apple compiler defines one of the macros __LITTLE_ENDIAN__ | |
648 and __BIG_ENDIAN__, but those macros are not part of the 1999 ISO C Standard | |
649 and they are not portable. | |
650 </P> | |
651 | |
652 <P> | |
653 Endian issues are not the only reason why the cross compiled binary will fail. | |
654 The configure script also detects other CPU specific idiosyncrasies to provide | |
655 more optimized code. | |
656 </P> | |
657 | |
658 <P> | |
659 Finally, the real show stopper problem with universal binaries is the problem | |
660 with the test suite. | |
661 libsndfile contains a huge, comprehensive test suite. | |
662 When you compile a universal binary and run the test suite, you only test the | |
663 native compile. | |
664 The cross compiled binary (the one with the much higher chance of having | |
665 problems) cannot be tested. | |
666 </P> | |
667 | |
668 <P> | |
669 Now, if you have read this far you're probably thinking there must be a way | |
670 to fix this and there probably is. | |
671 The problem is that its a hell of a lot of work and would require significant | |
672 changes to the configure process, the internal code and the test suite. | |
673 In addition, these changes must not break compilation on any of the platforms | |
674 libsndfile is currently working on. | |
675 </p> | |
676 | |
677 | |
678 <!-- ========================================================================= --> | |
679 <A NAME="Q019"></A> | |
680 <H2><BR/><B>Q19 : I have project files for Visual Studio / XCode / Whatever. Why | |
681 don't you distribute them with libsndfile? | |
682 </B></H2> | |
683 | |
684 <P> | |
685 There's a very good reason for this. | |
686 I will only distribute things that I actually have an ability to test and | |
687 maintain. | |
688 Project files for a bunch of different compilers and Integrated Development | |
689 Environments are simply too difficult to maintain. | |
690 </P> | |
691 | |
692 <P> | |
693 The problem is that every time I add a new file to libsndfile or rename an | |
694 existing file I would have to modify all the project files and then test that | |
695 libsndfile still built with all the different compilers. | |
696 </P> | |
697 | |
698 <P> | |
699 Maintaining these project files is also rather difficult if I don't have access | |
700 to the required compiler/IDE. | |
701 If I just edit the project files without testing them I will almost certainly | |
702 get it wrong. | |
703 If I release a version of libsndfile with broken project files, I'll get a bunch | |
704 of emails from people complaining about it not building and have no way of | |
705 fixing or even testing it. | |
706 </P> | |
707 | |
708 <P> | |
709 I currently release sources that I personally test on Win32, Linux and | |
710 MacOS X (PowerPC) using the compiler I trust (GNU GCC). | |
711 Supporting one compiler on three (actually much more because GCC is available | |
712 almost everywhere) platforms is doable without too much pain. | |
713 I also release binaries for Win32 with instructions on how to use those | |
714 binaries with Visual Studio. | |
715 As a guy who is mainly interested in Linux, I'm not to keen to jump through | |
716 a bunch of hoops to support compilers and operating systems I don't use. | |
717 </P> | |
718 | |
719 <P> | |
720 So, I hear you want to volunteer to maintain the project files for Some Crappy | |
721 Compiler 2007? | |
722 Well sorry, that won't work either. | |
723 I have had numerous people over the years offer to maintaining the project | |
724 files for Microsoft's Visual Studio. | |
725 Every single time that happened, they maintained it for a release or two and | |
726 then disappeared off the face of the earth. | |
727 Hence, I'm not willing to enter into an arrangement like that again. | |
728 </P> | |
729 | |
730 <!-- ========================================================================= --> | |
731 <A NAME="Q020"></A> | |
732 <H2><BR/><B>Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source | |
733 projects support it! | |
734 </B></H2> | |
735 | |
736 <P> | |
737 MP3 is not supported for one very good reason; doing so requires the payment | |
738 of licensing fees. | |
739 As can be seen from | |
740 <a href="http://www.mp3licensing.com/royalty/software.html"> | |
741 mp3licensing.com</a> | |
742 the required royalty payments are not cheap. | |
743 </P> | |
744 | |
745 <p> | |
746 Yes, I know other libraries ignore the licensing requirements, but their legal | |
747 status is extremely dubious. | |
748 At any time, the body selling the licenses could go after the authors of those | |
749 libraries. | |
750 Some of those authors may be students and hence wouldn't be worth pursuing. | |
751 </P> | |
752 | |
753 <p> | |
754 However, libsndfile is released under the name of a company, Mega Nerd Pty Ltd; | |
755 a company which has income from from libsamplerate licensing, libsndfile based | |
756 consulting income and other unrelated consulting income. | |
757 Adding MP3 support to libsndfile could place that income under legal threat. | |
758 </p> | |
759 | |
760 <p> | |
761 Fortunately, Ogg Vorbis exists as an alternative to MP3. | |
762 Support for Ogg Vorbis was added to libsndfile (mostly due to the efforts of | |
763 John ffitch of the Csound project) in version 1.0.18. | |
764 </p> | |
765 | |
766 | |
767 <!-- ========================================================================= --> | |
768 <A NAME="Q021"></A> | |
769 <H2><BR/><B>Q21 : How do I use libsndfile in a closed source or commercial program | |
770 and comply with the license? | |
771 </B></H2> | |
772 | |
773 <p> | |
774 Here is a checklist of things you need to do to make sure your use of libsndfile | |
775 in a closed source or commercial project complies with the license libsndfile is | |
776 released under, the GNU Lesser General Public License (LGPL): | |
777 </p> | |
778 | |
779 <ul> | |
780 <li>Make sure you are linking to libsndfile as a shared library (Linux and Unix | |
781 systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OS X). | |
782 If you are using some other operating system that doesn't allow dynamically | |
783 linked libraries, you will not be able to use libsndfile unless you release | |
784 the source code to your program. | |
785 <li>In the licensing documentation for your program, add a statement that your | |
786 software depends on libsndfile and that libsndfile is released under the GNU | |
787 Lesser General Public License, either | |
788 <a href="http://www.gnu.org/licenses/lgpl-2.1.txt">version 2.1</a> | |
789 or optionally | |
790 <a href="http://www.gnu.org/licenses/lgpl.txt">version 3</a>. | |
791 <li>Include the text for both versions of the license, possibly as separate | |
792 files named libsndfile_lgpl_v2_1.txt and libsndfile_lgpl_v3.txt. | |
793 </ul> | |
794 | |
795 <!-- ========================================================================= --> | |
796 <A NAME="Q022"></A> | |
797 <H2><BR/><B>Q22 : What versions of Windows does libsndfile work on? | |
798 </B></H2> | |
799 | |
800 <p> | |
801 Currently the precompiled windows binaries are thoroughly tested on Windows XP. | |
802 As such, they should also work on Win2k and Windows Vista. | |
803 They may also work on earlier versions of Windows. | |
804 </p> | |
805 | |
806 <p> | |
807 Since version 0.1.18 I have also been releasing precompiled binaries for Win64, | |
808 the 64 bit version of Windows. | |
809 These binaries have received much less testing than the 32 bit versions, but | |
810 should work as expected. | |
811 I'd be very interested in receiving feedback on these binaries. | |
812 </p> | |
813 | |
814 <!-- ========================================================================= --> | |
815 <A NAME="Q023"></A> | |
816 <H2><BR/><B>Q23 : I'm cross compiling libsndfile for another platform. How can I | |
817 run the test suite? | |
818 </B></H2> | |
819 | |
820 <p> | |
821 </p> | |
822 | |
823 <p> | |
824 Since version 1.0.21 the top level Makefile has an extra make target, | |
825 'test-tarball'. | |
826 Building this target creates a tarball called called: | |
827 </p> | |
828 | |
829 <center><tt> | |
830 libsndfile-testsuite-${host_triplet}-${version}.tar.gz | |
831 </tt></center> | |
832 | |
833 <p> | |
834 in the top level directory. | |
835 This tarball can then be copied to the target platform. | |
836 Once untarred and test script <tt>test_wrapper.sh</tt> can be run from | |
837 the top level of the extracted tarball. | |
838 </p> | |
839 | |
840 <!-- ========================================================================= --> | |
841 <HR> | |
842 <P> | |
843 The libsndfile home page is here : | |
844 <A HREF="http://www.mega-nerd.com/libsndfile/"> | |
845 http://www.mega-nerd.com/libsndfile/</A>. | |
846 <BR/> | |
847 Version : 1.0.27 | |
848 </P> | |
849 | |
850 </BODY> | |
851 </HTML> |