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