FS-11091: [mod_sndfile] Remove libsndfile from the code base, use pre-compiled binaries on Windows, update to libsndfile 1.0.28
This commit is contained in:
parent
c9ac9c66e3
commit
32c16669c4
|
@ -232,8 +232,6 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libaprutil", "libs\win32\ap
|
|||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iksemel", "libs\win32\iksemel\iksemel.2015.vcxproj", "{E727E8F6-935D-46FE-8B0E-37834748A0E3}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libsndfile", "libs\win32\libsndfile\libsndfile.2015.vcxproj", "{3D0370CA-BED2-4657-A475-32375CBCB6E4}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "xml", "libs\win32\apr-util\xml.2015.vcxproj", "{155844C3-EC5F-407F-97A4-A2DDADED9B2F}"
|
||||
EndProject
|
||||
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_sofia", "src\mod\endpoints\mod_sofia\mod_sofia.2015.vcxproj", "{0DF3ABD0-DDC0-4265-B778-07C66780979B}"
|
||||
|
@ -956,17 +954,6 @@ Global
|
|||
{E727E8F6-935D-46FE-8B0E-37834748A0E3}.Release|Win32.Build.0 = Release|Win32
|
||||
{E727E8F6-935D-46FE-8B0E-37834748A0E3}.Release|x64.ActiveCfg = Release|x64
|
||||
{E727E8F6-935D-46FE-8B0E-37834748A0E3}.Release|x64.Build.0 = Release|x64
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.All|Win32.ActiveCfg = Release|x64
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.All|x64.ActiveCfg = Release|x64
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.All|x64.Build.0 = Release|x64
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.Debug|Win32.ActiveCfg = Debug|Win32
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.Debug|Win32.Build.0 = Debug|Win32
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.Debug|x64.Build.0 = Debug|x64
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.Release|Win32.ActiveCfg = Release|Win32
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.Release|Win32.Build.0 = Release|Win32
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.Release|x64.ActiveCfg = Release|x64
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4}.Release|x64.Build.0 = Release|x64
|
||||
{155844C3-EC5F-407F-97A4-A2DDADED9B2F}.All|Win32.ActiveCfg = Debug|x64
|
||||
{155844C3-EC5F-407F-97A4-A2DDADED9B2F}.All|x64.ActiveCfg = Debug|x64
|
||||
{155844C3-EC5F-407F-97A4-A2DDADED9B2F}.All|x64.Build.0 = Debug|x64
|
||||
|
@ -3005,7 +2992,6 @@ Global
|
|||
{F6C55D93-B927-4483-BB69-15AEF3DD2DFF} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
|
||||
{F057DA7F-79E5-4B00-845C-EF446EF055E3} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
|
||||
{E727E8F6-935D-46FE-8B0E-37834748A0E3} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
|
||||
{3D0370CA-BED2-4657-A475-32375CBCB6E4} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
|
||||
{155844C3-EC5F-407F-97A4-A2DDADED9B2F} = {EB910B0D-F27D-4B62-B67B-DE834C99AC5B}
|
||||
{0DF3ABD0-DDC0-4265-B778-07C66780979B} = {9460B5F1-0A95-41C4-BEB7-9C2C96459A7C}
|
||||
{8B3B4C4C-13C2-446C-BEB0-F412CC2CFB9A} = {C120A020-773F-4EA3-923F-B67AF28B750D}
|
||||
|
|
|
@ -854,3 +854,5 @@ flite-*/
|
|||
flite-*
|
||||
pcre-*/
|
||||
pcre-*
|
||||
libsndfile-*/
|
||||
libsndfile-*
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
Fri Feb 28 03:45:32 CDT 2014
|
|
@ -1,14 +0,0 @@
|
|||
The main author of libsndfile is Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
apart from code in the following directories:
|
||||
|
||||
- src/GSM610 : Written by Jutta Degener <jutta@cs.tu-berlin.de> and Carsten
|
||||
Bormann <cabo@cs.tu-berlin.de>. They should not be contacted in relation to
|
||||
libsndfile or the GSM 6.10 code that is part of libsndfile. Their original
|
||||
code can be found at:
|
||||
|
||||
http://kbs.cs.tu-berlin.de/~jutta/toast.html
|
||||
|
||||
- src/G72x : Released by Sun Microsystems, Inc. to the public domain. Minor
|
||||
modifications were required to integrate these files into libsndfile. The
|
||||
changes are listed in src/G72x/ChangeLog.
|
||||
|
|
@ -1,503 +0,0 @@
|
|||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
Version 2.1, February 1999
|
||||
|
||||
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
||||
59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
[This is the first released version of the Lesser GPL. It also counts
|
||||
as the successor of the GNU Library Public License, version 2, hence
|
||||
the version number 2.1.]
|
||||
|
||||
Preamble
|
||||
|
||||
The licenses for most software are designed to take away your
|
||||
freedom to share and change it. By contrast, the GNU General Public
|
||||
Licenses are intended to guarantee your freedom to share and change
|
||||
free software--to make sure the software is free for all its users.
|
||||
|
||||
This license, the Lesser General Public License, applies to some
|
||||
specially designated software packages--typically libraries--of the
|
||||
Free Software Foundation and other authors who decide to use it. You
|
||||
can use it too, but we suggest you first think carefully about whether
|
||||
this license or the ordinary General Public License is the better
|
||||
strategy to use in any particular case, based on the explanations below.
|
||||
|
||||
When we speak of free software, we are referring to freedom of use,
|
||||
not price. Our General Public Licenses are designed to make sure that
|
||||
you have the freedom to distribute copies of free software (and charge
|
||||
for this service if you wish); that you receive source code or can get
|
||||
it if you want it; that you can change the software and use pieces of
|
||||
it in new free programs; and that you are informed that you can do
|
||||
these things.
|
||||
|
||||
To protect your rights, we need to make restrictions that forbid
|
||||
distributors to deny you these rights or to ask you to surrender these
|
||||
rights. These restrictions translate to certain responsibilities for
|
||||
you if you distribute copies of the library or if you modify it.
|
||||
|
||||
For example, if you distribute copies of the library, whether gratis
|
||||
or for a fee, you must give the recipients all the rights that we gave
|
||||
you. You must make sure that they, too, receive or can get the source
|
||||
code. If you link other code with the library, you must provide
|
||||
complete object files to the recipients, so that they can relink them
|
||||
with the library after making changes to the library and recompiling
|
||||
it. And you must show them these terms so they know their rights.
|
||||
|
||||
We protect your rights with a two-step method: (1) we copyright the
|
||||
library, and (2) we offer you this license, which gives you legal
|
||||
permission to copy, distribute and/or modify the library.
|
||||
|
||||
To protect each distributor, we want to make it very clear that
|
||||
there is no warranty for the free library. Also, if the library is
|
||||
modified by someone else and passed on, the recipients should know
|
||||
that what they have is not the original version, so that the original
|
||||
author's reputation will not be affected by problems that might be
|
||||
introduced by others.
|
||||
|
||||
Finally, software patents pose a constant threat to the existence of
|
||||
any free program. We wish to make sure that a company cannot
|
||||
effectively restrict the users of a free program by obtaining a
|
||||
restrictive license from a patent holder. Therefore, we insist that
|
||||
any patent license obtained for a version of the library must be
|
||||
consistent with the full freedom of use specified in this license.
|
||||
|
||||
Most GNU software, including some libraries, is covered by the
|
||||
ordinary GNU General Public License. This license, the GNU Lesser
|
||||
General Public License, applies to certain designated libraries, and
|
||||
is quite different from the ordinary General Public License. We use
|
||||
this license for certain libraries in order to permit linking those
|
||||
libraries into non-free programs.
|
||||
|
||||
When a program is linked with a library, whether statically or using
|
||||
a shared library, the combination of the two is legally speaking a
|
||||
combined work, a derivative of the original library. The ordinary
|
||||
General Public License therefore permits such linking only if the
|
||||
entire combination fits its criteria of freedom. The Lesser General
|
||||
Public License permits more lax criteria for linking other code with
|
||||
the library.
|
||||
|
||||
We call this license the "Lesser" General Public License because it
|
||||
does Less to protect the user's freedom than the ordinary General
|
||||
Public License. It also provides other free software developers Less
|
||||
of an advantage over competing non-free programs. These disadvantages
|
||||
are the reason we use the ordinary General Public License for many
|
||||
libraries. However, the Lesser license provides advantages in certain
|
||||
special circumstances.
|
||||
|
||||
For example, on rare occasions, there may be a special need to
|
||||
encourage the widest possible use of a certain library, so that it becomes
|
||||
a de-facto standard. To achieve this, non-free programs must be
|
||||
allowed to use the library. A more frequent case is that a free
|
||||
library does the same job as widely used non-free libraries. In this
|
||||
case, there is little to gain by limiting the free library to free
|
||||
software only, so we use the Lesser General Public License.
|
||||
|
||||
In other cases, permission to use a particular library in non-free
|
||||
programs enables a greater number of people to use a large body of
|
||||
free software. For example, permission to use the GNU C Library in
|
||||
non-free programs enables many more people to use the whole GNU
|
||||
operating system, as well as its variant, the GNU/Linux operating
|
||||
system.
|
||||
|
||||
Although the Lesser General Public License is Less protective of the
|
||||
users' freedom, it does ensure that the user of a program that is
|
||||
linked with the Library has the freedom and the wherewithal to run
|
||||
that program using a modified version of the Library.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow. Pay close attention to the difference between a
|
||||
"work based on the library" and a "work that uses the library". The
|
||||
former contains code derived from the library, whereas the latter must
|
||||
be combined with the library in order to run.
|
||||
|
||||
GNU LESSER GENERAL PUBLIC LICENSE
|
||||
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
|
||||
|
||||
0. This License Agreement applies to any software library or other
|
||||
program which contains a notice placed by the copyright holder or
|
||||
other authorized party saying it may be distributed under the terms of
|
||||
this Lesser General Public License (also called "this License").
|
||||
Each licensee is addressed as "you".
|
||||
|
||||
A "library" means a collection of software functions and/or data
|
||||
prepared so as to be conveniently linked with application programs
|
||||
(which use some of those functions and data) to form executables.
|
||||
|
||||
The "Library", below, refers to any such software library or work
|
||||
which has been distributed under these terms. A "work based on the
|
||||
Library" means either the Library or any derivative work under
|
||||
copyright law: that is to say, a work containing the Library or a
|
||||
portion of it, either verbatim or with modifications and/or translated
|
||||
straightforwardly into another language. (Hereinafter, translation is
|
||||
included without limitation in the term "modification".)
|
||||
|
||||
"Source code" for a work means the preferred form of the work for
|
||||
making modifications to it. For a library, complete source code means
|
||||
all the source code for all modules it contains, plus any associated
|
||||
interface definition files, plus the scripts used to control compilation
|
||||
and installation of the library.
|
||||
|
||||
Activities other than copying, distribution and modification are not
|
||||
covered by this License; they are outside its scope. The act of
|
||||
running a program using the Library is not restricted, and output from
|
||||
such a program is covered only if its contents constitute a work based
|
||||
on the Library (independent of the use of the Library in a tool for
|
||||
writing it). Whether that is true depends on what the Library does
|
||||
and what the program that uses the Library does.
|
||||
|
||||
1. You may copy and distribute verbatim copies of the Library's
|
||||
complete source code as you receive it, in any medium, provided that
|
||||
you conspicuously and appropriately publish on each copy an
|
||||
appropriate copyright notice and disclaimer of warranty; keep intact
|
||||
all the notices that refer to this License and to the absence of any
|
||||
warranty; and distribute a copy of this License along with the
|
||||
Library.
|
||||
|
||||
You may charge a fee for the physical act of transferring a copy,
|
||||
and you may at your option offer warranty protection in exchange for a
|
||||
fee.
|
||||
|
||||
2. You may modify your copy or copies of the Library or any portion
|
||||
of it, thus forming a work based on the Library, and copy and
|
||||
distribute such modifications or work under the terms of Section 1
|
||||
above, provided that you also meet all of these conditions:
|
||||
|
||||
a) The modified work must itself be a software library.
|
||||
|
||||
b) You must cause the files modified to carry prominent notices
|
||||
stating that you changed the files and the date of any change.
|
||||
|
||||
c) You must cause the whole of the work to be licensed at no
|
||||
charge to all third parties under the terms of this License.
|
||||
|
||||
d) If a facility in the modified Library refers to a function or a
|
||||
table of data to be supplied by an application program that uses
|
||||
the facility, other than as an argument passed when the facility
|
||||
is invoked, then you must make a good faith effort to ensure that,
|
||||
in the event an application does not supply such function or
|
||||
table, the facility still operates, and performs whatever part of
|
||||
its purpose remains meaningful.
|
||||
|
||||
(For example, a function in a library to compute square roots has
|
||||
a purpose that is entirely well-defined independent of the
|
||||
application. Therefore, Subsection 2d requires that any
|
||||
application-supplied function or table used by this function must
|
||||
be optional: if the application does not supply it, the square
|
||||
root function must still compute square roots.)
|
||||
|
||||
These requirements apply to the modified work as a whole. If
|
||||
identifiable sections of that work are not derived from the Library,
|
||||
and can be reasonably considered independent and separate works in
|
||||
themselves, then this License, and its terms, do not apply to those
|
||||
sections when you distribute them as separate works. But when you
|
||||
distribute the same sections as part of a whole which is a work based
|
||||
on the Library, the distribution of the whole must be on the terms of
|
||||
this License, whose permissions for other licensees extend to the
|
||||
entire whole, and thus to each and every part regardless of who wrote
|
||||
it.
|
||||
|
||||
Thus, it is not the intent of this section to claim rights or contest
|
||||
your rights to work written entirely by you; rather, the intent is to
|
||||
exercise the right to control the distribution of derivative or
|
||||
collective works based on the Library.
|
||||
|
||||
In addition, mere aggregation of another work not based on the Library
|
||||
with the Library (or with a work based on the Library) on a volume of
|
||||
a storage or distribution medium does not bring the other work under
|
||||
the scope of this License.
|
||||
|
||||
3. You may opt to apply the terms of the ordinary GNU General Public
|
||||
License instead of this License to a given copy of the Library. To do
|
||||
this, you must alter all the notices that refer to this License, so
|
||||
that they refer to the ordinary GNU General Public License, version 2,
|
||||
instead of to this License. (If a newer version than version 2 of the
|
||||
ordinary GNU General Public License has appeared, then you can specify
|
||||
that version instead if you wish.) Do not make any other change in
|
||||
these notices.
|
||||
|
||||
Once this change is made in a given copy, it is irreversible for
|
||||
that copy, so the ordinary GNU General Public License applies to all
|
||||
subsequent copies and derivative works made from that copy.
|
||||
|
||||
This option is useful when you wish to copy part of the code of
|
||||
the Library into a program that is not a library.
|
||||
|
||||
4. You may copy and distribute the Library (or a portion or
|
||||
derivative of it, under Section 2) in object code or executable form
|
||||
under the terms of Sections 1 and 2 above provided that you accompany
|
||||
it with the complete corresponding machine-readable source code, which
|
||||
must be distributed under the terms of Sections 1 and 2 above on a
|
||||
medium customarily used for software interchange.
|
||||
|
||||
If distribution of object code is made by offering access to copy
|
||||
from a designated place, then offering equivalent access to copy the
|
||||
source code from the same place satisfies the requirement to
|
||||
distribute the source code, even though third parties are not
|
||||
compelled to copy the source along with the object code.
|
||||
|
||||
5. A program that contains no derivative of any portion of the
|
||||
Library, but is designed to work with the Library by being compiled or
|
||||
linked with it, is called a "work that uses the Library". Such a
|
||||
work, in isolation, is not a derivative work of the Library, and
|
||||
therefore falls outside the scope of this License.
|
||||
|
||||
However, linking a "work that uses the Library" with the Library
|
||||
creates an executable that is a derivative of the Library (because it
|
||||
contains portions of the Library), rather than a "work that uses the
|
||||
library". The executable is therefore covered by this License.
|
||||
Section 6 states terms for distribution of such executables.
|
||||
|
||||
When a "work that uses the Library" uses material from a header file
|
||||
that is part of the Library, the object code for the work may be a
|
||||
derivative work of the Library even though the source code is not.
|
||||
Whether this is true is especially significant if the work can be
|
||||
linked without the Library, or if the work is itself a library. The
|
||||
threshold for this to be true is not precisely defined by law.
|
||||
|
||||
If such an object file uses only numerical parameters, data
|
||||
structure layouts and accessors, and small macros and small inline
|
||||
functions (ten lines or less in length), then the use of the object
|
||||
file is unrestricted, regardless of whether it is legally a derivative
|
||||
work. (Executables containing this object code plus portions of the
|
||||
Library will still fall under Section 6.)
|
||||
|
||||
Otherwise, if the work is a derivative of the Library, you may
|
||||
distribute the object code for the work under the terms of Section 6.
|
||||
Any executables containing that work also fall under Section 6,
|
||||
whether or not they are linked directly with the Library itself.
|
||||
|
||||
6. As an exception to the Sections above, you may also combine or
|
||||
link a "work that uses the Library" with the Library to produce a
|
||||
work containing portions of the Library, and distribute that work
|
||||
under terms of your choice, provided that the terms permit
|
||||
modification of the work for the customer's own use and reverse
|
||||
engineering for debugging such modifications.
|
||||
|
||||
You must give prominent notice with each copy of the work that the
|
||||
Library is used in it and that the Library and its use are covered by
|
||||
this License. You must supply a copy of this License. If the work
|
||||
during execution displays copyright notices, you must include the
|
||||
copyright notice for the Library among them, as well as a reference
|
||||
directing the user to the copy of this License. Also, you must do one
|
||||
of these things:
|
||||
|
||||
a) Accompany the work with the complete corresponding
|
||||
machine-readable source code for the Library including whatever
|
||||
changes were used in the work (which must be distributed under
|
||||
Sections 1 and 2 above); and, if the work is an executable linked
|
||||
with the Library, with the complete machine-readable "work that
|
||||
uses the Library", as object code and/or source code, so that the
|
||||
user can modify the Library and then relink to produce a modified
|
||||
executable containing the modified Library. (It is understood
|
||||
that the user who changes the contents of definitions files in the
|
||||
Library will not necessarily be able to recompile the application
|
||||
to use the modified definitions.)
|
||||
|
||||
b) Use a suitable shared library mechanism for linking with the
|
||||
Library. A suitable mechanism is one that (1) uses at run time a
|
||||
copy of the library already present on the user's computer system,
|
||||
rather than copying library functions into the executable, and (2)
|
||||
will operate properly with a modified version of the library, if
|
||||
the user installs one, as long as the modified version is
|
||||
interface-compatible with the version that the work was made with.
|
||||
|
||||
c) Accompany the work with a written offer, valid for at
|
||||
least three years, to give the same user the materials
|
||||
specified in Subsection 6a, above, for a charge no more
|
||||
than the cost of performing this distribution.
|
||||
|
||||
d) If distribution of the work is made by offering access to copy
|
||||
from a designated place, offer equivalent access to copy the above
|
||||
specified materials from the same place.
|
||||
|
||||
e) Verify that the user has already received a copy of these
|
||||
materials or that you have already sent this user a copy.
|
||||
|
||||
For an executable, the required form of the "work that uses the
|
||||
Library" must include any data and utility programs needed for
|
||||
reproducing the executable from it. However, as a special exception,
|
||||
the materials to be distributed need not include anything that is
|
||||
normally distributed (in either source or binary form) with the major
|
||||
components (compiler, kernel, and so on) of the operating system on
|
||||
which the executable runs, unless that component itself accompanies
|
||||
the executable.
|
||||
|
||||
It may happen that this requirement contradicts the license
|
||||
restrictions of other proprietary libraries that do not normally
|
||||
accompany the operating system. Such a contradiction means you cannot
|
||||
use both them and the Library together in an executable that you
|
||||
distribute.
|
||||
|
||||
7. You may place library facilities that are a work based on the
|
||||
Library side-by-side in a single library together with other library
|
||||
facilities not covered by this License, and distribute such a combined
|
||||
library, provided that the separate distribution of the work based on
|
||||
the Library and of the other library facilities is otherwise
|
||||
permitted, and provided that you do these two things:
|
||||
|
||||
a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities. This must be distributed under the terms of the
|
||||
Sections above.
|
||||
|
||||
b) Give prominent notice with the combined library of the fact
|
||||
that part of it is a work based on the Library, and explaining
|
||||
where to find the accompanying uncombined form of the same work.
|
||||
|
||||
8. You may not copy, modify, sublicense, link with, or distribute
|
||||
the Library except as expressly provided under this License. Any
|
||||
attempt otherwise to copy, modify, sublicense, link with, or
|
||||
distribute the Library is void, and will automatically terminate your
|
||||
rights under this License. However, parties who have received copies,
|
||||
or rights, from you under this License will not have their licenses
|
||||
terminated so long as such parties remain in full compliance.
|
||||
|
||||
9. You are not required to accept this License, since you have not
|
||||
signed it. However, nothing else grants you permission to modify or
|
||||
distribute the Library or its derivative works. These actions are
|
||||
prohibited by law if you do not accept this License. Therefore, by
|
||||
modifying or distributing the Library (or any work based on the
|
||||
Library), you indicate your acceptance of this License to do so, and
|
||||
all its terms and conditions for copying, distributing or modifying
|
||||
the Library or works based on it.
|
||||
|
||||
10. Each time you redistribute the Library (or any work based on the
|
||||
Library), the recipient automatically receives a license from the
|
||||
original licensor to copy, distribute, link with or modify the Library
|
||||
subject to these terms and conditions. You may not impose any further
|
||||
restrictions on the recipients' exercise of the rights granted herein.
|
||||
You are not responsible for enforcing compliance by third parties with
|
||||
this License.
|
||||
|
||||
11. If, as a consequence of a court judgment or allegation of patent
|
||||
infringement or for any other reason (not limited to patent issues),
|
||||
conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot
|
||||
distribute so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you
|
||||
may not distribute the Library at all. For example, if a patent
|
||||
license would not permit royalty-free redistribution of the Library by
|
||||
all those who receive copies directly or indirectly through you, then
|
||||
the only way you could satisfy both it and this License would be to
|
||||
refrain entirely from distribution of the Library.
|
||||
|
||||
If any portion of this section is held invalid or unenforceable under any
|
||||
particular circumstance, the balance of the section is intended to apply,
|
||||
and the section as a whole is intended to apply in other circumstances.
|
||||
|
||||
It is not the purpose of this section to induce you to infringe any
|
||||
patents or other property right claims or to contest validity of any
|
||||
such claims; this section has the sole purpose of protecting the
|
||||
integrity of the free software distribution system which is
|
||||
implemented by public license practices. Many people have made
|
||||
generous contributions to the wide range of software distributed
|
||||
through that system in reliance on consistent application of that
|
||||
system; it is up to the author/donor to decide if he or she is willing
|
||||
to distribute software through any other system and a licensee cannot
|
||||
impose that choice.
|
||||
|
||||
This section is intended to make thoroughly clear what is believed to
|
||||
be a consequence of the rest of this License.
|
||||
|
||||
12. If the distribution and/or use of the Library is restricted in
|
||||
certain countries either by patents or by copyrighted interfaces, the
|
||||
original copyright holder who places the Library under this License may add
|
||||
an explicit geographical distribution limitation excluding those countries,
|
||||
so that distribution is permitted only in or among countries not thus
|
||||
excluded. In such case, this License incorporates the limitation as if
|
||||
written in the body of this License.
|
||||
|
||||
13. The Free Software Foundation may publish revised and/or new
|
||||
versions of the Lesser General Public License from time to time.
|
||||
Such new versions will be similar in spirit to the present version,
|
||||
but may differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
specifies a version number of this License which applies to it and
|
||||
"any later version", you have the option of following the terms and
|
||||
conditions either of that version or of any later version published by
|
||||
the Free Software Foundation. If the Library does not specify a
|
||||
license version number, you may choose any version ever published by
|
||||
the Free Software Foundation.
|
||||
|
||||
14. If you wish to incorporate parts of the Library into other free
|
||||
programs whose distribution conditions are incompatible with these,
|
||||
write to the author to ask for permission. For software which is
|
||||
copyrighted by the Free Software Foundation, write to the Free
|
||||
Software Foundation; we sometimes make exceptions for this. Our
|
||||
decision will be guided by the two goals of preserving the free status
|
||||
of all derivatives of our free software and of promoting the sharing
|
||||
and reuse of software generally.
|
||||
|
||||
NO WARRANTY
|
||||
|
||||
15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
|
||||
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
|
||||
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
|
||||
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
|
||||
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
|
||||
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
|
||||
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
|
||||
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
|
||||
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
|
||||
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
|
||||
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
|
||||
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
|
||||
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
|
||||
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
|
||||
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
|
||||
DAMAGES.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Libraries
|
||||
|
||||
If you develop a new library, and you want it to be of the greatest
|
||||
possible use to the public, we recommend making it free software that
|
||||
everyone can redistribute and change. You can do so by permitting
|
||||
redistribution under these terms (or, alternatively, under the terms of the
|
||||
ordinary General Public License).
|
||||
|
||||
To apply these terms, attach the following notices to the library. It is
|
||||
safest to attach them to the start of each source file to most effectively
|
||||
convey the exclusion of warranty; and each file should have at least the
|
||||
"copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<one line to give the library's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) any later version.
|
||||
|
||||
This library is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library; if not, write to the Free Software
|
||||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
You should also get your employer (if you work as a programmer) or your
|
||||
school, if any, to sign a "copyright disclaimer" for the library, if
|
||||
necessary. Here is a sample; alter the names:
|
||||
|
||||
Yoyodyne, Inc., hereby disclaims all copyright interest in the
|
||||
library `Frob' (a library for tweaking knobs) written by James Random Hacker.
|
||||
|
||||
<signature of Ty Coon>, 1 April 1990
|
||||
Ty Coon, President of Vice
|
||||
|
||||
That's all there is to it!
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,182 +0,0 @@
|
|||
Basic Installation
|
||||
==================
|
||||
|
||||
These are generic installation instructions.
|
||||
|
||||
The `configure' shell script attempts to guess correct values for
|
||||
various system-dependent variables used during compilation. It uses
|
||||
those values to create a `Makefile' in each directory of the package.
|
||||
It may also create one or more `.h' files containing system-dependent
|
||||
definitions. Finally, it creates a shell script `config.status' that
|
||||
you can run in the future to recreate the current configuration, a file
|
||||
`config.cache' that saves the results of its tests to speed up
|
||||
reconfiguring, and a file `config.log' containing compiler output
|
||||
(useful mainly for debugging `configure').
|
||||
|
||||
If you need to do unusual things to compile the package, please try
|
||||
to figure out how `configure' could check whether to do them, and mail
|
||||
diffs or instructions to the address given in the `README' so they can
|
||||
be considered for the next release. If at some point `config.cache'
|
||||
contains results you don't want to keep, you may remove or edit it.
|
||||
|
||||
The file `configure.in' is used to create `configure' by a program
|
||||
called `autoconf'. You only need `configure.in' if you want to change
|
||||
it or regenerate `configure' using a newer version of `autoconf'.
|
||||
|
||||
The simplest way to compile this package is:
|
||||
|
||||
1. `cd' to the directory containing the package's source code and type
|
||||
`./configure' to configure the package for your system. If you're
|
||||
using `csh' on an old version of System V, you might need to type
|
||||
`sh ./configure' instead to prevent `csh' from trying to execute
|
||||
`configure' itself.
|
||||
|
||||
Running `configure' takes awhile. While running, it prints some
|
||||
messages telling which features it is checking for.
|
||||
|
||||
2. Type `make' to compile the package.
|
||||
|
||||
3. Optionally, type `make check' to run any self-tests that come with
|
||||
the package.
|
||||
|
||||
4. Type `make install' to install the programs and any data files and
|
||||
documentation.
|
||||
|
||||
5. You can remove the program binaries and object files from the
|
||||
source code directory by typing `make clean'. To also remove the
|
||||
files that `configure' created (so you can compile the package for
|
||||
a different kind of computer), type `make distclean'. There is
|
||||
also a `make maintainer-clean' target, but that is intended mainly
|
||||
for the package's developers. If you use it, you may have to get
|
||||
all sorts of other programs in order to regenerate files that came
|
||||
with the distribution.
|
||||
|
||||
Compilers and Options
|
||||
=====================
|
||||
|
||||
Some systems require unusual options for compilation or linking that
|
||||
the `configure' script does not know about. You can give `configure'
|
||||
initial values for variables by setting them in the environment. Using
|
||||
a Bourne-compatible shell, you can do that on the command line like
|
||||
this:
|
||||
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
|
||||
|
||||
Or on systems that have the `env' program, you can do it like this:
|
||||
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
|
||||
|
||||
Compiling For Multiple Architectures
|
||||
====================================
|
||||
|
||||
You can compile the package for more than one kind of computer at the
|
||||
same time, by placing the object files for each architecture in their
|
||||
own directory. To do this, you must use a version of `make' that
|
||||
supports the `VPATH' variable, such as GNU `make'. `cd' to the
|
||||
directory where you want the object files and executables to go and run
|
||||
the `configure' script. `configure' automatically checks for the
|
||||
source code in the directory that `configure' is in and in `..'.
|
||||
|
||||
If you have to use a `make' that does not supports the `VPATH'
|
||||
variable, you have to compile the package for one architecture at a time
|
||||
in the source code directory. After you have installed the package for
|
||||
one architecture, use `make distclean' before reconfiguring for another
|
||||
architecture.
|
||||
|
||||
Installation Names
|
||||
==================
|
||||
|
||||
By default, `make install' will install the package's files in
|
||||
`/usr/local/bin', `/usr/local/man', etc. You can specify an
|
||||
installation prefix other than `/usr/local' by giving `configure' the
|
||||
option `--prefix=PATH'.
|
||||
|
||||
You can specify separate installation prefixes for
|
||||
architecture-specific files and architecture-independent files. If you
|
||||
give `configure' the option `--exec-prefix=PATH', the package will use
|
||||
PATH as the prefix for installing programs and libraries.
|
||||
Documentation and other data files will still use the regular prefix.
|
||||
|
||||
In addition, if you use an unusual directory layout you can give
|
||||
options like `--bindir=PATH' to specify different values for particular
|
||||
kinds of files. Run `configure --help' for a list of the directories
|
||||
you can set and what kinds of files go in them.
|
||||
|
||||
If the package supports it, you can cause programs to be installed
|
||||
with an extra prefix or suffix on their names by giving `configure' the
|
||||
option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
|
||||
|
||||
Optional Features
|
||||
=================
|
||||
|
||||
Some packages pay attention to `--enable-FEATURE' options to
|
||||
`configure', where FEATURE indicates an optional part of the package.
|
||||
They may also pay attention to `--with-PACKAGE' options, where PACKAGE
|
||||
is something like `gnu-as' or `x' (for the X Window System). The
|
||||
`README' should mention any `--enable-' and `--with-' options that the
|
||||
package recognizes.
|
||||
|
||||
For packages that use the X Window System, `configure' can usually
|
||||
find the X include and library files automatically, but if it doesn't,
|
||||
you can use the `configure' options `--x-includes=DIR' and
|
||||
`--x-libraries=DIR' to specify their locations.
|
||||
|
||||
Specifying the System Type
|
||||
==========================
|
||||
|
||||
There may be some features `configure' can not figure out
|
||||
automatically, but needs to determine by the type of host the package
|
||||
will run on. Usually `configure' can figure that out, but if it prints
|
||||
a message saying it can not guess the host type, give it the
|
||||
`--host=TYPE' option. TYPE can either be a short name for the system
|
||||
type, such as `sun4', or a canonical name with three fields:
|
||||
CPU-COMPANY-SYSTEM
|
||||
|
||||
See the file `config.sub' for the possible values of each field. If
|
||||
`config.sub' isn't included in this package, then this package doesn't
|
||||
need to know the host type.
|
||||
|
||||
If you are building compiler tools for cross-compiling, you can also
|
||||
use the `--target=TYPE' option to select the type of system they will
|
||||
produce code for and the `--build=TYPE' option to select the type of
|
||||
system on which you are compiling the package.
|
||||
|
||||
Sharing Defaults
|
||||
================
|
||||
|
||||
If you want to set default values for `configure' scripts to share,
|
||||
you can create a site shell script called `config.site' that gives
|
||||
default values for variables like `CC', `cache_file', and `prefix'.
|
||||
`configure' looks for `PREFIX/share/config.site' if it exists, then
|
||||
`PREFIX/etc/config.site' if it exists. Or, you can set the
|
||||
`CONFIG_SITE' environment variable to the location of the site script.
|
||||
A warning: not all `configure' scripts look for a site script.
|
||||
|
||||
Operation Controls
|
||||
==================
|
||||
|
||||
`configure' recognizes the following options to control how it
|
||||
operates.
|
||||
|
||||
`--cache-file=FILE'
|
||||
Use and save the results of the tests in FILE instead of
|
||||
`./config.cache'. Set FILE to `/dev/null' to disable caching, for
|
||||
debugging `configure'.
|
||||
|
||||
`--help'
|
||||
Print a summary of the options to `configure', and exit.
|
||||
|
||||
`--quiet'
|
||||
`--silent'
|
||||
`-q'
|
||||
Do not print messages saying which checks are being made. To
|
||||
suppress all normal output, redirect it to `/dev/null' (any error
|
||||
messages will still be shown).
|
||||
|
||||
`--srcdir=DIR'
|
||||
Look for the package's source code in directory DIR. Usually
|
||||
`configure' can determine that directory automatically.
|
||||
|
||||
`--version'
|
||||
Print the version of Autoconf used to generate the `configure'
|
||||
script, and exit.
|
||||
|
||||
`configure' also accepts some other, not widely useful, options.
|
|
@ -1,5 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = add_cflags.m4 clip_mode.m4 endian.m4 \
|
||||
flexible_array.m4 llrint.m4 lrint.m4 lrintf.m4 octave.m4 extra_pkg.m4
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
dnl @synopsis MN_ADD_CFLAGS
|
||||
dnl
|
||||
dnl Add the given option to CFLAGS, if it doesn't break the compiler
|
||||
|
||||
AC_DEFUN([MN_ADD_CFLAGS],
|
||||
[AC_MSG_CHECKING([if $CC accepts $1])
|
||||
ac_add_cflags__old_cflags="$CFLAGS"
|
||||
CFLAGS="$1"
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
],
|
||||
[puts("Hello, World!"); return 0;],
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$ac_add_cflags__old_cflags $1",
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$ac_add_cflags__old_cflags"
|
||||
)
|
||||
])# MN_ADD_CFLAGS
|
|
@ -1,19 +0,0 @@
|
|||
dnl @synopsis MN_ADD_CXXFLAGS
|
||||
dnl
|
||||
dnl Add the given option to CXXFLAGS, if it doesn't break the compiler
|
||||
|
||||
AC_DEFUN([MN_ADD_CXXFLAGS],
|
||||
[AC_MSG_CHECKING([if $CXX accepts $1])
|
||||
AC_LANG_ASSERT([C++])
|
||||
ac_add_cxxflags__old_cxxflags="$CXXFLAGS"
|
||||
CXXFLAGS="$1"
|
||||
AC_TRY_LINK([
|
||||
#include <cstdio>
|
||||
],
|
||||
[puts("Hello, World!"); return 0;],
|
||||
AC_MSG_RESULT([yes])
|
||||
CXXFLAGS="$ac_add_cxxflags__old_cxxflags $1",
|
||||
AC_MSG_RESULT([no])
|
||||
CXXFLAGS="$ac_add_cxxflags__old_cxxflags"
|
||||
)
|
||||
])# MN_ADD_CXXFLAGS
|
|
@ -1,31 +0,0 @@
|
|||
dnl @synopsis MN_C_COMPILER_IS_CLANG
|
||||
dnl
|
||||
dnl Find out if a compiler claiming to be gcc really is gcc (fuck you clang).
|
||||
dnl @version 1.0 Oct 31 2013
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
|
||||
AC_DEFUN([MN_C_COMPILER_IS_CLANG],
|
||||
[AC_CACHE_CHECK(whether we are using the CLANG C compiler,
|
||||
mn_cv_c_compiler_clang,
|
||||
[ AC_LANG_ASSERT(C)
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
],
|
||||
[
|
||||
#ifndef __clang__
|
||||
This is not clang!
|
||||
#endif
|
||||
],
|
||||
mn_cv_c_compiler_clang=yes,
|
||||
mn_cv_c_compiler_clang=no
|
||||
])
|
||||
)
|
||||
])
|
|
@ -1,124 +0,0 @@
|
|||
dnl @synopsis MN_C_CLIP_MODE
|
||||
dnl
|
||||
dnl Determine the clipping mode when converting float to int.
|
||||
dnl @version 1.0 May 17 2003
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dnl Find the clipping mode in the following way:
|
||||
dnl 1) If we are not cross compiling test it.
|
||||
dnl 2) IF we are cross compiling, assume that clipping isn't done correctly.
|
||||
|
||||
AC_DEFUN([MN_C_CLIP_MODE],
|
||||
[AC_CACHE_CHECK(processor clipping capabilities,
|
||||
ac_cv_c_clip_type,
|
||||
|
||||
# Initialize to unknown
|
||||
ac_cv_c_clip_positive=unknown
|
||||
ac_cv_c_clip_negative=unknown
|
||||
|
||||
|
||||
if test $ac_cv_c_clip_positive = unknown ; then
|
||||
AC_TRY_RUN(
|
||||
[[
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
#include <math.h>
|
||||
int main (void)
|
||||
{ double fval ;
|
||||
int k, ival ;
|
||||
|
||||
fval = 1.0 * 0x7FFFFFFF ;
|
||||
for (k = 0 ; k < 100 ; k++)
|
||||
{ ival = (lrint (fval)) >> 24 ;
|
||||
if (ival != 127)
|
||||
return 1 ;
|
||||
|
||||
fval *= 1.2499999 ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
]],
|
||||
ac_cv_c_clip_positive=yes,
|
||||
ac_cv_c_clip_positive=no,
|
||||
ac_cv_c_clip_positive=unknown
|
||||
)
|
||||
|
||||
AC_TRY_RUN(
|
||||
[[
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
#include <math.h>
|
||||
int main (void)
|
||||
{ double fval ;
|
||||
int k, ival ;
|
||||
|
||||
fval = -8.0 * 0x10000000 ;
|
||||
for (k = 0 ; k < 100 ; k++)
|
||||
{ ival = (lrint (fval)) >> 24 ;
|
||||
if (ival != -128)
|
||||
return 1 ;
|
||||
|
||||
fval *= 1.2499999 ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
]],
|
||||
ac_cv_c_clip_negative=yes,
|
||||
ac_cv_c_clip_negative=no,
|
||||
ac_cv_c_clip_negative=unknown
|
||||
)
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_clip_positive = yes ; then
|
||||
ac_cv_c_clip_positive=1
|
||||
else
|
||||
ac_cv_c_clip_positive=0
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_clip_negative = yes ; then
|
||||
ac_cv_c_clip_negative=1
|
||||
else
|
||||
ac_cv_c_clip_negative=0
|
||||
fi
|
||||
|
||||
[[
|
||||
case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in
|
||||
"00")
|
||||
ac_cv_c_clip_type="none"
|
||||
;;
|
||||
"10")
|
||||
ac_cv_c_clip_type="positive"
|
||||
;;
|
||||
"01")
|
||||
ac_cv_c_clip_type="negative"
|
||||
;;
|
||||
"11")
|
||||
ac_cv_c_clip_type="both"
|
||||
;;
|
||||
esac
|
||||
]]
|
||||
|
||||
)
|
||||
]
|
||||
|
||||
)# MN_C_CLIP_MODE
|
||||
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
dnl @synopsis MN_C_FIND_ENDIAN
|
||||
dnl
|
||||
dnl Determine endian-ness of target processor.
|
||||
dnl @version 1.1 Mar 03 2002
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Majority written from scratch to replace the standard autoconf macro
|
||||
dnl AC_C_BIGENDIAN. Only part remaining from the original it the invocation
|
||||
dnl of the AC_TRY_RUN macro.
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
|
||||
dnl Find endian-ness in the following way:
|
||||
dnl 1) Look in <endian.h>.
|
||||
dnl 2) If 1) fails, look in <sys/types.h> and <sys/param.h>.
|
||||
dnl 3) If 1) and 2) fails and not cross compiling run a test program.
|
||||
dnl 4) If 1) and 2) fails and cross compiling then guess based on target.
|
||||
|
||||
AC_DEFUN([MN_C_FIND_ENDIAN],
|
||||
[AC_CACHE_CHECK(processor byte ordering,
|
||||
ac_cv_c_byte_order,
|
||||
|
||||
# Initialize to unknown
|
||||
ac_cv_c_byte_order=unknown
|
||||
|
||||
if test x$ac_cv_header_endian_h = xyes ; then
|
||||
|
||||
# First try <endian.h> which should set BYTE_ORDER.
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <endian.h>
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
], return 0 ;,
|
||||
ac_cv_c_byte_order=little
|
||||
)]
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <endian.h>
|
||||
#if BYTE_ORDER != BIG_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
], return 0 ;,
|
||||
ac_cv_c_byte_order=big
|
||||
)]
|
||||
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_byte_order = unknown ; then
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
|
||||
bogus endian macros
|
||||
#endif
|
||||
], return 0 ;,
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
], return 0 ;,
|
||||
ac_cv_c_byte_order=little
|
||||
)]
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
], return 0 ;,
|
||||
ac_cv_c_byte_order=little
|
||||
)]
|
||||
|
||||
)]
|
||||
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_byte_order = unknown ; then
|
||||
if test $cross_compiling = yes ; then
|
||||
# This is the last resort. Try to guess the target processor endian-ness
|
||||
# by looking at the target CPU type.
|
||||
[
|
||||
case "$target_cpu" in
|
||||
alpha* | i?86* | mipsel* | ia64*)
|
||||
ac_cv_c_byte_order=little
|
||||
;;
|
||||
|
||||
m68* | mips* | powerpc* | hppa* | sparc*)
|
||||
ac_cv_c_byte_order=big
|
||||
;;
|
||||
|
||||
esac
|
||||
]
|
||||
else
|
||||
AC_TRY_RUN(
|
||||
[[
|
||||
int main (void)
|
||||
{ /* Are we little or big endian? From Harbison&Steele. */
|
||||
union
|
||||
{ long l ;
|
||||
char c [sizeof (long)] ;
|
||||
} u ;
|
||||
u.l = 1 ;
|
||||
return (u.c [sizeof (long) - 1] == 1);
|
||||
}
|
||||
]], , ac_cv_c_byte_order=big,
|
||||
)
|
||||
|
||||
AC_TRY_RUN(
|
||||
[[int main (void)
|
||||
{ /* Are we little or big endian? From Harbison&Steele. */
|
||||
union
|
||||
{ long l ;
|
||||
char c [sizeof (long)] ;
|
||||
} u ;
|
||||
u.l = 1 ;
|
||||
return (u.c [0] == 1);
|
||||
}]], , ac_cv_c_byte_order=little,
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
)
|
||||
|
||||
if test $ac_cv_c_byte_order = big ; then
|
||||
ac_cv_c_big_endian=1
|
||||
ac_cv_c_little_endian=0
|
||||
elif test $ac_cv_c_byte_order = little ; then
|
||||
ac_cv_c_big_endian=0
|
||||
ac_cv_c_little_endian=1
|
||||
else
|
||||
ac_cv_c_big_endian=0
|
||||
ac_cv_c_little_endian=0
|
||||
|
||||
AC_MSG_WARN([[*****************************************************************]])
|
||||
AC_MSG_WARN([[*** Not able to determine endian-ness of target processor. ]])
|
||||
AC_MSG_WARN([[*** The constants CPU_IS_BIG_ENDIAN and CPU_IS_LITTLE_ENDIAN in ]])
|
||||
AC_MSG_WARN([[*** src/config.h may need to be hand editied. ]])
|
||||
AC_MSG_WARN([[*****************************************************************]])
|
||||
fi
|
||||
|
||||
]
|
||||
)# MN_C_FIND_ENDIAN
|
||||
|
||||
|
|
@ -1,114 +0,0 @@
|
|||
dnl By default, many hosts won't let programs access large files;
|
||||
dnl one must use special compiler options to get large-file access to work.
|
||||
dnl For more details about this brain damage please see:
|
||||
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
|
||||
|
||||
dnl Written by Paul Eggert <eggert@twinsun.com>.
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl MN_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME)
|
||||
AC_DEFUN([MN_SYS_EXTRA_LARGEFILE_FLAGS],
|
||||
[AC_CACHE_CHECK([for $1 value to request large file support],
|
||||
ac_cv_sys_largefile_$1,
|
||||
[ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
|
||||
ac_cv_sys_largefile_$1=no
|
||||
ifelse($1, CFLAGS,
|
||||
[case "$host_os" in
|
||||
# IRIX 6.2 and later require cc -n32.
|
||||
changequote(, )dnl
|
||||
irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
|
||||
changequote([, ])dnl
|
||||
if test "$GCC" != yes; then
|
||||
ac_cv_sys_largefile_CFLAGS=-n32
|
||||
fi
|
||||
ac_save_CC="$CC"
|
||||
CC="$CC $ac_cv_sys_largefile_CFLAGS"
|
||||
AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
|
||||
CC="$ac_save_CC"
|
||||
esac])
|
||||
}])])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(VAR, VAL)
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND],
|
||||
[case $2 in
|
||||
no) ;;
|
||||
?*)
|
||||
case "[$]$1" in
|
||||
'') $1=$2 ;;
|
||||
*) $1=[$]$1' '$2 ;;
|
||||
esac ;;
|
||||
esac])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE],
|
||||
[AC_CACHE_CHECK([for $1], $2,
|
||||
[$2=no
|
||||
changequote(, )dnl
|
||||
$4
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
-D$1)
|
||||
$2=1 ;;
|
||||
-D$1=*)
|
||||
$2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
|
||||
esac
|
||||
done
|
||||
changequote([, ])dnl
|
||||
])
|
||||
if test "[$]$2" != no; then
|
||||
AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
|
||||
fi])
|
||||
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE],
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_ARG_ENABLE(largefile,
|
||||
[ --disable-largefile omit support for large files])
|
||||
if test "$enable_largefile" != no; then
|
||||
AC_CHECK_TOOL(GETCONF, getconf)
|
||||
MN_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS)
|
||||
MN_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS)
|
||||
MN_SYS_EXTRA_LARGEFILE_FLAGS(LIBS)
|
||||
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
no) ;;
|
||||
-D_FILE_OFFSET_BITS=*) ;;
|
||||
-D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
|
||||
-D_LARGE_FILES | -D_LARGE_FILES=*) ;;
|
||||
-D?* | -I?*)
|
||||
AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
|
||||
*)
|
||||
AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
|
||||
esac
|
||||
done
|
||||
AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
|
||||
AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
|
||||
AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
|
||||
ac_cv_sys_file_offset_bits,
|
||||
[Number of bits in a file offset, on hosts where this is settable.])
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_sys_file_offset_bits=64 ;;
|
||||
esac]
|
||||
AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
|
||||
ac_cv_sys_largefile_source,
|
||||
[Define to make fseeko etc. visible, on some hosts.],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_sys_largefile_source=1 ;;
|
||||
esac])
|
||||
AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
|
||||
ac_cv_sys_large_files,
|
||||
[Define for large files, on AIX-style hosts.],
|
||||
[case "$host_os" in
|
||||
# AIX 4.2 and later
|
||||
aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
|
||||
ac_cv_sys_large_files=1 ;;
|
||||
esac])
|
||||
fi
|
||||
])
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
# extra_pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
#
|
||||
# Copyright (c) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
# Copyright (c) 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 2 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful, but
|
||||
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
# General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
#
|
||||
# As a special exception to the GNU General Public License, if you
|
||||
# distribute this file as part of a program that contains a
|
||||
# configuration script generated by Autoconf, you may include it under
|
||||
# the same distribution terms that you use for the rest of that program.
|
||||
|
||||
# --------------------------------------------------------------
|
||||
# PKG_CHECK_MOD_VERSION(VARIABLE-PREFIX, MODULES, [ACTION-IF-FOUND],
|
||||
# [ACTION-IF-NOT-FOUND])
|
||||
#
|
||||
# This is a very slight modification to the macro PKG_CHECK_MODULES that
|
||||
# is in the original pkg.m4 file. It prints the versions in the checking
|
||||
# message (erikd@mega-nerd.com).
|
||||
|
||||
AC_DEFUN([PKG_CHECK_MOD_VERSION],
|
||||
[AC_REQUIRE([PKG_PROG_PKG_CONFIG])dnl
|
||||
AC_ARG_VAR([$1][_CFLAGS], [C compiler flags for $1, overriding pkg-config])dnl
|
||||
AC_ARG_VAR([$1][_LIBS], [linker flags for $1, overriding pkg-config])dnl
|
||||
|
||||
pkg_failed=no
|
||||
AC_MSG_CHECKING([for $2 ])
|
||||
|
||||
_PKG_CONFIG([$1][_CFLAGS], [cflags], [$2])
|
||||
_PKG_CONFIG([$1][_LIBS], [libs], [$2])
|
||||
|
||||
pkg_link_saved_CFLAGS=$CFLAGS
|
||||
pkg_link_saved_LIBS=$LIBS
|
||||
|
||||
eval "pkg_CFLAGS=\${pkg_cv_[]$1[]_CFLAGS}"
|
||||
eval "pkg_LIBS=\${pkg_cv_[]$1[]_LIBS}"
|
||||
|
||||
CFLAGS="$CFLAGS $pkg_CFLAGS"
|
||||
LIBS="$LIBS $pkg_LIBS"
|
||||
|
||||
AC_TRY_LINK([], puts ("");, pkg_link=yes, pkg_link=no)
|
||||
|
||||
CFLAGS=$pkg_link_saved_CFLAGS
|
||||
LIBS=$pkg_link_saved_LIBS
|
||||
|
||||
if test $pkg_link = no ; then
|
||||
$as_echo_n "link failed ... "
|
||||
pkg_failed=yes
|
||||
fi
|
||||
|
||||
m4_define([_PKG_TEXT], [Alternatively, you may set the environment variables $1[]_CFLAGS
|
||||
and $1[]_LIBS to avoid the need to call pkg-config.
|
||||
See the pkg-config man page for more details.])
|
||||
|
||||
if test $pkg_failed = yes; then
|
||||
_PKG_SHORT_ERRORS_SUPPORTED
|
||||
if test $_pkg_short_errors_supported = yes; then
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --short-errors --errors-to-stdout --print-errors "$2"`
|
||||
else
|
||||
$1[]_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
|
||||
fi
|
||||
# Put the nasty error message in config.log where it belongs
|
||||
echo "$$1[]_PKG_ERRORS" >&AS_MESSAGE_LOG_FD
|
||||
|
||||
ifelse([$4], , [AC_MSG_ERROR(dnl
|
||||
[Package requirements ($2) were not met:
|
||||
|
||||
$$1_PKG_ERRORS
|
||||
|
||||
Consider adjusting the PKG_CONFIG_PATH environment variable if you
|
||||
installed software in a non-standard prefix.
|
||||
|
||||
_PKG_TEXT
|
||||
])],
|
||||
[AC_MSG_RESULT([no])
|
||||
$4])
|
||||
elif test $pkg_failed = untried; then
|
||||
ifelse([$4], , [AC_MSG_FAILURE(dnl
|
||||
[The pkg-config script could not be found or is too old. Make sure it
|
||||
is in your PATH or set the PKG_CONFIG environment variable to the full
|
||||
path to pkg-config.
|
||||
|
||||
_PKG_TEXT
|
||||
|
||||
To get pkg-config, see <http://pkg-config.freedesktop.org/>.])],
|
||||
[$4])
|
||||
else
|
||||
$1[]_CFLAGS=$pkg_cv_[]$1[]_CFLAGS
|
||||
$1[]_LIBS=$pkg_cv_[]$1[]_LIBS
|
||||
AC_MSG_RESULT([yes])
|
||||
ifelse([$3], , :, [$3])
|
||||
fi[]dnl
|
||||
])# PKG_CHECK_MOD_VERSION
|
|
@ -1,32 +0,0 @@
|
|||
dnl @synopsis MN_C99_FLEXIBLE_ARRAY
|
||||
dnl
|
||||
dnl Dose the compiler support the 1999 ISO C Standard "stuct hack".
|
||||
dnl @version 1.1 Mar 15 2004
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
|
||||
AC_DEFUN([MN_C99_FLEXIBLE_ARRAY],
|
||||
[AC_CACHE_CHECK(C99 struct flexible array support,
|
||||
ac_cv_c99_flexible_array,
|
||||
|
||||
# Initialize to unknown
|
||||
ac_cv_c99_flexible_array=no
|
||||
|
||||
AC_TRY_LINK([[
|
||||
#include <stdlib.h>
|
||||
typedef struct {
|
||||
int k;
|
||||
char buffer [] ;
|
||||
} MY_STRUCT ;
|
||||
]],
|
||||
[ MY_STRUCT *p = calloc (1, sizeof (MY_STRUCT) + 42); ],
|
||||
ac_cv_c99_flexible_array=yes,
|
||||
ac_cv_c99_flexible_array=no
|
||||
))]
|
||||
) # MN_C99_FLEXIBLE_ARRAY
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
dnl @synopsis MN_GCC_VERSION
|
||||
dnl
|
||||
dnl Find the version of gcc.
|
||||
dnl @version 1.0 Nov 05 2007
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([MN_GCC_VERSION],
|
||||
[
|
||||
if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
|
||||
|
||||
AC_MSG_CHECKING([for version of $CC])
|
||||
GCC_VERSION=`$CC -dumpversion`
|
||||
AC_MSG_RESULT($GCC_VERSION)
|
||||
|
||||
changequote(,)dnl
|
||||
GCC_MAJOR_VERSION=`echo $GCC_VERSION | sed "s/\..*//"`
|
||||
GCC_MINOR_VERSION=`echo $GCC_VERSION | sed "s/$GCC_MAJOR_VERSION\.//" | sed "s/\..*//"`
|
||||
changequote([,])dnl
|
||||
fi
|
||||
|
||||
AC_SUBST(GCC_VERSION)
|
||||
AC_SUBST(GCC_MAJOR_VERSION)
|
||||
AC_SUBST(GCC_MINOR_VERSION)
|
||||
|
||||
])# MN_GCC_VERSION
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
dnl @synopsis MN_C99_FUNC_LLRINT
|
||||
dnl
|
||||
dnl Check whether C99's llrint function is available.
|
||||
dnl @version 1.1 Sep 30 2002
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([MN_C99_FUNC_LLRINT],
|
||||
[AC_CACHE_CHECK(for llrint,
|
||||
ac_cv_c99_llrint,
|
||||
[
|
||||
llrint_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-lm"
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
], int64_t x ; x = llrint(3.14159) ;, ac_cv_c99_llrint=yes, ac_cv_c99_llrint=no)
|
||||
|
||||
CFLAGS=$llrint_save_CFLAGS
|
||||
|
||||
])
|
||||
|
||||
if test "$ac_cv_c99_llrint" = yes; then
|
||||
AC_DEFINE(HAVE_LLRINT, 1,
|
||||
[Define if you have C99's llrint function.])
|
||||
fi
|
||||
])# MN_C99_FUNC_LLRINT
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
dnl @synopsis MN_C99_FUNC_LRINT
|
||||
dnl
|
||||
dnl Check whether C99's lrint function is available.
|
||||
dnl @version 1.3 Feb 12 2002
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([MN_C99_FUNC_LRINT],
|
||||
[AC_CACHE_CHECK(for lrint,
|
||||
ac_cv_c99_lrint,
|
||||
[
|
||||
lrint_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-lm"
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
|
||||
#include <math.h>
|
||||
], if (!lrint(3.14159)) lrint(2.7183);, ac_cv_c99_lrint=yes, ac_cv_c99_lrint=no)
|
||||
|
||||
CFLAGS=$lrint_save_CFLAGS
|
||||
|
||||
])
|
||||
|
||||
if test "$ac_cv_c99_lrint" = yes; then
|
||||
AC_DEFINE(HAVE_LRINT, 1,
|
||||
[Define if you have C99's lrint function.])
|
||||
fi
|
||||
])# MN_C99_FUNC_LRINT
|
||||
|
|
@ -1,37 +0,0 @@
|
|||
dnl @synopsis MN_C99_FUNC_LRINTF
|
||||
dnl
|
||||
dnl Check whether C99's lrintf function is available.
|
||||
dnl @version 1.3 Feb 12 2002
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([MN_C99_FUNC_LRINTF],
|
||||
[AC_CACHE_CHECK(for lrintf,
|
||||
ac_cv_c99_lrintf,
|
||||
[
|
||||
lrintf_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-lm"
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
|
||||
#include <math.h>
|
||||
], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no)
|
||||
|
||||
CFLAGS=$lrintf_save_CFLAGS
|
||||
|
||||
])
|
||||
|
||||
if test "$ac_cv_c99_lrintf" = yes; then
|
||||
AC_DEFINE(HAVE_LRINTF, 1,
|
||||
[Define if you have C99's lrintf function.])
|
||||
fi
|
||||
])# MN_C99_FUNC_LRINTF
|
||||
|
|
@ -1,38 +0,0 @@
|
|||
dnl @synopsis OCTAVE_MKOCTFILE_VERSION
|
||||
dnl
|
||||
dnl Find the version of mkoctfile.
|
||||
dnl @version 1.0 Aug 23 2007
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([OCTAVE_MKOCTFILE_VERSION],
|
||||
[
|
||||
|
||||
|
||||
AC_ARG_WITH(mkoctfile,
|
||||
AC_HELP_STRING([--with-mkoctfile], [choose the mkoctfile version]),
|
||||
[ with_mkoctfile=$withval ])
|
||||
|
||||
test -z "$with_mkoctfile" && with_mkoctfile=mkoctfile
|
||||
|
||||
AC_CHECK_PROG(HAVE_MKOCTFILE,$with_mkoctfile,yes,no)
|
||||
|
||||
if test "x$ac_cv_prog_HAVE_MKOCTFILE" = "xyes" ; then
|
||||
MKOCTFILE=$with_mkoctfile
|
||||
|
||||
AC_MSG_CHECKING([for version of $MKOCTFILE])
|
||||
MKOCTFILE_VERSION=`$with_mkoctfile --version 2>&1 | sed 's/mkoctfile, version //g'`
|
||||
AC_MSG_RESULT($MKOCTFILE_VERSION)
|
||||
fi
|
||||
|
||||
AC_SUBST(MKOCTFILE)
|
||||
AC_SUBST(MKOCTFILE_VERSION)
|
||||
|
||||
])# OCTAVE_MKOCTFILE_VERSION
|
||||
|
|
@ -1,143 +0,0 @@
|
|||
dnl Evaluate an expression in octave
|
||||
dnl
|
||||
dnl OCTAVE_EVAL(expr,var) -> var=expr
|
||||
dnl
|
||||
dnl Stolen from octave-forge
|
||||
|
||||
AC_DEFUN([OCTAVE_EVAL],
|
||||
[
|
||||
AC_MSG_CHECKING([for $1 in $OCTAVE])
|
||||
$2=`TERM=;$OCTAVE -qfH --eval "disp($1)"`
|
||||
AC_MSG_RESULT($$2)
|
||||
AC_SUBST($2)
|
||||
]) # OCTAVE_EVAL
|
||||
|
||||
dnl @synopsis AC_OCTAVE_VERSION
|
||||
dnl
|
||||
dnl Find the version of Octave.
|
||||
dnl @version 1.0 Aug 23 2007
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AC_OCTAVE_VERSION],
|
||||
[
|
||||
|
||||
AC_ARG_WITH(octave,
|
||||
AC_HELP_STRING([--with-octave], [choose the octave version]),
|
||||
[ with_octave=$withval ])
|
||||
|
||||
test -z "$with_octave" && with_octave=octave
|
||||
|
||||
AC_CHECK_PROG(HAVE_OCTAVE,$with_octave,yes,no)
|
||||
|
||||
if test "x$ac_cv_prog_HAVE_OCTAVE" = "xyes" ; then
|
||||
OCTAVE=$with_octave
|
||||
OCTAVE_EVAL(OCTAVE_VERSION,OCTAVE_VERSION)
|
||||
fi
|
||||
|
||||
AC_SUBST(OCTAVE)
|
||||
AC_SUBST(OCTAVE_VERSION)
|
||||
|
||||
])# AC_OCTAVE_VERSION
|
||||
|
||||
dnl @synopsis AC_OCTAVE_CONFIG_VERSION
|
||||
dnl
|
||||
dnl Find the version of Octave.
|
||||
dnl @version 1.0 Aug 23 2007
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
AC_DEFUN([AC_OCTAVE_CONFIG_VERSION],
|
||||
[
|
||||
|
||||
AC_ARG_WITH(octave-config,
|
||||
AC_HELP_STRING([--with-octave-config], [choose the octave-config version]),
|
||||
[ with_octave_config=$withval ])
|
||||
|
||||
test -z "$with_octave_config" && with_octave_config=octave-config
|
||||
|
||||
AC_CHECK_PROG(HAVE_OCTAVE_CONFIG,$with_octave_config,yes,no)
|
||||
|
||||
if test "x$ac_cv_prog_HAVE_OCTAVE_CONFIG" = "xyes" ; then
|
||||
OCTAVE_CONFIG=$with_octave_config
|
||||
AC_MSG_CHECKING([for version of $OCTAVE_CONFIG])
|
||||
OCTAVE_CONFIG_VERSION=`$OCTAVE_CONFIG --version`
|
||||
AC_MSG_RESULT($OCTAVE_CONFIG_VERSION)
|
||||
fi
|
||||
|
||||
AC_SUBST(OCTAVE_CONFIG)
|
||||
AC_SUBST(OCTAVE_CONFIG_VERSION)
|
||||
|
||||
])# AC_OCTAVE_CONFIG_VERSION
|
||||
|
||||
dnl @synopsis AC_OCTAVE_BUILD
|
||||
dnl
|
||||
dnl Check programs and headers required for building octave plugins.
|
||||
dnl @version 1.0 Aug 23 2007
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
|
||||
|
||||
AC_DEFUN([AC_OCTAVE_BUILD],
|
||||
[
|
||||
|
||||
dnl Default to no.
|
||||
OCTAVE_BUILD=no
|
||||
|
||||
AC_OCTAVE_VERSION
|
||||
OCTAVE_MKOCTFILE_VERSION
|
||||
AC_OCTAVE_CONFIG_VERSION
|
||||
|
||||
prog_concat="$ac_cv_prog_HAVE_OCTAVE$ac_cv_prog_HAVE_OCTAVE_CONFIG$ac_cv_prog_HAVE_MKOCTFILE"
|
||||
|
||||
if test "x$prog_concat" = "xyesyesyes" ; then
|
||||
if test "x$OCTAVE_VERSION" != "x$MKOCTFILE_VERSION" ; then
|
||||
AC_MSG_WARN([** Mismatch between versions of octave and mkoctfile. **])
|
||||
AC_MSG_WARN([** Octave libsndfile modules will not be built. **])
|
||||
elif test "x$OCTAVE_VERSION" != "x$OCTAVE_CONFIG_VERSION" ; then
|
||||
AC_MSG_WARN([** Mismatch between versions of octave and octave-config. **])
|
||||
AC_MSG_WARN([** Octave libsndfile modules will not be built. **])
|
||||
else
|
||||
case "$MKOCTFILE_VERSION" in
|
||||
2.*)
|
||||
AC_MSG_WARN([Octave version 2.X is not supported.])
|
||||
;;
|
||||
3.*)
|
||||
OCTAVE_DEST_ODIR=`$OCTAVE_CONFIG --oct-site-dir | sed 's%^/usr%${prefix}%'`
|
||||
OCTAVE_DEST_MDIR=`$OCTAVE_CONFIG --m-site-dir | sed 's%^/usr%${prefix}%'`
|
||||
|
||||
OCTAVE_BUILD=yes
|
||||
;;
|
||||
*)
|
||||
AC_MSG_WARN([Octave version $MKOCTFILE_VERSION is not supported.])
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
AC_MSG_RESULT([building octave libsndfile module... $OCTAVE_BUILD])
|
||||
fi
|
||||
|
||||
AC_SUBST(OCTAVE_DEST_ODIR)
|
||||
AC_SUBST(OCTAVE_DEST_MDIR)
|
||||
|
||||
AC_SUBST(MKOCTFILE)
|
||||
|
||||
AM_CONDITIONAL(BUILD_OCTAVE_MOD, test "x$OCTAVE_BUILD" = xyes)
|
||||
|
||||
])# AC_OCTAVE_BUILD
|
|
@ -1,33 +0,0 @@
|
|||
dnl @synopsis MN_GCC_REALLY_IS_GCC
|
||||
dnl
|
||||
dnl Find out if a compiler claiming to be gcc really is gcc (fuck you clang).
|
||||
dnl @version 1.0 Oct 31 2013
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
|
||||
# If the configure script has already detected GNU GCC, then make sure it
|
||||
# isn't CLANG masquerading as GCC.
|
||||
|
||||
AC_DEFUN([MN_GCC_REALLY_IS_GCC],
|
||||
[ AC_LANG_ASSERT(C)
|
||||
if test "x$ac_cv_c_compiler_gnu" = "xyes" ; then
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
],
|
||||
[
|
||||
#ifdef __clang__
|
||||
This is clang!
|
||||
#endif
|
||||
],
|
||||
ac_cv_c_compiler_gnu=yes,
|
||||
ac_cv_c_compiler_gnu=no
|
||||
)
|
||||
fi
|
||||
|
||||
])
|
|
@ -1,73 +0,0 @@
|
|||
dnl Copyright (C) 2013 Xiph.org Foundation
|
||||
dnl
|
||||
dnl Redistribution and use in source and binary forms, with or without
|
||||
dnl modification, are permitted provided that the following conditions
|
||||
dnl are met:
|
||||
dnl
|
||||
dnl - Redistributions of source code must retain the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer.
|
||||
dnl
|
||||
dnl - Redistributions in binary form must reproduce the above copyright
|
||||
dnl notice, this list of conditions and the following disclaimer in the
|
||||
dnl documentation and/or other materials provided with the distribution.
|
||||
dnl
|
||||
dnl - Neither the name of the Xiph.org Foundation nor the names of its
|
||||
dnl contributors may be used to endorse or promote products derived from
|
||||
dnl this software without specific prior written permission.
|
||||
dnl
|
||||
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
dnl ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
dnl LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
||||
dnl A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR
|
||||
dnl CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
dnl Want to know of GCC stack protector works, botfor the C and for the C++
|
||||
dnl compiler.
|
||||
dnl
|
||||
dnl Just checking if the compiler accepts the required CFLAGSs is not enough
|
||||
dnl because we have seen at least one instance where this check was
|
||||
dnl in-sufficient.
|
||||
dnl
|
||||
dnl Instead, try to compile and link a test program with the stack protector
|
||||
dnl flags. If that works, we use it.
|
||||
|
||||
AC_DEFUN([XIPH_GCC_STACK_PROTECTOR],
|
||||
[AC_LANG_ASSERT(C)
|
||||
AC_MSG_CHECKING([if $CC supports stack smash protection])
|
||||
xiph_stack_check_old_cflags="$CFLAGS"
|
||||
SSP_FLAGS="-fstack-protector --param ssp-buffer-size=4"
|
||||
CFLAGS=$SSP_FLAGS
|
||||
AC_TRY_LINK([
|
||||
#include <stdio.h>
|
||||
],
|
||||
[puts("Hello, World!"); return 0;],
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS",
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$xiph_stack_check_old_cflags"
|
||||
)
|
||||
])# XIPH_GCC_STACK_PROTECTOR
|
||||
|
||||
AC_DEFUN([XIPH_GXX_STACK_PROTECTOR],
|
||||
[AC_LANG_PUSH([C++])
|
||||
AC_MSG_CHECKING([if $CXX supports stack smash protection])
|
||||
xiph_stack_check_old_cflags="$CFLAGS"
|
||||
SSP_FLAGS="-fstack-protector --param ssp-buffer-size=4"
|
||||
CFLAGS=$SSP_FLAGS
|
||||
AC_TRY_LINK([
|
||||
#include <cstdio>
|
||||
],
|
||||
[puts("Hello, World!"); return 0;],
|
||||
AC_MSG_RESULT([yes])
|
||||
CFLAGS="$xiph_stack_check_old_cflags $SSP_FLAGS",
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$xiph_stack_check_old_cflags"
|
||||
)
|
||||
AC_LANG_POP([C++])
|
||||
])# XIPH_GXX_STACK_PROTECTOR
|
|
@ -1,46 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
ACLOCAL_AMFLAGS = -I M4
|
||||
|
||||
DISTCHECK_CONFIGURE_FLAGS = --enable-gcc-werror
|
||||
|
||||
if BUILD_OCTAVE_MOD
|
||||
octave_dir = Octave
|
||||
endif
|
||||
|
||||
SUBDIRS = M4 Win32 src $(octave_dir)
|
||||
#man doc examples regtest tests programs
|
||||
|
||||
DIST_SUBDIRS = M4 man doc Win32 src Octave examples regtest tests programs
|
||||
|
||||
EXTRA_DIST = libsndfile.spec.in sndfile.pc.in Scripts/android-configure.sh \
|
||||
Scripts/linux-to-win-cross-configure.sh Scripts/build-test-tarball.mk.in
|
||||
|
||||
CLEANFILES = *~
|
||||
|
||||
#pkgconfig_DATA = sndfile.pc
|
||||
|
||||
m4datadir = $(datadir)/aclocal
|
||||
|
||||
#===============================================================================
|
||||
|
||||
test: check-recursive
|
||||
|
||||
# Target to make autogenerated files.
|
||||
genfiles :
|
||||
(cd src ; make genfiles)
|
||||
# (cd tests ; make genfiles)
|
||||
|
||||
checkprograms :
|
||||
(cd src ; make libsndfile.la checkprograms)
|
||||
# (cd tests ; make checkprograms)
|
||||
|
||||
testprogs :
|
||||
(cd src ; make testprogs)
|
||||
# (cd tests ; make testprogs)
|
||||
|
||||
|
||||
test-tarball : Scripts/build-test-tarball.mk
|
||||
(cd src ; make all libsndfile.la checkprograms)
|
||||
# (cd tests ; make all checkprograms)
|
||||
# make -f Scripts/build-test-tarball.mk
|
|
@ -1,116 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
# * Neither the author nor the names of any contributors may be used
|
||||
# to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
set -e
|
||||
|
||||
function unix_to_dos {
|
||||
sed -e "s/\n/\r\n/" $1 > temp_file
|
||||
mv -f temp_file $1
|
||||
}
|
||||
|
||||
if [ $# -lt 1 ] || [ $# -gt 2 ]; then
|
||||
echo "Usage : Mingw-make-dist.sh <source tarball>."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TARGZ=$1
|
||||
if [ ! -f $TARGZ ]; then
|
||||
echo "Can't find source tarball."
|
||||
fi
|
||||
|
||||
TARGZ=$1
|
||||
if [ ! -f $TARGZ.asc ]; then
|
||||
echo "Can't find source tarball signature."
|
||||
fi
|
||||
|
||||
UNAME=`uname -s`
|
||||
if [ x$UNAME != "xMINGW32_NT-5.1" ]; then
|
||||
echo "Not able to build Win32 binaries on this platform."
|
||||
fi
|
||||
|
||||
echo "Building MinGW binary/source zip file."
|
||||
|
||||
VERSION=`pwd | sed -e "s#.*/##" | sed -e s/libsndfile-//`
|
||||
BUILD=`echo $VERSION | sed -e "s/\./_/g"`
|
||||
INSTALL="libsndfile-$BUILD"
|
||||
ZIPNAME="$INSTALL.zip"
|
||||
|
||||
if [ -z "$BUILD" ]; then
|
||||
echo "Bad BUILD variable : '$BUILD'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -d $INSTALL/ ]; then
|
||||
mkdir $INSTALL
|
||||
fi
|
||||
|
||||
if [ ! -f config.status ]; then
|
||||
./configure --prefix=`pwd`/$INSTALL/
|
||||
else
|
||||
teststr=`grep "with options" config.status | grep -- --prefix=`
|
||||
if [ -z "$teststr" ]; then
|
||||
# --disable-static doesn't work.
|
||||
./configure --prefix=`pwd`/$INSTALL/
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f src/.libs/libsndfile-1.dll ]; then
|
||||
make all check
|
||||
fi
|
||||
|
||||
if [ ! -f $INSTALL/bin/libsndfile-1.dll ]; then
|
||||
make install
|
||||
rm -f $INSTALL/bin/sndfile-regtest.exe
|
||||
strip $INSTALL/bin/*.*
|
||||
mv $INSTALL/bin/*.* $INSTALL/include/*.* $INSTALL/
|
||||
rmdir $INSTALL/bin
|
||||
rm -rf $INSTALL/lib
|
||||
rmdir $INSTALL/include
|
||||
cp src/libsndfile.def $INSTALL/libsndfile-1.def
|
||||
cp Win32/README-precompiled-dll.txt Win32/testprog.c $INSTALL/
|
||||
unix_to_dos $INSTALL/libsndfile-1.def
|
||||
unix_to_dos $INSTALL/sndfile.h
|
||||
unix_to_dos $INSTALL/README-precompiled-dll.txt
|
||||
unix_to_dos $INSTALL/testprog.c
|
||||
fi
|
||||
|
||||
if [ ! -f $INSTALL/libsndfile-$VERSION.tar.gz ]; then
|
||||
cp $TARGZ $INSTALL/
|
||||
if [ -f $TARGZ.asc ]; then
|
||||
cp $TARGZ.asc $INSTALL/
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f $ZIPNAME ]; then
|
||||
zip -r $ZIPNAME $INSTALL/
|
||||
fi
|
||||
|
|
@ -1,175 +0,0 @@
|
|||
Version 1.0.25 (2011-07-13)
|
||||
* Fix for Secunia Advisory SA45125, heap overflow in PAF file handler.
|
||||
* Accept broken WAV files with blockalign == 0.
|
||||
* Minor bug fixes and improvements.
|
||||
|
||||
Version 1.0.24 (2011-03-23)
|
||||
* WAV files now have an 18 byte u-law and A-law fmt chunk.
|
||||
* Document virtual I/O functionality.
|
||||
* Two new methods rawHandle() and takeOwnership() in sndfile.hh.
|
||||
* AIFF fix for non-zero offset value in SSND chunk.
|
||||
* Minor bug fixes and improvements.
|
||||
|
||||
Version 1.0.23 (2010-10-10)
|
||||
* Add version metadata to Windows DLL.
|
||||
* Add a missing 'inline' to sndfile.hh.
|
||||
* Update docs.
|
||||
* Minor bug fixes and improvements.
|
||||
|
||||
Version 1.0.22 (2010-10-04)
|
||||
* Couple of fixes for SDS file writer.
|
||||
* Fixes arising from static analysis.
|
||||
* Handle FLAC files with ID3 meta data at start of file.
|
||||
* Handle FLAC files which report zero length.
|
||||
* Other minor bug fixes and improvements.
|
||||
|
||||
Version 1.0.21 (2009-12-13)
|
||||
* Add a couple of new binary programs to programs/ dir.
|
||||
* Remove sndfile-jackplay (now in sndfile-tools package).
|
||||
* Add windows only function sf_wchar_open().
|
||||
* Bunch of minor bug fixes.
|
||||
|
||||
Version 1.0.20 (2009-05-14)
|
||||
* Fix potential heap overflow in VOC file parser (Tobias Klein, http://www.trapkit.de/).
|
||||
|
||||
Version 1.0.19 (2009-03-02)
|
||||
* Fix for CVE-2009-0186 (Alin Rad Pop, Secunia Research).
|
||||
* Huge number of minor bug fixes as a result of static analysis.
|
||||
|
||||
Version 1.0.18 (2009-02-07)
|
||||
* Add Ogg/Vorbis support (thanks to John ffitch).
|
||||
* Remove captive FLAC library.
|
||||
* Many new features and bug fixes.
|
||||
* Generate Win32 and Win64 pre-compiled binaries.
|
||||
|
||||
Version 1.0.17 (2006-08-31)
|
||||
* Add sndfile.hh C++ wrapper.
|
||||
* Update Win32 MinGW build instructions.
|
||||
* Minor bug fixes and cleanups.
|
||||
|
||||
Version 1.0.16 (2006-04-30)
|
||||
* Add support for Broadcast (BEXT) chunks in WAV files.
|
||||
* Implement new commands SFC_GET_SIGNAL_MAX and SFC_GET_MAX_ALL_CHANNELS.
|
||||
* Add support for RIFX (big endian WAV variant).
|
||||
* Fix configure script bugs.
|
||||
* Fix bug in INST and MARK chunk writing for AIFF files.
|
||||
|
||||
Version 1.0.15 (2006-03-16)
|
||||
* Fix some ia64 issues.
|
||||
* Fix precompiled DLL.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.14 (2006-02-19)
|
||||
* Really fix MinGW compile problems.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.13 (2006-01-21)
|
||||
* Fix for MinGW compiler problems.
|
||||
* Allow readin/write of instrument chunks from WAV and AIFF files.
|
||||
* Compile problem fix for Solaris compiler.
|
||||
* Minor cleanups and bug fixes.
|
||||
|
||||
Version 1.0.12 (2005-09-30)
|
||||
* Add support for FLAC and Apple's Core Audio Format (CAF).
|
||||
* Add virtual I/O interface (still needs docs).
|
||||
* Cygwin and other Win32 fixes.
|
||||
* Minor bug fixes and cleanups.
|
||||
|
||||
Version 1.0.11 (2004-11-15)
|
||||
* Add support for SD2 files.
|
||||
* Add read support for loop info in WAV and AIFF files.
|
||||
* Add more tests.
|
||||
* Improve type safety.
|
||||
* Minor optimisations and bug fixes.
|
||||
|
||||
Version 1.0.10 (2004-06-15)
|
||||
* Fix AIFF read/write mode bugs.
|
||||
* Add support for compiling Win32 DLLS using MinGW.
|
||||
* Fix problems resulting in failed compiles with gcc-2.95.
|
||||
* Improve test suite.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.9 (2004-03-30)
|
||||
* Add handling of AVR (Audio Visual Research) files.
|
||||
* Improve handling of WAVEFORMATEXTENSIBLE WAV files.
|
||||
* Fix for using pipes on Win32.
|
||||
|
||||
Version 1.0.8 (2004-03-14)
|
||||
* Correct peak chunk handing for files with > 16 tracks.
|
||||
* Fix for WAV files with huge number of CUE chunks.
|
||||
|
||||
Version 1.0.7 (2004-02-25)
|
||||
* Fix clip mode detection on ia64, MIPS and other CPUs.
|
||||
* Fix two MacOSX build problems.
|
||||
|
||||
Version 1.0.6 (2004-02-08)
|
||||
* Added support for native Win32 file access API (Ross Bencina).
|
||||
* New mode to add clippling then a converting from float/double to integer
|
||||
would otherwise wrap around.
|
||||
* Fixed a bug in reading/writing files > 2Gig on Linux, Solaris and others.
|
||||
* Many minor bug fixes.
|
||||
* Other random fixes for Win32.
|
||||
|
||||
Version 1.0.5 (2003-05-03)
|
||||
* Added support for HTK files.
|
||||
* Added new function sf_open_fd() to allow for secure opening of temporary
|
||||
files as well as reading/writing sound files embedded within larger
|
||||
container files.
|
||||
* Added string support for AIFF files.
|
||||
* Minor bug fixes and code cleanups.
|
||||
|
||||
Version 1.0.4 (2003-02-02)
|
||||
* Added suport of PVF and XI files.
|
||||
* Added functionality for setting and retreiving strings from sound files.
|
||||
* Minor code cleanups and bug fixes.
|
||||
|
||||
Version 1.0.3 (2002-12-09)
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.2 (2002-11-24)
|
||||
* Added support for VOX ADPCM.
|
||||
* Improved error reporting.
|
||||
* Added version scripting on Linux and Solaris.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.1 (2002-09-14)
|
||||
* Added MAT and MAT5 file formats.
|
||||
* Minor bug fixes.
|
||||
|
||||
Version 1.0.0 (2002-08-16)
|
||||
* Final release for 1.0.0.
|
||||
|
||||
Version 1.0.0rc6 (2002-08-14)
|
||||
* Release candidate 6 for the 1.0.0 series.
|
||||
* MacOS9 fixes.
|
||||
|
||||
Version 1.0.0rc5 (2002-08-10)
|
||||
* Release candidate 5 for the 1.0.0 series.
|
||||
* Changed the definition of sf_count_t which was causing problems when
|
||||
libsndfile was compiled with other libraries (ie WxWindows).
|
||||
* Minor bug fixes.
|
||||
* Documentation cleanup.
|
||||
|
||||
Version 1.0.0rc4 (2002-08-03)
|
||||
* Release candidate 4 for the 1.0.0 series.
|
||||
* Minor bug fixes.
|
||||
* Fix broken Win32 "make check".
|
||||
|
||||
Version 1.0.0rc3 (2002-08-02)
|
||||
* Release candidate 3 for the 1.0.0 series.
|
||||
* Fix bug where libsndfile was reading beyond the end of the data chunk.
|
||||
* Added on-the-fly header updates on write.
|
||||
* Fix a couple of documentation issues.
|
||||
|
||||
Version 1.0.0rc2 (2002-06-24)
|
||||
* Release candidate 2 for the 1.0.0 series.
|
||||
* Fix compile problem for Win32.
|
||||
|
||||
Version 1.0.0rc1 (2002-06-24)
|
||||
* Release candidate 1 for the 1.0.0 series.
|
||||
|
||||
Version 0.0.28 (2002-04-27)
|
||||
* Last offical release of 0.0.X series of the library.
|
||||
|
||||
Version 0.0.8 (1999-02-16)
|
||||
* First offical release.
|
|
@ -1,79 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
# Prevent any extension.
|
||||
EXEEXT =
|
||||
|
||||
CXXLD = $(CXX)
|
||||
CXXLINK = $(LIBTOOL) --tag=CXX --mode=link $(CXXLD) $(AM_CXXFLAGS) \
|
||||
$(CXXFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
|
||||
|
||||
EXTRA_DIST = sndfile_load.m sndfile_save.m sndfile_play.m \
|
||||
octave_test.m octave_test.sh $(oct_module_srcs) PKG_ADD
|
||||
|
||||
octconfigdir = $(exec_prefix)/share/octave/site/m
|
||||
octconfig_DATA = sndfile_load.m sndfile_save.m sndfile_play.m
|
||||
|
||||
OCTAVE_DEST_MDIR = @OCTAVE_DEST_MDIR@
|
||||
OCTAVE_DEST_ODIR = @OCTAVE_DEST_ODIR@/sndfile
|
||||
|
||||
OCT_CXXFLAGS = @OCT_CXXFLAGS@
|
||||
OCT_LIB_DIR = @OCT_LIB_DIR@
|
||||
OCT_LIBS = @OCT_LIBS@
|
||||
|
||||
SNDFILEDIR = $(top_builddir)/src
|
||||
AM_CPPFLAGS = -I$(SNDFILEDIR)
|
||||
|
||||
oct_module_srcs = sndfile.cc
|
||||
oct_module_files = sndfile.oct PKG_ADD
|
||||
|
||||
# Make these noinst so they can be installed manually.
|
||||
noinst_DATA = $(oct_module_files)
|
||||
|
||||
|
||||
# Used by shave which cleans up automake generated Makefile output.
|
||||
V = @
|
||||
Q = $(V:1=)
|
||||
QUIET_GEN = $(Q:@=@echo ' GEN '$@;)
|
||||
|
||||
|
||||
# Use Octave's mkoctfile to do all the heavy lifting. Unfortunately, its
|
||||
# a little dumb so we need to guide it carefully.
|
||||
sndfile.oct : sndfile.o
|
||||
$(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) $(top_builddir)/Octave/$+ -L$(SNDFILEDIR)/.libs -L$(SNDFILEDIR) -lsndfile -o $(top_builddir)/Octave/$@ > /dev/null
|
||||
|
||||
sndfile.o : sndfile.cc
|
||||
$(QUIET_GEN) $(MKOCTFILE) -v $(INCLUDES) -c $+ -o $(top_builddir)/Octave/$@ > /dev/null
|
||||
|
||||
# Allow for the test being run in the build dir, but the test script
|
||||
# being located in the source dir.
|
||||
check :
|
||||
octave_src_dir=$(srcdir) $(srcdir)/octave_test.sh
|
||||
|
||||
|
||||
# Since the octave modules are installed in a special location, a custom install
|
||||
# and uninstall routine must be specified.
|
||||
install-exec-local : $(oct_module_files)
|
||||
@$(NORMAL_INSTALL)
|
||||
test -z "$(OCTAVE_DEST_ODIR)" || $(mkdir_p) "$(DESTDIR)$(OCTAVE_DEST_ODIR)"
|
||||
@list='$(oct_module_files)'; for p in $$list; do \
|
||||
p1=`echo $$p|sed 's/$(EXEEXT)$$//'`; \
|
||||
if test -f $$p \
|
||||
|| test -f $$p1 \
|
||||
; then \
|
||||
f=`echo "$$p1" | sed 's,^.*/,,;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL) '$$p' '$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f'"; \
|
||||
$(INSTALL_PROGRAM_ENV) $(LIBTOOL) --mode=install $(INSTALL) "$$p" "$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f" || exit 1; \
|
||||
else :; fi; \
|
||||
done
|
||||
|
||||
uninstall-local :
|
||||
@$(NORMAL_UNINSTALL)
|
||||
@list='$(oct_module_files)'; for p in $$list; do \
|
||||
f=`echo "$$p" | sed 's,^.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/'`; \
|
||||
echo " rm -f '$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f'"; \
|
||||
rm -f "$(DESTDIR)$(OCTAVE_DEST_ODIR)/$$f"; \
|
||||
done
|
||||
|
||||
clean-local :
|
||||
rm -f sndfile.o sndfile.oct
|
||||
@if test $(abs_builddir) != $(abs_srcdir) ; then rm -f PKG_ADD ; fi
|
|
@ -1,3 +0,0 @@
|
|||
autoload ("sfread", "sndfile.oct");
|
||||
autoload ("sfversion", "sndfile.oct");
|
||||
autoload ("sfwrite", "sndfile.oct");
|
|
@ -1,23 +0,0 @@
|
|||
The libsndfile Modules for GNU Octave
|
||||
=====================================
|
||||
|
||||
These modules are currently known to work with version 3.0 of GNU Octave on
|
||||
Linux. They have not been tested elsewhere.
|
||||
|
||||
|
||||
Build Requirements
|
||||
------------------
|
||||
|
||||
In order to build these libsndfile related modules for GNU Octave on a Debian
|
||||
GNU/Linux (or Debian derived) system, you will need (on top of what is normally
|
||||
required to build libsndfile) the package:
|
||||
|
||||
octaveX.Y-headers
|
||||
|
||||
where X.Y matches the version number of your installation of GNU Octave.
|
||||
|
||||
The configure script in the top level libsndfile directory will detect the
|
||||
presence and correct versions of the Octave build tools. The building of these
|
||||
modules will only go ahead if everything is correct.
|
||||
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
** the Free Software Foundation; either version 2.1 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
int format_of_str (const std::string & fmt) ;
|
||||
|
||||
void string_of_format (std::string & fmt, int format) ;
|
|
@ -1,52 +0,0 @@
|
|||
# Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser General Public License as published by
|
||||
# the Free Software Foundation; either version 2.1 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser General Public License
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
# These tests are nowhere near comprehensive.
|
||||
|
||||
printf (" Running Octave tests : ") ;
|
||||
fflush (stdout) ;
|
||||
|
||||
filename = "whatever" ;
|
||||
srate_out = 32000 ;
|
||||
fmt_out = "wav-float" ;
|
||||
|
||||
t = (2 * pi / srate_out * (0:srate_out-1))' ;
|
||||
data_out = sin (440.0 * t) ;
|
||||
|
||||
# Write out a file.
|
||||
sfwrite (filename, data_out, srate_out, fmt_out) ;
|
||||
|
||||
# Read it back in again.
|
||||
[ data_in, srate_in, fmt_in ] = sfread (filename) ;
|
||||
|
||||
if (srate_in != srate_out)
|
||||
error ("\n\nSample rate mismatch : %d -> %d.\n\n", srate_out, srate_in) ;
|
||||
endif
|
||||
|
||||
# Octave strcmp return 1 for the same.
|
||||
if (strcmp (fmt_in, fmt_out) != 1)
|
||||
error ("\n\nFormat error : '%s' -> '%s'.\n\n", fmt_out, fmt_in) ;
|
||||
endif
|
||||
|
||||
err = max (abs (data_out - data_in)) ;
|
||||
|
||||
if (err > 1e-7)
|
||||
error ("err : %g\n", err) ;
|
||||
endif
|
||||
|
||||
printf ("ok") ;
|
||||
|
||||
unlink (filename) ;
|
|
@ -1,81 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
|
||||
# Check where we're being run from.
|
||||
if test -d Octave ; then
|
||||
cd Octave
|
||||
octave_src_dir=$(pwd)
|
||||
elif test -z "$octave_src_dir" ; then
|
||||
echo
|
||||
echo "Error : \$octave_src_dir is undefined."
|
||||
echo
|
||||
exit 1
|
||||
else
|
||||
octave_src_dir=$(cd $octave_src_dir && pwd)
|
||||
fi
|
||||
|
||||
# Find libsndfile shared object.
|
||||
libsndfile_lib_location=""
|
||||
|
||||
if test -f "../src/.libs/libsndfile.so" ; then
|
||||
libsndfile_lib_location="../src/.libs/"
|
||||
elif test -f "../src/libsndfile.so" ; then
|
||||
libsndfile_lib_location="../src/"
|
||||
elif test -f "../src/.libs/libsndfile.dylib" ; then
|
||||
libsndfile_lib_location="../src/.libs/"
|
||||
elif test -f "../src/libsndfile.dylib" ; then
|
||||
libsndfile_lib_location="../src/"
|
||||
else
|
||||
echo
|
||||
echo "Not able to find the libsndfile shared lib we've just built."
|
||||
echo "This may cause the following test to fail."
|
||||
echo
|
||||
fi
|
||||
|
||||
libsndfile_lib_location=`(cd $libsndfile_lib_location && pwd)`
|
||||
|
||||
|
||||
# Find sndfile.oct
|
||||
sndfile_oct_location=""
|
||||
|
||||
if test -f .libs/sndfile.oct ; then
|
||||
sndfile_oct_location=".libs"
|
||||
elif test -f sndfile.oct ; then
|
||||
sndfile_oct_location="."
|
||||
else
|
||||
echo "Not able to find the sndfile.oct binaries we've just built."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
case `file -b $sndfile_oct_location/sndfile.oct` in
|
||||
ELF*)
|
||||
;;
|
||||
Mach*)
|
||||
echo "Tests don't work on this platform."
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Not able to find the sndfile.oct binary we just built."
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
# Make sure the TERM environment variable doesn't contain anything wrong.
|
||||
unset TERM
|
||||
# echo "octave_src_dir : $octave_src_dir"
|
||||
# echo "libsndfile_lib_location : $libsndfile_lib_location"
|
||||
# echo "sndfile_oct_location : $sndfile_oct_location"
|
||||
|
||||
if test ! -f PKG_ADD ; then
|
||||
cp $octave_src_dir/PKG_ADD .
|
||||
fi
|
||||
|
||||
export LD_LIBRARY_PATH="$libsndfile_lib_location:$LD_LIBRARY_PATH"
|
||||
|
||||
octave_script="$octave_src_dir/octave_test.m"
|
||||
|
||||
(cd $sndfile_oct_location && octave -qH $octave_script)
|
||||
res=$?
|
||||
echo
|
||||
exit $res
|
|
@ -1,405 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU Lesser General Public License as published by
|
||||
** the Free Software Foundation; either version 2.1 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU Lesser General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU Lesser General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <octave/oct.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
|
||||
#define FOUR_GIG (0x100000000LL)
|
||||
#define BUFFER_FRAMES 8192
|
||||
|
||||
|
||||
static int format_of_str (const std::string & fmt) ;
|
||||
static void string_of_format (std::string & fmt, int format) ;
|
||||
|
||||
|
||||
DEFUN_DLD (sfversion, args, nargout ,
|
||||
"-*- texinfo -*-\n\
|
||||
@deftypefn {Loadable Function} {@var{version} =} sfversion ()\n\
|
||||
@cindex Reading sound files\n\
|
||||
Return a string containing the libsndfile version.\n\
|
||||
@seealso{sfread, sfwrite}\n\
|
||||
@end deftypefn")
|
||||
{ char buffer [256] ;
|
||||
octave_value_list retval ;
|
||||
|
||||
/* Bail out if the input parameters are bad. */
|
||||
if (args.length () != 0 || nargout > 1)
|
||||
{ print_usage () ;
|
||||
return retval ;
|
||||
} ;
|
||||
|
||||
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
|
||||
|
||||
std::string version (buffer) ;
|
||||
|
||||
retval.append (version) ;
|
||||
return retval ;
|
||||
} /* sfversion */
|
||||
|
||||
|
||||
DEFUN_DLD (sfread, args, nargout ,
|
||||
"-*- texinfo -*-\n\
|
||||
@deftypefn {Loadable Function} {@var{data},@var{srate},@var{format} =} sfread (@var{filename})\n\
|
||||
@cindex Reading sound files\n\
|
||||
Read a sound file from disk using libsndfile.\n\
|
||||
@seealso{sfversion, sfwrite}\n\
|
||||
@end deftypefn")
|
||||
{ SNDFILE * file ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
octave_value_list retval ;
|
||||
|
||||
int nargin = args.length () ;
|
||||
|
||||
/* Bail out if the input parameters are bad. */
|
||||
if ((nargin != 1) || !args (0) .is_string () || nargout < 1 || nargout > 3)
|
||||
{ print_usage () ;
|
||||
return retval ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
std::string filename = args (0).string_value () ;
|
||||
|
||||
if ((file = sf_open (filename.c_str (), SFM_READ, &sfinfo)) == NULL)
|
||||
{ error ("sfread: couldn't open file %s : %s", filename.c_str (), sf_strerror (NULL)) ;
|
||||
return retval ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.frames > FOUR_GIG)
|
||||
printf ("This is a really huge file (%lld frames).\nYou may run out of memory trying to load it.\n", (long long) sfinfo.frames) ;
|
||||
|
||||
dim_vector dim = dim_vector () ;
|
||||
dim.resize (2) ;
|
||||
dim (0) = sfinfo.frames ;
|
||||
dim (1) = sfinfo.channels ;
|
||||
|
||||
/* Should I be using Matrix instead? */
|
||||
NDArray out (dim, 0.0) ;
|
||||
|
||||
float buffer [BUFFER_FRAMES * sfinfo.channels] ;
|
||||
int readcount ;
|
||||
sf_count_t total = 0 ;
|
||||
|
||||
do
|
||||
{ readcount = sf_readf_float (file, buffer, BUFFER_FRAMES) ;
|
||||
|
||||
/* Make sure we don't read more frames than we allocated. */
|
||||
if (total + readcount > sfinfo.frames)
|
||||
readcount = sfinfo.frames - total ;
|
||||
|
||||
for (int ch = 0 ; ch < sfinfo.channels ; ch++)
|
||||
{ for (int k = 0 ; k < readcount ; k++)
|
||||
out (total + k, ch) = buffer [k * sfinfo.channels + ch] ;
|
||||
} ;
|
||||
|
||||
total += readcount ;
|
||||
} while (readcount > 0 && total < sfinfo.frames) ;
|
||||
|
||||
retval.append (out.squeeze ()) ;
|
||||
|
||||
if (nargout >= 2)
|
||||
retval.append ((octave_uint32) sfinfo.samplerate) ;
|
||||
|
||||
if (nargout >= 3)
|
||||
{ std::string fmt ("") ;
|
||||
string_of_format (fmt, sfinfo.format) ;
|
||||
retval.append (fmt) ;
|
||||
} ;
|
||||
|
||||
/* Clean up. */
|
||||
sf_close (file) ;
|
||||
|
||||
return retval ;
|
||||
} /* sfread */
|
||||
|
||||
DEFUN_DLD (sfwrite, args, nargout ,
|
||||
"-*- texinfo -*-\n\
|
||||
@deftypefn {Function File} sfwrite (@var{filename},@var{data},@var{srate},@var{format})\n\
|
||||
Write a sound file to disk using libsndfile.\n\
|
||||
@seealso{sfread, sfversion}\n\
|
||||
@end deftypefn\n\
|
||||
")
|
||||
{ SNDFILE * file ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
octave_value_list retval ;
|
||||
|
||||
int nargin = args.length () ;
|
||||
|
||||
/* Bail out if the input parameters are bad. */
|
||||
if (nargin != 4 || !args (0).is_string () || !args (1).is_real_matrix ()
|
||||
|| !args (2).is_real_scalar () || !args (3).is_string ()
|
||||
|| nargout != 0)
|
||||
{ print_usage () ;
|
||||
return retval ;
|
||||
} ;
|
||||
|
||||
std::string filename = args (0).string_value () ;
|
||||
std::string format = args (3).string_value () ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
sfinfo.format = format_of_str (format) ;
|
||||
if (sfinfo.format == 0)
|
||||
{ error ("Bad format '%s'", format.c_str ()) ;
|
||||
return retval ;
|
||||
} ;
|
||||
|
||||
sfinfo.samplerate = lrint (args (2).scalar_value ()) ;
|
||||
if (sfinfo.samplerate < 1)
|
||||
{ error ("Bad sample rate : %d.\n", sfinfo.samplerate) ;
|
||||
return retval ;
|
||||
} ;
|
||||
|
||||
Matrix data = args (1).matrix_value () ;
|
||||
long rows = args (1).rows () ;
|
||||
long cols = args (1).columns () ;
|
||||
|
||||
if (cols > rows)
|
||||
{ error ("Audio data should have one column per channel, but supplied data "
|
||||
"has %ld rows and %ld columns.\n", rows, cols) ;
|
||||
return retval ;
|
||||
} ;
|
||||
|
||||
sfinfo.channels = cols ;
|
||||
|
||||
if ((file = sf_open (filename.c_str (), SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ error ("Couldn't open file %s : %s", filename.c_str (), sf_strerror (NULL)) ;
|
||||
return retval ;
|
||||
} ;
|
||||
|
||||
float buffer [BUFFER_FRAMES * sfinfo.channels] ;
|
||||
int writecount ;
|
||||
long total = 0 ;
|
||||
|
||||
do
|
||||
{
|
||||
writecount = BUFFER_FRAMES ;
|
||||
|
||||
/* Make sure we don't read more frames than we allocated. */
|
||||
if (total + writecount > rows)
|
||||
writecount = rows - total ;
|
||||
|
||||
for (int ch = 0 ; ch < sfinfo.channels ; ch++)
|
||||
{ for (int k = 0 ; k < writecount ; k++)
|
||||
buffer [k * sfinfo.channels + ch] = data (total + k, ch) ;
|
||||
} ;
|
||||
|
||||
if (writecount > 0)
|
||||
sf_writef_float (file, buffer, writecount) ;
|
||||
|
||||
total += writecount ;
|
||||
} while (writecount > 0 && total < rows) ;
|
||||
|
||||
/* Clean up. */
|
||||
sf_close (file) ;
|
||||
|
||||
return retval ;
|
||||
} /* sfwrite */
|
||||
|
||||
|
||||
static void
|
||||
str_split (const std::string & str, const std::string & delim, std::vector <std::string> & output)
|
||||
{
|
||||
unsigned int offset = 0 ;
|
||||
size_t delim_index = 0 ;
|
||||
|
||||
delim_index = str.find (delim, offset) ;
|
||||
|
||||
while (delim_index != std::string::npos)
|
||||
{
|
||||
output.push_back (str.substr(offset, delim_index - offset)) ;
|
||||
offset += delim_index - offset + delim.length () ;
|
||||
delim_index = str.find (delim, offset) ;
|
||||
}
|
||||
|
||||
output.push_back (str.substr (offset)) ;
|
||||
} /* str_split */
|
||||
|
||||
static int
|
||||
hash_of_str (const std::string & str)
|
||||
{
|
||||
int hash = 0 ;
|
||||
|
||||
for (unsigned k = 0 ; k < str.length () ; k++)
|
||||
hash = (hash * 3) + tolower (str [k]) ;
|
||||
|
||||
return hash ;
|
||||
} /* hash_of_str */
|
||||
|
||||
static int
|
||||
major_format_of_hash (const std::string & str)
|
||||
{ int hash ;
|
||||
|
||||
hash = hash_of_str (str) ;
|
||||
|
||||
switch (hash)
|
||||
{
|
||||
case 0x5c8 : /* 'wav' */ return SF_FORMAT_WAV ;
|
||||
case 0xf84 : /* 'aiff' */ return SF_FORMAT_AIFF ;
|
||||
case 0x198 : /* 'au' */ return SF_FORMAT_AU ;
|
||||
case 0x579 : /* 'paf' */ return SF_FORMAT_PAF ;
|
||||
case 0x5e5 : /* 'svx' */ return SF_FORMAT_SVX ;
|
||||
case 0x1118 : /* 'nist' */ return SF_FORMAT_NIST ;
|
||||
case 0x5d6 : /* 'voc' */ return SF_FORMAT_VOC ;
|
||||
case 0x324a : /* 'ircam' */ return SF_FORMAT_IRCAM ;
|
||||
case 0x505 : /* 'w64' */ return SF_FORMAT_W64 ;
|
||||
case 0x1078 : /* 'mat4' */ return SF_FORMAT_MAT4 ;
|
||||
case 0x1079 : /* 'mat5' */ return SF_FORMAT_MAT5 ;
|
||||
case 0x5b8 : /* 'pvf' */ return SF_FORMAT_PVF ;
|
||||
case 0x1d1 : /* 'xi' */ return SF_FORMAT_XI ;
|
||||
case 0x56f : /* 'htk' */ return SF_FORMAT_HTK ;
|
||||
case 0x5aa : /* 'sds' */ return SF_FORMAT_SDS ;
|
||||
case 0x53d : /* 'avr' */ return SF_FORMAT_AVR ;
|
||||
case 0x11d0 : /* 'wavx' */ return SF_FORMAT_WAVEX ;
|
||||
case 0x569 : /* 'sd2' */ return SF_FORMAT_SD2 ;
|
||||
case 0x1014 : /* 'flac' */ return SF_FORMAT_FLAC ;
|
||||
case 0x504 : /* 'caf' */ return SF_FORMAT_CAF ;
|
||||
case 0x5f6 : /* 'wve' */ return SF_FORMAT_WVE ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
printf ("%s : hash '%s' -> 0x%x\n", __func__, str.c_str (), hash) ;
|
||||
|
||||
return 0 ;
|
||||
} /* major_format_of_hash */
|
||||
|
||||
static int
|
||||
minor_format_of_hash (const std::string & str)
|
||||
{ int hash ;
|
||||
|
||||
hash = hash_of_str (str) ;
|
||||
|
||||
switch (hash)
|
||||
{
|
||||
case 0x1085 : /* 'int8' */ return SF_FORMAT_PCM_S8 ;
|
||||
case 0x358a : /* 'uint8' */ return SF_FORMAT_PCM_U8 ;
|
||||
case 0x31b0 : /* 'int16' */ return SF_FORMAT_PCM_16 ;
|
||||
case 0x31b1 : /* 'int24' */ return SF_FORMAT_PCM_24 ;
|
||||
case 0x31b2 : /* 'int32' */ return SF_FORMAT_PCM_32 ;
|
||||
case 0x3128 : /* 'float' */ return SF_FORMAT_FLOAT ;
|
||||
case 0x937d : /* 'double' */ return SF_FORMAT_DOUBLE ;
|
||||
case 0x11bd : /* 'ulaw' */ return SF_FORMAT_ULAW ;
|
||||
case 0xfa1 : /* 'alaw' */ return SF_FORMAT_ALAW ;
|
||||
case 0xfc361 : /* 'ima_adpcm' */ return SF_FORMAT_IMA_ADPCM ;
|
||||
case 0x5739a : /* 'ms_adpcm' */ return SF_FORMAT_MS_ADPCM ;
|
||||
case 0x9450 : /* 'gsm610' */ return SF_FORMAT_GSM610 ;
|
||||
case 0x172a3 : /* 'g721_32' */ return SF_FORMAT_G721_32 ;
|
||||
case 0x172d8 : /* 'g723_24' */ return SF_FORMAT_G723_24 ;
|
||||
case 0x172da : /* 'g723_40' */ return SF_FORMAT_G723_40 ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
printf ("%s : hash '%s' -> 0x%x\n", __func__, str.c_str (), hash) ;
|
||||
|
||||
return 0 ;
|
||||
} /* minor_format_of_hash */
|
||||
|
||||
|
||||
static const char *
|
||||
string_of_major_format (int format)
|
||||
{
|
||||
switch (format & SF_FORMAT_TYPEMASK)
|
||||
{
|
||||
case SF_FORMAT_WAV : return "wav" ;
|
||||
case SF_FORMAT_AIFF : return "aiff" ;
|
||||
case SF_FORMAT_AU : return "au" ;
|
||||
case SF_FORMAT_PAF : return "paf" ;
|
||||
case SF_FORMAT_SVX : return "svx" ;
|
||||
case SF_FORMAT_NIST : return "nist" ;
|
||||
case SF_FORMAT_VOC : return "voc" ;
|
||||
case SF_FORMAT_IRCAM : return "ircam" ;
|
||||
case SF_FORMAT_W64 : return "w64" ;
|
||||
case SF_FORMAT_MAT4 : return "mat4" ;
|
||||
case SF_FORMAT_MAT5 : return "mat5" ;
|
||||
case SF_FORMAT_PVF : return "pvf" ;
|
||||
case SF_FORMAT_XI : return "xi" ;
|
||||
case SF_FORMAT_HTK : return "htk" ;
|
||||
case SF_FORMAT_SDS : return "sds" ;
|
||||
case SF_FORMAT_AVR : return "avr" ;
|
||||
case SF_FORMAT_WAVEX : return "wavx" ;
|
||||
case SF_FORMAT_SD2 : return "sd2" ;
|
||||
case SF_FORMAT_FLAC : return "flac" ;
|
||||
case SF_FORMAT_CAF : return "caf" ;
|
||||
case SF_FORMAT_WVE : return "wfe" ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
return "unknown" ;
|
||||
} /* string_of_major_format */
|
||||
|
||||
static const char *
|
||||
string_of_minor_format (int format)
|
||||
{
|
||||
switch (format & SF_FORMAT_SUBMASK)
|
||||
{
|
||||
case SF_FORMAT_PCM_S8 : return "int8" ;
|
||||
case SF_FORMAT_PCM_U8 : return "uint8" ;
|
||||
case SF_FORMAT_PCM_16 : return "int16" ;
|
||||
case SF_FORMAT_PCM_24 : return "int24" ;
|
||||
case SF_FORMAT_PCM_32 : return "int32" ;
|
||||
case SF_FORMAT_FLOAT : return "float" ;
|
||||
case SF_FORMAT_DOUBLE : return "double" ;
|
||||
case SF_FORMAT_ULAW : return "ulaw" ;
|
||||
case SF_FORMAT_ALAW : return "alaw" ;
|
||||
case SF_FORMAT_IMA_ADPCM : return "ima_adpcm" ;
|
||||
case SF_FORMAT_MS_ADPCM : return "ms_adpcm" ;
|
||||
case SF_FORMAT_GSM610 : return "gsm610" ;
|
||||
case SF_FORMAT_G721_32 : return "g721_32" ;
|
||||
case SF_FORMAT_G723_24 : return "g723_24" ;
|
||||
case SF_FORMAT_G723_40 : return "g723_40" ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
return "unknown" ;
|
||||
} /* string_of_minor_format */
|
||||
|
||||
static int
|
||||
format_of_str (const std::string & fmt)
|
||||
{
|
||||
std::vector <std::string> split ;
|
||||
|
||||
str_split (fmt, "-", split) ;
|
||||
|
||||
if (split.size () != 2)
|
||||
return 0 ;
|
||||
|
||||
int major_fmt = major_format_of_hash (split.at (0)) ;
|
||||
if (major_fmt == 0)
|
||||
return 0 ;
|
||||
|
||||
int minor_fmt = minor_format_of_hash (split.at (1)) ;
|
||||
if (minor_fmt == 0)
|
||||
return 0 ;
|
||||
|
||||
return major_fmt | minor_fmt ;
|
||||
} /* format_of_str */
|
||||
|
||||
static void
|
||||
string_of_format (std::string & fmt, int format)
|
||||
{
|
||||
char buffer [64] ;
|
||||
|
||||
snprintf (buffer, sizeof (buffer), "%s-%s", string_of_major_format (format), string_of_minor_format (format)) ;
|
||||
|
||||
fmt = buffer ;
|
||||
|
||||
return ;
|
||||
} /* string_of_format */
|
|
@ -1,52 +0,0 @@
|
|||
## Copyright (C) 2002-2011 Erik de Castro Lopo
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2, or (at your option)
|
||||
## any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but
|
||||
## WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this file. If not, write to the Free Software Foundation,
|
||||
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
## -*- texinfo -*-
|
||||
## @deftypefn {Function File} {} sndfile_load (@var{filename})
|
||||
## Load data from the file given by @var{filename}.
|
||||
## @end deftypefn
|
||||
|
||||
## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
## Description: Load the sound data from the given file name
|
||||
|
||||
function [data fs] = sndfile_load (filename)
|
||||
|
||||
if (nargin != 1),
|
||||
error ("Need an input filename") ;
|
||||
endif
|
||||
|
||||
samplerate = -1 ;
|
||||
samplingrate = -1 ;
|
||||
wavedata = -1 ;
|
||||
|
||||
|
||||
eval (sprintf ('load -f %s', filename)) ;
|
||||
|
||||
if (samplerate > 0),
|
||||
fs = samplerate ;
|
||||
elseif (samplingrate > 0),
|
||||
fs = samplingrate ;
|
||||
else
|
||||
error ("Not able to find sample rate.") ;
|
||||
endif
|
||||
|
||||
if (max (size (wavedata)) > 1),
|
||||
data = wavedata ;
|
||||
else
|
||||
error ("Not able to find waveform data.") ;
|
||||
endif
|
||||
|
||||
endfunction
|
|
@ -1,59 +0,0 @@
|
|||
## Copyright (C) 2002-2011 Erik de Castro Lopo
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2, or (at your option)
|
||||
## any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but
|
||||
## WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this file. If not, write to the Free Software Foundation,
|
||||
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
## -*- texinfo -*-
|
||||
## @deftypefn {Function File} {} sndfile_play (@var{data, fs})
|
||||
## Play @var{data} at sample rate @var{fs} using the sndfile-play
|
||||
## program.
|
||||
## @end deftypefn
|
||||
|
||||
## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
## Description: Play the given data as a sound file
|
||||
|
||||
function sndfile_play (data, fs)
|
||||
|
||||
if nargin != 2,
|
||||
error ("Need two input arguments: data and fs.") ;
|
||||
endif
|
||||
|
||||
if (max (size (fs)) > 1),
|
||||
error ("Second parameter fs must be a single value.") ;
|
||||
endif
|
||||
|
||||
[nr nc] = size (data) ;
|
||||
|
||||
if (nr > nc),
|
||||
data = data' ;
|
||||
endif
|
||||
|
||||
samplerate = fs ;
|
||||
wavedata = data ;
|
||||
|
||||
filename = tmpnam () ;
|
||||
|
||||
cmd = sprintf ("save -mat-binary %s fs data", filename) ;
|
||||
|
||||
eval (cmd) ;
|
||||
|
||||
cmd = sprintf ("sndfile-play %s", filename) ;
|
||||
|
||||
[output, status] = system (cmd) ;
|
||||
|
||||
if (status),
|
||||
disp (outout) ;
|
||||
endif
|
||||
|
||||
endfunction
|
|
@ -1,53 +0,0 @@
|
|||
## Copyright (C) 2002-2011 Erik de Castro Lopo
|
||||
##
|
||||
## This program is free software; you can redistribute it and/or modify
|
||||
## it under the terms of the GNU General Public License as published by
|
||||
## the Free Software Foundation; either version 2, or (at your option)
|
||||
## any later version.
|
||||
##
|
||||
## This program is distributed in the hope that it will be useful, but
|
||||
## WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
## General Public License for more details.
|
||||
##
|
||||
## You should have received a copy of the GNU General Public License
|
||||
## along with this file. If not, write to the Free Software Foundation,
|
||||
## 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
|
||||
## -*- texinfo -*-
|
||||
## @deftypefn {Function File} {} sndfile_save (@var{filename, data, fs})
|
||||
## Save the given @var{data} as audio data to the given at @var{fs}. Set
|
||||
## the sample rate to @var{fs}.
|
||||
## @end deftypefn
|
||||
|
||||
## Author: Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
## Description: Save data as a sound file
|
||||
|
||||
function sndfile_save (filename, data, fs)
|
||||
|
||||
if nargin != 3,
|
||||
error ("Need three input arguments: filename, data and fs.") ;
|
||||
endif
|
||||
|
||||
if (! isstr (filename)),
|
||||
error ("First parameter 'filename' is must be a string.") ;
|
||||
endif
|
||||
|
||||
if (max (size (fs)) > 1),
|
||||
error ("Second parameter 'fs' must be a single value, not an array or matrix.") ;
|
||||
endif
|
||||
|
||||
[nr nc] = size (data) ;
|
||||
|
||||
if (nr > nc),
|
||||
data = data' ;
|
||||
endif
|
||||
|
||||
samplerate = fs ;
|
||||
wavedata = data ;
|
||||
|
||||
str = sprintf ("save -mat-binary %s samplerate wavedata", filename) ;
|
||||
|
||||
eval (str) ;
|
||||
|
||||
endfunction
|
|
@ -1,68 +0,0 @@
|
|||
This is libsndfile, 1.0.25
|
||||
|
||||
libsndfile is a library of C routines for reading and writing
|
||||
files containing sampled audio data.
|
||||
|
||||
The src/ directory contains the source code for library itself.
|
||||
|
||||
The doc/ directory contains the libsndfile documentation.
|
||||
|
||||
The examples/ directory contains examples of how to write code using
|
||||
libsndfile.
|
||||
|
||||
The tests/ directory contains programs which link against libsndfile
|
||||
and test its functionality.
|
||||
|
||||
The src/GSM610 directory contains code written by Jutta Degener and Carsten
|
||||
Bormann. Their original code can be found at :
|
||||
http://kbs.cs.tu-berlin.de/~jutta/toast.html
|
||||
|
||||
The src/G72x directory contains code written and released by Sun Microsystems
|
||||
under a suitably free license.
|
||||
|
||||
The src/ALAC directory contains code written and released by Apple Inc and
|
||||
released under the Apache license.
|
||||
|
||||
|
||||
LINUX
|
||||
-----
|
||||
Whereever possible, you should use the packages supplied by your Linux
|
||||
distribution.
|
||||
|
||||
If you really do need to compile from source it should be as easy as:
|
||||
|
||||
./configure
|
||||
make
|
||||
make install
|
||||
|
||||
Since libsndfile optionally links against libFLAC, libogg and libvorbis, you
|
||||
will need to install appropriate versions of these libraries before running
|
||||
configure as above.
|
||||
|
||||
|
||||
UNIX
|
||||
----
|
||||
Compile as for Linux.
|
||||
|
||||
|
||||
Win32/Win64
|
||||
-----------
|
||||
The default Windows compilers are nowhere near compliant with the 1999 ISO
|
||||
C Standard and hence not able to compile libsndfile.
|
||||
|
||||
Please use the libsndfile binaries available on the libsndfile web site.
|
||||
|
||||
|
||||
MacOSX
|
||||
------
|
||||
Building on MacOSX should be the same as building it on any other Unix.
|
||||
|
||||
|
||||
CONTACTS
|
||||
--------
|
||||
|
||||
libsndfile was written by Erik de Castro Lopo (erikd AT mega-nerd DOT com).
|
||||
The libsndfile home page is at :
|
||||
|
||||
http://www.mega-nerd.com/libsndfile/
|
||||
|
|
@ -1,79 +0,0 @@
|
|||
# libsndfile
|
||||
|
||||
libsndfile is a C library for reading and writing files containing sampled audio
|
||||
data.
|
||||
|
||||
## Hacking
|
||||
|
||||
The canonical source code repository for libsndfile is at
|
||||
[https://github.com/erikd/libsndfile/][github].
|
||||
|
||||
You can grab the source code using:
|
||||
|
||||
$ git clone git://github.com/erikd/libsndfile.git
|
||||
|
||||
Building on Linux, OSX and Windows (Using GNU GCC) will require a number of GNU
|
||||
and other Free and Open Source Software tools including:
|
||||
|
||||
* [Autoconf][autoconf]
|
||||
* [Autogen][autogen]
|
||||
* [Automake][automake]
|
||||
* [Libtool][libtool]
|
||||
* [Pkgconfig][pkgconfig]
|
||||
* [Python][python]
|
||||
|
||||
If you are on Linux, its probably best to install these via your Linux
|
||||
distribution's package manager.
|
||||
|
||||
If you want to compile libsndfile with support for formats like FLAC and
|
||||
Ogg/Vorbis you will also need to install the following optional libraries:
|
||||
|
||||
* [FLAC][flac]
|
||||
* [libogg][libogg]
|
||||
* [libvorbis][libvorbis]
|
||||
|
||||
Support for these extra libraries is an all or nothing affair. Unless all of
|
||||
them are installed none of them will be supported.
|
||||
|
||||
$ ./autogen.sh
|
||||
|
||||
Running `autogen.sh` also installs a git pre-commit hook. The pre-commit hook
|
||||
is run each time a user tries to commit and checks code about to be committed
|
||||
against coding guidelines.
|
||||
|
||||
Nest step is to run configure, with the following configure options being
|
||||
recommended for anyone contemplating sending libsndfile patches:
|
||||
|
||||
$ ./configure --enable-gcc-werror
|
||||
|
||||
Finally libsndfile can be built and tested:
|
||||
|
||||
$ make
|
||||
$ make check
|
||||
|
||||
## Submitting Patches.
|
||||
|
||||
* Patches should pass all pre-commit hook tests.
|
||||
* Patches should always be submitted via a either Github "pull request" or a
|
||||
via emailed patches created using "git format-patch".
|
||||
* Patches for new features should include tests and documentation.
|
||||
* Patches to fix bugs should either pass all tests, or modify the tests in some
|
||||
sane way.
|
||||
* When a new feature is added for a particular file format and that feature
|
||||
makes sense for other formats, then it should also be implemented for one
|
||||
or two of the other formats.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
[autoconf]: http://www.gnu.org/s/autoconf/
|
||||
[autogen]: http://www.gnu.org/s/autogen/
|
||||
[automake]: http://www.gnu.org/software/automake/
|
||||
[flac]: http://flac.sourceforge.net/
|
||||
[github]: https://github.com/erikd/libsndfile/
|
||||
[libogg]: http://xiph.org/ogg/
|
||||
[libtool]: http://www.gnu.org/software/libtool/
|
||||
[libvorbis]: http://www.vorbis.com/
|
||||
[pkgconfig]: http://www.freedesktop.org/wiki/Software/pkg-config
|
||||
[python]: http://www.python.org/
|
|
@ -1,92 +0,0 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
# Copyright (C) 2013 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# All rights reserved.
|
||||
#
|
||||
# Redistribution and use in source and binary forms, with or without
|
||||
# modification, are permitted provided that the following conditions are
|
||||
# met:
|
||||
#
|
||||
# * Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# * Neither the author nor the names of any contributors may be used
|
||||
# to endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
#
|
||||
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
# Android NDK version number; eg r8e, r9 etc
|
||||
ANDROID_NDK_VER=r9
|
||||
|
||||
# Android NDK gcc version; eg 4.7, 4.9 etc.
|
||||
ANDROID_GCC_VER=4.8
|
||||
|
||||
# Android API version; eg 9 (Android 2.3), 14 (Android 4.0) etc.
|
||||
ANDROID_API_VER=9
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# No more user config beyond here.
|
||||
|
||||
BUILD_MACHINE=$(uname -s | tr 'A-Z' 'a-z')-$(uname -m)
|
||||
|
||||
function die_with {
|
||||
echo $1
|
||||
exit 1
|
||||
}
|
||||
|
||||
export CROSS_COMPILE=arm-linux-androideabi
|
||||
|
||||
# I put all my dev stuff in here
|
||||
export DEV_PREFIX=$HOME/Android
|
||||
test -d ${DEV_PREFIX} || die_with "Error : DEV_PREFIX '$DEV_PREFIX' does not exist."
|
||||
|
||||
# Don't forget to adjust this to your NDK path
|
||||
export ANDROID_NDK=${DEV_PREFIX}/android-ndk-${ANDROID_NDK_VER}
|
||||
test -d ${ANDROID_NDK} || die_with "Error : ANDROID_NDK '$ANDROID_NDK' does not exist."
|
||||
|
||||
export ANDROID_PREFIX=${ANDROID_NDK}/toolchains/arm-linux-androideabi-${ANDROID_GCC_VER}/prebuilt/${BUILD_MACHINE}
|
||||
test -d ${ANDROID_PREFIX} || die_with "Error : ANDROID_PREFIX '$ANDROID_PREFIX' does not exist."
|
||||
|
||||
export SYSROOT=${ANDROID_NDK}/platforms/android-${ANDROID_API_VER}/arch-arm
|
||||
test -d ${SYSROOT} || die_with "Error : SYSROOT '$SYSROOT' does not exist."
|
||||
|
||||
export CROSS_PREFIX=${ANDROID_PREFIX}/bin/${CROSS_COMPILE}
|
||||
test -f ${CROSS_PREFIX}-gcc || die_with "Error : CROSS_PREFIX compiler '${CROSS_PREFIX}-gcc' does not exist."
|
||||
|
||||
|
||||
# Non-exhaustive lists of compiler + binutils
|
||||
# Depending on what you compile, you might need more binutils than that
|
||||
export CPP=${CROSS_PREFIX}-cpp
|
||||
export AR=${CROSS_PREFIX}-ar
|
||||
export AS=${CROSS_PREFIX}-as
|
||||
export NM=${CROSS_PREFIX}-nm
|
||||
export CC=${CROSS_PREFIX}-gcc
|
||||
export CXX=${CROSS_PREFIX}-g++
|
||||
export LD=${CROSS_PREFIX}-ld
|
||||
export RANLIB=${CROSS_PREFIX}-ranlib
|
||||
|
||||
# Don't mix up .pc files from your host and build target
|
||||
export PKG_CONFIG_PATH=${PREFIX}/lib/pkgconfig
|
||||
|
||||
# Set up the needed FLAGS.
|
||||
export CFLAGS="${CFLAGS} -gstabs --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include"
|
||||
export CXXFLAGS="${CXXFLAGS} -gstabs -fno-exceptions --sysroot=${SYSROOT} -I${SYSROOT}/usr/include -I${ANDROID_PREFIX}/include -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/include/ -I${ANDROID_NDK}/sources/cxx-stl/gnu-libstdc++/${ANDROID_GCC_VER}/libs/armeabi/include"
|
||||
|
||||
export CPPFLAGS="${CFLAGS}"
|
||||
export LDFLAGS="${LDFLAGS} -L${SYSROOT}/usr/lib -L${ANDROID_PREFIX}/lib"
|
||||
|
||||
# Create a symlink to the gdbclient.
|
||||
test -h gdbclient || ln -s ${ANDROID_PREFIX}/bin/arm-linux-androideabi-gdb gdbclient
|
||||
|
||||
./configure --host=${CROSS_COMPILE} --with-sysroot=${SYSROOT} "$@"
|
|
@ -1,61 +0,0 @@
|
|||
#!/usr/bin/make -f
|
||||
|
||||
# This is probably only going to work with GNU Make.
|
||||
# This in a separate file instead of in Makefile.am because Automake complains
|
||||
# about the GNU Make-isms.
|
||||
|
||||
EXEEXT = @EXEEXT@
|
||||
|
||||
PACKAGE_VERSION = @PACKAGE_VERSION@
|
||||
|
||||
HOST_TRIPLET = @HOST_TRIPLET@
|
||||
|
||||
SRC_BINDIR = @SRC_BINDIR@
|
||||
TEST_BINDIR = @TEST_BINDIR@
|
||||
|
||||
LIBRARY := $(SRC_BINDIR)libsndfile.so.$(LIB_VERSION)
|
||||
|
||||
LIB_VERSION := $(shell echo $(PACKAGE_VERSION) | sed -e 's/[a-z].*//')
|
||||
|
||||
TESTNAME = libsndfile-testsuite-$(HOST_TRIPLET)-$(PACKAGE_VERSION)
|
||||
|
||||
TARBALL = $(TESTNAME).tar.gz
|
||||
|
||||
# Find the test programs by grepping the script for the programs it executes.
|
||||
testprogs := $(shell grep '^\./' tests/test_wrapper.sh | sed -e "s|./||" -e "s/ .*//" | sort | uniq)
|
||||
# Also add the programs not found by the above.
|
||||
testprogs += sfversion@EXEEXT@ stdin_test@EXEEXT@ stdout_test@EXEEXT@ cpp_test@EXEEXT@ win32_test@EXEEXT@
|
||||
|
||||
# Find the single test program in src/ .
|
||||
srcprogs := $(shell if test -x src/.libs/test_main$(EXEEXT) ; then echo "src/.libs/test_main$(EXEEXT)" ; else echo "src/test_main$(EXEEXT)" ; fi)
|
||||
|
||||
libfiles := $(shell if test ! -z $(EXEEXT) ; then echo "src/libsndfile-1.def src/.libs/libsndfile-1.dll" ; elif test -f $(LIBRARY) ; then echo $(LIBRARY) ; fi ; fi)
|
||||
|
||||
testbins := $(addprefix $(TEST_BINDIR),$(subst @EXEEXT@,$(EXEEXT),$(testprogs))) $(libfiles) $(srcprogs)
|
||||
|
||||
|
||||
all : $(TARBALL)
|
||||
|
||||
clean :
|
||||
rm -rf $(TARBALL) $(TESTNAME)/
|
||||
|
||||
check : $(TESTNAME)/test_wrapper.sh
|
||||
(cd ./$(TESTNAME)/ && ./test_wrapper.sh)
|
||||
|
||||
$(TARBALL) : $(TESTNAME)/test_wrapper.sh
|
||||
tar zcf $@ $(TESTNAME)
|
||||
rm -rf $(TESTNAME)
|
||||
@echo
|
||||
@echo "Created : $(TARBALL)"
|
||||
@echo
|
||||
|
||||
$(TESTNAME)/test_wrapper.sh : $(testbins) tests/test_wrapper.sh tests/pedantic-header-test.sh
|
||||
rm -rf $(TESTNAME)
|
||||
mkdir -p $(TESTNAME)/tests/
|
||||
cp $(testbins) $(TESTNAME)/tests/
|
||||
cp tests/test_wrapper.sh $(TESTNAME)/
|
||||
cp tests/pedantic-header-test.sh $(TESTNAME)/tests/
|
||||
chmod u+x $@
|
||||
|
||||
tests/test_wrapper.sh : tests/test_wrapper.sh.in
|
||||
(cd tests/ ; make $@)
|
|
@ -1,13 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# This is known to work with clang-3.4 from Debian testing/unstable.
|
||||
# 2013/07/14
|
||||
|
||||
export CC=clang
|
||||
export CXX=clang++
|
||||
export CFLAGS="-O3 -fsanitize=address,integer,undefined"
|
||||
export CXXFLAGS="-O3 -fsanitize=address,integer,undefined"
|
||||
|
||||
./configure --enable-gcc-werror
|
||||
|
||||
make clean all check
|
|
@ -1,246 +0,0 @@
|
|||
#!/usr/bin/python -tt
|
||||
#
|
||||
# Copyright (C) 2005-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
#
|
||||
# Released under the 2 clause BSD license.
|
||||
|
||||
"""
|
||||
This program checks C code for compliance to coding standards used in
|
||||
libsndfile and other projects I run.
|
||||
"""
|
||||
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
class Preprocessor:
|
||||
"""
|
||||
Preprocess lines of C code to make it easier for the CStyleChecker class to
|
||||
test for correctness. Preprocessing works on a single line at a time but
|
||||
maintains state between consecutive lines so it can preprocessess multi-line
|
||||
comments.
|
||||
Preprocessing involves:
|
||||
- Strip C++ style comments from a line.
|
||||
- Strip C comments from a series of lines. When a C comment starts and
|
||||
ends on the same line it will be replaced with 'comment'.
|
||||
- Replace arbitrary C strings with the zero length string.
|
||||
- Replace '#define f(x)' with '#define f (c)' (The C #define requires that
|
||||
there be no space between defined macro name and the open paren of the
|
||||
argument list).
|
||||
Used by the CStyleChecker class.
|
||||
"""
|
||||
def __init__ (self):
|
||||
self.comment_nest = 0
|
||||
self.leading_space_re = re.compile ('^(\t+| )')
|
||||
self.trailing_space_re = re.compile ('(\t+| )$')
|
||||
self.define_hack_re = re.compile ("(#\s*define\s+[a-zA-Z0-9_]+)\(")
|
||||
|
||||
def comment_nesting (self):
|
||||
"""
|
||||
Return the currect comment nesting. At the start and end of the file,
|
||||
this value should be zero. Inside C comments it should be 1 or
|
||||
(possibly) more.
|
||||
"""
|
||||
return self.comment_nest
|
||||
|
||||
def __call__ (self, line):
|
||||
"""
|
||||
Strip the provided line of C and C++ comments. Stripping of multi-line
|
||||
C comments works as expected.
|
||||
"""
|
||||
|
||||
line = self.define_hack_re.sub (r'\1 (', line)
|
||||
|
||||
line = self.process_strings (line)
|
||||
|
||||
# Strip C++ style comments.
|
||||
if self.comment_nest == 0:
|
||||
line = re.sub ("( |\t*)//.*", '', line)
|
||||
|
||||
# Strip C style comments.
|
||||
open_comment = line.find ('/*')
|
||||
close_comment = line.find ('*/')
|
||||
|
||||
if self.comment_nest > 0 and close_comment < 0:
|
||||
# Inside a comment block that does not close on this line.
|
||||
return ""
|
||||
|
||||
if open_comment >= 0 and close_comment < 0:
|
||||
# A comment begins on this line but doesn't close on this line.
|
||||
self.comment_nest += 1
|
||||
return self.trailing_space_re.sub ('', line [:open_comment])
|
||||
|
||||
if open_comment < 0 and close_comment >= 0:
|
||||
# Currently open comment ends on this line.
|
||||
self.comment_nest -= 1
|
||||
return self.trailing_space_re.sub ('', line [close_comment + 2:])
|
||||
|
||||
if open_comment >= 0 and close_comment > 0 and self.comment_nest == 0:
|
||||
# Comment begins and ends on this line. Replace it with 'comment'
|
||||
# so we don't need to check whitespace before and after the comment
|
||||
# we're removing.
|
||||
newline = line [:open_comment] + "comment" + line [close_comment + 2:]
|
||||
return self.__call__ (newline)
|
||||
|
||||
return line
|
||||
|
||||
def process_strings (self, line):
|
||||
"""
|
||||
Given a line of C code, return a string where all literal C strings have
|
||||
been replaced with the empty string literal "".
|
||||
"""
|
||||
for k in range (0, len (line)):
|
||||
if line [k] == '"':
|
||||
start = k
|
||||
for k in range (start + 1, len (line)):
|
||||
if line [k] == '"' and line [k - 1] != '\\':
|
||||
return line [:start + 1] + '"' + self.process_strings (line [k + 1:])
|
||||
return line
|
||||
|
||||
|
||||
class CStyleChecker:
|
||||
"""
|
||||
A class for checking the whitespace and layout of a C code.
|
||||
"""
|
||||
def __init__ (self, debug):
|
||||
self.debug = debug
|
||||
self.filename = None
|
||||
self.error_count = 0
|
||||
self.line_num = 1
|
||||
self.orig_line = ''
|
||||
self.trailing_newline_re = re.compile ('[\r\n]+$')
|
||||
self.indent_re = re.compile ("^\s*")
|
||||
self.last_line_indent = ""
|
||||
self.last_line_indent_curly = False
|
||||
self.re_checks = \
|
||||
[ ( re.compile (" "), "multiple space instead of tab" )
|
||||
, ( re.compile ("\t "), "space after tab" )
|
||||
, ( re.compile ("[^ ];"), "missing space before semi-colon" )
|
||||
, ( re.compile ("{[^\s}]"), "missing space after open brace" )
|
||||
, ( re.compile ("[^{\s]}"), "missing space before close brace" )
|
||||
, ( re.compile ("[ \t]+$"), "contains trailing whitespace" )
|
||||
|
||||
, ( re.compile (",[^\s\n]"), "missing space after comma" )
|
||||
, ( re.compile (";[a-zA-Z0-9]"), "missing space after semi-colon" )
|
||||
, ( re.compile ("=[^\s\"'=]"), "missing space after assignment" )
|
||||
|
||||
# Open and close parenthesis.
|
||||
, ( re.compile ("[^\s\(\[\*&']\("), "missing space before open parenthesis" )
|
||||
, ( re.compile ("\)(-[^>]|[^,'\s\n\)\]-])"), "missing space after close parenthesis" )
|
||||
, ( re.compile ("\s(do|for|if|when)\s.*{$"), "trailing open parenthesis at end of line" )
|
||||
, ( re.compile ("\( [^;]"), "space after open parenthesis" )
|
||||
, ( re.compile ("[^;] \)"), "space before close parenthesis" )
|
||||
|
||||
# Open and close square brace.
|
||||
, ( re.compile ("[^\s\(\]]\["), "missing space before open square brace" )
|
||||
, ( re.compile ("\][^,\)\]\[\s\.-]"), "missing space after close square brace" )
|
||||
, ( re.compile ("\[ "), "space after open square brace" )
|
||||
, ( re.compile (" \]"), "space before close square brace" )
|
||||
|
||||
# Space around operators.
|
||||
, ( re.compile ("[^\s][\*/%+-][=][^\s]"), "missing space around opassign" )
|
||||
, ( re.compile ("[^\s][<>!=^/][=]{1,2}[^\s]"), "missing space around comparison" )
|
||||
|
||||
# Parens around single argument to return.
|
||||
, ( re.compile ("\s+return\s+\([a-zA-Z0-9_]+\)\s+;"), "parens around return value" )
|
||||
]
|
||||
|
||||
def get_error_count (self):
|
||||
"""
|
||||
Return the current error count for this CStyleChecker object.
|
||||
"""
|
||||
return self.error_count
|
||||
|
||||
def check_files (self, files):
|
||||
"""
|
||||
Run the style checker on all the specified files.
|
||||
"""
|
||||
for filename in files:
|
||||
self.check_file (filename)
|
||||
|
||||
def check_file (self, filename):
|
||||
"""
|
||||
Run the style checker on the specified file.
|
||||
"""
|
||||
self.filename = filename
|
||||
cfile = open (filename, "r")
|
||||
|
||||
self.line_num = 1
|
||||
|
||||
preprocess = Preprocessor ()
|
||||
while 1:
|
||||
line = cfile.readline ()
|
||||
if not line:
|
||||
break
|
||||
|
||||
line = self.trailing_newline_re.sub ('', line)
|
||||
self.orig_line = line
|
||||
|
||||
self.line_checks (preprocess (line))
|
||||
|
||||
self.line_num += 1
|
||||
|
||||
cfile.close ()
|
||||
self.filename = None
|
||||
|
||||
# Check for errors finding comments.
|
||||
if preprocess.comment_nesting () != 0:
|
||||
print ("Weird, comments nested incorrectly.")
|
||||
sys.exit (1)
|
||||
|
||||
return
|
||||
|
||||
def line_checks (self, line):
|
||||
"""
|
||||
Run the style checker on provided line of text, but within the context
|
||||
of how the line fits within the file.
|
||||
"""
|
||||
|
||||
indent = len (self.indent_re.search (line).group ())
|
||||
if re.search ("^\s+}", line):
|
||||
if not self.last_line_indent_curly and indent != self.last_line_indent:
|
||||
None # self.error ("bad indent on close curly brace")
|
||||
self.last_line_indent_curly = True
|
||||
else:
|
||||
self.last_line_indent_curly = False
|
||||
|
||||
# Now all the regex checks.
|
||||
for (check_re, msg) in self.re_checks:
|
||||
if check_re.search (line):
|
||||
self.error (msg)
|
||||
|
||||
if re.search ("[a-zA-Z0-9][<>!=^/&\|]{1,2}[a-zA-Z0-9]", line):
|
||||
if not re.search (".*#include.*[a-zA-Z0-9]/[a-zA-Z]", line):
|
||||
self.error ("missing space around operator")
|
||||
|
||||
self.last_line_indent = indent
|
||||
return
|
||||
|
||||
def error (self, msg):
|
||||
"""
|
||||
Print an error message and increment the error count.
|
||||
"""
|
||||
print ("%s (%d) : %s" % (self.filename, self.line_num, msg))
|
||||
if self.debug:
|
||||
print ("'" + self.orig_line + "'")
|
||||
self.error_count += 1
|
||||
|
||||
#-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
if len (sys.argv) < 1:
|
||||
print ("Usage : yada yada")
|
||||
sys.exit (1)
|
||||
|
||||
# Create a new CStyleChecker object
|
||||
if sys.argv [1] == '-d' or sys.argv [1] == '--debug':
|
||||
cstyle = CStyleChecker (True)
|
||||
cstyle.check_files (sys.argv [2:])
|
||||
else:
|
||||
cstyle = CStyleChecker (False)
|
||||
cstyle.check_files (sys.argv [1:])
|
||||
|
||||
|
||||
if cstyle.get_error_count ():
|
||||
sys.exit (1)
|
||||
|
||||
sys.exit (0)
|
|
@ -1,79 +0,0 @@
|
|||
#!/bin/sh
|
||||
#
|
||||
|
||||
if git rev-parse --verify HEAD >/dev/null 2>&1 ; then
|
||||
against=HEAD
|
||||
else
|
||||
# Initial commit: diff against an empty tree object
|
||||
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
|
||||
fi
|
||||
|
||||
files=$(git diff-index --name-status --cached HEAD | grep -v ^D | sed -r "s/^[A-Z]+[A-Z0-9]*[ \t]+/ /")
|
||||
|
||||
# Redirect output to stderr.
|
||||
exec 1>&2
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check the copyright notice of all files to be commited.
|
||||
|
||||
user=`git config --global user.email`
|
||||
year=`date +"%Y"`
|
||||
|
||||
missing_copyright_year=""
|
||||
if test $user = "erikd@mega-nerd.com" ; then
|
||||
for f in $files ; do
|
||||
if test `head -5 $f | grep -c -i copyright` -gt 0 ; then
|
||||
user_copyright=`grep -i copyright $f | grep $user | grep -c $year`
|
||||
if test $user_copyright -lt 1 ; then
|
||||
missing_copyright_year="$missing_copyright_year $f"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if test -n "$missing_copyright_year" ; then
|
||||
echo "Missing current year in the copyright notice of the following files:"
|
||||
for f in $missing_copyright_year ; do
|
||||
echo " $f"
|
||||
done
|
||||
echo "Commit aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Check the formatting of all C files.
|
||||
|
||||
cfiles=""
|
||||
for f in $files ; do
|
||||
if test `dirname $f` = "src/ALAC" ; then
|
||||
echo "Skipping cstyle checking on $f"
|
||||
elif test `echo $f | grep -c "\.[ch]$"` -gt 0 ; then
|
||||
cfiles="$cfiles $f"
|
||||
fi
|
||||
done
|
||||
|
||||
if test -n "$cfiles" ; then
|
||||
Scripts/cstyle.py $cfiles
|
||||
if test $? -ne 0 ; then
|
||||
echo
|
||||
echo "Commit aborted. Fix the above error before trying again."
|
||||
exit 1
|
||||
fi
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Prevent files with non-ascii filenames from being committed.
|
||||
|
||||
if test $(git diff --cached --name-only --diff-filter=A -z $against | LC_ALL=C tr -d '[ -~]\0' | wc -c) != 0 ; then
|
||||
echo "Error: Attempt to add a non-ascii file name."
|
||||
echo
|
||||
echo "This can cause problems if you want to work"
|
||||
echo "with people on other platforms."
|
||||
echo
|
||||
echo "To be portable it is advisable to rename the file ..."
|
||||
echo
|
||||
echo "Commit aborted."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
exit 0
|
|
@ -1,22 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
case "$1" in
|
||||
w32)
|
||||
compiler_name=i686-w64-mingw32
|
||||
;;
|
||||
w64)
|
||||
compiler_name=x86_64-w64-mingw32
|
||||
;;
|
||||
*)
|
||||
echo "$0 (w32|w64) <other args>"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
||||
shift
|
||||
|
||||
build_cpu=$(dpkg-architecture -qDEB_BUILD_GNU_CPU)
|
||||
build_host=$build_cpu-linux
|
||||
|
||||
./configure --host=$compiler_name --target=$compiler_name --build=$build_host \
|
||||
--program-prefix='' --disable-sqlite --disable-static $@
|
|
@ -1,42 +0,0 @@
|
|||
Here's a list of what I (erikd AT mega-nerd DOT com) think needs to be
|
||||
done. The list is by no means exhaustive and people are encouraged to
|
||||
email me with suggestions.
|
||||
|
||||
o Add pipe in/out capabilities. libsndfile should be able to read
|
||||
its input from a pipe and write its output to a pipe.
|
||||
|
||||
o Add checks of the error state after fseek???? Use ferror ().
|
||||
|
||||
o Modify tests/lossy_comp_test.c to add tests for stereo files.
|
||||
|
||||
o Testing compilation and correctness on more platforms.
|
||||
|
||||
o Improve testing routines. Must test all combinations of inputs
|
||||
and outputs.
|
||||
|
||||
o Test sf_seek function on write???
|
||||
|
||||
o Add more sound file formats. People should contact me with their
|
||||
requirements.
|
||||
|
||||
o Add support for accessing sound formats with multiple audio
|
||||
data sections (ie samples within tracker files, Soundfont II and
|
||||
multi-sample sampler formats).
|
||||
|
||||
o Add an interface to allow reading and writing of sample loop points
|
||||
and other info within AIFF and other file formats. This must be a
|
||||
general solution.
|
||||
|
||||
o Improve documentation. Is HTML documentation good enough?
|
||||
|
||||
o Look into the possibility of optional sample rate convert on file
|
||||
read.
|
||||
|
||||
As I am the person who knows libsndfile best, I can probably implement
|
||||
any new features faster than anybody else (and you can spend your time
|
||||
writing applications with libsndfile). All I need is some
|
||||
documentation and some sample files. Please contact me before emailing
|
||||
me documentation and sample files. I would much rather pull them off
|
||||
the web than have them clogging up my email inbox.
|
||||
|
||||
|
|
@ -1,4 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
EXTRA_DIST = README-precompiled-dll.txt testprog.c
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
Notes on Using the Pre-compiled libsndfile DLL.
|
||||
===============================================
|
||||
|
||||
In order to use this pre-compiled DLL with Visual Studio, you will need to
|
||||
generate a .LIB file from the DLL.
|
||||
|
||||
This can be achieved as follows:
|
||||
|
||||
1) In a CMD window, change to the directory containing this file and
|
||||
run the command:
|
||||
|
||||
lib /machine:i386 /def:libsndfile-1.def
|
||||
|
||||
You now have two files:
|
||||
|
||||
libsndfile-1.dll
|
||||
libsndfile-1.lib
|
||||
|
||||
to be used with VisualStudio.
|
||||
|
||||
If the lib command fails with a command saying "'lib' is not recognized as
|
||||
an internal or external command, operable program or batch file", you need
|
||||
to find the location of "lib.exe" and add that directory to your PATH
|
||||
environment variable. Another alternative is to use the "Visual Studio 2005
|
||||
Command Prompt" Start menu item:
|
||||
|
||||
Start ->
|
||||
All Programs ->
|
||||
Visual Studio 2005 ->
|
||||
Visual Studio Tools ->
|
||||
Visual Studio 2005 Command Prompt
|
||||
|
||||
If for some reason these instructions don't work for you or you are still
|
||||
not able to use the libsndfile DLL with you project, please do not contact
|
||||
the main author of libsndfile. Instead, join the libsndfile-users mailing
|
||||
list :
|
||||
|
||||
http://www.mega-nerd.com/libsndfile/lists.html
|
||||
|
||||
and ask a question there.
|
|
@ -1,16 +0,0 @@
|
|||
/* Simple test program to make sure that Win32 linking to libsndfile is
|
||||
** working.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "sndfile.h"
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ static char strbuffer [256] ;
|
||||
sf_command (NULL, SFC_GET_LIB_VERSION, strbuffer, sizeof (strbuffer)) ;
|
||||
puts (strbuffer) ;
|
||||
return 0 ;
|
||||
}
|
||||
|
|
@ -1,637 +0,0 @@
|
|||
dnl By default, many hosts won't let programs access large files;
|
||||
dnl one must use special compiler options to get large-file access to work.
|
||||
dnl For more details about this brain damage please see:
|
||||
dnl http://www.sas.com/standards/large.file/x_open.20Mar96.html
|
||||
|
||||
dnl Written by Paul Eggert <eggert@twinsun.com>.
|
||||
|
||||
m4_include([M4/gcc_version.m4])
|
||||
m4_include([M4/octave.m4])
|
||||
m4_include([M4/mkoctfile_version.m4])
|
||||
m4_include([M4/extra_pkg.m4])
|
||||
m4_include([M4/lrint.m4])
|
||||
m4_include([M4/lrintf.m4])
|
||||
m4_include([M4/clang.m4])
|
||||
m4_include([M4/really_gcc.m4])
|
||||
m4_include([M4/stack_protect.m4])
|
||||
m4_include([M4/clip_mode.m4])
|
||||
m4_include([M4/add_cflags.m4])
|
||||
m4_include([M4/add_cxxflags.m4])
|
||||
m4_include([M4/flexible_array.m4])
|
||||
m4_include([M4/endian.m4])
|
||||
m4_include([M4/extra_largefile.m4])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl AC_SYS_EXTRA_LARGEFILE_FLAGS(FLAGSNAME)
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_FLAGS],
|
||||
[AC_CACHE_CHECK([for $1 value to request large file support],
|
||||
ac_cv_sys_largefile_$1,
|
||||
[ac_cv_sys_largefile_$1=`($GETCONF LFS_$1) 2>/dev/null` || {
|
||||
ac_cv_sys_largefile_$1=no
|
||||
ifelse($1, CFLAGS,
|
||||
[case "$host_os" in
|
||||
# IRIX 6.2 and later require cc -n32.
|
||||
changequote(, )dnl
|
||||
irix6.[2-9]* | irix6.1[0-9]* | irix[7-9].* | irix[1-9][0-9]*)
|
||||
changequote([, ])dnl
|
||||
if test "$GCC" != yes; then
|
||||
ac_cv_sys_largefile_CFLAGS=-n32
|
||||
fi
|
||||
ac_save_CC="$CC"
|
||||
CC="$CC $ac_cv_sys_largefile_CFLAGS"
|
||||
AC_TRY_LINK(, , , ac_cv_sys_largefile_CFLAGS=no)
|
||||
CC="$ac_save_CC"
|
||||
esac])
|
||||
}])])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(VAR, VAL)
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND],
|
||||
[case $2 in
|
||||
no) ;;
|
||||
?*)
|
||||
case "[$]$1" in
|
||||
'') $1=$2 ;;
|
||||
*) $1=[$]$1' '$2 ;;
|
||||
esac ;;
|
||||
esac])
|
||||
|
||||
dnl Internal subroutine of AC_SYS_EXTRA_LARGEFILE.
|
||||
dnl AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(C-MACRO, CACHE-VAR, COMMENT, CODE-TO-SET-DEFAULT)
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE],
|
||||
[AC_CACHE_CHECK([for $1], $2,
|
||||
[$2=no
|
||||
changequote(, )dnl
|
||||
$4
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
-D$1)
|
||||
$2=1 ;;
|
||||
-D$1=*)
|
||||
$2=`expr " $ac_flag" : '[^=]*=\(.*\)'` ;;
|
||||
esac
|
||||
done
|
||||
changequote([, ])dnl
|
||||
])
|
||||
if test "[$]$2" != no; then
|
||||
AC_DEFINE_UNQUOTED([$1], [$]$2, [$3])
|
||||
fi])
|
||||
|
||||
AC_DEFUN([AC_SYS_EXTRA_LARGEFILE],
|
||||
[AC_REQUIRE([AC_CANONICAL_HOST])
|
||||
AC_ARG_ENABLE(largefile,
|
||||
[ --disable-largefile omit support for large files])
|
||||
if test "$enable_largefile" != no; then
|
||||
AC_CHECK_TOOL(GETCONF, getconf)
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(CFLAGS)
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(LDFLAGS)
|
||||
AC_SYS_EXTRA_LARGEFILE_FLAGS(LIBS)
|
||||
|
||||
for ac_flag in $ac_cv_sys_largefile_CFLAGS no; do
|
||||
case "$ac_flag" in
|
||||
no) ;;
|
||||
-D_FILE_OFFSET_BITS=*) ;;
|
||||
-D_LARGEFILE_SOURCE | -D_LARGEFILE_SOURCE=*) ;;
|
||||
-D_LARGE_FILES | -D_LARGE_FILES=*) ;;
|
||||
-D?* | -I?*)
|
||||
AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CPPFLAGS, "$ac_flag") ;;
|
||||
*)
|
||||
AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(CFLAGS, "$ac_flag") ;;
|
||||
esac
|
||||
done
|
||||
AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(LDFLAGS, "$ac_cv_sys_largefile_LDFLAGS")
|
||||
AC_SYS_EXTRA_LARGEFILE_SPACE_APPEND(LIBS, "$ac_cv_sys_largefile_LIBS")
|
||||
AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_FILE_OFFSET_BITS,
|
||||
ac_cv_sys_file_offset_bits,
|
||||
[Number of bits in a file offset, on hosts where this is settable.])
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_sys_file_offset_bits=64 ;;
|
||||
esac]
|
||||
AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGEFILE_SOURCE,
|
||||
ac_cv_sys_largefile_source,
|
||||
[Define to make fseeko etc. visible, on some hosts.],
|
||||
[case "$host_os" in
|
||||
# HP-UX 10.20 and later
|
||||
hpux10.[2-9][0-9]* | hpux1[1-9]* | hpux[2-9][0-9]*)
|
||||
ac_cv_sys_largefile_source=1 ;;
|
||||
esac])
|
||||
AC_SYS_EXTRA_LARGEFILE_MACRO_VALUE(_LARGE_FILES,
|
||||
ac_cv_sys_large_files,
|
||||
[Define for large files, on AIX-style hosts.],
|
||||
[case "$host_os" in
|
||||
# AIX 4.2 and later
|
||||
aix4.[2-9]* | aix4.1[0-9]* | aix[5-9].* | aix[1-9][0-9]*)
|
||||
ac_cv_sys_large_files=1 ;;
|
||||
esac])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C_FIND_ENDIAN
|
||||
dnl
|
||||
dnl Determine endian-ness of target processor.
|
||||
dnl @version 1.1 Mar 03 2002
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Majority written from scratch to replace the standard autoconf macro
|
||||
dnl AC_C_BIGENDIAN. Only part remaining from the original it the invocation
|
||||
dnl of the AC_TRY_RUN macro.
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
|
||||
dnl Find endian-ness in the following way:
|
||||
dnl 1) Look in <endian.h>.
|
||||
dnl 2) If 1) fails, look in <sys/types.h> and <sys/param.h>.
|
||||
dnl 3) If 1) and 2) fails and not cross compiling run a test program.
|
||||
dnl 4) If 1) and 2) fails and cross compiling then guess based on target.
|
||||
|
||||
AC_DEFUN([AC_C_FIND_ENDIAN],
|
||||
[AC_CACHE_CHECK(processor byte ordering,
|
||||
ac_cv_c_byte_order,
|
||||
|
||||
# Initialize to unknown
|
||||
ac_cv_c_byte_order=unknown
|
||||
|
||||
if test x$ac_cv_header_endian_h = xyes ; then
|
||||
|
||||
# First try <endian.h> which should set BYTE_ORDER.
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <endian.h>
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
], return 0 ;,
|
||||
ac_cv_c_byte_order=little
|
||||
)]
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <endian.h>
|
||||
#if BYTE_ORDER != BIG_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
], return 0 ;,
|
||||
ac_cv_c_byte_order=big
|
||||
)]
|
||||
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_byte_order = unknown ; then
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#if !BYTE_ORDER || !BIG_ENDIAN || !LITTLE_ENDIAN
|
||||
bogus endian macros
|
||||
#endif
|
||||
], return 0 ;,
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
], return 0 ;,
|
||||
ac_cv_c_byte_order=little
|
||||
)]
|
||||
|
||||
[AC_TRY_LINK([
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#if BYTE_ORDER != LITTLE_ENDIAN
|
||||
not big endian
|
||||
#endif
|
||||
], return 0 ;,
|
||||
ac_cv_c_byte_order=little
|
||||
)]
|
||||
|
||||
)]
|
||||
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_byte_order = unknown ; then
|
||||
if test $cross_compiling = yes ; then
|
||||
# This is the last resort. Try to guess the target processor endian-ness
|
||||
# by looking at the target CPU type.
|
||||
[
|
||||
case "$target_cpu" in
|
||||
alpha* | i?86* | mipsel* | ia64*)
|
||||
ac_cv_c_big_endian=0
|
||||
ac_cv_c_little_endian=1
|
||||
;;
|
||||
|
||||
m68* | mips* | powerpc* | hppa* | sparc*)
|
||||
ac_cv_c_big_endian=1
|
||||
ac_cv_c_little_endian=0
|
||||
;;
|
||||
|
||||
esac
|
||||
]
|
||||
else
|
||||
AC_TRY_RUN(
|
||||
[[
|
||||
int main (void)
|
||||
{ /* Are we little or big endian? From Harbison&Steele. */
|
||||
union
|
||||
{ long l ;
|
||||
char c [sizeof (long)] ;
|
||||
} u ;
|
||||
u.l = 1 ;
|
||||
return (u.c [sizeof (long) - 1] == 1);
|
||||
}
|
||||
]], , ac_cv_c_byte_order=big,
|
||||
ac_cv_c_byte_order=unknown
|
||||
)
|
||||
|
||||
AC_TRY_RUN(
|
||||
[[int main (void)
|
||||
{ /* Are we little or big endian? From Harbison&Steele. */
|
||||
union
|
||||
{ long l ;
|
||||
char c [sizeof (long)] ;
|
||||
} u ;
|
||||
u.l = 1 ;
|
||||
return (u.c [0] == 1);
|
||||
}]], , ac_cv_c_byte_order=little,
|
||||
ac_cv_c_byte_order=unknown
|
||||
)
|
||||
fi
|
||||
fi
|
||||
|
||||
)
|
||||
]
|
||||
|
||||
if test $ac_cv_c_byte_order = big ; then
|
||||
ac_cv_c_big_endian=1
|
||||
ac_cv_c_little_endian=0
|
||||
elif test $ac_cv_c_byte_order = little ; then
|
||||
ac_cv_c_big_endian=0
|
||||
ac_cv_c_little_endian=1
|
||||
else
|
||||
ac_cv_c_big_endian=0
|
||||
ac_cv_c_little_endian=0
|
||||
|
||||
fi
|
||||
|
||||
)# AC_C_FIND_ENDIAN
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C99_FLEXIBLE_ARRAY
|
||||
dnl
|
||||
dnl Dose the compiler support the 1999 ISO C Standard "stuct hack".
|
||||
dnl @version 1.1 Mar 15 2004
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
|
||||
AC_DEFUN([AC_C99_FLEXIBLE_ARRAY],
|
||||
[AC_CACHE_CHECK(C99 struct flexible array support,
|
||||
ac_cv_c99_flexible_array,
|
||||
|
||||
# Initialize to unknown
|
||||
ac_cv_c99_flexible_array=no
|
||||
|
||||
AC_TRY_LINK([[
|
||||
#include <stdlib.h>
|
||||
typedef struct {
|
||||
int k;
|
||||
char buffer [] ;
|
||||
} MY_STRUCT ;
|
||||
]],
|
||||
[ MY_STRUCT *p = calloc (1, sizeof (MY_STRUCT) + 42); ],
|
||||
ac_cv_c99_flexible_array=yes,
|
||||
ac_cv_c99_flexible_array=no
|
||||
))]
|
||||
) # AC_C99_FLEXIBLE_ARRAY
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C99_FUNC_LRINT
|
||||
dnl
|
||||
dnl Check whether C99's lrint function is available.
|
||||
dnl @version 1.3 Feb 12 2002
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([AC_C99_FUNC_LRINT],
|
||||
[AC_CACHE_CHECK(for lrint,
|
||||
ac_cv_c99_lrint,
|
||||
[
|
||||
lrint_save_CFLAGS=$CFLAGS
|
||||
CFLAGS="-lm"
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
|
||||
#include <math.h>
|
||||
], if (!lrint(3.14159)) lrint(2.7183);, ac_cv_c99_lrint=yes, ac_cv_c99_lrint=no)
|
||||
|
||||
CFLAGS=$lrint_save_CFLAGS
|
||||
|
||||
])
|
||||
|
||||
if test "$ac_cv_c99_lrint" = yes; then
|
||||
AC_DEFINE(HAVE_LRINT, 1,
|
||||
[Define if you have C99's lrint function.])
|
||||
fi
|
||||
])# AC_C99_FUNC_LRINT
|
||||
dnl @synopsis AC_C99_FUNC_LRINTF
|
||||
dnl
|
||||
dnl Check whether C99's lrintf function is available.
|
||||
dnl @version 1.3 Feb 12 2002
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([AC_C99_FUNC_LRINTF],
|
||||
[AC_CACHE_CHECK(for lrintf,
|
||||
ac_cv_c99_lrintf,
|
||||
[
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
|
||||
#include <math.h>
|
||||
], if (!lrintf(3.14159)) lrintf(2.7183);, ac_cv_c99_lrintf=yes, ac_cv_c99_lrintf=no)
|
||||
])
|
||||
|
||||
if test "$ac_cv_c99_lrintf" = yes; then
|
||||
AC_DEFINE(HAVE_LRINTF, 1,
|
||||
[Define if you have C99's lrintf function.])
|
||||
fi
|
||||
])# AC_C99_FUNC_LRINTF
|
||||
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C99_FUNC_LLRINT
|
||||
dnl
|
||||
dnl Check whether C99's llrint function is available.
|
||||
dnl @version 1.1 Sep 30 2002
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
dnl
|
||||
AC_DEFUN([AC_C99_FUNC_LLRINT],
|
||||
[AC_CACHE_CHECK(for llrint,
|
||||
ac_cv_c99_llrint,
|
||||
[
|
||||
AC_TRY_LINK([
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
], int64_t x ; x = llrint(3.14159) ;, ac_cv_c99_llrint=yes, ac_cv_c99_llrint=no)
|
||||
])
|
||||
|
||||
if test "$ac_cv_c99_llrint" = yes; then
|
||||
AC_DEFINE(HAVE_LLRINT, 1,
|
||||
[Define if you have C99's llrint function.])
|
||||
fi
|
||||
])# AC_C99_FUNC_LLRINT
|
||||
|
||||
|
||||
|
||||
dnl @synopsis AC_C_CLIP_MODE
|
||||
dnl
|
||||
dnl Determine the clipping mode when converting float to int.
|
||||
dnl @version 1.0 May 17 2003
|
||||
dnl @author Erik de Castro Lopo <erikd AT mega-nerd DOT com>
|
||||
dnl
|
||||
dnl Permission to use, copy, modify, distribute, and sell this file for any
|
||||
dnl purpose is hereby granted without fee, provided that the above copyright
|
||||
dnl and this permission notice appear in all copies. No representations are
|
||||
dnl made about the suitability of this software for any purpose. It is
|
||||
dnl provided "as is" without express or implied warranty.
|
||||
|
||||
|
||||
|
||||
dnl Find the clipping mode in the following way:
|
||||
dnl 1) If we are not cross compiling test it.
|
||||
dnl 2) IF we are cross compiling, assume that clipping isn't done correctly.
|
||||
|
||||
AC_DEFUN([AC_C_CLIP_MODE],
|
||||
[AC_CACHE_CHECK(processor clipping capabilities,
|
||||
ac_cv_c_clip_type,
|
||||
|
||||
# Initialize to unknown
|
||||
ac_cv_c_clip_positive=unknown
|
||||
ac_cv_c_clip_negative=unknown
|
||||
|
||||
if test $ac_cv_c_clip_positive = unknown ; then
|
||||
AC_TRY_RUN(
|
||||
[[
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
#include <math.h>
|
||||
int main (void)
|
||||
{ double fval ;
|
||||
int k, ival ;
|
||||
|
||||
fval = 1.0 * 0x7FFFFFFF ;
|
||||
for (k = 0 ; k < 100 ; k++)
|
||||
{ ival = (lrint (fval)) >> 24 ;
|
||||
if (ival != 127)
|
||||
return 1 ;
|
||||
|
||||
fval *= 1.2499999 ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
]],
|
||||
ac_cv_c_clip_positive=yes,
|
||||
ac_cv_c_clip_positive=no,
|
||||
ac_cv_c_clip_positive=unknown
|
||||
)
|
||||
|
||||
AC_TRY_RUN(
|
||||
[[
|
||||
#define _ISOC9X_SOURCE 1
|
||||
#define _ISOC99_SOURCE 1
|
||||
#define __USE_ISOC99 1
|
||||
#define __USE_ISOC9X 1
|
||||
#include <math.h>
|
||||
int main (void)
|
||||
{ double fval ;
|
||||
int k, ival ;
|
||||
|
||||
fval = -8.0 * 0x10000000 ;
|
||||
for (k = 0 ; k < 100 ; k++)
|
||||
{ ival = (lrint (fval)) >> 24 ;
|
||||
if (ival != -128)
|
||||
return 1 ;
|
||||
|
||||
fval *= 1.2499999 ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
}
|
||||
]],
|
||||
ac_cv_c_clip_negative=yes,
|
||||
ac_cv_c_clip_negative=no,
|
||||
ac_cv_c_clip_negative=unknown
|
||||
)
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_clip_positive = yes ; then
|
||||
ac_cv_c_clip_positive=1
|
||||
else
|
||||
ac_cv_c_clip_positive=0
|
||||
fi
|
||||
|
||||
if test $ac_cv_c_clip_negative = yes ; then
|
||||
ac_cv_c_clip_negative=1
|
||||
else
|
||||
ac_cv_c_clip_negative=0
|
||||
fi
|
||||
|
||||
[[
|
||||
case "$ac_cv_c_clip_positive$ac_cv_c_clip_negative" in
|
||||
"00")
|
||||
ac_cv_c_clip_type="none"
|
||||
;;
|
||||
"10")
|
||||
ac_cv_c_clip_type="positive"
|
||||
;;
|
||||
"01")
|
||||
ac_cv_c_clip_type="negative"
|
||||
;;
|
||||
"11")
|
||||
ac_cv_c_clip_type="both"
|
||||
;;
|
||||
esac
|
||||
]]
|
||||
|
||||
)
|
||||
]
|
||||
|
||||
)# AC_C_CLIP_MODE
|
||||
|
||||
|
||||
dnl @synopsis AC_ADD_CFLAGS
|
||||
dnl
|
||||
dnl Add the given option to CFLAGS, if it doesn't break the compiler
|
||||
|
||||
AC_DEFUN([AC_ADD_CFLAGS],
|
||||
[AC_MSG_CHECKING([if $CC accepts $1])
|
||||
ac_add_cflags__old_cflags="$CFLAGS"
|
||||
CFLAGS="$CFLAGS $1"
|
||||
AC_TRY_LINK([#include <stdio.h>],
|
||||
[printf("Hello, World!\n"); return 0;],
|
||||
AC_MSG_RESULT([yes]),
|
||||
AC_MSG_RESULT([no])
|
||||
CFLAGS="$ac_add_cflags__old_cflags")
|
||||
])
|
||||
|
||||
|
||||
|
||||
dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not)
|
||||
dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page
|
||||
dnl also defines GSTUFF_PKG_ERRORS on error
|
||||
AC_DEFUN([PKG_CHECK_MODULES], [
|
||||
succeeded=no
|
||||
|
||||
if test -z "$PKG_CONFIG"; then
|
||||
AC_PATH_PROG(PKG_CONFIG, pkg-config, no)
|
||||
fi
|
||||
|
||||
if test "$PKG_CONFIG" = "no" ; then
|
||||
echo "*** The pkg-config script could not be found. Make sure it is"
|
||||
echo "*** in your path, or set the PKG_CONFIG environment variable"
|
||||
echo "*** to the full path to pkg-config."
|
||||
echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config."
|
||||
else
|
||||
PKG_CONFIG_MIN_VERSION=0.9.0
|
||||
if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then
|
||||
AC_MSG_CHECKING(for $2)
|
||||
|
||||
if $PKG_CONFIG --exists "$2" ; then
|
||||
AC_MSG_RESULT(yes)
|
||||
succeeded=yes
|
||||
|
||||
AC_MSG_CHECKING($1_CFLAGS)
|
||||
$1_CFLAGS=`$PKG_CONFIG --cflags "$2"`
|
||||
AC_MSG_RESULT($$1_CFLAGS)
|
||||
|
||||
AC_MSG_CHECKING($1_LIBS)
|
||||
$1_LIBS=`$PKG_CONFIG --libs "$2"`
|
||||
AC_MSG_RESULT($$1_LIBS)
|
||||
else
|
||||
$1_CFLAGS=""
|
||||
$1_LIBS=""
|
||||
## If we have a custom action on failure, don't print errors, but
|
||||
## do set a variable so people can do so.
|
||||
$1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
|
||||
ifelse([$4], ,echo $$1_PKG_ERRORS,)
|
||||
fi
|
||||
|
||||
AC_SUBST($1_CFLAGS)
|
||||
AC_SUBST($1_LIBS)
|
||||
else
|
||||
echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer."
|
||||
echo "*** See http://www.freedesktop.org/software/pkgconfig"
|
||||
fi
|
||||
fi
|
||||
|
||||
if test $succeeded = yes; then
|
||||
ifelse([$3], , :, [$3])
|
||||
else
|
||||
ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4])
|
||||
fi
|
||||
])
|
||||
|
||||
|
||||
|
||||
|
||||
ifelse(dnl
|
||||
|
||||
Do not edit or modify anything in this comment block.
|
||||
The arch-tag line is a file identity tag for the GNU Arch
|
||||
revision control system.
|
||||
|
||||
arch-tag: bc38294d-bb5c-42ad-90b9-779def5eaab7
|
||||
|
||||
)dnl
|
|
@ -1,179 +0,0 @@
|
|||
#!/bin/sh
|
||||
# Run this to set up the build system: configure, makefiles, etc.
|
||||
# (based on the version in enlightenment's cvs)
|
||||
|
||||
package="libsndfile"
|
||||
|
||||
ACLOCAL_FLAGS="-I M4"
|
||||
|
||||
olddir=`pwd`
|
||||
srcdir=`dirname $0`
|
||||
test -z "$srcdir" && srcdir=.
|
||||
|
||||
cd "$srcdir"
|
||||
DIE=0
|
||||
|
||||
printf "checking for autogen ... "
|
||||
result="yes"
|
||||
(autogen --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have GNU autogen installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
result="no"
|
||||
DIE=1
|
||||
}
|
||||
echo $result
|
||||
|
||||
printf "checking for autoconf ... "
|
||||
result="yes"
|
||||
(autoconf --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have autoconf installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
result="no"
|
||||
DIE=1
|
||||
}
|
||||
echo $result
|
||||
|
||||
VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9][0-9]*\.[0-9][0-9]*\).*/\1/"
|
||||
VERSIONMKMAJ="sed -e s/\([0-9][0-9]*\)[^0-9].*/\\1/"
|
||||
VERSIONMKMIN="sed -e s/.*[0-9][0-9]*\.//"
|
||||
|
||||
# do we need automake?
|
||||
if test -r Makefile.am; then
|
||||
AM_OPTIONS=`fgrep AUTOMAKE_OPTIONS Makefile.am`
|
||||
AM_NEEDED=`echo $AM_OPTIONS | $VERSIONGREP`
|
||||
if test x"$AM_NEEDED" = "x$AM_OPTIONS"; then
|
||||
AM_NEEDED=""
|
||||
fi
|
||||
if test -z $AM_NEEDED; then
|
||||
printf "checking for automake ... "
|
||||
AUTOMAKE=automake
|
||||
ACLOCAL=aclocal
|
||||
if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then
|
||||
echo "yes"
|
||||
else
|
||||
echo "no"
|
||||
AUTOMAKE=
|
||||
fi
|
||||
else
|
||||
printf "checking for automake $AM_NEEDED or later ... "
|
||||
majneeded=`echo $AM_NEEDED | $VERSIONMKMAJ`
|
||||
minneeded=`echo $AM_NEEDED | $VERSIONMKMIN`
|
||||
for am in automake-$AM_NEEDED automake$AM_NEEDED \
|
||||
automake automake-1.7 automake-1.8 automake-1.9 automake-1.10; do
|
||||
($am --version < /dev/null > /dev/null 2>&1) || continue
|
||||
ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP`
|
||||
maj=`echo $ver | $VERSIONMKMAJ`
|
||||
min=`echo $ver | $VERSIONMKMIN`
|
||||
if test $maj -eq $majneeded -a $min -ge $minneeded; then
|
||||
AUTOMAKE=$am
|
||||
echo $AUTOMAKE
|
||||
break
|
||||
fi
|
||||
done
|
||||
test -z $AUTOMAKE && echo "no"
|
||||
printf "checking for aclocal $AM_NEEDED or later ... "
|
||||
for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED \
|
||||
aclocal aclocal-1.7 aclocal-1.8 aclocal-1.9 aclocal-1.10; do
|
||||
($ac --version < /dev/null > /dev/null 2>&1) || continue
|
||||
ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP`
|
||||
maj=`echo $ver | $VERSIONMKMAJ`
|
||||
min=`echo $ver | $VERSIONMKMIN`
|
||||
if test $maj -eq $majneeded -a $min -ge $minneeded; then
|
||||
ACLOCAL=$ac
|
||||
echo $ACLOCAL
|
||||
break
|
||||
fi
|
||||
done
|
||||
test -z $ACLOCAL && echo "no"
|
||||
fi
|
||||
test -z $AUTOMAKE || test -z $ACLOCAL && {
|
||||
echo
|
||||
echo "You must have automake installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
printf "checking for libtool ... "
|
||||
for LIBTOOLIZE in libtoolize glibtoolize nope; do
|
||||
($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break
|
||||
done
|
||||
if test x$LIBTOOLIZE = xnope; then
|
||||
echo "nope."
|
||||
LIBTOOLIZE=libtoolize
|
||||
else
|
||||
echo $LIBTOOLIZE
|
||||
fi
|
||||
($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have libtool installed to compile $package."
|
||||
echo "Download the appropriate package for your system,"
|
||||
echo "or get the source from one of the GNU ftp sites"
|
||||
echo "listed in http://www.gnu.org/order/ftp.html"
|
||||
DIE=1
|
||||
}
|
||||
|
||||
printf "checking for pkg-config ... "
|
||||
result="yes"
|
||||
(pkg-config --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have pkg-config installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution."
|
||||
result="no"
|
||||
DIE=1
|
||||
}
|
||||
echo $result
|
||||
|
||||
|
||||
printf "checking for python ... "
|
||||
result="yes"
|
||||
(python --version) < /dev/null > /dev/null 2>&1 || {
|
||||
echo
|
||||
echo "You must have Python installed to compile $package."
|
||||
echo "Download the appropriate package for your distribution,"
|
||||
echo "or get the source tarball at http://python.org/"
|
||||
result="no"
|
||||
DIE=1
|
||||
}
|
||||
echo $result
|
||||
|
||||
if test "$DIE" -eq 1; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if test ! -d Cfg ; then
|
||||
echo "Creating 'Cfg' directory."
|
||||
mkdir Cfg
|
||||
fi
|
||||
|
||||
echo "Generating configuration files for $package, please wait ... "
|
||||
|
||||
echo " $ACLOCAL $ACLOCAL_FLAGS"
|
||||
$ACLOCAL $ACLOCAL_FLAGS || exit 1
|
||||
echo " $LIBTOOLIZE --automake --force"
|
||||
$LIBTOOLIZE --automake --force || exit 1
|
||||
echo " autoheader"
|
||||
autoheader || exit 1
|
||||
echo " $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
|
||||
$AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1
|
||||
echo " autoconf"
|
||||
autoconf || exit 1
|
||||
|
||||
cd $olddir
|
||||
|
||||
fprecommit=.git/hooks/pre-commit
|
||||
if test ! -f $fprecommit ; then
|
||||
echo
|
||||
echo "Installing git pre-commit hook for this project."
|
||||
cat > $fprecommit << 'foobar'
|
||||
#!/bin/sh
|
||||
exec Scripts/git-pre-commit-hook
|
||||
foobar
|
||||
chmod u+x $fprecommit
|
||||
echo
|
||||
fi
|
|
@ -1,62 +0,0 @@
|
|||
g#!/usr/bin/python
|
||||
|
||||
import re, string, sys
|
||||
|
||||
def trim_function_and_params (section):
|
||||
k = string.find (section, "(") + 1
|
||||
brackets = 1
|
||||
section_len = len (section)
|
||||
while k < section_len:
|
||||
if section [k] == '(':
|
||||
brackets += 1
|
||||
elif section [k] == ')':
|
||||
brackets -= 1
|
||||
if brackets < 1:
|
||||
return section [:k+1]
|
||||
k += 1
|
||||
print "Whoops!!!!"
|
||||
sys.exit (1)
|
||||
|
||||
def get_function_calls (filedata):
|
||||
filedata = string.split (filedata, "psf_binheader_readf")
|
||||
filedata = filedata [1:]
|
||||
|
||||
func_calls = []
|
||||
for section in filedata:
|
||||
section = "psf_binheader_readf" + section
|
||||
func_calls.append (trim_function_and_params (section))
|
||||
|
||||
return func_calls
|
||||
|
||||
def search_for_problems (filename):
|
||||
filedata = open (filename, "r").read ()
|
||||
|
||||
if len (filedata) < 1:
|
||||
print "Error : file '%s' contains no data." % filename
|
||||
sys.exit (1)
|
||||
|
||||
count = 0
|
||||
|
||||
calls = get_function_calls (filedata)
|
||||
for call in calls:
|
||||
if string.find (call, "sizeof") > 0:
|
||||
print "Found : ", call
|
||||
count += 1
|
||||
|
||||
if count == 0:
|
||||
print "%-20s : No problems found." % filename
|
||||
else:
|
||||
print "\n%-20s : Found %d errors." % (filename, count)
|
||||
sys.exit (1)
|
||||
return
|
||||
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
if len (sys.argv) < 2:
|
||||
print "Usage : %s <file>" % sys.argv [0]
|
||||
sys.exit (1)
|
||||
|
||||
for file in sys.argv [1:]:
|
||||
search_for_problems (file)
|
||||
|
|
@ -1,697 +0,0 @@
|
|||
# Copyright (C) 1999-2013 Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
||||
dnl Require autoconf version
|
||||
AC_PREREQ(2.57)
|
||||
|
||||
AC_INIT([libsndfile],[1.0.26pre5],[sndfile@mega-nerd.com],
|
||||
[libsndfile],[http://www.mega-nerd.com/libsndfile/])
|
||||
|
||||
# Put config stuff in Cfg.
|
||||
AC_CONFIG_AUX_DIR(Cfg)
|
||||
|
||||
AC_CONFIG_SRCDIR([src/sndfile.c])
|
||||
AC_CANONICAL_TARGET([])
|
||||
|
||||
AC_CONFIG_MACRO_DIR([M4])
|
||||
AC_CONFIG_HEADERS([src/config.h])
|
||||
|
||||
CFLAGS="$CFLAGS $CONFIGURE_CFLAGS"
|
||||
CXXFLAGS="$CXXFLAGS $CONFIGURE_CXXFLAGS"
|
||||
LDFLAGS="$LDFLAGS $CONFIGURE_LDFLAGS"
|
||||
|
||||
AM_INIT_AUTOMAKE
|
||||
AC_SUBST(ACLOCAL_AMFLAGS, "-I M4")
|
||||
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
|
||||
|
||||
AC_LANG([C])
|
||||
|
||||
AC_PROG_CC_STDC
|
||||
AC_USE_SYSTEM_EXTENSIONS
|
||||
AM_PROG_CC_C_O
|
||||
AC_PROG_CXX
|
||||
|
||||
MN_C_COMPILER_IS_CLANG
|
||||
MN_GCC_REALLY_IS_GCC
|
||||
|
||||
AC_PROG_SED
|
||||
|
||||
# Do not check for F77.
|
||||
define([AC_LIBTOOL_LANG_F77_CONFIG], [:])dnl
|
||||
|
||||
AM_PROG_LIBTOOL
|
||||
LT_PROG_RC
|
||||
|
||||
AC_PROG_INSTALL
|
||||
AC_PROG_LN_S
|
||||
|
||||
AC_CHECK_PROG(HAVE_AUTOGEN, autogen, yes, no)
|
||||
AC_CHECK_PROG(HAVE_WINE, wine, yes, no)
|
||||
AC_CHECK_PROG(HAVE_XCODE_SELECT, xcode-select, yes, no)
|
||||
|
||||
#------------------------------------------------------------------------------------
|
||||
# Rules for library version information:
|
||||
#
|
||||
# 1. Start with version information of `0:0:0' for each libtool library.
|
||||
# 2. Update the version information only immediately before a public release of
|
||||
# your software. More frequent updates are unnecessary, and only guarantee
|
||||
# that the current interface number gets larger faster.
|
||||
# 3. If the library source code has changed at all since the last update, then
|
||||
# increment revision (`c:r:a' becomes `c:r+1:a').
|
||||
# 4. If any interfaces have been added, removed, or changed since the last update,
|
||||
# increment current, and set revision to 0.
|
||||
# 5. If any interfaces have been added since the last public release, then increment
|
||||
# age.
|
||||
# 6. If any interfaces have been removed since the last public release, then set age
|
||||
# to 0.
|
||||
|
||||
CLEAN_VERSION=`echo $PACKAGE_VERSION | $SED "s/p.*//"`
|
||||
VERSION_MINOR=`echo $CLEAN_VERSION | $SED "s/.*\.//"`
|
||||
|
||||
SHARED_VERSION_INFO="1:$VERSION_MINOR:0"
|
||||
|
||||
#------------------------------------------------------------------------------------
|
||||
|
||||
AC_HEADER_STDC
|
||||
|
||||
AC_CHECK_HEADERS(endian.h)
|
||||
AC_CHECK_HEADERS(byteswap.h)
|
||||
AC_CHECK_HEADERS(locale.h)
|
||||
AC_CHECK_HEADERS(sys/time.h)
|
||||
|
||||
AC_HEADER_SYS_WAIT
|
||||
|
||||
AC_CHECK_DECLS(S_IRGRP)
|
||||
if test x$ac_cv_have_decl_S_IRGRP = xyes ; then
|
||||
AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP],1,[Set to 1 if S_IRGRP is defined.])
|
||||
else
|
||||
AC_DEFINE_UNQUOTED([HAVE_DECL_S_IRGRP],0)
|
||||
fi
|
||||
|
||||
AM_CONDITIONAL([LINUX_MINGW_CROSS_TEST],
|
||||
[test "$build_os:$target_os:$host_os:$HAVE_WINE" = "linux-gnu:mingw32msvc:mingw32msvc:yes"])
|
||||
|
||||
#====================================================================================
|
||||
# Couple of initializations here. Fill in real values later.
|
||||
|
||||
SHLIB_VERSION_ARG=""
|
||||
|
||||
#====================================================================================
|
||||
# Finished checking, handle options.
|
||||
|
||||
AC_ARG_ENABLE(experimental,
|
||||
AC_HELP_STRING([--enable-experimental], [enable experimental code]))
|
||||
|
||||
EXPERIMENTAL_CODE=0
|
||||
if test x$enable_experimental = xyes ; then
|
||||
EXPERIMENTAL_CODE=1
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([ENABLE_EXPERIMENTAL_CODE],${EXPERIMENTAL_CODE}, [Set to 1 to enable experimental code.])
|
||||
|
||||
AC_ARG_ENABLE(werror,
|
||||
AC_HELP_STRING([--enable-werror], [enable -Werror in all Makefiles]))
|
||||
|
||||
AC_ARG_ENABLE(stack-smash-protection,
|
||||
AC_HELP_STRING([--enable-stack-smash-protection], [Enable GNU GCC stack smash protection]))
|
||||
|
||||
AC_ARG_ENABLE(gcc-pipe,
|
||||
AC_HELP_STRING([--disable-gcc-pipe], [disable gcc -pipe option]))
|
||||
|
||||
AC_ARG_ENABLE(gcc-opt,
|
||||
AC_HELP_STRING([--disable-gcc-opt], [disable gcc optimisations]))
|
||||
|
||||
AC_ARG_ENABLE(cpu-clip,
|
||||
AC_HELP_STRING([--disable-cpu-clip], [disable tricky cpu specific clipper]))
|
||||
|
||||
AC_ARG_ENABLE(bow-docs,
|
||||
AC_HELP_STRING([--enable-bow-docs], [enable black-on-white html docs]))
|
||||
|
||||
AC_ARG_ENABLE(sqlite,
|
||||
AC_HELP_STRING([--disable-sqlite], [disable use of sqlite]))
|
||||
|
||||
AC_ARG_ENABLE(alsa,
|
||||
AC_HELP_STRING([--disable-alsa], [disable use of ALSA]))
|
||||
|
||||
AC_ARG_ENABLE(external-libs,
|
||||
AC_HELP_STRING([--disable-external-libs], [disable use of FLAC, Ogg and Vorbis [[default=no]]]))
|
||||
|
||||
AC_ARG_ENABLE(octave,
|
||||
AC_HELP_STRING([--enable-octave], [disable building of GNU Octave module]))
|
||||
|
||||
AC_ARG_ENABLE(test-coverage,
|
||||
AC_HELP_STRING([--enable-test-coverage], [enable test coverage]))
|
||||
AM_CONDITIONAL([ENABLE_TEST_COVERAGE], [test "$enable_test_coverage" = yes])
|
||||
|
||||
#====================================================================================
|
||||
# Check types and their sizes.
|
||||
|
||||
AC_CHECK_SIZEOF(wchar_t,4)
|
||||
AC_CHECK_SIZEOF(short,2)
|
||||
AC_CHECK_SIZEOF(int,4)
|
||||
AC_CHECK_SIZEOF(long,4)
|
||||
AC_CHECK_SIZEOF(float,4)
|
||||
AC_CHECK_SIZEOF(double,4)
|
||||
AC_CHECK_SIZEOF(void*,8)
|
||||
AC_CHECK_SIZEOF(size_t,4)
|
||||
AC_CHECK_SIZEOF(int64_t,8)
|
||||
AC_CHECK_SIZEOF(long long,8)
|
||||
|
||||
#====================================================================================
|
||||
# Find an appropriate type for sf_count_t.
|
||||
# On systems supporting files larger than 2 Gig, sf_count_t must be a 64 bit value.
|
||||
# Unfortunately there is more than one way of ensuring this so need to do some
|
||||
# pretty rigourous testing here.
|
||||
|
||||
# Check for common 64 bit file offset types.
|
||||
AC_CHECK_SIZEOF(off_t,1)
|
||||
AC_CHECK_SIZEOF(loff_t,1)
|
||||
AC_CHECK_SIZEOF(off64_t,1)
|
||||
|
||||
if test "$enable_largefile:$ac_cv_sizeof_off_t" = "no:8" ; then
|
||||
echo
|
||||
echo "Error : Cannot disable large file support because sizeof (off_t) == 8."
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
case "$host_os" in
|
||||
mingw32msvc | mingw32)
|
||||
TYPEOF_SF_COUNT_T="__int64"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
AC_DEFINE([__USE_MINGW_ANSI_STDIO],1,[Set to 1 to use C99 printf/snprintf in MinGW.])
|
||||
;;
|
||||
*)
|
||||
SIZEOF_SF_COUNT_T=0
|
||||
if test "x$ac_cv_sizeof_off_t" = "x8" ; then
|
||||
# If sizeof (off_t) is 8, no further checking is needed.
|
||||
TYPEOF_SF_COUNT_T="int64_t"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
elif test "x$ac_cv_sizeof_loff_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="int64_t"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
elif test "x$ac_cv_sizeof_off64_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="int64_t"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
SIZEOF_SF_COUNT_T=8
|
||||
else
|
||||
# Save the old sizeof (off_t) value and then unset it to see if it
|
||||
# changes when Large File Support is enabled.
|
||||
pre_largefile_sizeof_off_t=$ac_cv_sizeof_off_t
|
||||
unset ac_cv_sizeof_off_t
|
||||
|
||||
AC_SYS_LARGEFILE
|
||||
|
||||
if test "x$ac_cv_sys_largefile_CFLAGS" = "xno" ; then
|
||||
ac_cv_sys_largefile_CFLAGS=""
|
||||
fi
|
||||
if test "x$ac_cv_sys_largefile_LDFLAGS" = "xno" ; then
|
||||
ac_cv_sys_largefile_LDFLAGS=""
|
||||
fi
|
||||
if test "x$ac_cv_sys_largefile_LIBS" = "xno" ; then
|
||||
ac_cv_sys_largefile_LIBS=""
|
||||
fi
|
||||
|
||||
AC_CHECK_SIZEOF(off_t,1)
|
||||
|
||||
if test "x$ac_cv_sizeof_off_t" = "x8" ; then
|
||||
TYPEOF_SF_COUNT_T="int64_t"
|
||||
SF_COUNT_MAX="0x7FFFFFFFFFFFFFFFLL"
|
||||
elif test "x$TYPEOF_SF_COUNT_T" = "xunknown" ; then
|
||||
echo
|
||||
echo "*** The configure process has determined that this system is capable"
|
||||
echo "*** of Large File Support but has not been able to find a type which"
|
||||
echo "*** is an unambiguous 64 bit file offset."
|
||||
echo "*** Please contact the author to help resolve this problem."
|
||||
echo
|
||||
AC_MSG_ERROR([[Bad file offset type.]])
|
||||
fi
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
if test $SIZEOF_SF_COUNT_T = 4 ; then
|
||||
SF_COUNT_MAX="0x7FFFFFFF"
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([TYPEOF_SF_COUNT_T],${TYPEOF_SF_COUNT_T}, [Set to long if unknown.])
|
||||
AC_SUBST(TYPEOF_SF_COUNT_T)
|
||||
|
||||
AC_DEFINE_UNQUOTED([SIZEOF_SF_COUNT_T],${SIZEOF_SF_COUNT_T}, [Set to sizeof (long) if unknown.])
|
||||
AC_SUBST(SIZEOF_SF_COUNT_T)
|
||||
|
||||
AC_DEFINE_UNQUOTED([SF_COUNT_MAX],${SF_COUNT_MAX}, [Set to maximum allowed value of sf_count_t type.])
|
||||
AC_SUBST(SF_COUNT_MAX)
|
||||
|
||||
AC_CHECK_TYPES(ssize_t)
|
||||
AC_CHECK_SIZEOF(ssize_t,4)
|
||||
|
||||
#====================================================================================
|
||||
# Determine endian-ness of target processor.
|
||||
|
||||
MN_C_FIND_ENDIAN
|
||||
|
||||
AC_DEFINE_UNQUOTED(CPU_IS_BIG_ENDIAN, ${ac_cv_c_big_endian},
|
||||
[Target processor is big endian.])
|
||||
AC_DEFINE_UNQUOTED(CPU_IS_LITTLE_ENDIAN, ${ac_cv_c_little_endian},
|
||||
[Target processor is little endian.])
|
||||
AC_DEFINE_UNQUOTED(WORDS_BIGENDIAN, ${ac_cv_c_big_endian},
|
||||
[Target processor is big endian.])
|
||||
|
||||
#====================================================================================
|
||||
# Check for functions.
|
||||
|
||||
AC_CHECK_FUNCS(malloc calloc realloc free)
|
||||
AC_CHECK_FUNCS(open read write lseek lseek64)
|
||||
AC_CHECK_FUNCS(fstat fstat64 ftruncate fsync)
|
||||
AC_CHECK_FUNCS(snprintf vsnprintf)
|
||||
AC_CHECK_FUNCS(gmtime gmtime_r localtime localtime_r gettimeofday)
|
||||
AC_CHECK_FUNCS(mmap getpagesize)
|
||||
AC_CHECK_FUNCS(setlocale)
|
||||
AC_CHECK_FUNCS(pipe waitpid)
|
||||
|
||||
AC_CHECK_LIB([m],floor)
|
||||
AC_CHECK_FUNCS(floor ceil fmod lround)
|
||||
|
||||
MN_C99_FUNC_LRINT
|
||||
MN_C99_FUNC_LRINTF
|
||||
|
||||
#====================================================================================
|
||||
# Check for requirements for building plugins for other languages/enviroments.
|
||||
|
||||
dnl Octave maths environment http://www.octave.org/
|
||||
if test x$cross_compiling = xno ; then
|
||||
if test x$enable_octave = xno ; then
|
||||
AM_CONDITIONAL(BUILD_OCTAVE_MOD, false)
|
||||
else
|
||||
AC_OCTAVE_BUILD
|
||||
fi
|
||||
else
|
||||
AM_CONDITIONAL(BUILD_OCTAVE_MOD, false)
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Check for Ogg, Vorbis and FLAC.
|
||||
|
||||
HAVE_EXTERNAL_LIBS=0
|
||||
EXTERNAL_CFLAGS=""
|
||||
EXTERNAL_LIBS=""
|
||||
|
||||
# Check for pkg-config outside the if statement.
|
||||
#PKG_PROG_PKG_CONFIG
|
||||
#m4_ifdef([PKG_INSTALLDIR], [PKG_INSTALLDIR], AC_SUBST([pkgconfigdir], ${libdir}/pkgconfig))
|
||||
|
||||
#if test -n "$PKG_CONFIG" ; then
|
||||
# if test x$enable_external_libs = xno ; then
|
||||
# AC_MSG_WARN([[*** External libs (FLAC, Ogg, Vorbis) disabled. ***]])
|
||||
# else
|
||||
# PKG_CHECK_MOD_VERSION([FLAC], [flac >= 1.2.1], [ac_cv_flac=yes], [ac_cv_flac=no])
|
||||
|
||||
# Make sure the FLAC_CFLAGS value is sane.
|
||||
# FLAC_CFLAGS=`echo $FLAC_CFLAGS | $SED "s|include/FLAC|include|"`
|
||||
|
||||
# PKG_CHECK_MOD_VERSION([OGG], [ogg >= 1.1.3], [ac_cv_ogg=yes], [ac_cv_ogg=no])
|
||||
|
||||
# if test x$enable_experimental = xyes ; then
|
||||
# PKG_CHECK_MOD_VERSION([SPEEX], [speex >= 1.2], [ac_cv_speex=yes], [ac_cv_speex=no])
|
||||
# else
|
||||
# SPEEX_CFLAGS=""
|
||||
# SPEEX_LIBS=""
|
||||
# fi
|
||||
|
||||
# Vorbis versions earlier than 1.2.3 have bugs that cause the libsndfile
|
||||
# test suite to fail on MIPS, PowerPC and others.
|
||||
# See: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=549899
|
||||
# PKG_CHECK_MOD_VERSION([VORBIS], [vorbis >= 1.2.3], [ac_cv_vorbis=yes], [ac_cv_vorbis=no])
|
||||
# PKG_CHECK_MOD_VERSION([VORBISENC], [vorbisenc >= 1.2.3], [ac_cv_vorbisenc=yes], [ac_cv_vorbisenc=no])
|
||||
# enable_external_libs=yes
|
||||
# fi
|
||||
|
||||
# if test x$ac_cv_flac$ac_cv_ogg$ac_cv_vorbis$ac_cv_vorbisenc = "xyesyesyesyes" ; then
|
||||
# HAVE_EXTERNAL_LIBS=1
|
||||
# enable_external_libs=yes
|
||||
|
||||
# EXTERNAL_CFLAGS="$FLAC_CFLAGS $OGG_CFLAGS $VORBIS_CFLAGS $VORBISENC_CFLAGS $SPEEX_CFLAGS"
|
||||
# EXTERNAL_LIBS="$FLAC_LIBS $OGG_LIBS $VORBIS_LIBS $VORBISENC_LIBS $SPEEX_LIBS "
|
||||
# else
|
||||
# echo
|
||||
# AC_MSG_WARN([[*** One or more of the external libraries (ie libflac, libogg and]])
|
||||
# AC_MSG_WARN([[*** libvorbis) is either missing (possibly only the development]])
|
||||
# AC_MSG_WARN([[*** headers) or is of an unsupported version.]])
|
||||
# AC_MSG_WARN([[***]])
|
||||
# AC_MSG_WARN([[*** Unfortunately, for ease of maintenance, the external libs]])
|
||||
# AC_MSG_WARN([[*** are an all or nothing affair.]])
|
||||
# echo
|
||||
# enable_external_libs=no
|
||||
# fi
|
||||
# fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([HAVE_EXTERNAL_LIBS], $HAVE_EXTERNAL_LIBS, [Will be set to 1 if flac, ogg and vorbis are available.])
|
||||
|
||||
#====================================================================================
|
||||
# Check for libsqlite3 (only used in regtest).
|
||||
|
||||
ac_cv_sqlite3=no
|
||||
#if test x$enable_sqlite != xno ; then
|
||||
# PKG_CHECK_MOD_VERSION([SQLITE3], [sqlite3 >= 3.2], [ac_cv_sqlite3=yes], [ac_cv_sqlite3=no])
|
||||
# fi
|
||||
|
||||
if test x$ac_cv_sqlite3 = "xyes" ; then
|
||||
HAVE_SQLITE3=1
|
||||
else
|
||||
HAVE_SQLITE3=0
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED([HAVE_SQLITE3],$HAVE_SQLITE3,[Set to 1 if you have libsqlite3.])
|
||||
|
||||
#====================================================================================
|
||||
# Determine if the processor can do clipping on float to int conversions.
|
||||
|
||||
if test x$enable_cpu_clip != "xno" ; then
|
||||
MN_C_CLIP_MODE
|
||||
else
|
||||
echo "checking processor clipping capabilities... disabled"
|
||||
ac_cv_c_clip_positive=0
|
||||
ac_cv_c_clip_negative=0
|
||||
fi
|
||||
|
||||
AC_DEFINE_UNQUOTED(CPU_CLIPS_POSITIVE, ${ac_cv_c_clip_positive},
|
||||
[Target processor clips on positive float to int conversion.])
|
||||
AC_DEFINE_UNQUOTED(CPU_CLIPS_NEGATIVE, ${ac_cv_c_clip_negative},
|
||||
[Target processor clips on negative float to int conversion.])
|
||||
|
||||
#====================================================================================
|
||||
# Target OS specific stuff.
|
||||
|
||||
OS_SPECIFIC_CFLAGS=""
|
||||
OS_SPECIFIC_LINKS=""
|
||||
os_is_win32=0
|
||||
use_windows_api=0
|
||||
osx_darwin_version=0
|
||||
|
||||
case "$host_os" in
|
||||
darwin* | rhapsody*)
|
||||
osx_darwin_version=$(echo "$host_os" | sed 's/\..*//;s/darwin//g')
|
||||
if test x$HAVE_XCODE_SELECT = xyes ; then
|
||||
developer_path=`xcode-select --print-path`
|
||||
else
|
||||
developer_path="/Developer"
|
||||
fi
|
||||
OS_SPECIFIC_CFLAGS="-I${developer_path}/Headers/FlatCarbon"
|
||||
OS_SPECIFIC_LINKS="-framework CoreAudio -framework AudioToolbox -framework CoreFoundation"
|
||||
;;
|
||||
mingw*)
|
||||
os_is_win32=1
|
||||
use_windows_api=1
|
||||
OS_SPECIFIC_LINKS="-lwinmm"
|
||||
;;
|
||||
esac
|
||||
|
||||
AC_DEFINE_UNQUOTED(OS_IS_WIN32, ${os_is_win32}, [Set to 1 if compiling for Win32])
|
||||
AC_DEFINE_UNQUOTED(USE_WINDOWS_API, ${use_windows_api}, [Set to 1 to use the native windows API])
|
||||
AC_DEFINE_UNQUOTED(OSX_DARWIN_VERSION, ${osx_darwin_version}, [The darwin version, no-zero is valid])
|
||||
AM_CONDITIONAL(USE_WIN_VERSION_FILE, test ${use_windows_api} -eq 1)
|
||||
|
||||
#====================================================================================
|
||||
# Check for ALSA.
|
||||
|
||||
ALSA_LIBS=""
|
||||
|
||||
if test x$enable_alsa != xno ; then
|
||||
AC_CHECK_HEADERS(alsa/asoundlib.h)
|
||||
if test x$ac_cv_header_alsa_asoundlib_h = xyes ; then
|
||||
ALSA_LIBS="-lasound"
|
||||
enable_alsa=yes
|
||||
fi
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Check for OpenBSD's sndio.
|
||||
|
||||
SNDIO_LIBS=""
|
||||
AC_CHECK_HEADERS(sndio.h)
|
||||
if test x$ac_cv_header_sndio_h = xyes ; then
|
||||
SNDIO_LIBS="-lsndio"
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Test for sanity when cross-compiling.
|
||||
|
||||
if test $ac_cv_sizeof_short != 2 ; then
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
AC_MSG_WARN([[*** sizeof (short) != 2. ]])
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
fi
|
||||
|
||||
if test $ac_cv_sizeof_int != 4 ; then
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
AC_MSG_WARN([[*** sizeof (int) != 4 ]])
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
fi
|
||||
|
||||
if test $ac_cv_sizeof_float != 4 ; then
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
AC_MSG_WARN([[*** sizeof (float) != 4. ]])
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
fi
|
||||
|
||||
if test $ac_cv_sizeof_double != 8 ; then
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
AC_MSG_WARN([[*** sizeof (double) != 8. ]])
|
||||
AC_MSG_WARN([[******************************************************************]])
|
||||
fi
|
||||
|
||||
if test x"$ac_cv_prog_HAVE_AUTOGEN" = "xno" ; then
|
||||
AC_MSG_WARN([[Touching files in directory tests/.]])
|
||||
touch tests/*.c tests/*.h
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Settings for the HTML documentation.
|
||||
|
||||
if test x$enable_bow_docs = "xyes" ; then
|
||||
HTML_BGCOLOUR="white"
|
||||
HTML_FGCOLOUR="black"
|
||||
else
|
||||
HTML_BGCOLOUR="black"
|
||||
HTML_FGCOLOUR="white"
|
||||
fi
|
||||
|
||||
#====================================================================================
|
||||
# Now use the information from the checking stage.
|
||||
|
||||
win32_target_dll=0
|
||||
COMPILER_IS_GCC=0
|
||||
|
||||
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
MN_ADD_CFLAGS(-std=gnu99)
|
||||
|
||||
MN_GCC_VERSION
|
||||
|
||||
if test "x$GCC_MAJOR_VERSION$GCC_MINOR_VERSION" = "x42" ; then
|
||||
AC_MSG_WARN([****************************************************************])
|
||||
AC_MSG_WARN([** GCC version 4.2 warns about the inline keyword for no good **])
|
||||
AC_MSG_WARN([** reason but the maintainers do not see it as a bug. **])
|
||||
AC_MSG_WARN([** See http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33995 **])
|
||||
AC_MSG_WARN([** Using -fgnu-inline to avoid this stupidity. **])
|
||||
AC_MSG_WARN([****************************************************************])
|
||||
MN_ADD_CFLAGS([-fgnu89-inline])
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS -Wall"
|
||||
CXXFLAGS="$CXXFLAGS -Wall"
|
||||
|
||||
MN_ADD_CFLAGS([-Wextra])
|
||||
|
||||
AC_LANG_PUSH([C++])
|
||||
MN_ADD_CXXFLAGS([-Wextra])
|
||||
AC_LANG_POP([C++])
|
||||
|
||||
MN_ADD_CFLAGS([-Wdeclaration-after-statement])
|
||||
MN_ADD_CFLAGS([-Wpointer-arith])
|
||||
MN_ADD_CFLAGS([-funsigned-char])
|
||||
|
||||
MN_ADD_CFLAGS([-D_FORTIFY_SOURCE=2])
|
||||
|
||||
if test x$enable_stack_smash_protection = "xyes" ; then
|
||||
XIPH_GCC_STACK_PROTECTOR
|
||||
XIPH_GXX_STACK_PROTECTOR
|
||||
fi
|
||||
|
||||
if test x$enable_test_coverage = "xyes" ; then
|
||||
# MN_ADD_CFLAGS([-ftest-coverage])
|
||||
MN_ADD_CFLAGS([-coverage])
|
||||
fi
|
||||
|
||||
CFLAGS="$CFLAGS -Wcast-align -Wcast-qual -Wshadow -Wbad-function-cast -Wwrite-strings -Wundef -Wuninitialized -Winit-self -Wnested-externs -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Waggregate-return"
|
||||
# -Winline -Wconversion -Wunreachable-code"
|
||||
CXXFLAGS="$CXXFLAGS -Wcast-align -Wcast-qual -Wshadow -Wwrite-strings -Wctor-dtor-privacy -Wnon-virtual-dtor -Woverloaded-virtual -Wreorder -Wsign-promo -Wundef -Wuninitialized -Winit-self"
|
||||
|
||||
if test "x$enable_gcc_opt" = "xno" ; then
|
||||
temp_CFLAGS=`echo $CFLAGS | $SED "s/O2/O0/"`
|
||||
CFLAGS=$temp_CFLAGS
|
||||
AC_MSG_WARN([[*** Compiler optimisations switched off. ***]])
|
||||
fi
|
||||
|
||||
# OS specific tweaks.
|
||||
case "$host_os" in
|
||||
darwin* | rhapsody*)
|
||||
# Disable -Wall, -pedantic and -Wshadow for Apple Darwin/Rhapsody.
|
||||
# System headers on these systems are broken.
|
||||
temp_CFLAGS=`echo $CFLAGS | $SED "s/-Wall -pedantic//" | $SED "s/-Wshadow//" | $SED "s/-Waggregate-return//"`
|
||||
CFLAGS=$temp_CFLAGS
|
||||
SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(builddir)/Symbols.darwin"
|
||||
;;
|
||||
linux*|kfreebsd*-gnu*|gnu*)
|
||||
SHLIB_VERSION_ARG="-Wl,--version-script=\$(builddir)/Symbols.gnu-binutils"
|
||||
;;
|
||||
mingw*)
|
||||
# Linker flag '-Wl,--out-implib' does not work with mingw cross compiler
|
||||
# so we don't use it here.
|
||||
SHLIB_VERSION_ARG="-Wl,\$(builddir)/libsndfile-1.def"
|
||||
win32_target_dll=1
|
||||
if test x"$enable_shared" = xno ; then
|
||||
win32_target_dll=0
|
||||
fi
|
||||
;;
|
||||
os2*)
|
||||
SHLIB_VERSION_ARG="-Wl,-export-symbols \$(builddir)/Symbols.os2"
|
||||
;;
|
||||
*)
|
||||
;;
|
||||
esac
|
||||
if test x$enable_gcc_pipe != "xno" ; then
|
||||
CFLAGS="$CFLAGS -pipe"
|
||||
fi
|
||||
|
||||
COMPILER_IS_GCC=1
|
||||
fi
|
||||
|
||||
if test x$enable_werror = "xyes" ; then
|
||||
MN_ADD_CFLAGS([-Werror])
|
||||
|
||||
AC_LANG_PUSH([C++])
|
||||
MN_ADD_CXXFLAGS([-Werror])
|
||||
AC_LANG_POP([C++])
|
||||
fi
|
||||
|
||||
|
||||
AC_DEFINE_UNQUOTED([WIN32_TARGET_DLL], ${win32_target_dll}, [Set to 1 if windows DLL is being built.])
|
||||
AC_DEFINE_UNQUOTED([COMPILER_IS_GCC], ${COMPILER_IS_GCC}, [Set to 1 if the compile is GNU GCC.])
|
||||
|
||||
CFLAGS="$CFLAGS $OS_SPECIFIC_CFLAGS"
|
||||
|
||||
if test x"$CFLAGS" = x ; then
|
||||
echo "Error in configure script. CFLAGS has been screwed up."
|
||||
exit
|
||||
fi
|
||||
|
||||
HOST_TRIPLET="${host_cpu}-${host_vendor}-${host_os}"
|
||||
|
||||
AC_DEFINE_UNQUOTED([HOST_TRIPLET], "${HOST_TRIPLET}", [The host triplet of the compiled binary.])
|
||||
|
||||
if test "$HOST_TRIPLET" = "x86_64-w64-mingw32" ; then
|
||||
OS_SPECIFIC_LINKS=" -static-libgcc $OS_SPECIFIC_LINKS"
|
||||
fi
|
||||
|
||||
WIN_RC_VERSION=`echo $PACKAGE_VERSION | $SED -e "s/p.*//" -e "s/\./,/g"`
|
||||
|
||||
|
||||
if test "$enable_static" = no ; then
|
||||
SRC_BINDIR=src/.libs/
|
||||
TEST_BINDIR=tests/.libs/
|
||||
else
|
||||
SRC_BINDIR=src/
|
||||
TEST_BINDIR=tests/
|
||||
fi
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
AC_SUBST(HOST_TRIPLET)
|
||||
|
||||
AC_SUBST(HTML_BGCOLOUR)
|
||||
AC_SUBST(HTML_FGCOLOUR)
|
||||
|
||||
AC_SUBST(SHLIB_VERSION_ARG)
|
||||
AC_SUBST(SHARED_VERSION_INFO)
|
||||
AC_SUBST(CLEAN_VERSION)
|
||||
AC_SUBST(WIN_RC_VERSION)
|
||||
|
||||
AC_SUBST(OS_SPECIFIC_CFLAGS)
|
||||
AC_SUBST(OS_SPECIFIC_LINKS)
|
||||
AC_SUBST(ALSA_LIBS)
|
||||
AC_SUBST(SNDIO_LIBS)
|
||||
|
||||
AC_SUBST(EXTERNAL_CFLAGS)
|
||||
AC_SUBST(EXTERNAL_LIBS)
|
||||
AC_SUBST(SRC_BINDIR)
|
||||
AC_SUBST(TEST_BINDIR)
|
||||
|
||||
dnl The following line causes the libtool distributed with the source
|
||||
dnl to be replaced if the build system has a more recent version.
|
||||
AC_SUBST(LIBTOOL_DEPS)
|
||||
|
||||
AC_CONFIG_FILES([ \
|
||||
src/Makefile man/Makefile examples/Makefile tests/Makefile regtest/Makefile \
|
||||
M4/Makefile Win32/Makefile Octave/Makefile programs/Makefile \
|
||||
Makefile \
|
||||
src/version-metadata.rc tests/test_wrapper.sh tests/pedantic-header-test.sh \
|
||||
doc/libsndfile.css Scripts/build-test-tarball.mk libsndfile.spec sndfile.pc \
|
||||
src/sndfile.h \
|
||||
echo-install-dirs
|
||||
])
|
||||
AC_OUTPUT
|
||||
|
||||
# Make sure these are executable.
|
||||
chmod u+x tests/test_wrapper.sh build-test-tarball.mk echo-install-dirs
|
||||
|
||||
#====================================================================================
|
||||
|
||||
AC_MSG_RESULT([
|
||||
-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
Configuration summary :
|
||||
|
||||
libsndfile version : .................. ${VERSION}
|
||||
|
||||
Host CPU : ............................ ${host_cpu}
|
||||
Host Vendor : ......................... ${host_vendor}
|
||||
Host OS : ............................. ${host_os}
|
||||
|
||||
Experimental code : ................... ${enable_experimental:-no}
|
||||
Using ALSA in example programs : ...... ${enable_alsa:-no}
|
||||
External FLAC/Ogg/Vorbis : ............ ${enable_external_libs:-no}
|
||||
])
|
||||
|
||||
if test -z "$PKG_CONFIG" ; then
|
||||
echo " *****************************************************************"
|
||||
echo " *** The pkg-config program is missing. ***"
|
||||
echo " *** External FLAC/Ogg/Vorbis libs cannot be found without it. ***"
|
||||
echo " *** http://pkg-config.freedesktop.org/wiki/ ***"
|
||||
echo " *****************************************************************"
|
||||
echo
|
||||
fi
|
||||
|
||||
echo " Tools :"
|
||||
echo
|
||||
echo " Compiler is Clang : ................... ${mn_cv_c_compiler_clang}"
|
||||
echo " Compiler is GCC : ..................... ${ac_cv_c_compiler_gnu}"
|
||||
|
||||
if test x$ac_cv_c_compiler_gnu = xyes ; then
|
||||
echo " GCC version : ......................... ${GCC_VERSION}"
|
||||
if test $GCC_MAJOR_VERSION -lt 3 ; then
|
||||
echo "\n"
|
||||
echo " ** This compiler version allows applications to write"
|
||||
echo " ** to static strings within the library."
|
||||
echo " ** Compile with GCC version 3.X or above to avoid this problem."
|
||||
fi
|
||||
fi
|
||||
|
||||
./echo-install-dirs
|
||||
|
||||
# Remove symlink created by Scripts/android-configure.sh.
|
||||
test -h gdbclient && rm -f gdbclient
|
||||
|
||||
(cd src && make genfiles)
|
|
@ -1,4 +0,0 @@
|
|||
#!/bin/sh
|
||||
srcpath=$(dirname $0 2>/dev/null ) || srcpath="."
|
||||
$srcpath/configure "$@" --disable-sqlite --disable-shared --with-pic --disable-octave --disable-external-libs
|
||||
|
|
@ -1,851 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile : Frequently Asked Questions.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Description" CONTENT="The libsndfile FAQ.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<H1><B>libsndfile : Frequently Asked Questions.</B></H1>
|
||||
<P>
|
||||
<A HREF="#Q001">Q1 : Do you plan to support XYZ codec in libsndfile?</A><BR/>
|
||||
<A HREF="#Q002">Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
|
||||
but version 1 does not. Why?</A><BR/>
|
||||
<A HREF="#Q003">Q3 : Compiling is really slow on MacOS X. Why?</A><BR/>
|
||||
<A HREF="#Q004">Q4 : When trying to compile libsndfile on Solaris I get a "bad
|
||||
substitution" error during linking. What can I do to fix this?</A><BR/>
|
||||
<A HREF="#Q005">Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</A><BR/>
|
||||
<A HREF="#Q006">Q6 : What's the best format for storing temporary files?</A><BR/>
|
||||
<A HREF="#Q007">Q7 : On Linux/Unix/MacOS X, what's the best way of detecting the
|
||||
presence of libsndfile?</A><BR/>
|
||||
<A HREF="#Q008">Q8 : I have libsndfile installed and now I want to use it. I
|
||||
just want a simple Makefile! What do I do?</A><BR/>
|
||||
<A HREF="#Q009">Q9 : How about adding the ability to write/read sound files to/from
|
||||
memory buffers?</A><BR/>
|
||||
<A HREF="#Q010">Q10 : Reading a 16 bit PCM file as normalised floats and then
|
||||
writing them back changes some sample values. Why?</A><BR/>
|
||||
<A HREF="#Q011">Q11 : I'm having problems with u-law encoded WAV files generated by
|
||||
libsndfile in Winamp. Why?</A><BR/>
|
||||
<A HREF="#Q012">Q12 : I'm looking at sf_read*. What are items? What are frames?</A><BR/>
|
||||
<A HREF="#Q013">Q13 : Why can't libsndfile open this Sound Designer II (SD2)
|
||||
file?</A><BR/>
|
||||
<A HREF="#Q014">Q14 : I'd like to statically link libsndfile to my closed source
|
||||
application. Can I buy a license so that this is possible?</A><BR/>
|
||||
<A HREF="#Q015">Q15 : My program is crashing during a call to a function in libsndfile.
|
||||
Is this a bug in libsndfile?</A><BR/>
|
||||
<A HREF="#Q016">Q16 : Will you accept a fix for compiling libsndfile with compiler X?
|
||||
</A><BR/>
|
||||
<A HREF="#Q017">Q17 : Can libsndfile read/write files from/to UNIX pipes?
|
||||
</A><BR/>
|
||||
<A HREF="#Q018">Q18 : Is it possible to build a Universal Binary on Mac OS X?
|
||||
</A><BR/>
|
||||
<A HREF="#Q019">Q19 : I have project files for Visual Studio / XCode / Whatever. Why
|
||||
don't you distribute them with libsndfile?
|
||||
</A><BR/>
|
||||
<A HREF="#Q020">Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
|
||||
projects support it!
|
||||
</A><BR/>
|
||||
<A HREF="#Q021">Q21 : How do I use libsndfile in a closed source or commercial program
|
||||
and comply with the license?
|
||||
</A><BR/>
|
||||
<A HREF="#Q022">Q22 : What versions of windows does libsndfile work on?
|
||||
</A><BR/>
|
||||
<A HREF="#Q023">Q23 : I'm cross compiling libsndfile for another platform. How can I
|
||||
run the test suite?
|
||||
</A><BR/>
|
||||
<HR>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q001"></A>
|
||||
<H2><BR/><B>Q1 : Do you plan to support XYZ codec in libsndfile?</B></H2>
|
||||
<P>
|
||||
If source code for XYZ codec is available under a suitable license (LGPL, BSD,
|
||||
MIT etc) then yes, I'd like to add it.
|
||||
</P>
|
||||
<P>
|
||||
If suitable documentation is available on how to decode and encode the format
|
||||
then maybe, depending on how much work is involved.
|
||||
</P>
|
||||
<P>
|
||||
If XYZ is some proprietary codec where no source code or documentation is
|
||||
available then no.
|
||||
</P>
|
||||
<P>
|
||||
So if you want support for XYZ codec, first find existing source code or
|
||||
documentation.
|
||||
If you can't find either then the answer is no.
|
||||
</P>
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q002"></A>
|
||||
<H2><BR/><B>Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
|
||||
but version 1 does not. Why?</B></H2>
|
||||
<P>
|
||||
This was dropped for a number of reasons:
|
||||
</P>
|
||||
<UL>
|
||||
<LI> pcmbitwidth makes little sense on compressed or floating point formats
|
||||
<LI> with the new API you really don't need to know it
|
||||
</UL>
|
||||
<P>
|
||||
As documented
|
||||
<A HREF="api.html#note1">here</A>
|
||||
there is now a well defined behaviour which ensures that no matter what the
|
||||
bit width of the source file, the scaling always does something sensible.
|
||||
This makes it safe to read 8, 16, 24 and 32 bit PCM files using sf_read_short()
|
||||
and always have the optimal behaviour.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q003"></A>
|
||||
<H2><BR/><B>Q3 : Compiling is really slow on MacOS X. Why?</B></H2>
|
||||
<P>
|
||||
When you configure and compile libsndfile, it uses the /bin/sh shell for a number
|
||||
of tasks (ie configure script and libtool).
|
||||
Older versions of OS X (10.2?) shipped a really crappy Bourne shell as /bin/sh
|
||||
which resulted in <b>really</b> slow compiles.
|
||||
Newer version of OS X ship GNU Bash as /bin/sh and this answer doesn't apply in that
|
||||
case.
|
||||
</P>
|
||||
<P>
|
||||
To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
|
||||
/bin/sh.old and make a symlink from /bin/sh to the bash shell.
|
||||
Bash is designed to behave as a Bourne shell when is is called as /bin/sh.
|
||||
</P>
|
||||
<P>
|
||||
When I did this on my iBook running MacOS X, compile times dropped from 13 minutes
|
||||
to 3 minutes.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q004"></A>
|
||||
<H2><BR/><B>Q4 : When trying to compile libsndfile on Solaris I get a "bad
|
||||
substitution" error on linking. Why?</B></H2>
|
||||
<P>
|
||||
It seems that the Solaris Bourne shell disagrees with GNU libtool.
|
||||
</P>
|
||||
<P>
|
||||
To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
|
||||
/bin/sh.old and make a symlink from /bin/sh to the bash shell.
|
||||
Bash is designed to behave as a Bourne shell when is is called as /bin/sh.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q005"></A>
|
||||
<H2><BR/><B>Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</B></H2>
|
||||
<P>
|
||||
This problem is bigger than it may seem at first.
|
||||
</P>
|
||||
<P>
|
||||
For a stereo file, it is a pretty safe bet that a simple interleaving/de-interleaving
|
||||
could satisfy most users.
|
||||
However, for files with more than 2 channels this is unlikely to be the case.
|
||||
If the user has a 4 channel file and want to play that file on a stereo output
|
||||
sound card they either want the first 2 channels or they want some mixed combination
|
||||
of the 4 channels.
|
||||
</P>
|
||||
<P>
|
||||
When you add more channels, the combinations grow exponentially and it becomes
|
||||
increasingly difficult to cover even a sensible subset of the possible combinations.
|
||||
On top of that, coding any one style of interleaver/de-interleaver is trivial, while
|
||||
coding one that can cover all combinations is far from trivial.
|
||||
This means that this feature will not be added any time soon.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q006"></A>
|
||||
<H2><BR/><B>Q6 : What's the best format for storing temporary files?</B></H2>
|
||||
|
||||
<P>
|
||||
When you want to store temporary data there are a number of requirements;
|
||||
</P>
|
||||
<UL>
|
||||
<LI> A simple, easy to parse header.
|
||||
<LI> The format must provide the fastest possible read and write rates (ie
|
||||
avoid conversions and encoding/decoding).
|
||||
<LI> The file format must be reasonably common and playable by most players.
|
||||
<LI> Able to store data in either endian-ness.
|
||||
</UL>
|
||||
<P>
|
||||
The format which best meets these requirements is AU, which allows data to be
|
||||
stored in any one of short, int, float and double (among others) formats.
|
||||
</P>
|
||||
<P>
|
||||
For instance, if an application uses float data internally, its temporary files
|
||||
should use a format of (SF_ENDIAN_CPU | SF_FORMAT_AU | SF_FORMAT_FLOAT) which
|
||||
will store big endian float data in big endian CPUs and little endian float data
|
||||
on little endian CPUs.
|
||||
Reading and writing this format will not require any conversions or byte swapping
|
||||
regardless of the host CPU.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q007"></A>
|
||||
<H2><BR/><B>Q7 : On Linux/Unix/MaxOS X, what's the best way of detecting the presence
|
||||
of libsndfile using autoconf?</B></H2>
|
||||
|
||||
<P>
|
||||
libsndfile uses the pkg-config (man pkg-config) method of registering itself with the
|
||||
host system.
|
||||
The best way of detecting its presence is using something like this in configure.ac
|
||||
(or configure.in):
|
||||
</P>
|
||||
<PRE>
|
||||
PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.2, ac_cv_sndfile=1, ac_cv_sndfile=0)
|
||||
|
||||
AC_DEFINE_UNQUOTED([HAVE_SNDFILE],${ac_cv_sndfile},
|
||||
[Set to 1 if you have libsndfile.])
|
||||
|
||||
AC_SUBST(SNDFILE_CFLAGS)
|
||||
AC_SUBST(SNDFILE_LIBS)
|
||||
</PRE>
|
||||
<P>
|
||||
This will automatically set the <B>SNDFILE_CFLAGS</B> and <B>SNDFILE_LIBS</B>
|
||||
variables which can be used in Makefile.am like this:
|
||||
</P>
|
||||
<PRE>
|
||||
SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
|
||||
SNDFILE_LIBS = @SNDFILE_LIBS@
|
||||
</PRE>
|
||||
<P>
|
||||
If you install libsndfile from source, you will probably need to set the
|
||||
<B>PKG_CONFIG_PATH</B> environment variable as suggested at the end of the
|
||||
libsndfile configure process. For instance on my system I get this:
|
||||
</P>
|
||||
<PRE>
|
||||
-=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
|
||||
|
||||
Configuration summary :
|
||||
|
||||
Version : ..................... 1.0.5
|
||||
Experimental code : ........... no
|
||||
|
||||
Tools :
|
||||
|
||||
Compiler is GCC : ............. yes
|
||||
GCC major version : ........... 3
|
||||
|
||||
Installation directories :
|
||||
|
||||
Library directory : ........... /usr/local/lib
|
||||
Program directory : ........... /usr/local/bin
|
||||
Pkgconfig directory : ......... /usr/local/lib/pkgconfig
|
||||
|
||||
Compiling some other packages against libsndfile may require
|
||||
the addition of "/usr/local/lib/pkgconfig" to the
|
||||
PKG_CONFIG_PATH environment variable.
|
||||
</PRE>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q008"></A>
|
||||
<H2><BR/><B>Q8 : I have libsndfile installed and now I want to use it. I just want
|
||||
a simple Makefile! What do I do?</B></H2>
|
||||
|
||||
<P>
|
||||
The <B>pkg-config</B> program makes finding the correct compiler flag values and
|
||||
library location far easier.
|
||||
During the installation of libsndfile, a file named <B>sndfile.pc</B> is installed
|
||||
in the directory <B>${libdir}/pkgconfig</B> (ie if libsndfile is installed in
|
||||
<B>/usr/local/lib</B>, <B>sndfile.pc</B> will be installed in
|
||||
<B>/usr/local/lib/pkgconfig/</B>).
|
||||
</P>
|
||||
<P>
|
||||
In order for pkg-config to find sndfile.pc it may be necessary to point the
|
||||
environment variable <B>PKG_CONFIG_PATH</B> in the right direction.
|
||||
</P>
|
||||
<PRE>
|
||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Then, to compile a C file into an object file, the command would be:
|
||||
</P>
|
||||
<PRE>
|
||||
gcc `pkg-config --cflags sndfile` -c somefile.c
|
||||
</PRE>
|
||||
<P>
|
||||
and to link a number of objects into an executable that links against libsndfile,
|
||||
the command would be:
|
||||
</P>
|
||||
<PRE>
|
||||
gcc `pkg-config --libs sndfile` obj1.o obj2.o -o program
|
||||
</PRE>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q009"></A>
|
||||
<H2><BR/><B>Q9 : How about adding the ability to write/read sound files to/from
|
||||
memory buffers?</B></H2>
|
||||
|
||||
<P>
|
||||
This has been added for version 1.0.13.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q010"></A>
|
||||
<H2><BR/><B>Q10 : Reading a 16 bit PCM file as normalised floats and then
|
||||
writing them back changes some sample values. Why?</B></H2>
|
||||
|
||||
<P>
|
||||
This is caused by the fact that the conversion from 16 bit short to float is
|
||||
done by dividing by 32768 (0x8000 in hexadecimal) while the conversion from
|
||||
float to 16 bit short is done by multiplying by 32767 (0x7FFF in hex).
|
||||
So for instance, a value in a 16 bit PCM file of 20000 gets read as a floating
|
||||
point number of 0.6103515625 (20000.0 / 0x8000).
|
||||
Converting that back to a 16 bit short results in a value of 19999.3896484375
|
||||
(0.6103515625 * 0x7FFF) which then gets rounded down to 19999.
|
||||
</P>
|
||||
<P>
|
||||
You will notice that for this particular case, the error is 1 in 20000 or
|
||||
0.005%.
|
||||
Interestingly, for values of less than 16369, dividing by 0x8000 followed
|
||||
by multiplying by 0x7FFF and then rounding the result, gives back the
|
||||
original value.
|
||||
It turns out that as long as the host operating system supplies the 1999 ISO
|
||||
C Standard functions <B>lrintf</B> and <B>lrint</B> (or a replacement has
|
||||
been supplied) then the maximum possible error is 1 in 16369 or about 0.006%.
|
||||
</P>
|
||||
<P>
|
||||
Regardless of the size of the error, the reason why this is done is rather
|
||||
subtle.
|
||||
</P>
|
||||
<P>
|
||||
In a file containing 16 bit PCM samples, the values are restricted to the range
|
||||
[-32768, 32767] while we want floating point values in the range [-1.0, 1.0].
|
||||
The only way to do this conversion is to do a floating point division by a value
|
||||
of 0x8000.
|
||||
Converting the other way, the only way to ensure that floating point values in
|
||||
the range [-1.0, 1.0] are within the valid range allowed by a 16 bit short is
|
||||
to multiply by 0x7FFF.
|
||||
</P>
|
||||
<P>
|
||||
Some people would say that this is a severe short-coming of libsndfile.
|
||||
I would counter that anybody who is constantly converting back and forth
|
||||
between 16 bit shorts and normalised floats is going to suffer other losses
|
||||
in audio quality that they should also be concerned about.
|
||||
</P>
|
||||
<P>
|
||||
Since this problem only occurs when converting between integer data on disk and
|
||||
normalized floats in the application, it can be avoided by using something
|
||||
other than normalized floats in the application.
|
||||
Alternatives to normalized floats are the <b>short</b> and <b>int</b> data
|
||||
types (ie using sf_read_short or sf_read_int) or using un-normalized floats
|
||||
(see
|
||||
<a href="command.html#SFC_SET_NORM_FLOAT">
|
||||
SFC_SET_NORM_FLOAT</a>).
|
||||
</P>
|
||||
<P>
|
||||
Another way to deal with this problem is to consider 16 bit short data as a
|
||||
final destination format only, not as an intermediate storage format.
|
||||
All intermediate data (ie which is going to be processed further) should be
|
||||
stored in floating point format which is supported by all of the most common
|
||||
file formats.
|
||||
If floating point files are considered too large (2 times the size of a 16 bit
|
||||
PCM file), it would also be possible to use 24 bit PCM as an intermediate
|
||||
storage format (and which is also supported by most common file types).
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q011"></A>
|
||||
<H2><BR/><B>Q11 : I'm having problems with u-law encoded WAV files generated by
|
||||
libsndfile in Winamp. Why?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
This is actually a Winamp problem.
|
||||
The official Microsoft spec suggests that the 'fmt ' chunk should be 18 bytes.
|
||||
Unfortunately at least one of Microsoft's own applications (Sound Recorder on
|
||||
Win98 I believe) did not accept 18 bytes 'fmt ' chunks.
|
||||
</P>
|
||||
<P>
|
||||
Michael Lee did some experimenting and found that:
|
||||
</P>
|
||||
<PRE>
|
||||
I have checked that Windows Media Player 9, QuickTime Player 6.4,
|
||||
RealOne Player 2.0 and GoldWave 5.06 can all play u-law files with
|
||||
16-byte or 18-byte 'fmt ' chunk. Only Winamp (2.91) and foobar2000
|
||||
are unable to play u-law files with 16-byte 'fmt ' chunk.
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Even this is a very small sampling of all the players out there.
|
||||
For that reason it is probably not a good idea to change this now because there
|
||||
is the risk of breaking something that currently works.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q012"></A>
|
||||
<H2><BR/><B>Q12 : I'm looking at sf_read*. What are items? What are frames?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
An <tt>item</tt> is a single sample of the data type you are reading; ie a
|
||||
single <tt>short</tt> value for <tt>sf_read_short</tt> or a single <tt>float</tt>
|
||||
for <tt>sf_read_float</tt>.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
For a sound file with only one channel, a frame is the same as a item (ie a
|
||||
single sample) while for multi channel sound files, a single frame contains a
|
||||
single item for each channel.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Here are two simple, correct examples, both of which are assumed to be working
|
||||
on a stereo file, first using items:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
#define CHANNELS 2
|
||||
short data [CHANNELS * 100] ;
|
||||
sf_count items_read = sf_read_short (file, data, 200) ;
|
||||
assert (items_read == 200) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
and now readng the exact same amount of data using frames:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
#define CHANNELS 2
|
||||
short data [CHANNELS * 100] ;
|
||||
sf_count frames_read = sf_readf_short (file, data, 100) ;
|
||||
assert (frames_read == 100) ;
|
||||
</PRE>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<A NAME="Q013"></A>
|
||||
<H2><BR/><B>Q13 : Why can't libsndfile open this Sound Designer II (SD2) file?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
This is somewhat complicated.
|
||||
First some background.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
SD2 files are native to the Apple Macintosh platform and use features of
|
||||
the Mac filesystem (file resource forks) to store the file's sample rate,
|
||||
number of channels, sample width and more.
|
||||
When you look at a file and its resource fork on Mac OS X it looks like
|
||||
this:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
-rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2
|
||||
-rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 file.sd2/rsrc
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Notice how the file itself looks like a directory containing a single file
|
||||
named <B>rsrc</B>.
|
||||
When libsndfile is compiled for MacOS X, it should open (for write and read)
|
||||
SD2 file with resource forks like this without any problems.
|
||||
It will also handle files with the resource fork in a separate file as
|
||||
described below.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
When SD2 files are moved to other platforms, the resource fork of the file
|
||||
can sometimes be dropped altogether.
|
||||
All that remains is the raw audio data and no information about the number
|
||||
of channels, sample rate or bit width which makes it a little difficult for
|
||||
libsndfile to open the file.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
However, it is possible to safely move an SD2 file to a Linux or Windows
|
||||
machine.
|
||||
For instance, when an SD2 file is copied from inside MacOS X to a windows
|
||||
shared directory or a Samba share (ie Linux), MacOS X is clever enough to
|
||||
store the resource fork of the file in a separate hidden file in the
|
||||
same directory like this:
|
||||
</P>
|
||||
<PRE>
|
||||
-rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 ._file.sd2
|
||||
-rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Regardless of what platform it is running on, when libsndfile is asked to
|
||||
open a file named <B>"foo"</B> and it can't recognize the file type from
|
||||
the data in the file, it will attempt to open the resource fork and if
|
||||
that fails, it then tries to open a file named <B>"._foo"</B> to see if
|
||||
the file has a valid resource fork.
|
||||
This is the same regardless of whether the file is being opened for read
|
||||
or write.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
In short, libsndfile should open SD2 files with a valid resource fork on
|
||||
all of the platforms that libsndfile supports.
|
||||
If a file has lost its resource fork, the only option is the open the file
|
||||
using the SF_FORMAT_RAW option and guessing its sample rate, channel count
|
||||
and bit width.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Occasionally, when SD2 files are moved to other systems, the file is
|
||||
<A HREF="http://www.macdisk.com/binhexen.php3">BinHexed</A>
|
||||
which wraps the resource fork and the data fork together.
|
||||
For these files, it would be possible to write a BinHex parser but
|
||||
there is not a lot to gain considering how rare these BinHexed SD2
|
||||
files are.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q014"></A>
|
||||
<H2><BR/><B>Q14 : I'd like to statically link libsndfile to my closed source
|
||||
application. Can I buy a license so that this is possible?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
Unfortunately no.
|
||||
libsndfile contains code written by other people who have agreed that their
|
||||
code be used under the GNU LGPL but no more.
|
||||
Even if they were to agree, there would be significant difficulties in
|
||||
dividing up the payments fairly.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The <B>only</B> way you can legally use libsndfile as a statically linked
|
||||
library is if your application is released under the GNU GPL or LGPL.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q015"></A>
|
||||
<H2><BR/><B>Q15 : My program is crashing during a call to a function in libsndfile.
|
||||
Is this a bug in libsndfile?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
libsndfile is being used by large numbers of people all over the world
|
||||
without any problems like this. That means that it is much more likely
|
||||
that your code has a bug than libsndfile. However, it is still possible
|
||||
that there is a bug in libsndfile.
|
||||
</P>
|
||||
<P>
|
||||
To figure out whether it is your code or libsndfile you should do the
|
||||
following:
|
||||
</P>
|
||||
<UL>
|
||||
<LI>Make sure you are compiling your code with warnings switched on and
|
||||
that you fix as many warnings as possible.
|
||||
With the GNU compiler (gcc) I would recommend at least
|
||||
<B>-W -Wall -Werror</B> which will force you to fix all warnings
|
||||
before you can run the code.
|
||||
<LI>Try using a memory debugger.
|
||||
<A HREF="http://valgrind.kde.org/">Valgrind</A> on x86 Linux is excellent.
|
||||
<A HREF="http://www.ibm.com/software/awdtools/purify/">Purify</A> also
|
||||
has a good reputation.
|
||||
<LI>If the code is clean after the above two steps and you still get
|
||||
a crash in libsndfile, then send me a small snippet of code (no
|
||||
more than 30-40 lines) which includes the call to sf_open() and
|
||||
also shows how all variables passed to/returned from sf_open()
|
||||
are defined.
|
||||
</UL>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q016"></A>
|
||||
<H2><BR/><B>Q16 : Will you accept a fix for compiling libsndfile with compiler X?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
If compiler X is a C++ compiler then no.
|
||||
C and C++ are different enough to make writing code that compiles as valid C
|
||||
and valid C++ too difficult.
|
||||
I would rather spend my time fixing bugs and adding features.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
If compiler X is a C compiler then I will do what I can as long as that does
|
||||
not hamper the correctness, portability and maintainability of the existing
|
||||
code.
|
||||
It should be noted however that libsndfile uses features specified by the 1999
|
||||
ISO C Standard.
|
||||
This can make compiling libsndfile with some older compilers difficult.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q017"></A>
|
||||
<H2><BR/><B>Q17 : Can libsndfile read/write files from/to UNIX pipes?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
Yes, libsndfile can read files from pipes.
|
||||
Unfortunately, the write case is much more complicated.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
File formats like AIFF and WAV have information at the start of the file (the
|
||||
file header) which states the length of the file, the number of sample frames
|
||||
etc.
|
||||
This information must be filled in correctly when the file header is written,
|
||||
but this information is not reliably known until the file is closed.
|
||||
This means that libsndfile cannot write AIFF, WAV and many other file types
|
||||
to a pipe.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
However, there is at least one file format (AU) which is specifically designed
|
||||
to be written to a pipe.
|
||||
Like AIFF and WAV, AU has a header with a sample frames field, but it is
|
||||
specifically allowable to set that frames field to 0x7FFFFFFF if the file
|
||||
length is not known when the header is written.
|
||||
The AU file format can also hold data in many of the standard formats (ie
|
||||
SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_FLOAT etc) as well as allowing
|
||||
data in both big and little endian format.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
See also <A HREF="#Q006">FAQ Q6</A>.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q018"></A>
|
||||
<H2><BR/><B>Q18 : Is it possible to build a Universal Binary on Mac OS X?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
Yes, but you must do two separate configure/build/test runs; one on PowerPC
|
||||
and one on Intel.
|
||||
It is then possible to merge the binaries into a single universal binary using
|
||||
one of the programs in the Apple tool chain.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
It is <b>not</b> possible to build a working universal binary via a single
|
||||
compile/build run on a single CPU.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The problem is that the libsndfile build process detects features of the CPU its
|
||||
being built for during the configure process and when building a universal binary,
|
||||
configure is only run once and that data is then used for both CPUs.
|
||||
That configure data will be wrong for one of those CPUs.
|
||||
You will still be able to compile libsndfile, and the test suite will pass on
|
||||
the machine you compiled it on.
|
||||
However, if you take the universal binary test suite programs compiled on one
|
||||
CPU and run them on the other, the test suite will fail.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Part of the problem is the the CPU endian-ness is detected at configure time.
|
||||
Yes, I know the Apple compiler defines one of the macros __LITTLE_ENDIAN__
|
||||
and __BIG_ENDIAN__, but those macros are not part of the 1999 ISO C Standard
|
||||
and they are not portable.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Endian issues are not the only reason why the cross compiled binary will fail.
|
||||
The configure script also detects other CPU specific idiosyncrasies to provide
|
||||
more optimized code.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Finally, the real show stopper problem with universal binaries is the problem
|
||||
with the test suite.
|
||||
libsndfile contains a huge, comprehensive test suite.
|
||||
When you compile a universal binary and run the test suite, you only test the
|
||||
native compile.
|
||||
The cross compiled binary (the one with the much higher chance of having
|
||||
problems) cannot be tested.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Now, if you have read this far you're probably thinking there must be a way
|
||||
to fix this and there probably is.
|
||||
The problem is that its a hell of a lot of work and would require significant
|
||||
changes to the configure process, the internal code and the test suite.
|
||||
In addition, these changes must not break compilation on any of the platforms
|
||||
libsndfile is currently working on.
|
||||
</p>
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q019"></A>
|
||||
<H2><BR/><B>Q19 : I have project files for Visual Studio / XCode / Whatever. Why
|
||||
don't you distribute them with libsndfile?
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
There's a very good reason for this.
|
||||
I will only distribute things that I actually have an ability to test and
|
||||
maintain.
|
||||
Project files for a bunch of different compilers and Integrated Development
|
||||
Environments are simply too difficult to maintain.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The problem is that every time I add a new file to libsndfile or rename an
|
||||
existing file I would have to modify all the project files and then test that
|
||||
libsndfile still built with all the different compilers.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Maintaining these project files is also rather difficult if I don't have access
|
||||
to the required compiler/IDE.
|
||||
If I just edit the project files without testing them I will almost certainly
|
||||
get it wrong.
|
||||
If I release a version of libsndfile with broken project files, I'll get a bunch
|
||||
of emails from people complaining about it not building and have no way of
|
||||
fixing or even testing it.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
I currently release sources that I personally test on Win32, Linux and
|
||||
MacOS X (PowerPC) using the compiler I trust (GNU GCC).
|
||||
Supporting one compiler on three (actually much more because GCC is available
|
||||
almost everywhere) platforms is doable without too much pain.
|
||||
I also release binaries for Win32 with instructions on how to use those
|
||||
binaries with Visual Studio.
|
||||
As a guy who is mainly interested in Linux, I'm not to keen to jump through
|
||||
a bunch of hoops to support compilers and operating systems I don't use.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
So, I hear you want to volunteer to maintain the project files for Some Crappy
|
||||
Compiler 2007?
|
||||
Well sorry, that won't work either.
|
||||
I have had numerous people over the years offer to maintaining the project
|
||||
files for Microsoft's Visual Studio.
|
||||
Every single time that happened, they maintained it for a release or two and
|
||||
then disappeared off the face of the earth.
|
||||
Hence, I'm not willing to enter into an arrangement like that again.
|
||||
</P>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q020"></A>
|
||||
<H2><BR/><B>Q20 : Why doesn't libsndfile support MP3? Lots of other Open Source
|
||||
projects support it!
|
||||
</B></H2>
|
||||
|
||||
<P>
|
||||
MP3 is not supported for one very good reason; doing so requires the payment
|
||||
of licensing fees.
|
||||
As can be seen from
|
||||
<a href="http://www.mp3licensing.com/royalty/software.html">
|
||||
mp3licensing.com</a>
|
||||
the required royalty payments are not cheap.
|
||||
</P>
|
||||
|
||||
<p>
|
||||
Yes, I know other libraries ignore the licensing requirements, but their legal
|
||||
status is extremely dubious.
|
||||
At any time, the body selling the licenses could go after the authors of those
|
||||
libraries.
|
||||
Some of those authors may be students and hence wouldn't be worth pursuing.
|
||||
</P>
|
||||
|
||||
<p>
|
||||
However, libsndfile is released under the name of a company, Mega Nerd Pty Ltd;
|
||||
a company which has income from from libsamplerate licensing, libsndfile based
|
||||
consulting income and other unrelated consulting income.
|
||||
Adding MP3 support to libsndfile could place that income under legal threat.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Fortunately, Ogg Vorbis exists as an alternative to MP3.
|
||||
Support for Ogg Vorbis was added to libsndfile (mostly due to the efforts of
|
||||
John ffitch of the Csound project) in version 1.0.18.
|
||||
</p>
|
||||
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q021"></A>
|
||||
<H2><BR/><B>Q21 : How do I use libsndfile in a closed source or commercial program
|
||||
and comply with the license?
|
||||
</B></H2>
|
||||
|
||||
<p>
|
||||
Here is a checklist of things you need to do to make sure your use of libsndfile
|
||||
in a closed source or commercial project complies with the license libsndfile is
|
||||
released under, the GNU Lesser General Public License (LGPL):
|
||||
</p>
|
||||
|
||||
<ul>
|
||||
<li>Make sure you are linking to libsndfile as a shared library (Linux and Unix
|
||||
systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OS X).
|
||||
If you are using some other operating system that doesn't allow dynamically
|
||||
linked libraries, you will not be able to use libsndfile unless you release
|
||||
the source code to your program.
|
||||
<li>In the licensing documentation for your program, add a statement that your
|
||||
software depends on libsndfile and that libsndfile is released under the GNU
|
||||
Lesser General Public License, either
|
||||
<a href="http://www.gnu.org/licenses/lgpl-2.1.txt">version 2.1</a>
|
||||
or optionally
|
||||
<a href="http://www.gnu.org/licenses/lgpl.txt">version 3</a>.
|
||||
<li>Include the text for both versions of the license, possibly as separate
|
||||
files named libsndfile_lgpl_v2_1.txt and libsndfile_lgpl_v3.txt.
|
||||
</ul>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q022"></A>
|
||||
<H2><BR/><B>Q22 : What versions of Windows does libsndfile work on?
|
||||
</B></H2>
|
||||
|
||||
<p>
|
||||
Currently the precompiled windows binaries are thoroughly tested on Windows XP.
|
||||
As such, they should also work on Win2k and Windows Vista.
|
||||
They may also work on earlier versions of Windows.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Since version 0.1.18 I have also been releasing precompiled binaries for Win64,
|
||||
the 64 bit version of Windows.
|
||||
These binaries have received much less testing than the 32 bit versions, but
|
||||
should work as expected.
|
||||
I'd be very interested in receiving feedback on these binaries.
|
||||
</p>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<A NAME="Q023"></A>
|
||||
<H2><BR/><B>Q23 : I'm cross compiling libsndfile for another platform. How can I
|
||||
run the test suite?
|
||||
</B></H2>
|
||||
|
||||
<p>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
Since version 1.0.21 the top level Makefile has an extra make target,
|
||||
'test-tarball'.
|
||||
Building this target creates a tarball called called:
|
||||
</p>
|
||||
|
||||
<center><tt>
|
||||
libsndfile-testsuite-${host_triplet}-${version}.tar.gz
|
||||
</tt></center>
|
||||
|
||||
<p>
|
||||
in the top level directory.
|
||||
This tarball can then be copied to the target platform.
|
||||
Once untarred and test script <tt>test_wrapper.sh</tt> can be run from
|
||||
the top level of the extracted tarball.
|
||||
</p>
|
||||
|
||||
<!-- ========================================================================= -->
|
||||
<HR>
|
||||
<P>
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
<BR/>
|
||||
Version : 1.0.25
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,9 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
html_DATA = index.html libsndfile.jpg libsndfile.css api.html command.html \
|
||||
bugs.html sndfile_info.html new_file_type.HOWTO \
|
||||
win32.html FAQ.html lists.html embedded_files.html octave.html \
|
||||
dither.html tutorial.html
|
||||
|
||||
EXTRA_DIST = $(html_DATA)
|
||||
|
|
@ -1,781 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
The libsndfile API
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Description" CONTENT="The libsndfile API.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<BR>
|
||||
<H1><B>libsndfile</B></H1>
|
||||
<P>
|
||||
Libsndfile is a library designed to allow the reading and writing of many
|
||||
different sampled sound file formats (such as MS Windows WAV and the Apple/SGI
|
||||
AIFF format) through one standard library interface.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
During read and write operations, formats are seamlessly converted between the
|
||||
format the application program has requested or supplied and the file's data
|
||||
format. The application programmer can remain blissfully unaware of issues
|
||||
such as file endian-ness and data format. See <A HREF="#note1">Note 1</A> and
|
||||
<A HREF="#note2">Note 2</A>.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
Every effort is made to keep these documents up-to-date, error free and
|
||||
unambiguous.
|
||||
However, since maintaining the documentation is the least fun part of working
|
||||
on libsndfile, these docs can and do fall behind the behaviour of library.
|
||||
If any errors, omissions or ambiguities are found, please notify me (erikd)
|
||||
at mega-nerd dot com.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
To supplement this reference documentation, there are simple example programs
|
||||
included in the source code tarball.
|
||||
The test suite which is also part of the source code tarball is also a good
|
||||
place to look for the correct usage of the library functions.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
<B> Finally, if you think there is some feature missing from libsndfile, check that
|
||||
it isn't already implemented (and documented)
|
||||
<A HREF="command.html">here</A>.
|
||||
</B>
|
||||
</P>
|
||||
|
||||
<H2><B>Synopsis</B></H2>
|
||||
<P>
|
||||
The functions of libsndfile are defined as follows:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
#include <stdio.h>
|
||||
#include <sndfile.h>
|
||||
|
||||
SNDFILE* <A HREF="#open">sf_open</A> (const char *path, int mode, SF_INFO *sfinfo) ;
|
||||
SNDFILE* <A HREF="#open_fd">sf_open_fd</A> (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
|
||||
SNDFILE* <A HREF="#open_virtual">sf_open_virtual</A> (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
|
||||
int <A HREF="#check">sf_format_check</A> (const SF_INFO *info) ;
|
||||
|
||||
sf_count_t <A HREF="#seek">sf_seek</A> (SNDFILE *sndfile, sf_count_t frames, int whence) ;
|
||||
|
||||
int <A HREF="command.html">sf_command</A> (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
|
||||
|
||||
int <A HREF="#error">sf_error</A> (SNDFILE *sndfile) ;
|
||||
const char* <A HREF="#error">sf_strerror</A> (SNDFILE *sndfile) ;
|
||||
const char* <A HREF="#error">sf_error_number</A> (int errnum) ;
|
||||
|
||||
int <A HREF="#error">sf_perror</A> (SNDFILE *sndfile) ;
|
||||
int <A HREF="#error">sf_error_str</A> (SNDFILE *sndfile, char* str, size_t len) ;
|
||||
|
||||
int <A HREF="#close">sf_close</A> (SNDFILE *sndfile) ;
|
||||
void <A HREF="#write_sync">sf_write_sync</A> (SNDFILE *sndfile) ;
|
||||
|
||||
sf_count_t <A HREF="#read">sf_read_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
sf_count_t <A HREF="#read">sf_read_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
sf_count_t <A HREF="#read">sf_read_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
sf_count_t <A HREF="#read">sf_read_double</A> (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
|
||||
|
||||
sf_count_t <A HREF="#readf">sf_readf_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
|
||||
sf_count_t <A HREF="#readf">sf_readf_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
|
||||
sf_count_t <A HREF="#readf">sf_readf_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
|
||||
sf_count_t <A HREF="#readf">sf_readf_double</A> (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
|
||||
|
||||
sf_count_t <A HREF="#write">sf_write_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
sf_count_t <A HREF="#write">sf_write_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
sf_count_t <A HREF="#write">sf_write_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
sf_count_t <A HREF="#write">sf_write_double</A> (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
|
||||
|
||||
sf_count_t <A HREF="#writef">sf_writef_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
|
||||
sf_count_t <A HREF="#writef">sf_writef_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
|
||||
sf_count_t <A HREF="#writef">sf_writef_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
|
||||
sf_count_t <A HREF="#writef">sf_writef_double</A> (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
|
||||
|
||||
sf_count_t <A HREF="#raw">sf_read_raw</A> (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
sf_count_t <A HREF="#raw">sf_write_raw</A> (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
|
||||
const char* <A HREF="#string">sf_get_string</A> (SNDFILE *sndfile, int str_type) ;
|
||||
int <A HREF="#string">sf_set_string</A> (SNDFILE *sndfile, int str_type, const char* str) ;
|
||||
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
SNDFILE* is an anonymous pointer to data which is private to the library.
|
||||
</P>
|
||||
|
||||
|
||||
<A NAME="open"></A>
|
||||
<H2><B>File Open Function</B></H2>
|
||||
|
||||
<PRE>
|
||||
SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The SF_INFO structure is for passing data between the calling function and the library
|
||||
when opening a file for reading or writing. It is defined in sndfile.h as follows:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
typedef struct
|
||||
{ sf_count_t frames ; /* Used to be called samples. */
|
||||
int samplerate ;
|
||||
int channels ;
|
||||
int format ;
|
||||
int sections ;
|
||||
int seekable ;
|
||||
} SF_INFO ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The mode parameter for this function can be any one of the following three values:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
SFM_READ - read only mode
|
||||
SFM_WRITE - write only mode
|
||||
SFM_RDWR - read/write mode
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
When opening a file for read, the <b>format</B> field should be set to zero before
|
||||
calling sf_open().
|
||||
The only exception to this is the case of RAW files where the caller has to set
|
||||
the samplerate, channels and format fields to valid values.
|
||||
All other fields of the structure are filled in by the library.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
When opening a file for write, the caller must fill in structure members samplerate,
|
||||
channels, and format.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The format field in the above SF_INFO structure is made up of the bit-wise OR of a
|
||||
major format type (values between 0x10000 and 0x08000000), a minor format type
|
||||
(with values less than 0x10000) and an optional endian-ness value.
|
||||
The currently understood formats are listed in sndfile.h as follows and also include
|
||||
bitmasks for separating major and minor file types.
|
||||
Not all combinations of endian-ness and major and minor file types are valid.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
enum
|
||||
{ /* Major formats. */
|
||||
SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian). */
|
||||
SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */
|
||||
SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */
|
||||
SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */
|
||||
SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */
|
||||
SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */
|
||||
SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */
|
||||
SF_FORMAT_VOC = 0x080000, /* VOC files. */
|
||||
SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */
|
||||
SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */
|
||||
SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */
|
||||
SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */
|
||||
SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */
|
||||
SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */
|
||||
SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */
|
||||
SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */
|
||||
SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */
|
||||
SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */
|
||||
SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */
|
||||
SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */
|
||||
SF_FORMAT_CAF = 0x180000, /* Core Audio File format */
|
||||
SF_FORMAT_WVE = 0x190000, /* Psion WVE format */
|
||||
SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */
|
||||
SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */
|
||||
SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */
|
||||
|
||||
/* Subtypes from here on. */
|
||||
|
||||
SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */
|
||||
SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */
|
||||
SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */
|
||||
SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */
|
||||
|
||||
SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */
|
||||
|
||||
SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */
|
||||
SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */
|
||||
|
||||
SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */
|
||||
SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */
|
||||
SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */
|
||||
SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */
|
||||
|
||||
SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */
|
||||
SF_FORMAT_VOX_ADPCM = 0x0021, /* Oki Dialogic ADPCM encoding. */
|
||||
|
||||
SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */
|
||||
SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */
|
||||
SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */
|
||||
|
||||
SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */
|
||||
|
||||
SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
|
||||
SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
|
||||
|
||||
SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */
|
||||
|
||||
/* Endian-ness options. */
|
||||
|
||||
SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
|
||||
SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */
|
||||
SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */
|
||||
SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */
|
||||
|
||||
SF_FORMAT_SUBMASK = 0x0000FFFF,
|
||||
SF_FORMAT_TYPEMASK = 0x0FFF0000,
|
||||
SF_FORMAT_ENDMASK = 0x30000000
|
||||
} ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
Every call to sf_open() should be matched with a call to sf_close() to free up
|
||||
memory allocated during the call to sf_open().
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
On success, the sf_open function returns a non-NULL pointer which should be
|
||||
passed as the first parameter to all subsequent libsndfile calls dealing with
|
||||
that audio file.
|
||||
On fail, the sf_open function returns a NULL pointer.
|
||||
An explanation of the error can obtained by passing NULL to
|
||||
<A HREF="#error">sf_strerror</A>.
|
||||
</P>
|
||||
|
||||
<A NAME="open_fd"></A>
|
||||
<H3><B>File Descriptor Open</B></H3>
|
||||
|
||||
<PRE>
|
||||
SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<b>Note:</b> On Microsoft Windows, this function does not work if the
|
||||
application and the libsndfile DLL are linked to different versions of the
|
||||
Microsoft C runtime DLL.
|
||||
</P>
|
||||
<P>
|
||||
The second open function takes a file descriptor of a file that has already been
|
||||
opened.
|
||||
Care should be taken to ensure that the mode of the file represented by the
|
||||
descriptor matches the mode argument.
|
||||
This function is useful in the following circumstances:
|
||||
</P>
|
||||
|
||||
<UL>
|
||||
<LI>Opening temporary files securely (ie use the tmpfile() to return a
|
||||
FILE* pointer and then using fileno() to retrieve the file descriptor
|
||||
which is then passed to libsndfile).
|
||||
<LI>Opening files with file names using OS specific character encodings
|
||||
and then passing the file descriptor to sf_open_fd().
|
||||
<LI>Opening sound files embedded within larger files.
|
||||
<A HREF="embedded_files.html">More info</A>.
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
Every call to sf_open_fd() should be matched with a call to sf_close() to free up
|
||||
memory allocated during the call to sf_open().
|
||||
</P>
|
||||
|
||||
<P>
|
||||
When sf_close() is called, the file descriptor is only closed if the <B>close_desc</B>
|
||||
parameter was TRUE when the sf_open_fd() function was called.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
On success, the sf_open_fd function returns a non-NULL pointer which should be
|
||||
passed as the first parameter to all subsequent libsndfile calls dealing with
|
||||
that audio file.
|
||||
On fail, the sf_open_fd function returns a NULL pointer.
|
||||
</P>
|
||||
|
||||
<A NAME="open_virtual"></A>
|
||||
<h3><b>Virtual File Open Function</b></h3>
|
||||
<pre>
|
||||
SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
Opens a soundfile from a virtual file I/O context which is provided
|
||||
by the caller. This is usually used to interface libsndfile to a stream or buffer
|
||||
based system. Apart from the sfvirtual and the user_data parameters this function behaves
|
||||
like <a href="#open">sf_open</a>.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
typedef struct
|
||||
{ sf_vio_get_filelen get_filelen ;
|
||||
sf_vio_seek seek ;
|
||||
sf_vio_read read ;
|
||||
sf_vio_write write ;
|
||||
sf_vio_tell tell ;
|
||||
} SF_VIRTUAL_IO ;
|
||||
</pre>
|
||||
<p>
|
||||
Libsndfile calls the callbacks provided by the SF_VIRTUAL_IO structure when opening, reading
|
||||
and writing to the virtual file context. The user_data pointer is a user defined context which
|
||||
will be available in the callbacks.
|
||||
</p>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
|
||||
typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
|
||||
typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
|
||||
typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
|
||||
typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
|
||||
</pre>
|
||||
<h4>sf_vio_get_filelen</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
The virtual file contex must return the length of the virtual file in bytes.<br>
|
||||
</p>
|
||||
<h4>sf_vio_seek</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
The virtual file context must seek to offset using the seek mode provided by whence which is one of<br>
|
||||
</p>
|
||||
<pre>
|
||||
SEEK_CUR
|
||||
SEEK_SET
|
||||
SEEK_END
|
||||
</pre>
|
||||
<p>
|
||||
The return value must contain the new offset in the file.
|
||||
</p>
|
||||
<h4>sf_vio_read</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
The virtual file context must copy ("read") "count" bytes into the
|
||||
buffer provided by ptr and return the count of actually copied bytes.
|
||||
</p>
|
||||
<h4>sf_vio_write</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
The virtual file context must process "count" bytes stored in the
|
||||
buffer passed with ptr and return the count of actually processed bytes.<br>
|
||||
</p>
|
||||
<h4>sf_vio_tell</h4>
|
||||
<pre>
|
||||
typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
|
||||
</pre>
|
||||
<p>
|
||||
Return the current position of the virtual file context.<br>
|
||||
</p>
|
||||
|
||||
|
||||
<A NAME="check"></A>
|
||||
<BR><H2><B>Format Check Function</B></H2>
|
||||
|
||||
<PRE>
|
||||
int sf_format_check (const SF_INFO *info) ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
This function allows the caller to check if a set of parameters in the SF_INFO struct
|
||||
is valid before calling sf_open (SFM_WRITE).
|
||||
</P>
|
||||
<P>
|
||||
sf_format_check returns TRUE if the parameters are valid and FALSE otherwise.
|
||||
</P>
|
||||
|
||||
<A NAME="seek"></A>
|
||||
<BR><H2><B>File Seek Functions</B></H2>
|
||||
|
||||
<PRE>
|
||||
sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The file seek functions work much like lseek in unistd.h with the exception that
|
||||
the non-audio data is ignored and the seek only moves within the audio data section of
|
||||
the file.
|
||||
In addition, seeks are defined in number of (multichannel) frames.
|
||||
Therefore, a seek in a stereo file from the current position forward with an offset
|
||||
of 1 would skip forward by one sample of both channels.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
like lseek(), the whence parameter can be any one of the following three values:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
SEEK_SET - The offset is set to the start of the audio data plus offset (multichannel) frames.
|
||||
SEEK_CUR - The offset is set to its current location plus offset (multichannel) frames.
|
||||
SEEK_END - The offset is set to the end of the data plus offset (multichannel) frames.
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
Internally, libsndfile keeps track of the read and write locations using separate
|
||||
read and write pointers.
|
||||
If a file has been opened with a mode of SFM_RDWR, bitwise OR-ing the standard whence
|
||||
values above with either SFM_READ or SFM_WRITE allows the read and write pointers to
|
||||
be modified separately.
|
||||
If the SEEK_* values are used on their own, the read and write pointers are
|
||||
both modified.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
Note that the frames offset can be negative and in fact should be when SEEK_END is used for the
|
||||
whence parameter.
|
||||
</P>
|
||||
<P>
|
||||
sf_seek will return the offset in (multichannel) frames from the start of the audio data
|
||||
or -1 if an error occured (ie an attempt is made to seek beyond the start or end of the file).
|
||||
</P>
|
||||
|
||||
<A NAME="error"></A>
|
||||
<H2><BR><B>Error Reporting Functions</B></H2>
|
||||
|
||||
|
||||
<PRE>
|
||||
int sf_error (SNDFILE *sndfile) ;
|
||||
</PRE>
|
||||
<P>
|
||||
This function returns the current error number for the given SNDFILE.
|
||||
The error number may be one of the following:
|
||||
</P>
|
||||
<PRE>
|
||||
enum
|
||||
{ SF_ERR_NO_ERROR = 0,
|
||||
SF_ERR_UNRECOGNISED_FORMAT = 1,
|
||||
SF_ERR_SYSTEM = 2,
|
||||
SF_ERR_MALFORMED_FILE = 3,
|
||||
SF_ERR_UNSUPPORTED_ENCODING = 4
|
||||
} ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
or any one of many other internal error values.
|
||||
Applications should only test the return value against error values defined in
|
||||
<sndfile.h> as the internal error values are subject to change at any
|
||||
time.
|
||||
For errors not in the above list, the function sf_error_number() can be used to
|
||||
convert it to an error string.
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
const char* sf_strerror (SNDFILE *sndfile) ;
|
||||
const char* sf_error_number (int errnum) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The error functions sf_strerror() and sf_error_number() convert the library's internal
|
||||
error enumerations into text strings.
|
||||
</P>
|
||||
<PRE>
|
||||
int sf_perror (SNDFILE *sndfile) ;
|
||||
int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The functions sf_perror() and sf_error_str() are deprecated and will be dropped
|
||||
from the library at some later date.
|
||||
</P>
|
||||
|
||||
<A NAME="close"></A>
|
||||
<H2><BR><B>File Close Function</B></H2>
|
||||
|
||||
<PRE>
|
||||
int sf_close (SNDFILE *sndfile) ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The close function closes the file, deallocates its internal buffers and returns
|
||||
0 on success or an error value otherwise.
|
||||
</P>
|
||||
<BR>
|
||||
|
||||
<A NAME="write_sync"></A>
|
||||
<H2><BR><B>Write Sync Function</B></H2>
|
||||
|
||||
<PRE>
|
||||
void sf_write_sync (SNDFILE *sndfile) ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
If the file is opened SFM_WRITE or SFM_RDWR, call the operating system's function
|
||||
to force the writing of all file cache buffers to disk. If the file is opened
|
||||
SFM_READ no action is taken.
|
||||
</P>
|
||||
<BR>
|
||||
|
||||
|
||||
<A NAME="read"></A>
|
||||
<H2><BR><B>File Read Functions (Items)</B></H2>
|
||||
|
||||
<PRE>
|
||||
sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The file read items functions fill the array pointed to by ptr with the requested
|
||||
number of items. The items parameter must be an integer product of the number
|
||||
of channels or an error will occur.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
It is important to note that the data type used by the calling program and the data
|
||||
format of the file do not need to be the same. For instance, it is possible to open
|
||||
a 16 bit PCM encoded WAV file and read the data using sf_read_float(). The library
|
||||
seamlessly converts between the two formats on-the-fly. See
|
||||
<A HREF="#note1">Note 1</A>.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The sf_read_XXXX functions return the number of items read.
|
||||
Unless the end of the file was reached during the read, the return value should
|
||||
equal the number of items requested.
|
||||
Attempts to read beyond the end of the file will not result in an error but will
|
||||
cause the sf_read_XXXX functions to return less than the number of items requested
|
||||
or 0 if already at the end of the file.
|
||||
</P>
|
||||
|
||||
<A NAME="readf"></A>
|
||||
<H2><BR><B>File Read Functions (Frames)</B></H2>
|
||||
|
||||
<PRE>
|
||||
sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The file read frames functions fill the array pointed to by ptr with the requested
|
||||
number of frames of data. The array must be large enough to hold the product of
|
||||
frames and the number of channels.
|
||||
</P>
|
||||
|
||||
<P><B>
|
||||
Care must be taken to ensure that there is enough space in the array pointed to by
|
||||
ptr, to take (frames * channels) number of items (shorts, ints, floats or doubles).
|
||||
</B></P>
|
||||
|
||||
<P>
|
||||
The sf_readf_XXXX functions return the number of frames read.
|
||||
Unless the end of the file was reached during the read, the return value should equal
|
||||
the number of frames requested.
|
||||
Attempts to read beyond the end of the file will not result in an error but will cause
|
||||
the sf_readf_XXXX functions to return less than the number of frames requested or 0 if
|
||||
already at the end of the file.
|
||||
</P>
|
||||
|
||||
<A NAME="write"></A>
|
||||
<H2><BR><B>File Write Functions (Items)</B></H2>
|
||||
|
||||
<PRE>
|
||||
sf_count_t sf_write_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
|
||||
sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The file write items functions write the data in the array pointed to by ptr to the file.
|
||||
The items parameter must be an integer product of the number of channels or an error
|
||||
will occur.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
It is important to note that the data type used by the calling program and the data
|
||||
format of the file do not need to be the same. For instance, it is possible to open
|
||||
a 16 bit PCM encoded WAV file and write the data using sf_write_float(). The library
|
||||
seamlessly converts between the two formats on-the-fly. See
|
||||
<A HREF="#note1">Note 1</A>.
|
||||
</P>
|
||||
<P>
|
||||
The sf_write_XXXX functions return the number of items written (which should be the
|
||||
same as the items parameter).
|
||||
</P>
|
||||
|
||||
<A NAME="writef"></A>
|
||||
<H2><BR><B>File Write Functions (Frames)</B></H2>
|
||||
|
||||
<PRE>
|
||||
sf_count_t sf_writef_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
|
||||
sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The file write frames functions write the data in the array pointed to by ptr to the file.
|
||||
The array must be large enough to hold the product of frames and the number of channels.
|
||||
</P>
|
||||
<P>
|
||||
The sf_writef_XXXX functions return the number of frames written (which should be the
|
||||
same as the frames parameter).
|
||||
</P>
|
||||
|
||||
<A NAME="raw"></A>
|
||||
<H2><BR><B>Raw File Read and Write Functions</B></H2>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
<b>Note:</b> Unless you are writing an external decoder/encode that uses
|
||||
libsndfile to handle the file headers, you should not be using these
|
||||
functions.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The raw read and write functions read raw audio data from the audio file (not to be
|
||||
confused with reading RAW header-less PCM files). The number of bytes read or written
|
||||
must always be an integer multiple of the number of channels multiplied by the number
|
||||
of bytes required to represent one sample from one channel.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The raw read and write functions return the number of bytes read or written (which
|
||||
should be the same as the bytes parameter).
|
||||
</P>
|
||||
|
||||
<P>
|
||||
<B>
|
||||
Note : The result of using of both regular reads/writes and raw reads/writes on
|
||||
compressed file formats other than SF_FORMAT_ALAW and SF_FORMAT_ULAW is undefined.
|
||||
</B>
|
||||
</P>
|
||||
|
||||
<p>
|
||||
See also : <a href="command.html#SFC_RAW_NEEDS_ENDSWAP">SFC_RAW_NEEDS_ENDSWAP</a>
|
||||
</p>
|
||||
|
||||
<A NAME="string"></A>
|
||||
<H2><BR><B>Functions for Reading and Writing String Data</B></H2>
|
||||
|
||||
|
||||
<PRE>
|
||||
const char* sf_get_string (SNDFILE *sndfile, int str_type) ;
|
||||
int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
These functions allow strings to be set on files opened for write and to be
|
||||
retrieved from files opened for read where supported by the given file type.
|
||||
The <B>str_type</B> parameter can be any one of the following string types:
|
||||
</P>
|
||||
|
||||
<PRE>
|
||||
enum
|
||||
{ SF_STR_TITLE,
|
||||
SF_STR_COPYRIGHT,
|
||||
SF_STR_SOFTWARE,
|
||||
SF_STR_ARTIST,
|
||||
SF_STR_COMMENT,
|
||||
SF_STR_DATE,
|
||||
SF_STR_ALBUM,
|
||||
SF_STR_LICENSE,
|
||||
SF_STR_TRACKNUMBER,
|
||||
SF_STR_GENRE
|
||||
} ;
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The sf_get_string() function returns the specified string if it exists and a
|
||||
NULL pointer otherwise.
|
||||
In addition to the string ids above, SF_STR_FIRST (== SF_STR_TITLE) and
|
||||
SF_STR_LAST (always the same as the highest numbers string id) are also
|
||||
available to allow iteration over all the available string ids.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
The sf_set_string() function sets the string data.
|
||||
It returns zero on success and non-zero on error.
|
||||
The error code can be converted to a string using sf_error_number().
|
||||
</P>
|
||||
|
||||
|
||||
<P>
|
||||
|
||||
</P>
|
||||
|
||||
<HR>
|
||||
|
||||
<A NAME="note1"></A>
|
||||
<H2><BR><B>Note 1</B></H2>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
When converting between integer PCM formats of differing size (ie using sf_read_int()
|
||||
to read a 16 bit PCM encoded WAV file) libsndfile obeys one simple rule:
|
||||
</P>
|
||||
|
||||
<P CLASS=indent_block>
|
||||
Whenever integer data is moved from one sized container to another sized container,
|
||||
the most significant bit in the source container will become the most significant bit
|
||||
in the destination container.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
When converting between integer data and floating point data, different rules apply.
|
||||
The default behaviour when reading floating point data (sf_read_float() or
|
||||
sf_read_double ()) from a file with integer data is normalisation. Regardless of
|
||||
whether data in the file is 8, 16, 24 or 32 bit wide, the data will be read as
|
||||
floating point data in the range [-1.0, 1.0]. Similarly, data in the range [-1.0, 1.0]
|
||||
will be written to an integer PCM file so that a data value of 1.0 will be the largest
|
||||
allowable integer for the given bit width. This normalisation can be turned on or off
|
||||
using the <A HREF="command.html">sf_command</A> interface.
|
||||
</P>
|
||||
|
||||
<A NAME="note2"></A>
|
||||
<H2><BR><B>Note 2</B></H2>
|
||||
|
||||
<P>
|
||||
Reading a file containg floating point data (allowable with WAV, AIFF, AU and other
|
||||
file formats) using integer read methods (sf_read_short() or sf_read_int()) can
|
||||
produce unexpected results.
|
||||
For instance the data in the file may have a maximum absolute value < 1.0 which
|
||||
would mean that all sample values read from the file will be zero.
|
||||
In order to read these files correctly using integer read methods, it is recommended
|
||||
that you use the
|
||||
<A HREF="command.html">sf_command</A>
|
||||
interface, a command of
|
||||
<A HREF="command.html#SFC_SET_SCALE_FLOAT_INT_READ">SFC_SET_SCALE_FLOAT_INT_READ</A>
|
||||
and a parameter of SF_TRUE to force correct scaling.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<HR>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The libsndfile home page is
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">here</A>.
|
||||
</P>
|
||||
<P>
|
||||
Version : 1.0.25
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,76 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
Bug Reporting
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<CENTER>
|
||||
<H1><B>Reporting Bugs in libsndfile</B></H1>
|
||||
</CENTER>
|
||||
<P>
|
||||
Before even attempting to report a bug in libsndfile please make sure you have
|
||||
read the
|
||||
<A HREF="FAQ.html">Frequently Asked Questions</A>.
|
||||
If you are having a problem writing code using libsndfile make sure you read
|
||||
the
|
||||
<A HREF="api.html">Application Programming Interface</A>
|
||||
documentation.
|
||||
</P>
|
||||
<P>
|
||||
That said, I am interested in finding and fixing all genuine bugs in libsndfile.
|
||||
Bugs I want to fix include any of the following problems (and probably others) :
|
||||
</P>
|
||||
<UL>
|
||||
<LI> Compilation problems on new platforms.
|
||||
<LI> Errors being detected during the `make check' process.
|
||||
<LI> Segmentation faults occuring inside libsndfile.
|
||||
<LI> libsndfile hanging when opening a file.
|
||||
<LI> Supported sound file types being incorrectly read or written.
|
||||
<LI> Omissions, errors or spelling mistakes in the documentation.
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
When submitting a bug report you must include :
|
||||
</P>
|
||||
<UL>
|
||||
<LI> Your system (CPU and memory size should be enough).
|
||||
<LI> The operating system you are using.
|
||||
<LI> Whether you are using a package provided by your distribution or you
|
||||
compiled it youself.
|
||||
<LI> If you compiled it yourself, the compiler you are using. (Also make
|
||||
sure to run 'make check'.)
|
||||
<LI> A description of the problem.
|
||||
<LI> Information generated by the sndfile-info program (see next paragraph).
|
||||
<LI> If you are having problems with sndfile-play and ALSA on Linux, I will
|
||||
need information about your kernel, ALSA version, compiler version,
|
||||
whether you compiled the kernel/ALSA your self or installed from a
|
||||
package etc.
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
If libsndfile compiles and installs correctly but has difficulty reading a particular
|
||||
file or type of file you should run the <B>sndfile-info</B> program (from the examples
|
||||
directory of the libsndfile distribution) on the file. See
|
||||
<A HREF="sndfile_info.html">here</A>
|
||||
for an example of the use of the <B>sndfile-info</B> program.
|
||||
</P>
|
||||
<P>
|
||||
Please do not send me a sound file which fails to open under libsndfile unless I
|
||||
specifically ask you to. The above information should usually suffice for most
|
||||
problems.
|
||||
</P>
|
||||
<P>
|
||||
Once you have the above information you should submit a ticket on the libsnfile
|
||||
<A HREF="https://github.com/erikd/libsndfile/issues">github issue tracker</A>.
|
||||
|
||||
</P>
|
||||
</BODY>
|
||||
</HTML>
|
File diff suppressed because it is too large
Load Diff
|
@ -1,43 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile Development
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<!-- pepper -->
|
||||
<H1><BR>libsndfile Development</H1>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
libsndfile is being developed by a small but growing community of users
|
||||
and hackers led by Erik de Castro Lopo.
|
||||
People interested in helping should join the libsndfile-devel
|
||||
<A HREF="lists.html">mailing list</A>
|
||||
where most of the discussion about new features takes place.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The main repository can be found on Github:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<center>
|
||||
<A HREF="https://github.com/erikd/libsndfile/">
|
||||
https://github.com/erikd/libsndfile/</A>
|
||||
</center>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
and includes
|
||||
<a href="https://github.com/erikd/libsndfile/blob/master/README.md">
|
||||
instuctions</a>
|
||||
on how to build libsndfilefrom the Git repo.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -1,112 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile : donate.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<!-- Another version at the bottom of the page. -->
|
||||
<META NAME="Description" CONTENT="The libsndfile API.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<br/>
|
||||
<!-- pepper -->
|
||||
<center>
|
||||
<IMG SRC="libsndfile.jpg" HEIGHT=98 WIDTH=367 ALT="libsndfile.jpg">
|
||||
</center>
|
||||
<!-- pepper -->
|
||||
<br/>
|
||||
|
||||
<p>
|
||||
Dear libsndfile user,
|
||||
</p>
|
||||
<!-- pepper -->
|
||||
<p>
|
||||
This library was developed on Linux for Linux. I am not a Windows user and
|
||||
maintaining this library for Windows costs me significant amounts of time above
|
||||
and beyond the time taken to make it work on Linux and Unix-like systems.
|
||||
</p>
|
||||
<!-- pepper -->
|
||||
<p>
|
||||
I therefore ask Windows users of libsndfile to donate to ensure that libsndfile's
|
||||
support for Windows continues. As long as donations continue to flow in at a decent
|
||||
rate, I will continue to release precompiled Windows binaries in sync with the
|
||||
Linux/Unix version. If donations are poor, support for windows will fall behind.
|
||||
</p>
|
||||
<!-- pepper -->
|
||||
|
||||
<p>
|
||||
You are free to donate any amount you chose.
|
||||
As a guideline:
|
||||
</p>
|
||||
<!-- pepper -->
|
||||
<ul>
|
||||
<li>If you are simply a user of libsndfile that would like to ensure that
|
||||
the development of libsndfile continues, a donation of $10US would be more
|
||||
than adequate.
|
||||
</li>
|
||||
<li>If you are shareware author that distributes libsndfile with your app and
|
||||
makes more than $1000 a year from your shareware, a one off donation of $50
|
||||
would be appropriate.
|
||||
</li>
|
||||
<li>If your company is a commercial software house that distributes one or more
|
||||
products that ship with libsndfile, a donation of $100 every second or third
|
||||
year would be appropriate.
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- pepper -->
|
||||
<p>
|
||||
Donations can be made in Bitcoin to the Bitcoin address
|
||||
<b>15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ</b>
|
||||
|
||||
which can be verified by checking the following GPG signature.
|
||||
</p>
|
||||
|
||||
<pre>
|
||||
-----BEGIN PGP SIGNED MESSAGE-----
|
||||
Hash: SHA256
|
||||
|
||||
libsndfile Bitcoin address : 15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ
|
||||
-----BEGIN PGP SIGNATURE-----
|
||||
Version: GnuPG v1.4.12 (GNU/Linux)
|
||||
|
||||
iQIcBAEBCAAGBQJSK7MUAAoJEEXYQ7zIiotIgXEP/R8hy65tlV7TiPw9bY9BklXS
|
||||
/Vl8FU2RhDkBt61ZmxbfDTybyQ5Vce/3wWph15L4RvpoX1OyeintQFmwwuPjOGiq
|
||||
eIz0nT9vDorG37Xdo5NZNBu9Tp1Od9MNtxFaAsRWFrDfvKEKljBHrcfM972cYrAp
|
||||
DaFd0Ik+bHKom9iQXFB7TFd0w2V4uszVMQDUGqb/vRNeRURZS7ypeMNwc8tZyTKR
|
||||
waEGMTa5sxxRjs7MqGRxSovnFT7JV3TNfdkBInUliIR/XvrudFR9J4Fiv+8Dk9P8
|
||||
WNjm6uFxvgIqiu1G9bjrwwr+DsBju93ljGNcZoayAKw5vwbX6KTcCbc31k9dP8Hf
|
||||
p6YdmPlZVKZmva+P3nLSJBTlxNu24Jm+ha+ZM/svDXTaPFWC8l5FP17kK0Bj8wCq
|
||||
N7pDz6RchEn10u+HdhfT1XiUjxj0zNXrr0GGj9apjl0RlT0O49eBttV0oXIdBRLi
|
||||
nTEaOWITpCgu7ggw1kWXHIWEncuiaSuJy/iH8PgNepWVj/6PxQRMrTqG4ux2Snk8
|
||||
Ua4vO8YHLMZX/XvSUS7eMtgfM7AO6YjJ/ac9bQif9bh6LsYEVVklysMUin6ZRS7Z
|
||||
Cms23FnqeQKtJOzdvqSJiV06lK6fP+tYdM4WSYn+AfL4IfYl2v48xXVU8XOOK9BH
|
||||
bJPKMDcz1ZvfYtX5mSW1
|
||||
=WXGB
|
||||
-----END PGP SIGNATURE-----
|
||||
</pre>
|
||||
|
||||
<p>
|
||||
Thanks and regards,
|
||||
<br/>
|
||||
Erik de Castro Lopo
|
||||
<br/>
|
||||
Main libsndfile author and maintainer
|
||||
</p>
|
||||
|
||||
<!-- pepper -->
|
||||
|
||||
<img src=
|
||||
"/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|trgb=0;0;0|wxh=15;20|md=6|dd=B|st=1|sh=1|df=libsndfile-donate.dat"
|
||||
HEIGHT=0 WIDTH=0 ALT="">
|
||||
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,47 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile : Embedded Sound Files.
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Description" CONTENT="The libsndfile API.">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
<!-- pepper -->
|
||||
<BODY>
|
||||
<!-- pepper -->
|
||||
<H1><B>Embedded Sound Files.</B></H1>
|
||||
|
||||
<P>
|
||||
By using the open SNDFILE with a file descriptor function:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<PRE>
|
||||
SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
|
||||
</PRE>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
it is possible to open sound files embedded within larger files.
|
||||
There are however a couple of caveats:
|
||||
<P>
|
||||
<!-- pepper -->
|
||||
<UL>
|
||||
<LI> Read/Write mode (SFM_RDWR) is not supported.
|
||||
<LI> Writing of embedded files is only supported at the end of the file.
|
||||
<LI> Reading of embedded files is only supported at file offsets greater
|
||||
than zero.
|
||||
<LI> Not all file formats are supported (currently only WAV, AIFF and AU).
|
||||
</UL>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The test program <B>multi_file_test.c</B> in the <B>tests/</B> directory of the
|
||||
source code tarball shows how this functionality is used to read and write
|
||||
embedded files.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,493 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<META NAME="Version" CONTENT="libsndfile-1.0.25">
|
||||
<META NAME="Description" CONTENT="The libsndfile Home Page">
|
||||
<META NAME="Keywords" CONTENT="WAV AIFF AU SVX PAF NIST W64 libsndfile sound audio dsp Linux">
|
||||
<META NAME="ROBOTS" CONTENT="NOFOLLOW">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<!-- pepper -->
|
||||
<CENTER>
|
||||
<IMG SRC="libsndfile.jpg" HEIGHT=98 WIDTH=367 ALT="libsndfile.jpg">
|
||||
</CENTER>
|
||||
<!-- pepper -->
|
||||
<CENTER>
|
||||
<A HREF="#History">History</A> -+-
|
||||
<A HREF="#Features">Features</A> -+-
|
||||
<A HREF="#Similar">Similar or Related Projects</A> -+-
|
||||
<A HREF="NEWS">News</A>
|
||||
<br>
|
||||
<A HREF="development.html">Development</A> -+-
|
||||
<A HREF="api.html">Programming Interface</A> -+-
|
||||
<A HREF="bugs.html">Bug Reporting</A> -+-
|
||||
<A HREF="#Download">Download</A>
|
||||
<br>
|
||||
<A HREF="FAQ.html">FAQ</A> -+-
|
||||
<A HREF="lists.html">Mailing Lists</A> -+-
|
||||
<A HREF="ChangeLog">Change Log</A> -+-
|
||||
<A HREF="#Licensing">Licensing Information</A> -+-
|
||||
<A HREF="#SeeAlso">See Also</A>
|
||||
</CENTER>
|
||||
|
||||
<br><br>
|
||||
<P>
|
||||
Libsndfile is a C library for reading and writing files containing sampled sound
|
||||
(such as MS Windows WAV and the Apple/SGI AIFF format) through one standard
|
||||
library interface. It is released in source code format under the
|
||||
<A HREF="http://www.gnu.org/copyleft/lesser.html">Gnu Lesser General Public License</A>.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The library was written to compile and run on a Linux system but should compile
|
||||
and run on just about any Unix (including MacOS X).
|
||||
There are also pre-compiled binaries available for 32 and 64 bit windows.
|
||||
</P>
|
||||
<P>
|
||||
It was designed to handle both little-endian (such as WAV) and big-endian
|
||||
(such as AIFF) data, and to compile and run correctly on little-endian (such as Intel
|
||||
and DEC/Compaq Alpha) processor systems as well as big-endian processor systems such
|
||||
as Motorola 68k, Power PC, MIPS and Sparc.
|
||||
Hopefully the design of the library will also make it easy to extend for reading and
|
||||
writing new sound file formats.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
It has been compiled and tested (at one time or another) on the following systems:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<UL>
|
||||
<LI>Every platform supported by Debian GNU/Linux including x86_64-linux-gnu,
|
||||
i486-linux-gnu, powerpc-linux-gnu, sparc-linux-gnu, alpha-linux-gnu,
|
||||
mips-linux-gnu and armel-linux-gnu.</LI>
|
||||
<LI>powerpc-apple-darwin7.0 (Mac OS X 10.3)</LI>
|
||||
<LI>sparc-sun-solaris2.8 (using gcc)</LI>
|
||||
<LI>mips-sgi-irix5.3 (using gcc)</LI>
|
||||
<LI>QNX 6.0</LI>
|
||||
<LI>i386-unknown-openbsd2.9</LI>
|
||||
</UL>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
At the moment, each new release is being tested on i386 Linux, x86_64 Linux,
|
||||
PowerPC Linux, Win32 and Win64.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
|
||||
<A NAME="Capabilities"></A>
|
||||
<A NAME="Features"></A>
|
||||
<H1><B>Features</B></H1>
|
||||
<P>
|
||||
libsndfile has the following main features :
|
||||
</P>
|
||||
<UL>
|
||||
<lI> Ability to read and write a large number of file formats.
|
||||
<LI> A simple, elegant and easy to use Applications Programming Interface.
|
||||
<LI> Usable on Unix, Win32, MacOS and others.
|
||||
<LI> On the fly format conversion, including endian-ness swapping, type conversion
|
||||
and bitwidth scaling.
|
||||
<LI> Optional normalisation when reading floating point data from files containing
|
||||
integer data.
|
||||
<LI> Ability to open files in read/write mode.
|
||||
<LI> The ability to write the file header without closing the file (only on files
|
||||
open for write or read/write).
|
||||
<LI> Ability to query the library about all supported formats and retrieve text
|
||||
strings describing each format.
|
||||
</UL>
|
||||
<P>
|
||||
libsndfile has a comprehensive test suite so that each release is as bug free
|
||||
as possible.
|
||||
When new bugs are found, new tests are added to the test suite to ensure that
|
||||
these bugs don't creep back into the code.
|
||||
When new features are added, tests are added to the test suite to make sure that
|
||||
these features continue to work correctly even when they are old features.
|
||||
</P>
|
||||
<P>
|
||||
The following table lists the file formats and encodings that libsndfile can read
|
||||
and write.
|
||||
The file formats are arranged across the top and encodings along the left
|
||||
edge.
|
||||
</P>
|
||||
<br>
|
||||
|
||||
<TABLE BORDER="1" cellpadding="2">
|
||||
<TR><TD> </TD>
|
||||
<TD ALIGN="center">Micro- soft<br>WAV</TD>
|
||||
<TD ALIGN="center">SGI / Apple<br>AIFF / AIFC</TD>
|
||||
<TD ALIGN="center">Sun / DEC /<br>NeXT<br>AU / SND</TD>
|
||||
<TD ALIGN="center">Header- less<br>RAW</TD>
|
||||
<TD ALIGN="center">Paris Audio<br>File<br>PAF</TD>
|
||||
<TD ALIGN="center">Commo- dore<br>Amiga<br>IFF / SVX</TD>
|
||||
<TD ALIGN="center">Sphere<br>Nist<br>WAV</TD>
|
||||
<TD ALIGN="center">IRCAM<br>SF</TD>
|
||||
<TD ALIGN="center">Creative<br>VOC</TD>
|
||||
<TD ALIGN="center">Sound forge<br>W64</TD>
|
||||
<TD ALIGN="center"><A HREF="octave.html">GNU Octave 2.0</A><br>MAT4</TD>
|
||||
<TD ALIGN="center"><A HREF="octave.html">GNU Octave 2.1</A><br>MAT5</TD>
|
||||
<TD ALIGN="center">Portable Voice Format<br>PVF</TD>
|
||||
<TD ALIGN="center">Fasttracker 2<br>XI</TD>
|
||||
<TD ALIGN="center">HMM Tool Kit<br>HTK</TD>
|
||||
<TD ALIGN="center">Apple<br>CAF</TD>
|
||||
<TD ALIGN="center">Sound<br>Designer II<br>SD2</TD>
|
||||
<TD ALIGN="center">Free Lossless Audio Codec<br>FLAC</TD>
|
||||
</TR>
|
||||
<TR><TD>Unsigned 8 bit PCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>Signed 8 bit PCM</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>Signed 16 bit PCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>Signed 24 bit PCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>Signed 32 bit PCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>32 bit float</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>64 bit double</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>u-law encoding</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
<TR><TD>A-law encoding</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>IMA ADPCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>MS ADPCM</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>GSM 6.10</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>G721 ADPCM 32kbps</TD>
|
||||
<TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>G723 ADPCM 24kbps</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>G723 ADPCM 40kbps</TD>
|
||||
<TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>12 bit DWVW</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>16 bit DWVW</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
|
||||
<TR><TD>24 bit DWVW</TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
<TR><TD>Ok Dialogic ADPCM</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
<TR><TD>8 bit DPCM</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
<TR><TD>16 bit DPCM</TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
<TD> </TD><TD ALIGN="center">R/W</TD><TD> </TD><TD> </TD><TD> </TD><TD> </TD>
|
||||
</TR>
|
||||
</TABLE>
|
||||
|
||||
<p>
|
||||
From version 1.0.18, libsndfile also reads and writes
|
||||
<a href="http://flac.sourceforge.net/">FLAC</a>
|
||||
and
|
||||
<a href="http://www.vorbis.com/">Ogg/Vorbis</a>.
|
||||
</p>
|
||||
|
||||
<!-- pepper -->
|
||||
|
||||
<P>
|
||||
Some of the file formats I am also interested in adding are:
|
||||
</P>
|
||||
<UL>
|
||||
<LI> Kurzweil K2000 sampler files.
|
||||
<LI> Ogg Speex.
|
||||
</UL>
|
||||
<P>
|
||||
I have decided that I will not be adding support for MPEG Layer 3 (commonly
|
||||
known as MP3) due to the patent issues surrounding this file format.
|
||||
See
|
||||
<a href="FAQ.html#Q020">
|
||||
the FAQ</a>
|
||||
for more.
|
||||
</P>
|
||||
<P>
|
||||
Other file formats may also be added on request.
|
||||
</P>
|
||||
|
||||
<!-- pepper -->
|
||||
|
||||
<A NAME="History"></A>
|
||||
<H1><B>History</B></H1>
|
||||
<P>
|
||||
My first attempt at reading and writing WAV files was in 1990 or so under Windows
|
||||
3.1.
|
||||
I started using Linux in early 1995 and contributed some code to the
|
||||
<A HREF="http://www.vaxxine.com/ve3wwg/gnuwave.html">wavplay</A>
|
||||
program.
|
||||
That contributed code would eventually mutate into this library.
|
||||
As one of my interests is Digital Signal Processing (DSP) I decided that as well as
|
||||
reading data from an audio file in the native format (typically 16 bit short integers)
|
||||
it would also be useful to be able to have the library do the conversion to floating
|
||||
point numbers for DSP applications.
|
||||
It then dawned on me that whatever file format (anything from 8 bit unsigned chars,
|
||||
to 32 bit floating point numbers) the library should be able to convert the data to
|
||||
whatever format the library user wishes to use it in.
|
||||
For example, in a sound playback program, the library caller typically wants the sound
|
||||
data in 16 bit short integers to dump into a sound card even though the data in the
|
||||
file may be 32 bit floating point numbers (ie Microsoft's WAVE_FORMAT_IEEE_FLOAT
|
||||
format).
|
||||
Another example would be someone doing speech recognition research who has recorded
|
||||
some speech as a 16 bit WAV file but wants to process it as double precision floating
|
||||
point numbers.
|
||||
</P>
|
||||
<P>
|
||||
Here is the release history for libsndfile :
|
||||
</P>
|
||||
<UL>
|
||||
<LI>Version 0.0.8 (Feb 15 1999) First official release.
|
||||
<LI>Version 0.0.28 (Apr 26 2002) Final release of version 0 of libsndfile.
|
||||
<LI>Version 1.0.0rc1 (Jun 24 2002) Release candidate 1 of version 1 of libsndfile.
|
||||
<LI>Version 1.0.0rc6 (Aug 14 2002) MacOS 9 fixes.
|
||||
<LI>Version 1.0.0 (Aug 16 2002) First 1.0.X release.
|
||||
<LI>Version 1.0.1 (Sep 14 2002) Added MAT4 and MAT5 file formats.
|
||||
<LI>Version 1.0.2 (Nov 24 2002) Added VOX ADPCM format.
|
||||
<LI>Version 1.0.3 (Dec 09 2002) Fixes for Linux on ia64 CPUs.
|
||||
<LI>Version 1.0.4 (Feb 02 2003) New file formats and functionality.
|
||||
<LI>Version 1.0.5 (May 03 2003) One new file format and new functionality.
|
||||
<LI>Version 1.0.6 (Feb 08 2004) Large file fix for Linux/Solaris, new functionality
|
||||
and Win32 improvements.
|
||||
<LI>Version 1.0.7 (Feb 24 2004) Fix build problems on MacOS X and fix ia64/MIPS etc
|
||||
clip mode detction.
|
||||
<LI>Version 1.0.8 (Mar 14 2004) Minor bug fixes.
|
||||
<LI>Version 1.0.9 (Mar 30 2004) Add AVR format. Improve handling of some WAV files.
|
||||
<LI>Version 1.0.10 (Jun 15 2004) Minor bug fixes. Fix support for Win32 MinGW compiler.
|
||||
<LI>Version 1.0.11 (Nov 15 2004) Add SD2 file support, reading of loop data in WAV and AIFF.
|
||||
Minor bug fixes.
|
||||
<LI>Version 1.0.12 (Sep 30 2005) Add FLAC and CAF file support, virtual I/O interface.
|
||||
Minor bug fixes and cleanups.
|
||||
<LI>Version 1.0.13 (Jan 21 2006) Add read/write of instrument chunks. Minor bug fixes.
|
||||
<LI>Version 1.0.14 (Feb 19 2006) Minor bug fixes. Start shipping windows binary/source ZIP.
|
||||
<LI>Version 1.0.15 (Mar 16 2006) Minor bug fixes.
|
||||
<LI>Version 1.0.16 (Apr 30 2006) Add support for RIFX. Other minor feature enhancements and
|
||||
bug fixes.
|
||||
<LI>Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and cleanups.
|
||||
<LI>Version 1.0.18 (Feb 07 2009) Add Ogg/Vorbis suppport, remove captive libraries, many
|
||||
new features and bug fixes. Generate Win32 and Win64 pre-compiled binaries.
|
||||
<LI>Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes as a
|
||||
result of static analysis.
|
||||
<LI>Version 1.0.20 (May 14 2009) Fix for potential heap overflow.
|
||||
<LI>Version 1.0.21 (December 13 2009) Bunch of minor bug fixes.
|
||||
<LI>Version 1.0.22 (October 04 2010) Bunch of minor bug fixes.
|
||||
<LI>Version 1.0.23 (October 10 2010) Minor bug fixes.
|
||||
<LI>Version 1.0.24 (March 23 2011) Minor bug fixes.
|
||||
<LI>Version 1.0.25 (July 13 2011) Fix for Secunia Advisory SA45125. Minor bug fixes and
|
||||
improvements.
|
||||
</UL>
|
||||
|
||||
<A NAME="Similar"></A>
|
||||
<H1><B>Similar or Related Projects</B></H1>
|
||||
|
||||
<UL>
|
||||
<LI><A HREF="http://sox.sourceforge.net/">SoX</A> is a program for
|
||||
converting between sound file formats.
|
||||
<LI><A HREF="http://www.hitsquad.com/smm/programs/WavPlay/">Wavplay</A> started out
|
||||
as a minimal WAV file player under Linux and has mutated into Gnuwave, a client/server
|
||||
application for more general multimedia and games sound playback.
|
||||
<LI><A HREF="http://www.68k.org/~michael/audiofile/">Audiofile</A> (libaudiofile) is
|
||||
a library similar to libsndfile but with a different programming interface. The
|
||||
author Michael Pruett has set out to clone (and fix some bugs in) the libaudiofile
|
||||
library which ships with SGI's IRIX OS.
|
||||
<LI><A HREF="ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz">sndlib.tar.gz</A> is
|
||||
another library written by Bill Schottstaedt of CCRMA.
|
||||
</UL>
|
||||
|
||||
<A NAME="Licensing"></A>
|
||||
<H1><B>Licensing</B></H1>
|
||||
<P>
|
||||
libsndfile is released under the terms of the GNU Lesser General Public License,
|
||||
of which there are two versions;
|
||||
<a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">version 2.1</a>
|
||||
and
|
||||
<a href="http://www.gnu.org/copyleft/lesser.html">version 3</a>.
|
||||
To maximise the compatibility of libsndfile, the user may choose to use libsndfile
|
||||
under either of the above two licenses.
|
||||
You can also read a simple explanation of the ideas behind the GPL and the LGPL
|
||||
<A HREF="http://www.gnu.org/copyleft/copyleft.html">here</A>.
|
||||
</P>
|
||||
<P>
|
||||
You can use libsndfile with
|
||||
<A HREF="http://www.gnu.org/">Free Software</A>,
|
||||
<A HREF="http://www.opensource.org/">Open Source</A>,
|
||||
proprietary, shareware or other closed source applications as long as libsndfile
|
||||
is used as a dynamically loaded library and you abide by a small number of other
|
||||
conditions (read the LGPL for more info).
|
||||
With applications released under the GNU GPL you can also use libsndfile statically
|
||||
linked to your application.
|
||||
</P>
|
||||
<P>
|
||||
I would like to see libsndfile used as widely as possible but I would prefer it
|
||||
if you released software that uses libsndfile as
|
||||
<A HREF="http://www.gnu.org/">Free Software</A>
|
||||
or
|
||||
<A HREF="http://www.opensource.org/">Open Source</A>.
|
||||
However, if you put in a great deal of effort building a significant application
|
||||
which simply uses libsndfile for file I/O, then I have no problem with you releasing
|
||||
that as closed source and charging as much money as you want for it as long as you
|
||||
abide by <A HREF="http://www.gnu.org/copyleft/lesser.html">the license</A>.
|
||||
</P>
|
||||
|
||||
<A NAME="Download"></A>
|
||||
<H1><B>Download</B></H1>
|
||||
<P>
|
||||
Here is the latest version. It is available in the following formats:
|
||||
</P>
|
||||
<UL>
|
||||
<LI>Source code as a .tar.gz :
|
||||
<A HREF="files/libsndfile-1.0.25.tar.gz">libsndfile-1.0.25.tar.gz</A>
|
||||
and
|
||||
<A HREF="files/libsndfile-1.0.25.tar.gz.asc">(GPG signature)</A>.
|
||||
<LI>Win32 installer:
|
||||
<A HREF="files/libsndfile-1.0.25-w32-setup.exe">
|
||||
libsndfile-1.0.25-w32-setup.exe</A> (thoroughly tested under
|
||||
<a href="http://www.winehq.com/">Wine</a> and Windows XP).
|
||||
<LI>Win64 installer:
|
||||
<A HREF="files/libsndfile-1.0.25-w64-setup.exe">
|
||||
libsndfile-1.0.25-w64-setup.exe</A>
|
||||
(thoroughly tested on 64 bit Windows 7).
|
||||
</UL>
|
||||
|
||||
<P>
|
||||
The Win32 installer was compiled for Windows XP but should also work on Windows
|
||||
2000, Vista and Windows 7.
|
||||
</p>
|
||||
|
||||
<P>
|
||||
Pre-release versions of libsndfile are available
|
||||
<A HREF="http://www.mega-nerd.com/tmp/">here</A>
|
||||
and are announced on the
|
||||
<A HREF="lists.html">libsndfile-devel</A>
|
||||
mailing list.
|
||||
</P>
|
||||
|
||||
<A NAME="SeeAlso"></A>
|
||||
<H1><B>See Also</B></H1>
|
||||
<UL>
|
||||
<LI><a href="http://www.mega-nerd.com/libsndfile/tools/">
|
||||
sndfile-tools</a>
|
||||
: a small collection of programs which use libsndfile.
|
||||
</UL>
|
||||
|
||||
<br><br>
|
||||
|
||||
<hr>
|
||||
|
||||
<P>
|
||||
The latest version of this document can be found
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">here</A>.
|
||||
</P>
|
||||
<P>
|
||||
Author :
|
||||
<A HREF="mailto:erikd@mega-nerd.com">
|
||||
Erik de Castro Lopo</a>
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
This page has been accessed
|
||||
<IMG SRC=
|
||||
"/cgi-bin/Count.cgi?ft=6|frgb=55;55;55|tr=0|trgb=0;0;0|wxh=15;20|md=7|dd=B|st=1|sh=1|df=libsndfile.dat"
|
||||
HEIGHT=30 WIDTH=100 ALT="counter.gif">
|
||||
times.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
|
||||
<br><br>
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,92 +0,0 @@
|
|||
body {
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : @HTML_FGCOLOUR@ ;
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
line-height: 1.5 ;
|
||||
}
|
||||
td {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : @HTML_FGCOLOUR@ ;
|
||||
}
|
||||
center {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
}
|
||||
p {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
.indent_block {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 10% ;
|
||||
margin-right : 10% ;
|
||||
}
|
||||
br {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
}
|
||||
form {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
}
|
||||
ul {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 6% ;
|
||||
}
|
||||
ol {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 6% ;
|
||||
}
|
||||
dl {
|
||||
font-family : arial, helvetica, sans-serif ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h1 {
|
||||
font-size : xx-large ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h2 {
|
||||
font-size : x-large ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h3 {
|
||||
font-size : large ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
h4 {
|
||||
font-size : medium ;
|
||||
background : @HTML_BGCOLOUR@ ;
|
||||
color : #5050FF ;
|
||||
text-align : left ;
|
||||
margin-left : 3% ;
|
||||
margin-right : 3% ;
|
||||
}
|
||||
pre {
|
||||
font-family : courier, monospace ;
|
||||
font-size : medium ;
|
||||
margin-left : 6% ;
|
||||
margin-right : 6% ;
|
||||
}
|
||||
a:link { color : #9090FF ; }
|
||||
a:visited { color : #5050FF ; }
|
||||
a:active { color : #FF00FF ; }
|
||||
a:hover { background-color : #202080 ; }
|
|
@ -1,434 +0,0 @@
|
|||
# Here are some some emails I exchanged with a guy trying to use
|
||||
# libsndfile version 1 with code from the book "Linux Games Programming"
|
||||
# by John Hall. The email addresses have been changed to foil the spam
|
||||
# bots.
|
||||
|
||||
Date: Tue, 20 Jul 2004 22:49:21 +0100
|
||||
From: Paul <paul@fake-domain-name.co.uk>
|
||||
To: erikd@fake-domain-name.com
|
||||
Subject: Can you help with a problem?
|
||||
Date: Tue, 20 Jul 2004 22:49:21 +0100
|
||||
|
||||
Hi,
|
||||
|
||||
I'm trying to get the source examples in the "Programming Linux Games"
|
||||
(NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile.
|
||||
|
||||
While I can guess some of the newer versions of function calls and
|
||||
enumerations, there are some which I cannot guess.
|
||||
|
||||
Would you be able to translate them to the current version of
|
||||
enumeration and function calls so that I can update the source?
|
||||
|
||||
These are the three currently failing me:
|
||||
|
||||
sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,SFM_READ, &sfinfo))
|
||||
SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
|
||||
SF_INFO.pcmbitwidth (guess: no idea!)
|
||||
|
||||
There are probably more. I'm happy to send you the source files for
|
||||
sound calls, scan the pages or anything else. Failing that, is there
|
||||
somewhere with the changes listed so I can try and fix the code for myself?
|
||||
|
||||
Thanks
|
||||
|
||||
TTFN
|
||||
|
||||
Paul
|
||||
|
||||
================================================================================
|
||||
|
||||
Date: Wed, 21 Jul 2004 17:38:08 +1000
|
||||
From: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
To: Paul <paul@fake-domain-name.co.uk>
|
||||
Subject: Re: Can you help with a problem?
|
||||
|
||||
On Tue, 20 Jul 2004 22:49:21 +0100
|
||||
Paul <paul@fake-domain-name.co.uk> wrote:
|
||||
|
||||
> Hi,
|
||||
>
|
||||
> I'm trying to get the source examples in the "Programming Linux Games"
|
||||
> (NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile.
|
||||
>
|
||||
> While I can guess some of the newer versions of function calls and
|
||||
> enumerations, there are some which I cannot guess.
|
||||
>
|
||||
> Would you be able to translate them to the current version of
|
||||
> enumeration and function calls so that I can update the source?
|
||||
>
|
||||
> These are the three currently failing me:
|
||||
>
|
||||
> sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,
|
||||
> SFM_READ, &sfinfo))
|
||||
|
||||
yes.
|
||||
|
||||
> SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
|
||||
|
||||
Actually this list:
|
||||
|
||||
SF_FORMAT_PCM_U8
|
||||
SF_FORMAT_PCM_S8
|
||||
SF_FORMAT_PCM_16
|
||||
SF_FORMAT_PCM_24
|
||||
SF_FORMAT_PCM_32
|
||||
|
||||
> SF_INFO.pcmbitwidth (guess: no idea!)
|
||||
|
||||
WIth the above change, pcmbitwidth becomes redundant.
|
||||
|
||||
> There are probably more. I'm happy to send you the source files for
|
||||
> sound calls, scan the pages or anything else. Failing that, is there
|
||||
> somewhere with the changes listed so I can try and fix the code for
|
||||
> myself?
|
||||
|
||||
Version 1.0.0 came out some time ago, but I think this:
|
||||
|
||||
http://www.mega-nerd.com/libsndfile/version-1.html
|
||||
|
||||
lists most of the changes. You should also look at the API docs:
|
||||
|
||||
http://www.mega-nerd.com/libsndfile/api.html
|
||||
|
||||
HTH,
|
||||
Erik
|
||||
--
|
||||
+-----------------------------------------------------------+
|
||||
Erik de Castro Lopo nospam@fake-domain-name.com
|
||||
+-----------------------------------------------------------+
|
||||
"There is no reason why anyone would want a computer in their home"
|
||||
Ken Olson, DEC, 1977
|
||||
|
||||
================================================================================
|
||||
|
||||
From: PFJ <paul@fake-domain-name.co.uk>
|
||||
To: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
Subject: Re: Can you help with a problem?
|
||||
Date: Wed, 21 Jul 2004 09:07:39 +0100
|
||||
|
||||
|
||||
Hi Erik,
|
||||
|
||||
Thanks for getting back to me.
|
||||
|
||||
> > sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename, SFM_READ, &sfinfo))
|
||||
>
|
||||
> yes.
|
||||
|
||||
Yay!
|
||||
|
||||
> > SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
|
||||
>
|
||||
> Actually this list:
|
||||
>
|
||||
> SF_FORMAT_PCM_U8
|
||||
> SF_FORMAT_PCM_S8
|
||||
> SF_FORMAT_PCM_16
|
||||
> SF_FORMAT_PCM_24
|
||||
> SF_FORMAT_PCM_32
|
||||
|
||||
I know, but the source code explicitly has SF_FORMAT_PCM which given the
|
||||
code afterwards would equate to one of the above, but given that PCM
|
||||
files can have a varied bitwidth the author probably wanted to cover all
|
||||
bases.
|
||||
|
||||
> Version 1.0.0 came out some time ago, but I think this:
|
||||
>
|
||||
> http://www.mega-nerd.com/libsndfile/version-1.html
|
||||
>
|
||||
> lists most of the changes. You should also look at the API docs:
|
||||
>
|
||||
> http://www.mega-nerd.com/libsndfile/api.html
|
||||
|
||||
I'll download them and see what I can gleen.
|
||||
|
||||
Thanks again for getting back to me
|
||||
|
||||
TTFN
|
||||
|
||||
Paul
|
||||
|
||||
================================================================================
|
||||
|
||||
Date: Wed, 21 Jul 2004 18:20:29 +1000
|
||||
From: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
To: PFJ <paul@fake-domain-name.co.uk>
|
||||
Subject: Re: Can you help with a problem?
|
||||
|
||||
On Wed, 21 Jul 2004 09:07:39 +0100
|
||||
PFJ <paul@fake-domain-name.co.uk> wrote:
|
||||
|
||||
> I know, but the source code explicitly has SF_FORMAT_PCM which given the
|
||||
> code afterwards would equate to one of the above, but given that PCM
|
||||
> files can have a varied bitwidth the author probably wanted to cover all
|
||||
> bases.
|
||||
|
||||
But surely the existing code does something like:
|
||||
|
||||
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
|
||||
sfinfo.pcmbitwidth = 16;
|
||||
|
||||
which can be directly translated to:
|
||||
|
||||
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
|
||||
|
||||
and the same for pcmbitwitdhs of 24 and 32. For pcmbitwidth of 8
|
||||
you need to know that WAV files use SF_FORMAT_PCM_U8 and AIFF
|
||||
files use SF_FORMAT_PCM_S8. Thats all there is to it.
|
||||
|
||||
Erik
|
||||
--
|
||||
+-----------------------------------------------------------+
|
||||
Erik de Castro Lopo nospam@fake-domain-name.com
|
||||
+-----------------------------------------------------------+
|
||||
"Python addresses true pseudocode's two major failings: that it
|
||||
isn't standardized, and it isn't executable."
|
||||
- Grant R. Griffin in comp.dsp
|
||||
|
||||
================================================================================
|
||||
|
||||
Subject: Re: Can you help with a problem?
|
||||
From: PFJ <paul@fake-domain-name.co.uk>
|
||||
To: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
Date: Wed, 21 Jul 2004 09:50:55 +0100
|
||||
|
||||
Hi Erik,
|
||||
|
||||
> > I know, but the source code explicitly has SF_FORMAT_PCM which given the
|
||||
> > code afterwards would equate to one of the above, but given that PCM
|
||||
> > files can have a varied bitwidth the author probably wanted to cover all
|
||||
> > bases.
|
||||
>
|
||||
> But surely the existing code does something like:
|
||||
>
|
||||
> sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
|
||||
> sfinfo.pcmbitwidth = 16;
|
||||
|
||||
If only!
|
||||
|
||||
The actual code is this
|
||||
|
||||
int LoadSoundFile(char *filename, sound_p sound)
|
||||
{
|
||||
SNDFILE *file;
|
||||
SF_INFO file_info;
|
||||
short *buffer_short = NULL;
|
||||
u_int8_t *buffer_8 = NULL;
|
||||
int16_t *buffer_16 = NULL;
|
||||
unsigned int i;
|
||||
|
||||
/* Open the file and retrieve sample information. */
|
||||
file = sf_open_read(filename, &file_info);
|
||||
// I've sorted this one already - PFJ
|
||||
|
||||
/* Make sure the format is acceptable. */
|
||||
if ((file_info.format & 0x0F) != SF_FORMAT_PCM) {
|
||||
printf("'%s' is not a PCM-based audio file.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) {
|
||||
sound->format = AL_FORMAT_MONO8;
|
||||
} else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) {
|
||||
sound->format = AL_FORMAT_STEREO8;
|
||||
} else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) {
|
||||
sound->format = AL_FORMAT_MONO16;
|
||||
} else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) {
|
||||
sound->format = AL_FORMAT_STEREO16;
|
||||
} else {
|
||||
printf("Unknown sample format in %s.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* Allocate buffers. */
|
||||
buffer_short = (short *)malloc(file_info.samples * file_info.channels * sizeof (short));
|
||||
|
||||
buffer_8 = (u_int8_t *)malloc(file_info.samples * file_info.channels * file_info.pcmbitwidth / 8);
|
||||
|
||||
buffer_16 = (int16_t *)buffer_8;
|
||||
|
||||
if (buffer_short == NULL || buffer_8 == NULL) {
|
||||
printf("Unable to allocate enough memory for '%s'.\n", filename);
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
/* Read the entire sound file. */
|
||||
if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)-1) {
|
||||
printf("Error while reading samples from '%s'.\n", filename);
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
<minor snip>
|
||||
|
||||
/* Fill in the sound data structure. */
|
||||
sound->freq = file_info.samplerate;
|
||||
sound->size = file_info.samples * file_info.channels * file_info.pcmbitwidth / 8;
|
||||
|
||||
/* Give our sound data to OpenAL. */
|
||||
alGenBuffers(1, &sound->name);
|
||||
if (alGetError() != AL_NO_ERROR) {
|
||||
printf("Error creating an AL buffer name for %s.\n", filename);
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
alBufferData(sound->name, sound->format, buffer_8, sound->size,sound->freq);
|
||||
if (alGetError() != AL_NO_ERROR) {
|
||||
printf("Error sending buffer data to OpenAL for %s.\n", filename);
|
||||
goto error_cleanup;
|
||||
}
|
||||
|
||||
/* Close the file and return success. */
|
||||
sf_close(file);
|
||||
free(buffer_short);
|
||||
free(buffer_8);
|
||||
|
||||
return 0;
|
||||
|
||||
error_cleanup:
|
||||
if (file != NULL) fclose(file);
|
||||
free(buffer_short);
|
||||
free(buffer_8);
|
||||
return -1;
|
||||
}
|
||||
|
||||
As you can see, the PCM material in the listing will not currently
|
||||
compile and for the other sndfile material, it probably won't either.
|
||||
|
||||
Any help would be appreciated.
|
||||
|
||||
TTFN
|
||||
|
||||
Paul
|
||||
|
||||
================================================================================
|
||||
|
||||
From: Erik de Castro Lopo <erikd@fake-domain-name.com>
|
||||
To: PFJ <paul@fake-domain-name.co.uk>
|
||||
Subject: Re: Can you help with a problem?
|
||||
Date: Wed, 21 Jul 2004 19:36:46 +1000
|
||||
|
||||
On Wed, 21 Jul 2004 09:50:55 +0100
|
||||
PFJ <paul@fake-domain-name.co.uk> wrote:
|
||||
|
||||
> Hi Erik,
|
||||
>
|
||||
> > > I know, but the source code explicitly has SF_FORMAT_PCM which given the
|
||||
> > > code afterwards would equate to one of the above, but given that PCM
|
||||
> > > files can have a varied bitwidth the author probably wanted to cover all
|
||||
> > > bases.
|
||||
> >
|
||||
> > But surely the existing code does something like:
|
||||
> >
|
||||
> > sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
|
||||
> > sfinfo.pcmbitwidth = 16;
|
||||
>
|
||||
> If only!
|
||||
|
||||
No, really.
|
||||
|
||||
Drop this completely:
|
||||
|
||||
> /* Make sure the format is acceptable. */
|
||||
> if ((file_info.format & 0x0F) != SF_FORMAT_PCM) {
|
||||
> printf("'%s' is not a PCM-based audio file.\n", filename);
|
||||
> sf_close(file);
|
||||
> return -1;
|
||||
> }
|
||||
|
||||
Replace this block:
|
||||
|
||||
> if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) {
|
||||
> sound->format = AL_FORMAT_MONO8;
|
||||
> } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) {
|
||||
> sound->format = AL_FORMAT_STEREO8;
|
||||
> } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) {
|
||||
> sound->format = AL_FORMAT_MONO16;
|
||||
> } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) {
|
||||
> sound->format = AL_FORMAT_STEREO16;
|
||||
> } else {
|
||||
> printf("Unknown sample format in %s.\n", filename);
|
||||
> sf_close(file);
|
||||
> return -1;
|
||||
> }
|
||||
|
||||
with:
|
||||
|
||||
int pcmbitwidth = 0;
|
||||
|
||||
if (file_info.format & SF_FORMAT_SUBMASK != SF_FORMAT_PCM_16)
|
||||
{ printf("'%s' is not a PCM-based audio file.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (file_info.channels < 1 || file_info.channels > 2)
|
||||
{ printf("'%s' bad channel count.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
switch (file_info.format & SF_FORMAT_SUBMASK + file_info.channels << 16)
|
||||
{ case (SF_FORMAT_PCM_U8 + 1 << 16):
|
||||
sound->format = AL_FORMAT_MONO8;
|
||||
pcmbitwidth = 8;
|
||||
break;
|
||||
case (SF_FORMAT_PCM_U8 + 2 << 16):
|
||||
sound->format = AL_FORMAT_STEREO8;
|
||||
pcmbitwidth = 8;
|
||||
break;
|
||||
case (SF_FORMAT_PCM_16 + 1 << 16):
|
||||
sound->format = AL_FORMAT_MONO16;
|
||||
pcmbitwidth = 16;
|
||||
break;
|
||||
case (SF_FORMAT_PCM_16 + 2 << 16):
|
||||
sound->format = AL_FORMAT_STEREO16;
|
||||
pcmbitwidth = 16;
|
||||
break;
|
||||
default:
|
||||
printf("Unknown sample format in %s.\n", filename);
|
||||
sf_close(file);
|
||||
return -1;
|
||||
}
|
||||
|
||||
> /* Allocate buffers. */
|
||||
> buffer_short = (short *)malloc(file_info.samples *
|
||||
> file_info.channels *
|
||||
> sizeof (short));
|
||||
>
|
||||
> buffer_8 = (u_int8_t *)malloc(file_info.samples *
|
||||
> file_info.channels *
|
||||
> file_info.pcmbitwidth / 8);
|
||||
|
||||
Use pcmbitwidth as calculated above.
|
||||
|
||||
> buffer_16 = (int16_t *)buffer_8;
|
||||
>
|
||||
> if (buffer_short == NULL || buffer_8 == NULL) {
|
||||
> printf("Unable to allocate enough memory for '%s'.\n", filename);
|
||||
> goto error_cleanup;
|
||||
> }
|
||||
>
|
||||
> /* Read the entire sound file. */
|
||||
> if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)- 1) {
|
||||
|
||||
Replace "(size_t) - 1" with " < 0".
|
||||
|
||||
> As you can see, the PCM material in the listing will not currently
|
||||
> compile and for the other sndfile material, it probably won't either.
|
||||
|
||||
None of the changes above should have been very difficult to figure
|
||||
out.
|
||||
|
||||
Erik
|
||||
--
|
||||
+-----------------------------------------------------------+
|
||||
Erik de Castro Lopo nospam@fake-domain-name.com
|
||||
+-----------------------------------------------------------+
|
||||
Microsoft is finally bringing all of its Windows operating system families
|
||||
under one roof. It will combine all of the features of CE, stability and
|
||||
support of ME and the speed of NT.
|
||||
It will be called Windows CEMENT...
|
||||
|
|
@ -1,52 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile Mailing Lists
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<!-- pepper -->
|
||||
<H1><BR>libsndfile Mailing Lists</H1>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
There are three mailing lists for libsndfile:
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<UL>
|
||||
<LI> <B>libsndfile-announce@mega-nerd.com</B> <!-- pepper -->
|
||||
<A HREF="mailto:libsndfile-announce-request@mega-nerd.com?subject=subscribe">Subscribe</A>
|
||||
<BR>
|
||||
A list which will announce each new release of libsndfile.
|
||||
Noone can post to this list except the author.
|
||||
<BR><BR>
|
||||
|
||||
<LI> <B>libsndfile-devel@mega-nerd.com</B> <!-- pepper -->
|
||||
<A HREF="mailto:libsndfile-devel-request@mega-nerd.com?subject=subscribe">Subscribe</A>
|
||||
<BR>
|
||||
A list for discussing bugs, porting issues and feature requests.
|
||||
Posting is restricted to subscribers.
|
||||
<BR><BR>
|
||||
|
||||
<LI> <B>libsndfile-users@mega-nerd.com</B> <!-- pepper -->
|
||||
<A HREF="mailto:libsndfile-users-request@mega-nerd.com?subject=subscribe">Subscribe</A>
|
||||
<BR>
|
||||
A list for discussing the use of libsndfile in other programs.
|
||||
Posting is restricted to subscribers.
|
||||
<!-- pepper -->
|
||||
<BR><BR>
|
||||
</UL>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
The libsndfile-devel and libsndfile-users list will automatically receive a
|
||||
copy of all emails to the libsndfile-announce list.
|
||||
</P>
|
||||
<BR>
|
||||
<!-- pepper -->
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,135 +0,0 @@
|
|||
new_file_type.HOWTO
|
||||
===================
|
||||
|
||||
Original : Wed May 23 19:05:07 EST 2001
|
||||
Update 1 : Fri Jul 11 22:12:38 EST 2003
|
||||
|
||||
This document will attempt to explain as fully as possible how to add code to
|
||||
libsndfile to allow the reading and writing of new file types. By new file
|
||||
type I particularly mean a new header type rather than a new encoding method
|
||||
for an existing file type.
|
||||
|
||||
This HOWTO will take the form of a step by step guide. It will assume that you
|
||||
have all required tools including :
|
||||
|
||||
- gcc
|
||||
- make (should really be the GNU version)
|
||||
- autoconf
|
||||
- automake
|
||||
- libtool
|
||||
|
||||
These should all be available on the GNU ftp site: ftp://ftp.gnu.org/pub/gnu/.
|
||||
|
||||
To help make these steps clearer let's suppose we are adding support for the
|
||||
Whacky file format whose files contain 'W','A','C' and 'K' as the first four
|
||||
bytes of the file format. Lets also assume that Whacky files contain PCM encoded
|
||||
data.
|
||||
|
||||
Step 1
|
||||
------
|
||||
Create a new .c file in the src/ directory of the libsndfile source tree. The
|
||||
file name should be reasonable descriptive so that is is obvious that files of
|
||||
the new type are handled by this file. In this particular case the file might
|
||||
be named 'whacky.c'.
|
||||
|
||||
Step 2
|
||||
------
|
||||
Add your new source code file to the build process.
|
||||
|
||||
Edit the file src/Makefile.am and add the name of your file handler to the
|
||||
FILESPECIFIC list of handlers. This list looks something like this:
|
||||
|
||||
FILESPECIFIC = aiff.c au.c au_g72x.c nist.c paf.c raw.c samplitude.c \
|
||||
svx.c wav.c wav_float.c wav_gsm610.c wav_ima_adpcm.c \
|
||||
wav_ms_adpcm.c
|
||||
|
||||
Then, run the script named 'reconf' in the libsndfile top level directory,
|
||||
which will run autoconf and other associated tools. Finally run "./configure"
|
||||
in the top level directory. You may want to use the "--disable-gcc-opt" option
|
||||
to disable gcc optimisations and make debugging with gdb/ddd easier.
|
||||
|
||||
Step 3
|
||||
------
|
||||
Add a unique identifier for the new file type.
|
||||
|
||||
Edit src/sndfile.h.in and find the enum containing the SF_FORMAT_XXX identifiers.
|
||||
Since you will be adding a major file type you should add your identifier to the
|
||||
top part of the list where the values are above 0x10000 in value. The easiest
|
||||
way to do this is to find the largest value in the list, add 0x10000 to it and
|
||||
make that your new identifier value. The identifier should be something like
|
||||
SF_FORMAT_WACK.
|
||||
|
||||
Step 4
|
||||
------
|
||||
Add code to the file type recogniser function.
|
||||
|
||||
Edit src/sndfile.c and find the function guess_file_type (). This function
|
||||
reads the first 3 ints of the file and from that makes a guess at the file
|
||||
type. In our case we would add:
|
||||
|
||||
|
||||
if (buffer [0] == MAKE_MARKER ('W','A','C','K'))
|
||||
return SF_FORMAT_WACK ;
|
||||
|
||||
The use of the MAKE_MARKER macro should be pretty obvious and it is defined at the
|
||||
top of file should you need to have a look at it.
|
||||
|
||||
Step 5
|
||||
------
|
||||
Add a call to your open function from psf_open_file ().
|
||||
|
||||
Edit src/sndfile.c and find the switch statement in psf_open_file (). It starts
|
||||
like this:
|
||||
|
||||
switch (filetype)
|
||||
{ case SF_FORMAT_WAV :
|
||||
error = wav_open (psf) ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_AIFF :
|
||||
error = aiff_open (psf) ;
|
||||
break ;
|
||||
|
||||
Towards the bottom of this switch statement your should add one for the new file
|
||||
type. Something like:
|
||||
|
||||
case SF_FORMAT_WACK :
|
||||
sf_errno = whacky_open (psf) ;
|
||||
break ;
|
||||
|
||||
Setp 6
|
||||
------
|
||||
Add prototypes for new open read and open write functions.
|
||||
|
||||
Edit src/common.h, go to the bottom of the file and add something like
|
||||
|
||||
int whacky_open (SF_PRIVATE *psf) ;
|
||||
|
||||
Step 7
|
||||
------
|
||||
|
||||
Implement your open read function. The best way to do this is by coding
|
||||
something much like one of the other file formats. The file src/au.c might be
|
||||
a good place to start.
|
||||
|
||||
In src/whacky.c you should now implement the function whacky_open() which
|
||||
was prototyped in src/common.h. This function should return 0 on success and
|
||||
a non-zero number on error.
|
||||
|
||||
Error values are defined in src/common.h in a enum which starts at SFE_NO_ERROR.
|
||||
When adding a new error value, you also need to add an error string to the
|
||||
SndfileErrors array in src/sndfile.c.
|
||||
|
||||
To parse the header of your new file type you should avoid using standard read/
|
||||
write/seek functions (and the fread/fwrite/fseek etc) and instead use
|
||||
psf_binheader_readf () which is implemented and documented in src/common.h.
|
||||
|
||||
During the parsing process, you should also print logging information to
|
||||
libsndfile's internal log buffer using the psf_log_printf() function.
|
||||
|
||||
At the end of the open read process, you should have set a number of fields in the
|
||||
SF_PRIVATE structure pointed to by psf.
|
||||
|
||||
|
||||
|
||||
*** THIS FILE IS INCOMPLETE ***
|
|
@ -1,118 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile and GNU Octave
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<BR>
|
||||
<H1><B>libsndfile and GNU Octave</B></H1>
|
||||
<P>
|
||||
<A HREF="http://www.octave.org/">GNU Octave</A> is a high-level interactive
|
||||
language for numerical computations.
|
||||
There are currently two development streams, a stable 2.0.X series and a
|
||||
development 2.1.X series.
|
||||
Octave reads and writes data in binary formats that were originally developed
|
||||
for
|
||||
<A HREF="http://www.mathworks.com/">MATLAB</A>.
|
||||
Version 2.0.X of Octave uses binary data files compatible with MATLAB
|
||||
version 4.2 while Octave 2.1.X uses binary data files compatible
|
||||
with MATLAB version 5.0 as well as being able to read the older MATLAB 4.2
|
||||
format.
|
||||
</P>
|
||||
<P>
|
||||
From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading
|
||||
and writing a small subset of the binary data files used by both versions
|
||||
of GNU Octave.
|
||||
This gives people using GNU Octave for audio based work an easy method of
|
||||
moving audio data between GNU Octave and other programs which use libsndfile.
|
||||
</P>
|
||||
<P>
|
||||
For instance it is now possible to do the following:
|
||||
</P>
|
||||
|
||||
<UL>
|
||||
<LI> Load a WAV file into a sound file editor such as
|
||||
<A HREF="http://www.metadecks.org/software/sweep/">Sweep</A>.
|
||||
<LI> Save it as a MAT4 file.
|
||||
<LI> Load the data into Octave for manipulation.
|
||||
<LI> Save the modified data.
|
||||
<LI> Reload it in Sweep.
|
||||
</UL>
|
||||
<P>
|
||||
Another example would be using the MAT4 or MAT5 file formats as a format which
|
||||
can be easily loaded into Octave for viewing/analyzing as well as a format
|
||||
which can be played with command line players such as the one included with
|
||||
libsndfile.
|
||||
</P>
|
||||
|
||||
<H2><B>Details</B></H2>
|
||||
<P>
|
||||
Octave, like most programming languages, uses variables to store data, and
|
||||
Octave variables can contain both arrays and matrices.
|
||||
It is also able to store one or more of these variables in a file.
|
||||
When reading Octave files, libsndfile expects a file to contain two
|
||||
variables and their associated data.
|
||||
The first variable should contain a variable holding the file sample rate
|
||||
while the second variable contains the audio data.
|
||||
</P>
|
||||
<P>
|
||||
For example, to generate a sine wave and store it as a binary file which
|
||||
is compatible with libsndfile, do the following:
|
||||
</P>
|
||||
<PRE>
|
||||
octave:1 > samplerate = 44100 ;
|
||||
octave:2 > wavedata = sin ((0:1023)*2*pi/1024) ;
|
||||
octave:3 > save sine.mat samplerate wavedata
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
The process of reading and writing files compatible with libsndfile can be
|
||||
made easier by use of two Octave script files :
|
||||
</P>
|
||||
<PRE>
|
||||
octave:4 > [data fs] = sndfile_load ("sine.mat") ;
|
||||
octave:5 > sndfile_save ("sine2.mat", data, fs) ;
|
||||
</PRE>
|
||||
<P>
|
||||
In addition, libsndfile contains a command line program which which is able
|
||||
to play the correct types of Octave files.
|
||||
Using this command line player <B>sndfile-play</B> and a third Octave script
|
||||
file allows Octave data to be played from within Octave on any of the platforms
|
||||
which <B>sndfile-play</B> supports (at the moment: Linux, MacOS X, Solaris and
|
||||
Win32).
|
||||
</P>
|
||||
<PRE>
|
||||
octave:6 > sndfile_play (data, fs) ;
|
||||
</PRE>
|
||||
<P>
|
||||
These three Octave scripts are installed automatically in Octave's site
|
||||
script directory when libsndfile is installed (except on Win32) ie when
|
||||
libsndfile is being installed into /usr/local, the Octave scripts will
|
||||
be installed in /usr/local/share/octave/site/m/.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
There are some other Octave scripts for audio to be found
|
||||
<A HREF="http://octave.sourceforge.net/audio/index.html">here</A>.
|
||||
</P>
|
||||
|
||||
<BR>
|
||||
<!-- ========================================================================= -->
|
||||
|
||||
<HR>
|
||||
<P>
|
||||
The libsndfile home page is here :
|
||||
<A HREF="http://www.mega-nerd.com/libsndfile/">
|
||||
http://www.mega-nerd.com/libsndfile/</A>.
|
||||
</P>
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,71 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile : pkg-config
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<BR>
|
||||
<H1>libsndfile and pkg-config</H1>
|
||||
|
||||
<P>
|
||||
From version 1.0.0 libsndfile has had the ability to read and write files of
|
||||
greater than 2 Gig in size on most OSes even if sizeof (long) == 4.
|
||||
OSes which support this feature include Linux (2.4 kernel, glibc6) on x86, PPC and
|
||||
probably others, Win32, MacOS X, *BSD, Solaris and probably others.
|
||||
OSes on 64 bit processors where the default compile environment is LP64 (longs and
|
||||
pointers are 64 bit ie Linux on DEC/Compaq/HP Alpha processors) automatically
|
||||
support large file access.
|
||||
</P>
|
||||
<P>
|
||||
Other OSes including Linux on 32 bit processors, 32 bit Solaris and others require
|
||||
special compiler flags to add large file support.
|
||||
This applies to both the compilation of the library itself and the compilation of
|
||||
programs which link to the library.
|
||||
</P>
|
||||
<P>
|
||||
Note : People using Win32, MacOS (both OS X and pre-OS X) or *BSD can disregard the
|
||||
rest of this document as it does not apply to either of these OSes.
|
||||
</P>
|
||||
<P>
|
||||
The <B>pkg-config</B> program makes finding the correct compiler flag values and
|
||||
library location far easier.
|
||||
During the installation of libsndfile, a file named <B>sndfile.pc</B> is installed
|
||||
in the directory <B>${libdir}/pkgconfig</B> (ie if libsndfile is installed in
|
||||
<B>/usr/local/lib</B>, <B>sndfile.pc</B> will be installed in
|
||||
<B>/usr/local/lib/pkgconfig/</B>).
|
||||
</P>
|
||||
<P>
|
||||
In order for pkg-config to find sndfile.pc it may be necessary to point the
|
||||
environment variable <B>PKG_CONFIG_PATH</B> in the right direction.
|
||||
</P>
|
||||
<PRE>
|
||||
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Then, to compile a C file into an object file, the command would be:
|
||||
</P>
|
||||
<PRE>
|
||||
gcc `pkg-config --cflags sndfile` -c somefile.c
|
||||
</PRE>
|
||||
<P>
|
||||
and to link a number of objects into an executable that links against libsndfile,
|
||||
the command would be:
|
||||
</P>
|
||||
<PRE>
|
||||
gcc `pkg-config --libs sndfile` obj1.o obj2.o -o program
|
||||
</PRE>
|
||||
|
||||
<P>
|
||||
Obviously all this can be rolled into a Makefile for easier maintenance.
|
||||
</P>
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,14 +0,0 @@
|
|||
body {
|
||||
background:white;
|
||||
color:black;
|
||||
}
|
||||
|
||||
h1{
|
||||
background:white;
|
||||
color:black;
|
||||
}
|
||||
|
||||
h2 {
|
||||
background:white;
|
||||
color:#666;
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
sndfile-info
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
|
||||
<P>
|
||||
Here is an example of the output from the <B>sndfile-info</B> program distributed with
|
||||
libsndfile.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
This file was opened and parsed correctly but had been truncated so that the values
|
||||
in the <B>FORM</B> and <B>SSND</B> chunks were incorrect.
|
||||
</P>
|
||||
<PRE>
|
||||
<B>erikd@hendrix ></B> examples/sndfile-info truncated.aiff
|
||||
truncated.aiff
|
||||
size : 200000
|
||||
FORM : 307474 (should be 199992)
|
||||
AIFF
|
||||
COMM : 18
|
||||
Sample Rate : 16000
|
||||
Samples : 76857
|
||||
Channels : 2
|
||||
Sample Size : 16
|
||||
SSND : 307436 (should be 199946)
|
||||
Offset : 0
|
||||
Block Size : 0
|
||||
|
||||
--------------------------------
|
||||
Sample Rate : 16000
|
||||
Frames : 76857
|
||||
Channels : 2
|
||||
Bit Width : 16
|
||||
Format : 0x00020001
|
||||
Sections : 1
|
||||
Seekable : TRUE
|
||||
Signal Max : 32766
|
||||
|
||||
</PRE>
|
||||
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,34 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
libsndfile Tutorial
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<!-- pepper -->
|
||||
<H1><BR>libsndfile Tutorial</H1>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
<b>More coming soon.</b>
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<P>
|
||||
For now, the best place to look for example code is the <tt>examples/</tt>
|
||||
directory of the source code distribution and the libsndfile test suite which
|
||||
is located in the <tt>tests/</tt> directory of the source code distribution.
|
||||
</P>
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
</BODY>
|
||||
</HTML>
|
||||
|
|
@ -1,53 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<HTML>
|
||||
|
||||
<HEAD>
|
||||
<TITLE>
|
||||
Building libsndfile on Win32
|
||||
</TITLE>
|
||||
<META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
|
||||
<LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
|
||||
<LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
|
||||
</HEAD>
|
||||
|
||||
<BODY>
|
||||
<!-- pepper -->
|
||||
<H1><BR>Building libsndfile on Win32</H1>
|
||||
|
||||
<P><B>
|
||||
Note : For pre-compiled binaries for windows, both for win32 and win64, see the
|
||||
main web page.
|
||||
</B></P>
|
||||
|
||||
<P>
|
||||
There is currently only one way of building libsndfile for Win32 and Win64;
|
||||
cross compiling from Linux using the MinGW cross compiler.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
libsndfile is written to be compiled by a compiler which supports large
|
||||
chunks of the 1999 ISO C Standard.
|
||||
Unfortunately, the microsoft compiler supports close to nothing of this
|
||||
standard and hence is not suitable for libsndfile.
|
||||
</P>
|
||||
|
||||
<P>
|
||||
It <b>may</b> be possible to compile libsndfile on windows using the
|
||||
<a href="http://www.mingw.org/">MinGW</a>
|
||||
compiler suite, but I haven't tested that and have no interest in supporting
|
||||
that.
|
||||
</P>
|
||||
|
||||
<!--===========================================================================-->
|
||||
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<BR>
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
<!-- pepper -->
|
||||
|
||||
</BODY>
|
||||
</HTML>
|
|
@ -1,25 +0,0 @@
|
|||
#!/bin/sh
|
||||
# @configure_input@
|
||||
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
bindir=@bindir@
|
||||
pkgconfigdir=@pkgconfigdir@
|
||||
datadir=@datadir@
|
||||
datarootdir=@datarootdir@
|
||||
docdir=@docdir@
|
||||
htmldir=@htmldir@
|
||||
|
||||
echo "
|
||||
Installation directories :
|
||||
|
||||
Library directory : ................... $libdir
|
||||
Program directory : ................... $bindir
|
||||
Pkgconfig directory : ................. $pkgconfigdir
|
||||
HTML docs directory : ................. $htmldir
|
||||
"
|
||||
echo "Compiling some other packages against libsndfile may require"
|
||||
echo "the addition of '$pkgconfigdir' to the"
|
||||
echo "PKG_CONFIG_PATH environment variable."
|
||||
echo
|
|
@ -1,25 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
noinst_PROGRAMS = make_sine sfprocess list_formats generate sndfilehandle sndfile-to-text
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src
|
||||
|
||||
sndfile_to_text_SOURCES = sndfile-to-text.c
|
||||
sndfile_to_text_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
make_sine_SOURCES = make_sine.c
|
||||
make_sine_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sfprocess_SOURCES = sfprocess.c
|
||||
sfprocess_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
list_formats_SOURCES = list_formats.c
|
||||
list_formats_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
generate_SOURCES = generate.c
|
||||
generate_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfilehandle_SOURCES = sndfilehandle.cc
|
||||
sndfilehandle_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
CLEANFILES = *~ *.exe
|
|
@ -1,231 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2002-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
static void usage_exit (char *progname) ;
|
||||
static int is_data_really_float (SNDFILE *sndfile) ;
|
||||
static void fix_file (char *filename) ;
|
||||
static off_t file_size (char *filename) ;
|
||||
|
||||
static union
|
||||
{ int i [BUFFER_LEN] ;
|
||||
float f [BUFFER_LEN] ;
|
||||
} buffer ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, data_is_float, converted = 0 ;
|
||||
|
||||
puts ("\nCooledit Fixer.\n---------------") ;
|
||||
|
||||
if (argc < 2)
|
||||
usage_exit (argv [0]) ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ if ((sndfile = sf_open (argv [k], SFM_READ, &sfinfo)) == NULL)
|
||||
{ /*-printf ("Failed to open : %s\n", argv [k]) ;-*/
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.format != (SF_FORMAT_WAV | SF_FORMAT_PCM_32))
|
||||
{ /*-printf ("%-50s : not a 32 bit PCM WAV file.\n", argv [k]) ;-*/
|
||||
sf_close (sndfile) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
data_is_float = is_data_really_float (sndfile) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
|
||||
if (data_is_float == SF_FALSE)
|
||||
{ /*-printf ("%-50s : not a Cooledit abomination.\n", argv [k]) ;-*/
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
fix_file (argv [k]) ;
|
||||
converted ++ ;
|
||||
} ;
|
||||
|
||||
if (converted == 0)
|
||||
puts ("\nNo files converted.") ;
|
||||
|
||||
puts ("") ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
|
||||
static void
|
||||
usage_exit (char *progname)
|
||||
{ char *cptr ;
|
||||
|
||||
if ((cptr = strrchr (progname, '/')))
|
||||
progname = cptr + 1 ;
|
||||
if ((cptr = strrchr (progname, '\\')))
|
||||
progname = cptr + 1 ;
|
||||
|
||||
printf ("\n Usage : %s <filename>\n", progname) ;
|
||||
puts ("\n"
|
||||
"Fix broken files created by Syntrillium's Cooledit. These files are \n"
|
||||
"marked as containing PCM data but actually contain floating point \n"
|
||||
"data. Only the broken files created by Cooledit are processed. All \n"
|
||||
"other files remain untouched.\n"
|
||||
"\n"
|
||||
"More than one file may be included on the command line. \n"
|
||||
) ;
|
||||
|
||||
exit (1) ;
|
||||
} /* usage_exit */
|
||||
|
||||
static int
|
||||
is_data_really_float (SNDFILE *sndfile)
|
||||
{ int k, readcount ;
|
||||
|
||||
while ((readcount = sf_read_int (sndfile, buffer.i, BUFFER_LEN)) > 0)
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
{ if (buffer.i [k] == 0)
|
||||
continue ;
|
||||
|
||||
if (fabs (buffer.f [k]) > 32768.0)
|
||||
return SF_FALSE ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
return SF_TRUE ;
|
||||
} /* is_data_really_float */
|
||||
|
||||
static void
|
||||
fix_file (char *filename)
|
||||
{ static char newfilename [512] ;
|
||||
|
||||
SNDFILE *infile, *outfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int readcount, k ;
|
||||
float normfactor ;
|
||||
char *cptr ;
|
||||
|
||||
printf ("\nFixing : %s\n", filename) ;
|
||||
|
||||
if ((infile = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open input file %s\n", filename) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (strlen (filename) >= sizeof (newfilename) - 1)
|
||||
{ puts ("Error : Path name too long.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
strncpy (newfilename, filename, sizeof (newfilename)) ;
|
||||
newfilename [sizeof (newfilename) - 1] = 0 ;
|
||||
|
||||
if ((cptr = strrchr (newfilename, '/')) == NULL)
|
||||
cptr = strrchr (newfilename, '\\') ;
|
||||
|
||||
if (cptr)
|
||||
{ cptr [1] = 0 ;
|
||||
strncat (newfilename, "fixed.wav", sizeof (newfilename) - strlen (newfilename) - 1) ;
|
||||
}
|
||||
else
|
||||
strncpy (newfilename, "fixed.wav", sizeof (newfilename) - 1) ;
|
||||
|
||||
newfilename [sizeof (newfilename) - 1] = 0 ;
|
||||
|
||||
printf (" Output : %s\n", newfilename) ;
|
||||
|
||||
sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT ;
|
||||
|
||||
if ((outfile = sf_open (newfilename, SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to output open file %s\n", filename) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
/* Find the file peak. sf-command (SFC_CALC_SIGNAL_MAX) cannot be used. */
|
||||
|
||||
normfactor = 0.0 ;
|
||||
|
||||
while ((readcount = sf_read_int (infile, buffer.i, BUFFER_LEN)) > 0)
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
if (fabs (buffer.f [k]) > normfactor)
|
||||
normfactor = fabs (buffer.f [k]) ;
|
||||
} ;
|
||||
|
||||
printf (" Peak : %g\n", normfactor) ;
|
||||
|
||||
normfactor = 1.0 / normfactor ;
|
||||
|
||||
sf_seek (infile, 0, SEEK_SET) ;
|
||||
|
||||
while ((readcount = sf_read_int (infile, buffer.i, BUFFER_LEN)) > 0)
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
buffer.f [k] *= normfactor ;
|
||||
sf_write_float (outfile, buffer.f, readcount) ;
|
||||
} ;
|
||||
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
||||
if (abs (file_size (filename) - file_size (newfilename)) > 50)
|
||||
{ puts ("Error : file size mismatch.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
printf (" Renaming : %s\n", filename) ;
|
||||
|
||||
if (remove (filename) != 0)
|
||||
{ perror ("rename") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (rename (newfilename, filename) != 0)
|
||||
{ perror ("rename") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* fix_file */
|
||||
|
||||
static off_t
|
||||
file_size (char *filename)
|
||||
{ struct stat buf ;
|
||||
|
||||
if (stat (filename, &buf) != 0)
|
||||
{ perror ("stat") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return buf.st_size ;
|
||||
} /* file_size */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 5475655e-3898-40ff-969b-c8ab2351b0e4
|
||||
*/
|
|
@ -1,133 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2002-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN 4096
|
||||
|
||||
static void encode_file (const char *infilename, const char *outfilename, int filetype) ;
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
{ puts ("\nEncode a single input file into a number of different output ") ;
|
||||
puts ("encodings. These output encodings can then be moved to another ") ;
|
||||
puts ("OS for testing.\n") ;
|
||||
puts (" Usage : generate <filename>\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
/* A couple of standard WAV files. Make sure Win32 plays these. */
|
||||
encode_file (argv [1], "pcmu8.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_U8) ;
|
||||
encode_file (argv [1], "pcm16.wav" , SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
|
||||
encode_file (argv [1], "imaadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_MS_ADPCM) ;
|
||||
encode_file (argv [1], "msadpcm.wav", SF_FORMAT_WAV | SF_FORMAT_IMA_ADPCM) ;
|
||||
encode_file (argv [1], "gsm610.wav" , SF_FORMAT_WAV | SF_FORMAT_GSM610) ;
|
||||
|
||||
/* Soundforge W64. */
|
||||
encode_file (argv [1], "pcmu8.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_U8) ;
|
||||
encode_file (argv [1], "pcm16.w64" , SF_FORMAT_W64 | SF_FORMAT_PCM_16) ;
|
||||
encode_file (argv [1], "imaadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_MS_ADPCM) ;
|
||||
encode_file (argv [1], "msadpcm.w64", SF_FORMAT_W64 | SF_FORMAT_IMA_ADPCM) ;
|
||||
encode_file (argv [1], "gsm610.w64" , SF_FORMAT_W64 | SF_FORMAT_GSM610) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*============================================================================================
|
||||
** Helper functions and macros.
|
||||
*/
|
||||
|
||||
#define PUT_DOTS(k) \
|
||||
{ while (k--) \
|
||||
putchar ('.') ; \
|
||||
putchar (' ') ; \
|
||||
}
|
||||
|
||||
/*========================================================================================
|
||||
*/
|
||||
|
||||
static void
|
||||
encode_file (const char *infilename, const char *outfilename, int filetype)
|
||||
{ static float buffer [BUFFER_LEN] ;
|
||||
|
||||
SNDFILE *infile, *outfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, readcount ;
|
||||
|
||||
printf (" %s -> %s ", infilename, outfilename) ;
|
||||
fflush (stdout) ;
|
||||
|
||||
k = 16 - strlen (outfilename) ;
|
||||
PUT_DOTS (k) ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
|
||||
{ printf ("Error : could not open file : %s\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
}
|
||||
|
||||
sfinfo.format = filetype ;
|
||||
|
||||
if (! sf_format_check (&sfinfo))
|
||||
{ sf_close (infile) ;
|
||||
printf ("Invalid encoding\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : could not open file : %s\n", outfilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
while ((readcount = sf_read_float (infile, buffer, BUFFER_LEN)) > 0)
|
||||
sf_write_float (outfile, buffer, readcount) ;
|
||||
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
||||
printf ("ok\n") ;
|
||||
|
||||
return ;
|
||||
} /* encode_file */
|
||||
|
|
@ -1,250 +0,0 @@
|
|||
/* (c) 2004 James Robson, http://www.arbingersys.com
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
**
|
||||
** ****************************
|
||||
**
|
||||
** How to use:
|
||||
** - libsndfile.dll must have already been compiled and be in this
|
||||
** application's search path
|
||||
**
|
||||
** - You must edit this file to point to the file you want to convert. Set
|
||||
** the following line of code (found in the Main() function further below)
|
||||
** to the name of a .WAV file that exists on your system.
|
||||
** 186: string sfn = "input.wav";
|
||||
**
|
||||
** - From a command prompt type
|
||||
** csc generate.cs
|
||||
**
|
||||
** - Run the resulting executable 'generate.exe'
|
||||
**
|
||||
**
|
||||
** Note: You will obviously need the csc compiler and the .NET runtime. I think
|
||||
** these are freely available for download from Microsoft's website
|
||||
** (part of the .NET SDK?).
|
||||
*/
|
||||
|
||||
|
||||
using System;
|
||||
using System.Runtime.InteropServices;
|
||||
using sf_count_t = System.Int64; //alias; see SF_INFO struct
|
||||
|
||||
#if PLATFORM_64
|
||||
using size_t = System.UInt64;
|
||||
#else
|
||||
using size_t = System.UInt32;
|
||||
#endif
|
||||
|
||||
|
||||
class lsndf_example {
|
||||
|
||||
|
||||
//sound file formats
|
||||
public enum lsndf_frmts {
|
||||
SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian). */
|
||||
SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */
|
||||
SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */
|
||||
SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */
|
||||
SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */
|
||||
SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */
|
||||
SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */
|
||||
SF_FORMAT_VOC = 0x080000, /* VOC files. */
|
||||
SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */
|
||||
SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */
|
||||
SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */
|
||||
SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */
|
||||
SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */
|
||||
SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */
|
||||
SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */
|
||||
SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */
|
||||
|
||||
/* Subtypes from here on. */
|
||||
|
||||
SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */
|
||||
SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */
|
||||
SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */
|
||||
SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */
|
||||
|
||||
SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */
|
||||
|
||||
SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */
|
||||
SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */
|
||||
|
||||
SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */
|
||||
SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */
|
||||
SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */
|
||||
SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */
|
||||
|
||||
SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */
|
||||
SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */
|
||||
|
||||
SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */
|
||||
SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */
|
||||
SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */
|
||||
|
||||
SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */
|
||||
SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */
|
||||
|
||||
SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
|
||||
SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
|
||||
|
||||
|
||||
/* Endian-ness options. */
|
||||
|
||||
SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
|
||||
SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */
|
||||
SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */
|
||||
SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */
|
||||
|
||||
SF_FORMAT_SUBMASK = 0x0000FFFF,
|
||||
SF_FORMAT_TYPEMASK = 0x0FFF0000,
|
||||
SF_FORMAT_ENDMASK = 0x30000000
|
||||
}
|
||||
|
||||
|
||||
//modes and other
|
||||
public enum lsndf_tf
|
||||
{ /* True and false */
|
||||
SF_FALSE = 0,
|
||||
SF_TRUE = 1,
|
||||
|
||||
/* Modes for opening files. */
|
||||
SFM_READ = 0x10,
|
||||
SFM_WRITE = 0x20,
|
||||
SFM_RDWR = 0x30
|
||||
}
|
||||
|
||||
|
||||
//important SF_INFO structure
|
||||
[StructLayout(LayoutKind.Sequential)]
|
||||
public struct SF_INFO
|
||||
{
|
||||
public sf_count_t frames ; // Used to be called samples. Changed to avoid confusion.
|
||||
public int samplerate ;
|
||||
public int channels ;
|
||||
public int format ;
|
||||
public int sections ;
|
||||
public int seekable ;
|
||||
};
|
||||
|
||||
|
||||
//function declarations
|
||||
//Note: Not all functions have been prototyped here. Only the ones necessary to
|
||||
// make this application work. The below code should give some clues as to
|
||||
// how to add the rest since they have a lot of parameter and return type
|
||||
// similarities.
|
||||
[DllImport("libsndfile.dll")]
|
||||
public static extern IntPtr sf_open ([MarshalAs(UnmanagedType.LPStr)] string path, int mode, ref SF_INFO sfinfo);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern int sf_error (IntPtr sndfile);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern IntPtr sf_strerror (IntPtr sndfile);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern int sf_format_check (ref SF_INFO info);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern sf_count_t sf_read_float (IntPtr sndfile, float[] ptr, sf_count_t items);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern sf_count_t sf_write_float (IntPtr sndfile, float[] ptr, sf_count_t items);
|
||||
|
||||
[DllImport("libsndfile.dll")]
|
||||
static extern int sf_close (IntPtr sndfile);
|
||||
|
||||
|
||||
public const sf_count_t BUFFER_LEN = 4096;
|
||||
|
||||
|
||||
//program entry
|
||||
static void Main( ) {
|
||||
|
||||
|
||||
//declarations
|
||||
SF_INFO sfinfo = new SF_INFO();
|
||||
float[] buffer = new float[BUFFER_LEN];
|
||||
sf_count_t rcnt;
|
||||
|
||||
//set the input file
|
||||
string sfn = "input.wav"; //set to a file on YOUR system
|
||||
//string sfn = "noexist.wav"; //test with non-existent file
|
||||
|
||||
//set the output file
|
||||
string ofn = "output.wav";
|
||||
|
||||
//read in sound file to convert
|
||||
IntPtr infile = sf_open (sfn, (int)lsndf_tf.SFM_READ, ref sfinfo);
|
||||
|
||||
//exit if error was thrown
|
||||
if ( (int)infile == 0 ) {
|
||||
Console.WriteLine("Error opening " + sfn);
|
||||
Console.WriteLine("Error #" + sf_error(infile));
|
||||
return;
|
||||
}
|
||||
|
||||
//set the file type for the output file
|
||||
//uncomment one and only one of the statements below to change the output
|
||||
//file encoding.
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_PCM_U8);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_PCM_16);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_MS_ADPCM);
|
||||
sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_IMA_ADPCM);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_WAV | lsndf_frmts.SF_FORMAT_GSM610);
|
||||
/* Soundforge W64. */
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_PCM_U8);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_PCM_16);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_MS_ADPCM);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_IMA_ADPCM);
|
||||
//sfinfo.format = (int)(lsndf_frmts.SF_FORMAT_W64 | lsndf_frmts.SF_FORMAT_GSM610);
|
||||
|
||||
|
||||
//check that SF_INFO is valid
|
||||
if ( sf_format_check(ref sfinfo) == 0 ) {
|
||||
Console.WriteLine("sf_format_check failed. Invalid encoding");
|
||||
return;
|
||||
}
|
||||
|
||||
//open output file
|
||||
IntPtr outfile = sf_open (ofn, (int)lsndf_tf.SFM_WRITE, ref sfinfo);
|
||||
|
||||
//exit if error was thrown
|
||||
if ( (int)outfile == 0 ) {
|
||||
Console.WriteLine("Error opening " + ofn);
|
||||
Console.WriteLine("Error #" + sf_error(outfile));
|
||||
return;
|
||||
}
|
||||
|
||||
//infile -> outfile
|
||||
Console.Write(sfn + " -> " + ofn);
|
||||
while ( (rcnt = sf_read_float (infile, buffer, BUFFER_LEN)) > 0) {
|
||||
Console.Write(".");
|
||||
sf_write_float (outfile, buffer, BUFFER_LEN);
|
||||
}
|
||||
Console.WriteLine("done.");
|
||||
|
||||
//close up shop
|
||||
sf_close(infile);
|
||||
sf_close(outfile);
|
||||
|
||||
|
||||
} //main()
|
||||
|
||||
|
||||
} //class lsndf_example {}
|
||||
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2001-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ SF_FORMAT_INFO info ;
|
||||
SF_INFO sfinfo ;
|
||||
char buffer [128] ;
|
||||
int format, major_count, subtype_count, m, s ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
buffer [0] = 0 ;
|
||||
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
|
||||
if (strlen (buffer) < 1)
|
||||
{ printf ("Line %d: could not retrieve lib version.\n", __LINE__) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
printf ("Version : %s\n\n", buffer) ;
|
||||
|
||||
sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
|
||||
|
||||
sfinfo.channels = 1 ;
|
||||
for (m = 0 ; m < major_count ; m++)
|
||||
{ info.format = m ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
|
||||
printf ("%s (extension \"%s\")\n", info.name, info.extension) ;
|
||||
|
||||
format = info.format ;
|
||||
|
||||
for (s = 0 ; s < subtype_count ; s++)
|
||||
{ info.format = s ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ;
|
||||
|
||||
format = (format & SF_FORMAT_TYPEMASK) | info.format ;
|
||||
|
||||
sfinfo.format = format ;
|
||||
if (sf_format_check (&sfinfo))
|
||||
printf (" %s\n", info.name) ;
|
||||
} ;
|
||||
puts ("") ;
|
||||
} ;
|
||||
puts ("") ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
|
@ -1,96 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 1999-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#ifndef M_PI
|
||||
#define M_PI 3.14159265358979323846264338
|
||||
#endif
|
||||
|
||||
#define SAMPLE_RATE 44100
|
||||
#define SAMPLE_COUNT (SAMPLE_RATE * 4) /* 4 seconds */
|
||||
#define AMPLITUDE (1.0 * 0x7F000000)
|
||||
#define LEFT_FREQ (344.0 / SAMPLE_RATE)
|
||||
#define RIGHT_FREQ (466.0 / SAMPLE_RATE)
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
int k ;
|
||||
int *buffer ;
|
||||
|
||||
if (! (buffer = malloc (2 * SAMPLE_COUNT * sizeof (int))))
|
||||
{ printf ("Malloc failed.\n") ;
|
||||
exit (0) ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
sfinfo.samplerate = SAMPLE_RATE ;
|
||||
sfinfo.frames = SAMPLE_COUNT ;
|
||||
sfinfo.channels = 2 ;
|
||||
sfinfo.format = (SF_FORMAT_WAV | SF_FORMAT_PCM_24) ;
|
||||
|
||||
if (! (file = sf_open ("sine.wav", SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Error : Not able to open output file.\n") ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels == 1)
|
||||
{ for (k = 0 ; k < SAMPLE_COUNT ; k++)
|
||||
buffer [k] = AMPLITUDE * sin (LEFT_FREQ * 2 * k * M_PI) ;
|
||||
}
|
||||
else if (sfinfo.channels == 2)
|
||||
{ for (k = 0 ; k < SAMPLE_COUNT ; k++)
|
||||
{ buffer [2 * k] = AMPLITUDE * sin (LEFT_FREQ * 2 * k * M_PI) ;
|
||||
buffer [2 * k + 1] = AMPLITUDE * sin (RIGHT_FREQ * 2 * k * M_PI) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ printf ("makesine can only generate mono or stereo files.\n") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (sf_write_int (file, buffer, sfinfo.channels * SAMPLE_COUNT) !=
|
||||
sfinfo.channels * SAMPLE_COUNT)
|
||||
puts (sf_strerror (file)) ;
|
||||
|
||||
sf_close (file) ;
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
|
@ -1,142 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2001-2013 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
/* Include this header file to use functions from libsndfile. */
|
||||
#include <sndfile.h>
|
||||
|
||||
/* This will be the length of the buffer used to hold.frames while
|
||||
** we process them.
|
||||
*/
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
/* libsndfile can handle more than 6 channels but we'll restrict it to 6. */
|
||||
#define MAX_CHANNELS 6
|
||||
|
||||
/* Function prototype. */
|
||||
static void process_data (double *data, int count, int channels) ;
|
||||
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ /* This is a buffer of double precision floating point values
|
||||
** which will hold our data while we process it.
|
||||
*/
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
/* A SNDFILE is very much like a FILE in the Standard C library. The
|
||||
** sf_open function return an SNDFILE* pointer when they sucessfully
|
||||
** open the specified file.
|
||||
*/
|
||||
SNDFILE *infile, *outfile ;
|
||||
|
||||
/* A pointer to an SF_INFO struct is passed to sf_open.
|
||||
** On read, the library fills this struct with information about the file.
|
||||
** On write, the struct must be filled in before calling sf_open.
|
||||
*/
|
||||
SF_INFO sfinfo ;
|
||||
int readcount ;
|
||||
const char *infilename = "input.wav" ;
|
||||
const char *outfilename = "output.wav" ;
|
||||
|
||||
/* The SF_INFO struct must be initialized before using it.
|
||||
*/
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
/* Here's where we open the input file. We pass sf_open the file name and
|
||||
** a pointer to an SF_INFO struct.
|
||||
** On successful open, sf_open returns a SNDFILE* pointer which is used
|
||||
** for all subsequent operations on that file.
|
||||
** If an error occurs during sf_open, the function returns a NULL pointer.
|
||||
**
|
||||
** If you are trying to open a raw headerless file you will need to set the
|
||||
** format and channels fields of sfinfo before calling sf_open(). For
|
||||
** instance to open a raw 16 bit stereo PCM file you would need the following
|
||||
** two lines:
|
||||
**
|
||||
** sfinfo.format = SF_FORMAT_RAW | SF_FORMAT_PCM_16 ;
|
||||
** sfinfo.channels = 2 ;
|
||||
*/
|
||||
if (! (infile = sf_open (infilename, SFM_READ, &sfinfo)))
|
||||
{ /* Open failed so print an error message. */
|
||||
printf ("Not able to open input file %s.\n", infilename) ;
|
||||
/* Print the error message from libsndfile. */
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels > MAX_CHANNELS)
|
||||
{ printf ("Not able to process more than %d channels\n", MAX_CHANNELS) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
/* Open the output file. */
|
||||
if (! (outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)))
|
||||
{ printf ("Not able to open output file %s.\n", outfilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* While there are.frames in the input file, read them, process
|
||||
** them and write them to the output file.
|
||||
*/
|
||||
while ((readcount = sf_read_double (infile, data, BUFFER_LEN)))
|
||||
{ process_data (data, readcount, sfinfo.channels) ;
|
||||
sf_write_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
|
||||
/* Close input and output files. */
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
process_data (double *data, int count, int channels)
|
||||
{ double channel_gain [MAX_CHANNELS] = { 0.5, 0.8, 0.1, 0.4, 0.4, 0.9 } ;
|
||||
int k, chan ;
|
||||
|
||||
/* Process the data here.
|
||||
** If the soundfile contains more then 1 channel you need to take care of
|
||||
** the data interleaving youself.
|
||||
** Current we just apply a channel dependant gain.
|
||||
*/
|
||||
|
||||
for (chan = 0 ; chan < channels ; chan ++)
|
||||
for (k = chan ; k < count ; k+= channels)
|
||||
data [k] *= channel_gain [chan] ;
|
||||
|
||||
return ;
|
||||
} /* process_data */
|
||||
|
|
@ -1,376 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
|
||||
typedef struct
|
||||
{ char *infilename, *outfilename ;
|
||||
SF_INFO infileinfo, outfileinfo ;
|
||||
} OptionData ;
|
||||
|
||||
typedef struct
|
||||
{ const char *ext ;
|
||||
int len ;
|
||||
int format ;
|
||||
} OUTPUT_FORMAT_MAP ;
|
||||
|
||||
static void copy_metadata (SNDFILE *outfile, SNDFILE *infile) ;
|
||||
static void copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
static void copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels) ;
|
||||
|
||||
static OUTPUT_FORMAT_MAP format_map [] =
|
||||
{
|
||||
{ "aif", 3, SF_FORMAT_AIFF },
|
||||
{ "wav", 0, SF_FORMAT_WAV },
|
||||
{ "au", 0, SF_FORMAT_AU },
|
||||
{ "caf", 0, SF_FORMAT_CAF },
|
||||
{ "flac", 0, SF_FORMAT_FLAC },
|
||||
{ "snd", 0, SF_FORMAT_AU },
|
||||
{ "svx", 0, SF_FORMAT_SVX },
|
||||
{ "paf", 0, SF_ENDIAN_BIG | SF_FORMAT_PAF },
|
||||
{ "fap", 0, SF_ENDIAN_LITTLE | SF_FORMAT_PAF },
|
||||
{ "gsm", 0, SF_FORMAT_RAW },
|
||||
{ "nist", 0, SF_FORMAT_NIST },
|
||||
{ "ircam", 0, SF_FORMAT_IRCAM },
|
||||
{ "sf", 0, SF_FORMAT_IRCAM },
|
||||
{ "voc", 0, SF_FORMAT_VOC },
|
||||
{ "w64", 0, SF_FORMAT_W64 },
|
||||
{ "raw", 0, SF_FORMAT_RAW },
|
||||
{ "mat4", 0, SF_FORMAT_MAT4 },
|
||||
{ "mat5", 0, SF_FORMAT_MAT5 },
|
||||
{ "mat", 0, SF_FORMAT_MAT4 },
|
||||
{ "pvf", 0, SF_FORMAT_PVF },
|
||||
{ "sds", 0, SF_FORMAT_SDS },
|
||||
{ "sd2", 0, SF_FORMAT_SD2 },
|
||||
{ "vox", 0, SF_FORMAT_RAW },
|
||||
{ "xi", 0, SF_FORMAT_XI }
|
||||
} ; /* format_map */
|
||||
|
||||
static int
|
||||
guess_output_file_type (char *str, int format)
|
||||
{ char buffer [16], *cptr ;
|
||||
int k ;
|
||||
|
||||
format &= SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((cptr = strrchr (str, '.')) == NULL)
|
||||
return 0 ;
|
||||
|
||||
strncpy (buffer, cptr + 1, 15) ;
|
||||
buffer [15] = 0 ;
|
||||
|
||||
for (k = 0 ; buffer [k] ; k++)
|
||||
buffer [k] = tolower ((buffer [k])) ;
|
||||
|
||||
if (strcmp (buffer, "gsm") == 0)
|
||||
return SF_FORMAT_RAW | SF_FORMAT_GSM610 ;
|
||||
|
||||
if (strcmp (buffer, "vox") == 0)
|
||||
return SF_FORMAT_RAW | SF_FORMAT_VOX_ADPCM ;
|
||||
|
||||
for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
|
||||
{ if (format_map [k].len > 0 && strncmp (buffer, format_map [k].ext, format_map [k].len) == 0)
|
||||
return format_map [k].format | format ;
|
||||
else if (strcmp (buffer, format_map [k].ext) == 0)
|
||||
return format_map [k].format | format ;
|
||||
} ;
|
||||
|
||||
return 0 ;
|
||||
} /* guess_output_file_type */
|
||||
|
||||
|
||||
static void
|
||||
print_usage (char *progname)
|
||||
{ SF_FORMAT_INFO info ;
|
||||
|
||||
int k ;
|
||||
|
||||
printf ("\nUsage : %s [encoding] <input file> <output file>\n", progname) ;
|
||||
puts ("\n"
|
||||
" where [encoding] may be one of the following:\n\n"
|
||||
" -pcms8 : force the output to signed 8 bit pcm\n"
|
||||
" -pcmu8 : force the output to unsigned 8 bit pcm\n"
|
||||
" -pcm16 : force the output to 16 bit pcm\n"
|
||||
" -pcm24 : force the output to 24 bit pcm\n"
|
||||
" -pcm32 : force the output to 32 bit pcm\n"
|
||||
" -float32 : force the output to 32 bit floating point"
|
||||
) ;
|
||||
puts (
|
||||
" -ulaw : force the output ULAW\n"
|
||||
" -alaw : force the output ALAW\n"
|
||||
" -ima-adpcm : force the output to IMA ADPCM (WAV only)\n"
|
||||
" -ms-adpcm : force the output to MS ADPCM (WAV only)\n"
|
||||
" -gsm610 : force the GSM6.10 (WAV only)\n"
|
||||
" -dwvw12 : force the output to 12 bit DWVW (AIFF only)\n"
|
||||
" -dwvw16 : force the output to 16 bit DWVW (AIFF only)\n"
|
||||
" -dwvw24 : force the output to 24 bit DWVW (AIFF only)\n"
|
||||
) ;
|
||||
|
||||
puts (
|
||||
" The format of the output file is determined by the file extension of the\n"
|
||||
" output file name. The following extensions are currently understood:\n"
|
||||
) ;
|
||||
|
||||
for (k = 0 ; k < (int) (sizeof (format_map) / sizeof (format_map [0])) ; k++)
|
||||
{ info.format = format_map [k].format ;
|
||||
sf_command (NULL, SFC_GET_FORMAT_INFO, &info, sizeof (info)) ;
|
||||
printf (" %-10s : %s\n", format_map [k].ext, info.name) ;
|
||||
} ;
|
||||
|
||||
puts ("") ;
|
||||
} /* print_usage */
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{ char *progname, *infilename, *outfilename ;
|
||||
SNDFILE *infile = NULL, *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, outfilemajor, outfileminor = 0, infileminor ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
if (argc < 3 || argc > 5)
|
||||
{ print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
infilename = argv [argc-2] ;
|
||||
outfilename = argv [argc-1] ;
|
||||
|
||||
if (strcmp (infilename, outfilename) == 0)
|
||||
{ printf ("Error : Input and output filenames are the same.\n\n") ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (infilename [0] == '-')
|
||||
{ printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (outfilename [0] == '-')
|
||||
{ printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
for (k = 1 ; k < argc - 2 ; k++)
|
||||
{ if (! strcmp (argv [k], "-pcms8"))
|
||||
{ outfileminor = SF_FORMAT_PCM_S8 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-pcmu8"))
|
||||
{ outfileminor = SF_FORMAT_PCM_U8 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-pcm16"))
|
||||
{ outfileminor = SF_FORMAT_PCM_16 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-pcm24"))
|
||||
{ outfileminor = SF_FORMAT_PCM_24 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-pcm32"))
|
||||
{ outfileminor = SF_FORMAT_PCM_32 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-float32"))
|
||||
{ outfileminor = SF_FORMAT_FLOAT ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-ulaw"))
|
||||
{ outfileminor = SF_FORMAT_ULAW ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-alaw"))
|
||||
{ outfileminor = SF_FORMAT_ALAW ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-ima-adpcm"))
|
||||
{ outfileminor = SF_FORMAT_IMA_ADPCM ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-ms-adpcm"))
|
||||
{ outfileminor = SF_FORMAT_MS_ADPCM ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-gsm610"))
|
||||
{ outfileminor = SF_FORMAT_GSM610 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-dwvw12"))
|
||||
{ outfileminor = SF_FORMAT_DWVW_12 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-dwvw16"))
|
||||
{ outfileminor = SF_FORMAT_DWVW_16 ;
|
||||
continue ;
|
||||
} ;
|
||||
if (! strcmp (argv [k], "-dwvw24"))
|
||||
{ outfileminor = SF_FORMAT_DWVW_24 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
printf ("Error : Not able to decode argunment '%s'.\n", argv [k]) ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open input file %s.\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
infileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if ((sfinfo.format = guess_output_file_type (outfilename, sfinfo.format)) == 0)
|
||||
{ printf ("Error : Not able to determine output file type for %s.\n", outfilename) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
outfilemajor = sfinfo.format & (SF_FORMAT_TYPEMASK | SF_FORMAT_ENDMASK) ;
|
||||
|
||||
if (outfileminor == 0)
|
||||
outfileminor = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (outfileminor != 0)
|
||||
sfinfo.format = outfilemajor | outfileminor ;
|
||||
else
|
||||
sfinfo.format = outfilemajor | (sfinfo.format & SF_FORMAT_SUBMASK) ;
|
||||
|
||||
if ((sfinfo.format & SF_FORMAT_TYPEMASK) == SF_FORMAT_XI)
|
||||
switch (sfinfo.format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_PCM_16 :
|
||||
sfinfo.format = outfilemajor | SF_FORMAT_DPCM_16 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_S8 :
|
||||
case SF_FORMAT_PCM_U8 :
|
||||
sfinfo.format = outfilemajor | SF_FORMAT_DPCM_8 ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
if (sf_format_check (&sfinfo) == 0)
|
||||
{ printf ("Error : output file format is invalid (0x%08X).\n", sfinfo.format) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Open the output file. */
|
||||
if ((outfile = sf_open (outfilename, SFM_WRITE, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Copy the metadata */
|
||||
copy_metadata (outfile, infile) ;
|
||||
|
||||
if ((outfileminor == SF_FORMAT_DOUBLE) || (outfileminor == SF_FORMAT_FLOAT) ||
|
||||
(infileminor == SF_FORMAT_DOUBLE) || (infileminor == SF_FORMAT_FLOAT))
|
||||
copy_data_fp (outfile, infile, sfinfo.channels) ;
|
||||
else
|
||||
copy_data_int (outfile, infile, sfinfo.channels) ;
|
||||
|
||||
sf_close (infile) ;
|
||||
sf_close (outfile) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
static void
|
||||
copy_metadata (SNDFILE *outfile, SNDFILE *infile)
|
||||
{ SF_INSTRUMENT inst ;
|
||||
const char *str ;
|
||||
int k, err = 0 ;
|
||||
|
||||
for (k = SF_STR_FIRST ; k <= SF_STR_LAST ; k++)
|
||||
{ str = sf_get_string (infile, k) ;
|
||||
if (str != NULL)
|
||||
err = sf_set_string (outfile, k, str) ;
|
||||
} ;
|
||||
|
||||
memset (&inst, 0, sizeof (inst)) ;
|
||||
if (sf_command (infile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) == SF_TRUE)
|
||||
sf_command (outfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
|
||||
} /* copy_metadata */
|
||||
|
||||
static void
|
||||
copy_data_fp (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
{ static double data [BUFFER_LEN], max ;
|
||||
int frames, readcount, k ;
|
||||
|
||||
frames = BUFFER_LEN / channels ;
|
||||
readcount = frames ;
|
||||
|
||||
sf_command (infile, SFC_CALC_SIGNAL_MAX, &max, sizeof (max)) ;
|
||||
|
||||
if (max < 1.0)
|
||||
{ while (readcount > 0)
|
||||
{ readcount = sf_readf_double (infile, data, frames) ;
|
||||
sf_writef_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ sf_command (infile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
|
||||
|
||||
while (readcount > 0)
|
||||
{ readcount = sf_readf_double (infile, data, frames) ;
|
||||
for (k = 0 ; k < readcount * channels ; k++)
|
||||
data [k] /= max ;
|
||||
sf_writef_double (outfile, data, readcount) ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* copy_data_fp */
|
||||
|
||||
static void
|
||||
copy_data_int (SNDFILE *outfile, SNDFILE *infile, int channels)
|
||||
{ static int data [BUFFER_LEN] ;
|
||||
int frames, readcount ;
|
||||
|
||||
frames = BUFFER_LEN / channels ;
|
||||
readcount = frames ;
|
||||
|
||||
while (readcount > 0)
|
||||
{ readcount = sf_readf_int (infile, data, frames) ;
|
||||
sf_writef_int (outfile, data, readcount) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* copy_data_int */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 259682b3-2887-48a6-b5bb-3cde00521ba3
|
||||
*/
|
|
@ -1,354 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 1999-2006 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
#include <math.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN (1 << 16)
|
||||
|
||||
#if (defined (WIN32) || defined (_WIN32))
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
static void print_version (void) ;
|
||||
static void print_usage (const char *progname) ;
|
||||
|
||||
static void info_dump (const char *filename) ;
|
||||
static void instrument_dump (const char *filename) ;
|
||||
static void broadcast_dump (const char *filename) ;
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{ int k ;
|
||||
|
||||
print_version () ;
|
||||
|
||||
if (argc < 2 || strcmp (argv [1], "--help") == 0 || strcmp (argv [1], "-h") == 0)
|
||||
{ char *progname ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "-i") == 0)
|
||||
{ instrument_dump (argv [2]) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
if (strcmp (argv [1], "-b") == 0)
|
||||
{ broadcast_dump (argv [2]) ;
|
||||
return 0 ;
|
||||
} ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
info_dump (argv [k]) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
/*==============================================================================
|
||||
** Print version and usage.
|
||||
*/
|
||||
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
static void
|
||||
print_version (void)
|
||||
{ char buffer [256] ;
|
||||
|
||||
sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
|
||||
printf ("\nVersion : %s\n\n", buffer) ;
|
||||
} /* print_version */
|
||||
|
||||
|
||||
static void
|
||||
print_usage (const char *progname)
|
||||
{ printf ("Usage :\n %s <file> ...\n", progname) ;
|
||||
printf (" Prints out information about one or more sound files.\n\n") ;
|
||||
printf (" %s -i <file>\n", progname) ;
|
||||
printf (" Prints out the instrument data for the given file.\n\n") ;
|
||||
printf (" %s -b <file>\n", progname) ;
|
||||
printf (" Prints out the broadcast WAV info for the given file.\n\n") ;
|
||||
#if (defined (_WIN32) || defined (WIN32))
|
||||
printf ("This is a Unix style command line application which\n"
|
||||
"should be run in a MSDOS box or Command Shell window.\n\n") ;
|
||||
printf ("Sleeping for 5 seconds before exiting.\n\n") ;
|
||||
fflush (stdout) ;
|
||||
|
||||
/* This is the officially blessed by microsoft way but I can't get
|
||||
** it to link.
|
||||
** Sleep (15) ;
|
||||
** Instead, use this:
|
||||
*/
|
||||
_sleep (5 * 1000) ;
|
||||
#endif
|
||||
} /* print_usage */
|
||||
|
||||
/*==============================================================================
|
||||
** Dumping of sndfile info.
|
||||
*/
|
||||
|
||||
static double data [BUFFER_LEN] ;
|
||||
|
||||
static double
|
||||
get_signal_max (SNDFILE *file)
|
||||
{ double max, temp ;
|
||||
int readcount, k, save_state ;
|
||||
|
||||
save_state = sf_command (file, SFC_GET_NORM_DOUBLE, NULL, 0) ;
|
||||
sf_command (file, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
|
||||
|
||||
max = 0.0 ;
|
||||
while ((readcount = sf_read_double (file, data, BUFFER_LEN)))
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
{ temp = fabs (data [k]) ;
|
||||
if (temp > max)
|
||||
max = temp ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
sf_command (file, SFC_SET_NORM_DOUBLE, NULL, save_state) ;
|
||||
|
||||
return max ;
|
||||
} /* get_signal_max */
|
||||
|
||||
static double
|
||||
calc_decibels (SF_INFO * sfinfo, double max)
|
||||
{ double decibels ;
|
||||
|
||||
switch (sfinfo->format & SF_FORMAT_SUBMASK)
|
||||
{ case SF_FORMAT_PCM_U8 :
|
||||
case SF_FORMAT_PCM_S8 :
|
||||
decibels = max / 0x80 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_16 :
|
||||
decibels = max / 0x8000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_24 :
|
||||
decibels = max / 0x800000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_PCM_32 :
|
||||
decibels = max / 0x80000000 ;
|
||||
break ;
|
||||
|
||||
case SF_FORMAT_FLOAT :
|
||||
case SF_FORMAT_DOUBLE :
|
||||
decibels = max / 1.0 ;
|
||||
break ;
|
||||
|
||||
default :
|
||||
decibels = max / 0x8000 ;
|
||||
break ;
|
||||
} ;
|
||||
|
||||
return 20.0 * log10 (decibels) ;
|
||||
} /* calc_decibels */
|
||||
|
||||
static const char *
|
||||
generate_duration_str (SF_INFO *sfinfo)
|
||||
{ static char str [128] ;
|
||||
|
||||
int seconds ;
|
||||
|
||||
memset (str, 0, sizeof (str)) ;
|
||||
|
||||
if (sfinfo->samplerate < 1)
|
||||
return NULL ;
|
||||
|
||||
if (sfinfo->frames / sfinfo->samplerate > 0x7FFFFFFF)
|
||||
return "unknown" ;
|
||||
|
||||
seconds = sfinfo->frames / sfinfo->samplerate ;
|
||||
|
||||
snprintf (str, sizeof (str) - 1, "%02d:", seconds / 60 / 60) ;
|
||||
|
||||
seconds = seconds % (60 * 60) ;
|
||||
snprintf (str + strlen (str), sizeof (str) - strlen (str) - 1, "%02d:", seconds / 60) ;
|
||||
|
||||
seconds = seconds % 60 ;
|
||||
snprintf (str + strlen (str), sizeof (str) - strlen (str) - 1, "%02d.", seconds) ;
|
||||
|
||||
seconds = ((1000 * sfinfo->frames) / sfinfo->samplerate) % 1000 ;
|
||||
snprintf (str + strlen (str), sizeof (str) - strlen (str) - 1, "%03d", seconds) ;
|
||||
|
||||
return str ;
|
||||
} /* generate_duration_str */
|
||||
|
||||
static void
|
||||
info_dump (const char *filename)
|
||||
{ static char strbuffer [BUFFER_LEN] ;
|
||||
SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
double signal_max, decibels ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
|
||||
puts (strbuffer) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
printf ("========================================\n") ;
|
||||
sf_command (file, SFC_GET_LOG_INFO, strbuffer, BUFFER_LEN) ;
|
||||
puts (strbuffer) ;
|
||||
printf ("----------------------------------------\n") ;
|
||||
|
||||
if (file == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
}
|
||||
else
|
||||
{ printf ("Sample Rate : %d\n", sfinfo.samplerate) ;
|
||||
if (sfinfo.frames > 0x7FFFFFFF)
|
||||
printf ("Frames : unknown\n") ;
|
||||
else
|
||||
printf ("Frames : %ld\n", (long) sfinfo.frames) ;
|
||||
printf ("Channels : %d\n", sfinfo.channels) ;
|
||||
printf ("Format : 0x%08X\n", sfinfo.format) ;
|
||||
printf ("Sections : %d\n", sfinfo.sections) ;
|
||||
printf ("Seekable : %s\n", (sfinfo.seekable ? "TRUE" : "FALSE")) ;
|
||||
printf ("Duration : %s\n", generate_duration_str (&sfinfo)) ;
|
||||
|
||||
/* Do not use sf_signal_max because it doesn work for non-seekable files . */
|
||||
signal_max = get_signal_max (file) ;
|
||||
decibels = calc_decibels (&sfinfo, signal_max) ;
|
||||
printf ("Signal Max : %g (%4.2f dB)\n\n", signal_max, decibels) ;
|
||||
} ;
|
||||
|
||||
sf_close (file) ;
|
||||
|
||||
} /* info_dump */
|
||||
|
||||
/*==============================================================================
|
||||
** Dumping of SF_INSTRUMENT data.
|
||||
*/
|
||||
|
||||
static const char *
|
||||
str_of_type (int mode)
|
||||
{ switch (mode)
|
||||
{ case SF_LOOP_NONE : return "none" ;
|
||||
case SF_LOOP_FORWARD : return "fwd " ;
|
||||
case SF_LOOP_BACKWARD : return "back" ;
|
||||
case SF_LOOP_ALTERNATING : return "alt " ;
|
||||
default : break ;
|
||||
} ;
|
||||
|
||||
return "????" ;
|
||||
} /* str_of_mode */
|
||||
|
||||
static void
|
||||
instrument_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_INSTRUMENT inst ;
|
||||
int got_inst, k ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
got_inst = sf_command (file, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ;
|
||||
sf_close (file) ;
|
||||
|
||||
if (got_inst == SF_FALSE)
|
||||
{ printf ("Error : File '%s' does not contain instrument data.\n\n", filename) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
printf ("Instrument : %s\n\n", filename) ;
|
||||
printf (" Gain : %d\n", inst.gain) ;
|
||||
printf (" Base note : %d\n", inst.basenote) ;
|
||||
printf (" Velocity : %d - %d\n", (int) inst.velocity_lo, (int) inst.velocity_hi) ;
|
||||
printf (" Key : %d - %d\n", (int) inst.key_lo, (int) inst.key_hi) ;
|
||||
printf (" Loop points : %d\n", inst.loop_count) ;
|
||||
|
||||
for (k = 0 ; k < inst.loop_count ; k++)
|
||||
printf (" %-2d Mode : %s Start : %6d End : %6d Count : %6d\n", k, str_of_type (inst.loops [k].mode), inst.loops [k].start, inst.loops [k].end, inst.loops [k].count) ;
|
||||
|
||||
putchar ('\n') ;
|
||||
} /* instrument_dump */
|
||||
|
||||
static void
|
||||
broadcast_dump (const char *filename)
|
||||
{ SNDFILE *file ;
|
||||
SF_INFO sfinfo ;
|
||||
SF_BROADCAST_INFO bext ;
|
||||
int got_bext ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((file = sf_open (filename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Error : Not able to open input file %s.\n", filename) ;
|
||||
fflush (stdout) ;
|
||||
memset (data, 0, sizeof (data)) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
memset (&bext, 0, sizeof (SF_BROADCAST_INFO)) ;
|
||||
|
||||
got_bext = sf_command (file, SFC_GET_BROADCAST_INFO, &bext, sizeof (bext)) ;
|
||||
sf_close (file) ;
|
||||
|
||||
if (got_bext == SF_FALSE)
|
||||
{ printf ("Error : File '%s' does not contain broadcast information.\n\n", filename) ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
printf ("Description : %.*s\n", (int) sizeof (bext.description), bext.description) ;
|
||||
printf ("Originator : %.*s\n", (int) sizeof (bext.originator), bext.originator) ;
|
||||
printf ("Origination ref : %.*s\n", (int) sizeof (bext.originator_reference), bext.originator_reference) ;
|
||||
printf ("Origination date : %.*s\n", (int) sizeof (bext.origination_date), bext.origination_date) ;
|
||||
printf ("Origination time : %.*s\n", (int) sizeof (bext.origination_time), bext.origination_time) ;
|
||||
printf ("BWF version : %d\n", bext.version) ;
|
||||
printf ("UMID : %.*s\n", (int) sizeof (bext.umid), bext.umid) ;
|
||||
printf ("Coding history : %.*s\n", bext.coding_history_size, bext.coding_history) ;
|
||||
|
||||
} /* broadcast_dump */
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: f59a05db-a182-41de-aedd-d717ce2bb099
|
||||
*/
|
|
@ -1,153 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2001 Marcus Overhagen <marcus@overhagen.de>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include <Application.h>
|
||||
#include <SoundPlayer.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** BeOS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if defined (__BEOS__)
|
||||
|
||||
struct shared_data
|
||||
{
|
||||
BSoundPlayer *player;
|
||||
SNDFILE *sndfile;
|
||||
SF_INFO sfinfo;
|
||||
sem_id finished;
|
||||
};
|
||||
|
||||
static void
|
||||
buffer_callback(void *theCookie, void *buf, size_t size, const media_raw_audio_format &format)
|
||||
{
|
||||
shared_data *data = (shared_data *)theCookie;
|
||||
short *buffer = (short *)buf;
|
||||
int count = size / sizeof(short);
|
||||
int m, readcount;
|
||||
|
||||
if (!data->player->HasData())
|
||||
return;
|
||||
|
||||
readcount = sf_read_short(data->sndfile, buffer, count);
|
||||
if (readcount == 0)
|
||||
{ data->player->SetHasData(false);
|
||||
release_sem(data->finished);
|
||||
}
|
||||
if (readcount < count)
|
||||
{ for (m = readcount ; m < count ; m++)
|
||||
buffer [m] = 0 ;
|
||||
}
|
||||
if (data->sfinfo.pcmbitwidth < 16)
|
||||
{ for (m = 0 ; m < count ; m++)
|
||||
buffer [m] *= 256 ;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
beos_play (int argc, char *argv [])
|
||||
{
|
||||
shared_data data;
|
||||
status_t status;
|
||||
int k;
|
||||
|
||||
/* BSoundPlayer requires a BApplication object */
|
||||
BApplication app("application/x-vnd.MarcusOverhagen-sfplay");
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (data.sndfile = sf_open_read (argv [k], &data.sfinfo)))
|
||||
{ sf_perror (NULL) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (data.sfinfo.channels < 1 || data.sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", data.sfinfo.channels) ;
|
||||
sf_close (data.sndfile) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
data.finished = create_sem(0,"finished");
|
||||
|
||||
media_raw_audio_format format =
|
||||
{ data.sfinfo.samplerate,
|
||||
data.sfinfo.channels,
|
||||
media_raw_audio_format::B_AUDIO_SHORT,
|
||||
B_HOST_IS_LENDIAN ? B_MEDIA_LITTLE_ENDIAN : B_MEDIA_BIG_ENDIAN,
|
||||
BUFFER_LEN * sizeof(short)
|
||||
};
|
||||
|
||||
BSoundPlayer player(&format,"player",buffer_callback,NULL,&data);
|
||||
data.player = &player;
|
||||
|
||||
if ((status = player.InitCheck()) != B_OK)
|
||||
{
|
||||
printf ("Error : BSoundPlayer init failed, %s.\n", strerror(status)) ;
|
||||
delete_sem(data.finished);
|
||||
sf_close (data.sndfile) ;
|
||||
continue ;
|
||||
}
|
||||
|
||||
player.SetVolume(1.0);
|
||||
player.Start();
|
||||
player.SetHasData(true);
|
||||
acquire_sem(data.finished);
|
||||
player.Stop();
|
||||
delete_sem(data.finished);
|
||||
|
||||
sf_close (data.sndfile) ;
|
||||
|
||||
} ;
|
||||
|
||||
} /* beos_play */
|
||||
|
||||
#endif
|
||||
|
||||
/*==============================================================================
|
||||
** Main function.
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc < 2)
|
||||
{ printf ("Usage : %s <input sound file>\n\n", argv [0]) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
beos_play (argc, argv) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 5407a79d-88de-41c7-8d8e-9acf2cf13cc1
|
||||
*/
|
||||
|
|
@ -1,960 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 1999-2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include "sfconfig.h"
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
#if HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
#define ALSA_PCM_NEW_HW_PARAMS_API
|
||||
#define ALSA_PCM_NEW_SW_PARAMS_API
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
|
||||
#if defined (__linux__)
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/soundcard.h>
|
||||
|
||||
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||
#include <Carbon.h>
|
||||
#include <CoreAudio/AudioHardware.h>
|
||||
|
||||
#elif (defined (sun) && defined (unix))
|
||||
#include <fcntl.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/audioio.h>
|
||||
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
|
||||
#endif
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define SIGNED_SIZEOF(x) ((int) sizeof (x))
|
||||
#define BUFFER_LEN (2048)
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Linux/OSS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
|
||||
static snd_pcm_t * alsa_open (int channels, unsigned srate, int realtime) ;
|
||||
static int alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels) ;
|
||||
|
||||
static void
|
||||
alsa_play (int argc, char *argv [])
|
||||
{ static float buffer [BUFFER_LEN] ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
snd_pcm_t * alsa_dev ;
|
||||
int k, readcount, subformat ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 1 || sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if ((alsa_dev = alsa_open (sfinfo.channels, (unsigned) sfinfo.samplerate, SF_FALSE)) == NULL)
|
||||
continue ;
|
||||
|
||||
subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
|
||||
{ double scale ;
|
||||
int m ;
|
||||
|
||||
sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
|
||||
if (scale < 1e-10)
|
||||
scale = 1.0 ;
|
||||
else
|
||||
scale = 32700.0 / scale ;
|
||||
|
||||
while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN)))
|
||||
{ for (m = 0 ; m < readcount ; m++)
|
||||
buffer [m] *= scale ;
|
||||
alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ while ((readcount = sf_read_float (sndfile, buffer, BUFFER_LEN)))
|
||||
alsa_write_float (alsa_dev, buffer, BUFFER_LEN / sfinfo.channels, sfinfo.channels) ;
|
||||
} ;
|
||||
|
||||
snd_pcm_drain (alsa_dev) ;
|
||||
snd_pcm_close (alsa_dev) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* alsa_play */
|
||||
|
||||
static snd_pcm_t *
|
||||
alsa_open (int channels, unsigned samplerate, int realtime)
|
||||
{ const char * device = "plughw:0" ;
|
||||
snd_pcm_t *alsa_dev = NULL ;
|
||||
snd_pcm_hw_params_t *hw_params ;
|
||||
snd_pcm_uframes_t buffer_size, xfer_align, start_threshold ;
|
||||
snd_pcm_uframes_t alsa_period_size, alsa_buffer_frames ;
|
||||
snd_pcm_sw_params_t *sw_params ;
|
||||
|
||||
int err ;
|
||||
|
||||
if (realtime)
|
||||
{ alsa_period_size = 256 ;
|
||||
alsa_buffer_frames = 3 * alsa_period_size ;
|
||||
}
|
||||
else
|
||||
{ alsa_period_size = 1024 ;
|
||||
alsa_buffer_frames = 4 * alsa_period_size ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_open (&alsa_dev, device, SND_PCM_STREAM_PLAYBACK, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot open audio device \"%s\" (%s)\n", device, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_nonblock (alsa_dev, 0) ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_malloc (&hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot allocate hardware parameter structure (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_any (alsa_dev, hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot initialize hardware parameter structure (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_access (alsa_dev, hw_params, SND_PCM_ACCESS_RW_INTERLEAVED)) < 0)
|
||||
{ fprintf (stderr, "cannot set access type (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_format (alsa_dev, hw_params, SND_PCM_FORMAT_FLOAT)) < 0)
|
||||
{ fprintf (stderr, "cannot set sample format (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_rate_near (alsa_dev, hw_params, &samplerate, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot set sample rate (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_channels (alsa_dev, hw_params, channels)) < 0)
|
||||
{ fprintf (stderr, "cannot set channel count (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_buffer_size_near (alsa_dev, hw_params, &alsa_buffer_frames)) < 0)
|
||||
{ fprintf (stderr, "cannot set buffer size (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params_set_period_size_near (alsa_dev, hw_params, &alsa_period_size, 0)) < 0)
|
||||
{ fprintf (stderr, "cannot set period size (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_hw_params (alsa_dev, hw_params)) < 0)
|
||||
{ fprintf (stderr, "cannot set parameters (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
/* extra check: if we have only one period, this code won't work */
|
||||
snd_pcm_hw_params_get_period_size (hw_params, &alsa_period_size, 0) ;
|
||||
snd_pcm_hw_params_get_buffer_size (hw_params, &buffer_size) ;
|
||||
if (alsa_period_size == buffer_size)
|
||||
{ fprintf (stderr, "Can't use period equal to buffer size (%lu == %lu)", alsa_period_size, buffer_size) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_hw_params_free (hw_params) ;
|
||||
|
||||
if ((err = snd_pcm_sw_params_malloc (&sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params_malloc: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_sw_params_current (alsa_dev, sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params_current: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
/* note: set start threshold to delay start until the ring buffer is full */
|
||||
snd_pcm_sw_params_current (alsa_dev, sw_params) ;
|
||||
if ((err = snd_pcm_sw_params_get_xfer_align (sw_params, &xfer_align)) < 0)
|
||||
{ fprintf (stderr, "cannot get xfer align (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
/* round up to closest transfer boundary */
|
||||
start_threshold = (buffer_size / xfer_align) * xfer_align ;
|
||||
if (start_threshold < 1)
|
||||
start_threshold = 1 ;
|
||||
if ((err = snd_pcm_sw_params_set_start_threshold (alsa_dev, sw_params, start_threshold)) < 0)
|
||||
{ fprintf (stderr, "cannot set start threshold (%s)\n", snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
if ((err = snd_pcm_sw_params (alsa_dev, sw_params)) != 0)
|
||||
{ fprintf (stderr, "%s: snd_pcm_sw_params: %s", __func__, snd_strerror (err)) ;
|
||||
goto catch_error ;
|
||||
} ;
|
||||
|
||||
snd_pcm_sw_params_free (sw_params) ;
|
||||
|
||||
snd_pcm_reset (alsa_dev) ;
|
||||
|
||||
catch_error :
|
||||
|
||||
if (err < 0 && alsa_dev != NULL)
|
||||
{ snd_pcm_close (alsa_dev) ;
|
||||
return NULL ;
|
||||
} ;
|
||||
|
||||
return alsa_dev ;
|
||||
} /* alsa_open */
|
||||
|
||||
static int
|
||||
alsa_write_float (snd_pcm_t *alsa_dev, float *data, int frames, int channels)
|
||||
{ static int epipe_count = 0 ;
|
||||
|
||||
snd_pcm_status_t *status ;
|
||||
int total = 0 ;
|
||||
int retval ;
|
||||
|
||||
if (epipe_count > 0)
|
||||
epipe_count -- ;
|
||||
|
||||
while (total < frames)
|
||||
{ retval = snd_pcm_writei (alsa_dev, data + total * channels, frames - total) ;
|
||||
|
||||
if (retval >= 0)
|
||||
{ total += retval ;
|
||||
if (total == frames)
|
||||
return total ;
|
||||
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
switch (retval)
|
||||
{ case -EAGAIN :
|
||||
puts ("alsa_write_float: EAGAIN") ;
|
||||
continue ;
|
||||
break ;
|
||||
|
||||
case -EPIPE :
|
||||
if (epipe_count > 0)
|
||||
{ printf ("alsa_write_float: EPIPE %d\n", epipe_count) ;
|
||||
if (epipe_count > 140)
|
||||
return retval ;
|
||||
} ;
|
||||
epipe_count += 100 ;
|
||||
|
||||
if (0)
|
||||
{ snd_pcm_status_alloca (&status) ;
|
||||
if ((retval = snd_pcm_status (alsa_dev, status)) < 0)
|
||||
fprintf (stderr, "alsa_out: xrun. can't determine length\n") ;
|
||||
else if (snd_pcm_status_get_state (status) == SND_PCM_STATE_XRUN)
|
||||
{ struct timeval now, diff, tstamp ;
|
||||
|
||||
gettimeofday (&now, 0) ;
|
||||
snd_pcm_status_get_trigger_tstamp (status, &tstamp) ;
|
||||
timersub (&now, &tstamp, &diff) ;
|
||||
|
||||
fprintf (stderr, "alsa_write_float xrun: of at least %.3f msecs. resetting stream\n",
|
||||
diff.tv_sec * 1000 + diff.tv_usec / 1000.0) ;
|
||||
}
|
||||
else
|
||||
fprintf (stderr, "alsa_write_float: xrun. can't determine length\n") ;
|
||||
} ;
|
||||
|
||||
snd_pcm_prepare (alsa_dev) ;
|
||||
break ;
|
||||
|
||||
case -EBADFD :
|
||||
fprintf (stderr, "alsa_write_float: Bad PCM state.n") ;
|
||||
return 0 ;
|
||||
break ;
|
||||
|
||||
case -ESTRPIPE :
|
||||
fprintf (stderr, "alsa_write_float: Suspend event.n") ;
|
||||
return 0 ;
|
||||
break ;
|
||||
|
||||
case -EIO :
|
||||
puts ("alsa_write_float: EIO") ;
|
||||
return 0 ;
|
||||
|
||||
default :
|
||||
fprintf (stderr, "alsa_write_float: retval = %d\n", retval) ;
|
||||
return 0 ;
|
||||
break ;
|
||||
} ; /* switch */
|
||||
} ; /* while */
|
||||
|
||||
return total ;
|
||||
} /* alsa_write_float */
|
||||
|
||||
#endif /* HAVE_ALSA_ASOUNDLIB_H */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Linux/OSS functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if defined (__linux__)
|
||||
|
||||
static int linux_open_dsp_device (int channels, int srate) ;
|
||||
|
||||
static void
|
||||
linux_play (int argc, char *argv [])
|
||||
{ static short buffer [BUFFER_LEN] ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
int k, audio_device, readcount, subformat ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 1 || sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_device = linux_open_dsp_device (sfinfo.channels, sfinfo.samplerate) ;
|
||||
|
||||
subformat = sfinfo.format & SF_FORMAT_SUBMASK ;
|
||||
|
||||
if (subformat == SF_FORMAT_FLOAT || subformat == SF_FORMAT_DOUBLE)
|
||||
{ static float float_buffer [BUFFER_LEN] ;
|
||||
double scale ;
|
||||
int m ;
|
||||
|
||||
sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &scale, sizeof (scale)) ;
|
||||
if (scale < 1e-10)
|
||||
scale = 1.0 ;
|
||||
else
|
||||
scale = 32700.0 / scale ;
|
||||
|
||||
while ((readcount = sf_read_float (sndfile, float_buffer, BUFFER_LEN)))
|
||||
{ for (m = 0 ; m < readcount ; m++)
|
||||
buffer [m] = scale * float_buffer [m] ;
|
||||
write (audio_device, buffer, readcount * sizeof (short)) ;
|
||||
} ;
|
||||
}
|
||||
else
|
||||
{ while ((readcount = sf_read_short (sndfile, buffer, BUFFER_LEN)))
|
||||
write (audio_device, buffer, readcount * sizeof (short)) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (audio_device, SNDCTL_DSP_POST, 0) == -1)
|
||||
perror ("ioctl (SNDCTL_DSP_POST) ") ;
|
||||
|
||||
if (ioctl (audio_device, SNDCTL_DSP_SYNC, 0) == -1)
|
||||
perror ("ioctl (SNDCTL_DSP_SYNC) ") ;
|
||||
|
||||
close (audio_device) ;
|
||||
|
||||
sf_close (sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* linux_play */
|
||||
|
||||
static int
|
||||
linux_open_dsp_device (int channels, int srate)
|
||||
{ int fd, stereo, fmt ;
|
||||
|
||||
if ((fd = open ("/dev/dsp", O_WRONLY, 0)) == -1 &&
|
||||
(fd = open ("/dev/sound/dsp", O_WRONLY, 0)) == -1)
|
||||
{ perror ("linux_open_dsp_device : open ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
stereo = 0 ;
|
||||
if (ioctl (fd, SNDCTL_DSP_STEREO, &stereo) == -1)
|
||||
{ /* Fatal error */
|
||||
perror ("linux_open_dsp_device : stereo ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_RESET, 0))
|
||||
{ perror ("linux_open_dsp_device : reset ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
fmt = CPU_IS_BIG_ENDIAN ? AFMT_S16_BE : AFMT_S16_LE ;
|
||||
if (ioctl (fd, SOUND_PCM_SETFMT, &fmt) != 0)
|
||||
{ perror ("linux_open_dsp_device : set format ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SOUND_PCM_WRITE_CHANNELS, &channels) != 0)
|
||||
{ perror ("linux_open_dsp_device : channels ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SOUND_PCM_WRITE_RATE, &srate) != 0)
|
||||
{ perror ("linux_open_dsp_device : sample rate ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
if (ioctl (fd, SNDCTL_DSP_SYNC, 0) != 0)
|
||||
{ perror ("linux_open_dsp_device : sync ") ;
|
||||
exit (1) ;
|
||||
} ;
|
||||
|
||||
return fd ;
|
||||
} /* linux_open_dsp_device */
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Mac OS X functions for playing a sound.
|
||||
*/
|
||||
|
||||
#if (defined (__MACH__) && defined (__APPLE__)) /* MacOSX */
|
||||
|
||||
typedef struct
|
||||
{ AudioStreamBasicDescription format ;
|
||||
|
||||
UInt32 buf_size ;
|
||||
AudioDeviceID device ;
|
||||
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
int fake_stereo ;
|
||||
int done_playing ;
|
||||
} MacOSXAudioData ;
|
||||
|
||||
#include <math.h>
|
||||
|
||||
static OSStatus
|
||||
macosx_audio_out_callback (AudioDeviceID device, const AudioTimeStamp* current_time,
|
||||
const AudioBufferList* data_in, const AudioTimeStamp* time_in,
|
||||
AudioBufferList* data_out, const AudioTimeStamp* time_out,
|
||||
void* client_data)
|
||||
{ MacOSXAudioData *audio_data ;
|
||||
int size, sample_count, read_count, k ;
|
||||
float *buffer ;
|
||||
|
||||
/* Prevent compiler warnings. */
|
||||
device = device ;
|
||||
current_time = current_time ;
|
||||
data_in = data_in ;
|
||||
time_in = time_in ;
|
||||
time_out = time_out ;
|
||||
|
||||
audio_data = (MacOSXAudioData*) client_data ;
|
||||
|
||||
size = data_out->mBuffers [0].mDataByteSize ;
|
||||
sample_count = size / sizeof (float) ;
|
||||
|
||||
buffer = (float*) data_out->mBuffers [0].mData ;
|
||||
|
||||
if (audio_data->fake_stereo != 0)
|
||||
{ read_count = sf_read_float (audio_data->sndfile, buffer, sample_count / 2) ;
|
||||
|
||||
for (k = read_count - 1 ; k >= 0 ; k--)
|
||||
{ buffer [2 * k ] = buffer [k] ;
|
||||
buffer [2 * k + 1] = buffer [k] ;
|
||||
} ;
|
||||
read_count *= 2 ;
|
||||
}
|
||||
else
|
||||
read_count = sf_read_float (audio_data->sndfile, buffer, sample_count) ;
|
||||
|
||||
/* Fill the remainder with zeroes. */
|
||||
if (read_count < sample_count)
|
||||
{ if (audio_data->fake_stereo == 0)
|
||||
memset (&(buffer [read_count]), 0, (sample_count - read_count) * sizeof (float)) ;
|
||||
/* Tell the main application to terminate. */
|
||||
audio_data->done_playing = SF_TRUE ;
|
||||
} ;
|
||||
|
||||
return noErr ;
|
||||
} /* macosx_audio_out_callback */
|
||||
|
||||
static void
|
||||
macosx_play (int argc, char *argv [])
|
||||
{ MacOSXAudioData audio_data ;
|
||||
OSStatus err ;
|
||||
UInt32 count, buffer_size ;
|
||||
int k ;
|
||||
|
||||
audio_data.fake_stereo = 0 ;
|
||||
audio_data.device = kAudioDeviceUnknown ;
|
||||
|
||||
/* get the default output device for the HAL */
|
||||
count = sizeof (AudioDeviceID) ;
|
||||
if ((err = AudioHardwareGetProperty (kAudioHardwarePropertyDefaultOutputDevice,
|
||||
&count, (void *) &(audio_data.device))) != noErr)
|
||||
{ printf ("AudioHardwareGetProperty (kAudioDevicePropertyDefaultOutputDevice) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* get the buffersize that the default device uses for IO */
|
||||
count = sizeof (UInt32) ;
|
||||
if ((err = AudioDeviceGetProperty (audio_data.device, 0, false, kAudioDevicePropertyBufferSize,
|
||||
&count, &buffer_size)) != noErr)
|
||||
{ printf ("AudioDeviceGetProperty (kAudioDevicePropertyBufferSize) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* get a description of the data format used by the default device */
|
||||
count = sizeof (AudioStreamBasicDescription) ;
|
||||
if ((err = AudioDeviceGetProperty (audio_data.device, 0, false, kAudioDevicePropertyStreamFormat,
|
||||
&count, &(audio_data.format))) != noErr)
|
||||
{ printf ("AudioDeviceGetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* Base setup completed. Now play files. */
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo))))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (audio_data.sfinfo.channels < 1 || audio_data.sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", audio_data.sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_data.format.mSampleRate = audio_data.sfinfo.samplerate ;
|
||||
|
||||
if (audio_data.sfinfo.channels == 1)
|
||||
{ audio_data.format.mChannelsPerFrame = 2 ;
|
||||
audio_data.fake_stereo = 1 ;
|
||||
}
|
||||
else
|
||||
audio_data.format.mChannelsPerFrame = audio_data.sfinfo.channels ;
|
||||
|
||||
if ((err = AudioDeviceSetProperty (audio_data.device, NULL, 0, false, kAudioDevicePropertyStreamFormat,
|
||||
sizeof (AudioStreamBasicDescription), &(audio_data.format))) != noErr)
|
||||
{ printf ("AudioDeviceSetProperty (kAudioDevicePropertyStreamFormat) failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* we want linear pcm */
|
||||
if (audio_data.format.mFormatID != kAudioFormatLinearPCM)
|
||||
return ;
|
||||
|
||||
/* Fire off the device. */
|
||||
if ((err = AudioDeviceAddIOProc (audio_data.device, macosx_audio_out_callback,
|
||||
(void *) &audio_data)) != noErr)
|
||||
{ printf ("AudioDeviceAddIOProc failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
err = AudioDeviceStart (audio_data.device, macosx_audio_out_callback) ;
|
||||
if (err != noErr)
|
||||
return ;
|
||||
|
||||
audio_data.done_playing = SF_FALSE ;
|
||||
|
||||
while (audio_data.done_playing == SF_FALSE)
|
||||
usleep (10 * 1000) ; /* 10 000 milliseconds. */
|
||||
|
||||
if ((err = AudioDeviceStop (audio_data.device, macosx_audio_out_callback)) != noErr)
|
||||
{ printf ("AudioDeviceStop failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
err = AudioDeviceRemoveIOProc (audio_data.device, macosx_audio_out_callback) ;
|
||||
if (err != noErr)
|
||||
{ printf ("AudioDeviceRemoveIOProc failed.\n") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
sf_close (audio_data.sndfile) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* macosx_play */
|
||||
|
||||
#endif /* MacOSX */
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Win32 functions for playing a sound.
|
||||
**
|
||||
** This API sucks. Its needlessly complicated and is *WAY* too loose with
|
||||
** passing pointers arounf in integers and and using char* pointers to
|
||||
** point to data instead of short*. It plain sucks!
|
||||
*/
|
||||
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
|
||||
#define WIN32_BUFFER_LEN (1<<15)
|
||||
|
||||
typedef struct
|
||||
{ HWAVEOUT hwave ;
|
||||
WAVEHDR whdr [2] ;
|
||||
|
||||
CRITICAL_SECTION mutex ; /* to control access to BuffersInUSe */
|
||||
HANDLE Event ; /* signal that a buffer is free */
|
||||
|
||||
short buffer [WIN32_BUFFER_LEN / sizeof (short)] ;
|
||||
int current, bufferlen ;
|
||||
int BuffersInUse ;
|
||||
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
sf_count_t remaining ;
|
||||
} Win32_Audio_Data ;
|
||||
|
||||
|
||||
static void
|
||||
win32_play_data (Win32_Audio_Data *audio_data)
|
||||
{ int thisread, readcount ;
|
||||
|
||||
/* fill a buffer if there is more data and we can read it sucessfully */
|
||||
readcount = (audio_data->remaining > audio_data->bufferlen) ? audio_data->bufferlen : (int) audio_data->remaining ;
|
||||
|
||||
thisread = (int) sf_read_short (audio_data->sndfile, (short *) (audio_data->whdr [audio_data->current].lpData), readcount) ;
|
||||
|
||||
audio_data->remaining -= thisread ;
|
||||
|
||||
if (thisread > 0)
|
||||
{ /* Fix buffer length if this is only a partial block. */
|
||||
if (thisread < audio_data->bufferlen)
|
||||
audio_data->whdr [audio_data->current].dwBufferLength = thisread * sizeof (short) ;
|
||||
|
||||
/* Queue the WAVEHDR */
|
||||
waveOutWrite (audio_data->hwave, (LPWAVEHDR) &(audio_data->whdr [audio_data->current]), sizeof (WAVEHDR)) ;
|
||||
|
||||
/* count another buffer in use */
|
||||
EnterCriticalSection (&audio_data->mutex) ;
|
||||
audio_data->BuffersInUse ++ ;
|
||||
LeaveCriticalSection (&audio_data->mutex) ;
|
||||
|
||||
/* use the other buffer next time */
|
||||
audio_data->current = (audio_data->current + 1) % 2 ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* win32_play_data */
|
||||
|
||||
static void CALLBACK
|
||||
win32_audio_out_callback (HWAVEOUT hwave, UINT msg, DWORD data, DWORD param1, DWORD param2)
|
||||
{ Win32_Audio_Data *audio_data ;
|
||||
|
||||
/* Prevent compiler warnings. */
|
||||
hwave = hwave ;
|
||||
param1 = param2 ;
|
||||
|
||||
if (data == 0)
|
||||
return ;
|
||||
|
||||
/*
|
||||
** I consider this technique of passing a pointer via an integer as
|
||||
** fundamentally broken but thats the way microsoft has defined the
|
||||
** interface.
|
||||
*/
|
||||
audio_data = (Win32_Audio_Data*) data ;
|
||||
|
||||
/* let main loop know a buffer is free */
|
||||
if (msg == MM_WOM_DONE)
|
||||
{ EnterCriticalSection (&audio_data->mutex) ;
|
||||
audio_data->BuffersInUse -- ;
|
||||
LeaveCriticalSection (&audio_data->mutex) ;
|
||||
SetEvent (audio_data->Event) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* win32_audio_out_callback */
|
||||
|
||||
/* This is needed for earlier versions of the M$ development tools. */
|
||||
#ifndef DWORD_PTR
|
||||
#define DWORD_PTR DWORD
|
||||
#endif
|
||||
|
||||
static void
|
||||
win32_play (int argc, char *argv [])
|
||||
{ Win32_Audio_Data audio_data ;
|
||||
|
||||
WAVEFORMATEX wf ;
|
||||
int k, error ;
|
||||
|
||||
audio_data.sndfile = NULL ;
|
||||
audio_data.hwave = 0 ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
|
||||
if (! (audio_data.sndfile = sf_open (argv [k], SFM_READ, &(audio_data.sfinfo))))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_data.remaining = audio_data.sfinfo.frames * audio_data.sfinfo.channels ;
|
||||
audio_data.current = 0 ;
|
||||
|
||||
InitializeCriticalSection (&audio_data.mutex) ;
|
||||
audio_data.Event = CreateEvent (0, FALSE, FALSE, 0) ;
|
||||
|
||||
wf.nChannels = audio_data.sfinfo.channels ;
|
||||
wf.wFormatTag = WAVE_FORMAT_PCM ;
|
||||
wf.cbSize = 0 ;
|
||||
wf.wBitsPerSample = 16 ;
|
||||
|
||||
wf.nSamplesPerSec = audio_data.sfinfo.samplerate ;
|
||||
|
||||
wf.nBlockAlign = audio_data.sfinfo.channels * sizeof (short) ;
|
||||
|
||||
wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec ;
|
||||
|
||||
error = waveOutOpen (&(audio_data.hwave), WAVE_MAPPER, &wf, (DWORD_PTR) win32_audio_out_callback,
|
||||
(DWORD_PTR) &audio_data, CALLBACK_FUNCTION) ;
|
||||
if (error)
|
||||
{ puts ("waveOutOpen failed.") ;
|
||||
audio_data.hwave = 0 ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
audio_data.whdr [0].lpData = (char*) audio_data.buffer ;
|
||||
audio_data.whdr [1].lpData = ((char*) audio_data.buffer) + sizeof (audio_data.buffer) / 2 ;
|
||||
|
||||
audio_data.whdr [0].dwBufferLength = sizeof (audio_data.buffer) / 2 ;
|
||||
audio_data.whdr [1].dwBufferLength = sizeof (audio_data.buffer) / 2 ;
|
||||
|
||||
audio_data.whdr [0].dwFlags = 0 ;
|
||||
audio_data.whdr [1].dwFlags = 0 ;
|
||||
|
||||
/* length of each audio buffer in samples */
|
||||
audio_data.bufferlen = sizeof (audio_data.buffer) / 2 / sizeof (short) ;
|
||||
|
||||
/* Prepare the WAVEHDRs */
|
||||
if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR))))
|
||||
{ printf ("waveOutPrepareHeader [0] failed : %08X\n", error) ;
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if ((error = waveOutPrepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR))))
|
||||
{ printf ("waveOutPrepareHeader [1] failed : %08X\n", error) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ;
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
/* Fill up both buffers with audio data */
|
||||
audio_data.BuffersInUse = 0 ;
|
||||
win32_play_data (&audio_data) ;
|
||||
win32_play_data (&audio_data) ;
|
||||
|
||||
/* loop until both buffers are released */
|
||||
while (audio_data.BuffersInUse > 0)
|
||||
{
|
||||
/* wait for buffer to be released */
|
||||
WaitForSingleObject (audio_data.Event, INFINITE) ;
|
||||
|
||||
/* refill the buffer if there is more data to play */
|
||||
win32_play_data (&audio_data) ;
|
||||
} ;
|
||||
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [0]), sizeof (WAVEHDR)) ;
|
||||
waveOutUnprepareHeader (audio_data.hwave, &(audio_data.whdr [1]), sizeof (WAVEHDR)) ;
|
||||
|
||||
waveOutClose (audio_data.hwave) ;
|
||||
audio_data.hwave = 0 ;
|
||||
|
||||
DeleteCriticalSection (&audio_data.mutex) ;
|
||||
|
||||
sf_close (audio_data.sndfile) ;
|
||||
} ;
|
||||
|
||||
} /* win32_play */
|
||||
|
||||
#endif /* Win32 */
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
** Solaris.
|
||||
*/
|
||||
|
||||
#if (defined (sun) && defined (unix)) /* ie Solaris */
|
||||
|
||||
static void
|
||||
solaris_play (int argc, char *argv [])
|
||||
{ static short buffer [BUFFER_LEN] ;
|
||||
audio_info_t audio_info ;
|
||||
SNDFILE *sndfile ;
|
||||
SF_INFO sfinfo ;
|
||||
unsigned long delay_time ;
|
||||
long k, start_count, output_count, write_count, read_count ;
|
||||
int audio_fd, error, done ;
|
||||
|
||||
for (k = 1 ; k < argc ; k++)
|
||||
{ printf ("Playing %s\n", argv [k]) ;
|
||||
if (! (sndfile = sf_open (argv [k], SFM_READ, &sfinfo)))
|
||||
{ puts (sf_strerror (NULL)) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
if (sfinfo.channels < 1 || sfinfo.channels > 2)
|
||||
{ printf ("Error : channels = %d.\n", sfinfo.channels) ;
|
||||
continue ;
|
||||
} ;
|
||||
|
||||
/* open the audio device - write only, non-blocking */
|
||||
if ((audio_fd = open ("/dev/audio", O_WRONLY | O_NONBLOCK)) < 0)
|
||||
{ perror ("open (/dev/audio) failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* Retrive standard values. */
|
||||
AUDIO_INITINFO (&audio_info) ;
|
||||
|
||||
audio_info.play.sample_rate = sfinfo.samplerate ;
|
||||
audio_info.play.channels = sfinfo.channels ;
|
||||
audio_info.play.precision = 16 ;
|
||||
audio_info.play.encoding = AUDIO_ENCODING_LINEAR ;
|
||||
audio_info.play.gain = AUDIO_MAX_GAIN ;
|
||||
audio_info.play.balance = AUDIO_MID_BALANCE ;
|
||||
|
||||
if ((error = ioctl (audio_fd, AUDIO_SETINFO, &audio_info)))
|
||||
{ perror ("ioctl (AUDIO_SETINFO) failed") ;
|
||||
return ;
|
||||
} ;
|
||||
|
||||
/* Delay time equal to 1/4 of a buffer in microseconds. */
|
||||
delay_time = (BUFFER_LEN * 1000000) / (audio_info.play.sample_rate * 4) ;
|
||||
|
||||
done = 0 ;
|
||||
while (! done)
|
||||
{ read_count = sf_read_short (sndfile, buffer, BUFFER_LEN) ;
|
||||
if (read_count < BUFFER_LEN)
|
||||
{ memset (&(buffer [read_count]), 0, (BUFFER_LEN - read_count) * sizeof (short)) ;
|
||||
/* Tell the main application to terminate. */
|
||||
done = SF_TRUE ;
|
||||
} ;
|
||||
|
||||
start_count = 0 ;
|
||||
output_count = BUFFER_LEN * sizeof (short) ;
|
||||
|
||||
while (output_count > 0)
|
||||
{ /* write as much data as possible */
|
||||
write_count = write (audio_fd, &(buffer [start_count]), output_count) ;
|
||||
if (write_count > 0)
|
||||
{ output_count -= write_count ;
|
||||
start_count += write_count ;
|
||||
}
|
||||
else
|
||||
{ /* Give the audio output time to catch up. */
|
||||
usleep (delay_time) ;
|
||||
} ;
|
||||
} ; /* while (outpur_count > 0) */
|
||||
} ; /* while (! done) */
|
||||
|
||||
close (audio_fd) ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* solaris_play */
|
||||
|
||||
#endif /* Solaris */
|
||||
|
||||
/*==============================================================================
|
||||
** Main function.
|
||||
*/
|
||||
|
||||
int
|
||||
main (int argc, char *argv [])
|
||||
{
|
||||
if (argc < 2)
|
||||
{
|
||||
printf ("\nUsage : %s <input sound file>\n\n", argv [0]) ;
|
||||
#if (OS_IS_WIN32 == 1)
|
||||
printf ("This is a Unix style command line application which\n"
|
||||
"should be run in a MSDOS box or Command Shell window.\n\n") ;
|
||||
printf ("Sleeping for 5 seconds before exiting.\n\n") ;
|
||||
|
||||
/* This is the officially blessed by microsoft way but I can't get
|
||||
** it to link.
|
||||
** Sleep (15) ;
|
||||
** Instead, use this:
|
||||
*/
|
||||
_sleep (5 * 1000) ;
|
||||
#endif
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
#if defined (__linux__)
|
||||
#if HAVE_ALSA_ASOUNDLIB_H
|
||||
if (access ("/proc/asound/cards", R_OK) == 0)
|
||||
alsa_play (argc, argv) ;
|
||||
else
|
||||
#endif
|
||||
linux_play (argc, argv) ;
|
||||
#elif (defined (__MACH__) && defined (__APPLE__))
|
||||
macosx_play (argc, argv) ;
|
||||
#elif (defined (sun) && defined (unix))
|
||||
solaris_play (argc, argv) ;
|
||||
#elif (OS_IS_WIN32 == 1)
|
||||
win32_play (argc, argv) ;
|
||||
#elif defined (__BEOS__)
|
||||
printf ("This program cannot be compiled on BeOS.\n") ;
|
||||
printf ("Instead, compile the file sfplay_beos.cpp.\n") ;
|
||||
return 1 ;
|
||||
#else
|
||||
puts ("*** Playing sound not yet supported on this platform.") ;
|
||||
puts ("*** Please feel free to submit a patch.") ;
|
||||
return 1 ;
|
||||
#endif
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
/*
|
||||
** Do not edit or modify anything in this comment block.
|
||||
** The arch-tag line is a file identity tag for the GNU Arch
|
||||
** revision control system.
|
||||
**
|
||||
** arch-tag: 8fc4110d-6cec-4e03-91df-0f384cabedac
|
||||
*/
|
|
@ -1,128 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2008-2012 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** All rights reserved.
|
||||
**
|
||||
** Redistribution and use in source and binary forms, with or without
|
||||
** modification, are permitted provided that the following conditions are
|
||||
** met:
|
||||
**
|
||||
** * Redistributions of source code must retain the above copyright
|
||||
** notice, this list of conditions and the following disclaimer.
|
||||
** * Redistributions in binary form must reproduce the above copyright
|
||||
** notice, this list of conditions and the following disclaimer in
|
||||
** the documentation and/or other materials provided with the
|
||||
** distribution.
|
||||
** * Neither the author nor the names of any contributors may be used
|
||||
** to endorse or promote products derived from this software without
|
||||
** specific prior written permission.
|
||||
**
|
||||
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
||||
** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
||||
** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
||||
** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||
** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define BLOCK_SIZE 512
|
||||
|
||||
static void
|
||||
print_usage (char *progname)
|
||||
{ printf ("\nUsage : %s <input file> <output file>\n", progname) ;
|
||||
puts ("\n"
|
||||
" Where the output file will contain a line for each frame\n"
|
||||
" and a column for each channel.\n"
|
||||
) ;
|
||||
|
||||
} /* print_usage */
|
||||
|
||||
static void
|
||||
convert_to_text (SNDFILE * infile, FILE * outfile, int channels)
|
||||
{ float buf [channels * BLOCK_SIZE] ;
|
||||
int k, m, readcount ;
|
||||
|
||||
while ((readcount = sf_readf_float (infile, buf, BLOCK_SIZE)) > 0)
|
||||
{ for (k = 0 ; k < readcount ; k++)
|
||||
{ for (m = 0 ; m < channels ; m++)
|
||||
fprintf (outfile, " % 12.10f", buf [k * channels + m]) ;
|
||||
fprintf (outfile, "\n") ;
|
||||
} ;
|
||||
} ;
|
||||
|
||||
return ;
|
||||
} /* convert_to_text */
|
||||
|
||||
int
|
||||
main (int argc, char * argv [])
|
||||
{ char *progname, *infilename, *outfilename ;
|
||||
SNDFILE *infile = NULL ;
|
||||
FILE *outfile = NULL ;
|
||||
SF_INFO sfinfo ;
|
||||
|
||||
progname = strrchr (argv [0], '/') ;
|
||||
progname = progname ? progname + 1 : argv [0] ;
|
||||
|
||||
if (argc != 3)
|
||||
{ print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
infilename = argv [1] ;
|
||||
outfilename = argv [2] ;
|
||||
|
||||
if (strcmp (infilename, outfilename) == 0)
|
||||
{ printf ("Error : Input and output filenames are the same.\n\n") ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (infilename [0] == '-')
|
||||
{ printf ("Error : Input filename (%s) looks like an option.\n\n", infilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
if (outfilename [0] == '-')
|
||||
{ printf ("Error : Output filename (%s) looks like an option.\n\n", outfilename) ;
|
||||
print_usage (progname) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
memset (&sfinfo, 0, sizeof (sfinfo)) ;
|
||||
|
||||
if ((infile = sf_open (infilename, SFM_READ, &sfinfo)) == NULL)
|
||||
{ printf ("Not able to open input file %s.\n", infilename) ;
|
||||
puts (sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
/* Open the output file. */
|
||||
if ((outfile = fopen (outfilename, "w")) == NULL)
|
||||
{ printf ("Not able to open output file %s : %s\n", outfilename, sf_strerror (NULL)) ;
|
||||
return 1 ;
|
||||
} ;
|
||||
|
||||
fprintf (outfile, "# Converted from file %s.\n", infilename) ;
|
||||
fprintf (outfile, "# Channels %d, Sample rate %d\n", sfinfo.channels, sfinfo.samplerate) ;
|
||||
|
||||
convert_to_text (infile, outfile, sfinfo.channels) ;
|
||||
|
||||
sf_close (infile) ;
|
||||
fclose (outfile) ;
|
||||
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
|
@ -1,84 +0,0 @@
|
|||
/*
|
||||
** Copyright (C) 2007-2011 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
**
|
||||
** This program is free software; you can redistribute it and/or modify
|
||||
** it under the terms of the GNU General Public License as published by
|
||||
** the Free Software Foundation; either version 2 of the License, or
|
||||
** (at your option) any later version.
|
||||
**
|
||||
** This program is distributed in the hope that it will be useful,
|
||||
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
** GNU General Public License for more details.
|
||||
**
|
||||
** You should have received a copy of the GNU General Public License
|
||||
** along with this program; if not, write to the Free Software
|
||||
** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstring>
|
||||
|
||||
#include <sndfile.hh>
|
||||
|
||||
#define BUFFER_LEN 1024
|
||||
|
||||
static void
|
||||
create_file (const char * fname, int format)
|
||||
{ static short buffer [BUFFER_LEN] ;
|
||||
|
||||
SndfileHandle file ;
|
||||
int channels = 2 ;
|
||||
int srate = 48000 ;
|
||||
|
||||
printf ("Creating file named '%s'\n", fname) ;
|
||||
|
||||
file = SndfileHandle (fname, SFM_WRITE, format, channels, srate) ;
|
||||
|
||||
memset (buffer, 0, sizeof (buffer)) ;
|
||||
|
||||
file.write (buffer, BUFFER_LEN) ;
|
||||
|
||||
puts ("") ;
|
||||
/*
|
||||
** The SndfileHandle object will automatically close the file and
|
||||
** release all allocated memory when the object goes out of scope.
|
||||
** This is the Resource Acquisition Is Initailization idom.
|
||||
** See : http://en.wikipedia.org/wiki/Resource_Acquisition_Is_Initialization
|
||||
*/
|
||||
} /* create_file */
|
||||
|
||||
static void
|
||||
read_file (const char * fname)
|
||||
{ static short buffer [BUFFER_LEN] ;
|
||||
|
||||
SndfileHandle file ;
|
||||
|
||||
file = SndfileHandle (fname) ;
|
||||
|
||||
printf ("Opened file '%s'\n", fname) ;
|
||||
printf (" Sample rate : %d\n", file.samplerate ()) ;
|
||||
printf (" Channels : %d\n", file.channels ()) ;
|
||||
|
||||
file.read (buffer, BUFFER_LEN) ;
|
||||
|
||||
puts ("") ;
|
||||
|
||||
/* RAII takes care of destroying SndfileHandle object. */
|
||||
} /* read_file */
|
||||
|
||||
int
|
||||
main (void)
|
||||
{ const char * fname = "test.wav" ;
|
||||
|
||||
puts ("\nSimple example showing usage of the C++ SndfileHandle object.\n") ;
|
||||
|
||||
create_file (fname, SF_FORMAT_WAV | SF_FORMAT_PCM_16) ;
|
||||
|
||||
read_file (fname) ;
|
||||
|
||||
puts ("Done.\n") ;
|
||||
return 0 ;
|
||||
} /* main */
|
||||
|
||||
|
|
@ -1,69 +0,0 @@
|
|||
|
||||
%define name @PACKAGE@
|
||||
%define version @VERSION@
|
||||
%define release 1
|
||||
|
||||
Summary: A library to handle various audio file formats.
|
||||
Name: %{name}
|
||||
Version: %{version}
|
||||
Release: %{release}
|
||||
Copyright: LGPL
|
||||
Group: Libraries/Sound
|
||||
Source: http://www.mega-nerd.com/libsndfile/libsndfile-%{version}.tar.gz
|
||||
Url: http://www.mega-nerd.com/libsndfile/
|
||||
BuildRoot: /var/tmp/%{name}-%{version}
|
||||
|
||||
%description
|
||||
libsndfile is a C library for reading and writing sound files such as
|
||||
AIFF, AU and WAV files through one standard interface. It can currently
|
||||
read/write 8, 16, 24 and 32-bit PCM files as well as 32-bit floating
|
||||
point WAV files and a number of compressed formats.
|
||||
|
||||
%package devel
|
||||
Summary: Libraries, includes, etc to develop libsndfile applications
|
||||
Group: Libraries
|
||||
|
||||
%description devel
|
||||
Libraries, include files, etc you can use to develop libsndfile applications.
|
||||
|
||||
%prep
|
||||
%setup
|
||||
|
||||
%build
|
||||
%configure
|
||||
make
|
||||
|
||||
%install
|
||||
if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
|
||||
mkdir -p $RPM_BUILD_ROOT
|
||||
make DESTDIR=$RPM_BUILD_ROOT install
|
||||
%clean
|
||||
if [ -d $RPM_BUILD_ROOT ]; then rm -rf $RPM_BUILD_ROOT; fi
|
||||
|
||||
%files
|
||||
%defattr(-,root,root)
|
||||
%doc AUTHORS COPYING ChangeLog INSTALL NEWS README TODO doc
|
||||
%{_libdir}/libsndfile.so.*
|
||||
%{_bindir}/*
|
||||
%{_mandir}/man1/*
|
||||
%{_datadir}/octave/site/m/*
|
||||
%{_defaultdocdir}/libsndfile1-dev/html/*
|
||||
|
||||
%files devel
|
||||
%defattr(-,root,root)
|
||||
%{_libdir}/libsndfile.a
|
||||
%{_libdir}/libsndfile.la
|
||||
%{_libdir}/libsndfile.so
|
||||
%{_includedir}/sndfile.h
|
||||
%{_libdir}/pkgconfig/sndfile.pc
|
||||
|
||||
%changelog
|
||||
* Sun May 15 2005 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
- Add html files to the files section.
|
||||
* Tue Sep 16 2003 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
- Apply corrections from Andrew Schultz.
|
||||
* Mon Oct 21 2002 Erik de Castro Lopo <erikd@mega-nerd.com>
|
||||
- Force installation of sndfile.pc file.
|
||||
* Thu Jul 6 2000 Josh Green <jgreen@users.sourceforge.net>
|
||||
- Created libsndfile.spec.in
|
||||
|
|
@ -1,491 +0,0 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
import commands, os, re, string, sys, time
|
||||
|
||||
def count_enclosed_functions (source):
|
||||
func_count = 0
|
||||
open_brace = 0
|
||||
close_brace = 0
|
||||
for ch in source:
|
||||
if ch == '{':
|
||||
open_brace += 1
|
||||
elif ch == '}':
|
||||
close_brace += 1
|
||||
if open_brace == close_brace:
|
||||
func_count += 1
|
||||
if open_brace < close_brace:
|
||||
print "count_enclosed_functions : open_brace < close_brace"
|
||||
return -1
|
||||
return func_count
|
||||
|
||||
def find_function_prototype (source, proto_name):
|
||||
proto_re = "(^[a-zA-Z_ \t]+\s+%s[^a-zA-Z0-9_]\s*\([^\)]+\)\s+;\n)" % (proto_name)
|
||||
proto_result = re.search (proto_re, source, re.MULTILINE | re.DOTALL)
|
||||
if not proto_result:
|
||||
return None
|
||||
proto_text = proto_result.groups ()[0]
|
||||
return proto_text
|
||||
|
||||
def find_function_definition (source, func_name):
|
||||
func_re = "(\n[a-zA-Z_ \t]+\n%s[^a-zA-Z0-9_].* /\* %s \*/\n)" % (func_name, func_name)
|
||||
func_result = re.search (func_re, source, re.MULTILINE | re.DOTALL)
|
||||
if not func_result:
|
||||
sys.exit (1)
|
||||
return None
|
||||
func_text = func_result.groups ()[0]
|
||||
|
||||
# Now to check that we only have one enclosing function.
|
||||
func_count = count_enclosed_functions (func_text)
|
||||
if func_count != 1:
|
||||
return None
|
||||
return func_text
|
||||
|
||||
def find_include (source, inc_name):
|
||||
inc_re = "(^#include\s+[\<\"]%s[\"\>]\s*)" % inc_name
|
||||
inc_result = re.search (inc_re, source, re.MULTILINE | re.DOTALL)
|
||||
if not inc_result:
|
||||
return None
|
||||
inc_text = inc_result.groups ()[0]
|
||||
return inc_text
|
||||
|
||||
def find_assign_statement (source, var_name):
|
||||
var_re = "(^\s+%s\s*=[^;]+;)" % var_name
|
||||
var_result = re.search (var_re, source, re.MULTILINE | re.DOTALL)
|
||||
if not var_result:
|
||||
return None
|
||||
assign_text = var_result.groups ()[0]
|
||||
return assign_text
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
|
||||
def remove_include (source, inc_name):
|
||||
inc_text = find_include (source, inc_name)
|
||||
if not inc_text:
|
||||
print "remove_include : include '%s' not found. Exiting." % inc_name
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, inc_text, "")
|
||||
return source
|
||||
|
||||
def remove_assign (source, assign_name):
|
||||
assign_text = find_assign (source, inc_name)
|
||||
if not inc_text:
|
||||
print "remove_include : include '%s' not found. Exiting." % inc_name
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, inc_text, "")
|
||||
return source
|
||||
|
||||
def remove_prototype (source, proto_name):
|
||||
proto_text = find_function_prototype (source, proto_name)
|
||||
if not proto_text:
|
||||
print "remove_prototype : prototype '%s' not found. Exiting." % proto_name
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, proto_text, "")
|
||||
return source
|
||||
|
||||
def remove_function (source, func_name):
|
||||
func_text = find_function_definition (source, func_name)
|
||||
if not func_text:
|
||||
print "remove_function : function '%s' not found. Exiting." % func_name
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, func_text, "/* Function %s() removed here. */\n" % func_name)
|
||||
return source
|
||||
|
||||
def remove_all_assignments (source, var):
|
||||
count = 0
|
||||
while 1:
|
||||
assign_text = find_assign_statement (source, var)
|
||||
if not assign_text:
|
||||
if count != 0:
|
||||
break
|
||||
print "remove_all_assignments : variable '%s' not found. Exiting." % var
|
||||
sys.exit (1)
|
||||
|
||||
source = string.replace (source, assign_text, "")
|
||||
count += 1
|
||||
return source
|
||||
|
||||
|
||||
|
||||
#----------------------------------------------------------------
|
||||
|
||||
def remove_funcs_and_protos_from_file (filename, func_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for func in func_list:
|
||||
source_code = remove_prototype (source_code, func) ;
|
||||
source_code = remove_function (source_code, func) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_funcs_from_file (filename, func_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for func in func_list:
|
||||
source_code = remove_function (source_code, func) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_protos_from_file (filename, func_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for func in func_list:
|
||||
source_code = remove_prototype (source_code, func) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_includes_from_file (filename, inc_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for inc in inc_list:
|
||||
source_code = remove_include (source_code, inc) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_all_assignments_from_file (filename, var_list):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
for var in var_list:
|
||||
source_code = remove_all_assignments (source_code, var) ;
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_comment_start_end (filename, start_comment, end_comment):
|
||||
source_code = open (filename, 'r').read ()
|
||||
|
||||
while 1:
|
||||
start_index = string.find (source_code, start_comment)
|
||||
end_index = string.find (source_code, end_comment)
|
||||
if start_index < 0 or end_index < start_index:
|
||||
break
|
||||
end_index += len (end_comment)
|
||||
source_code = source_code [:start_index-1] + source_code [end_index:] ;
|
||||
|
||||
open (filename, 'w').write (source_code)
|
||||
|
||||
def remove_strings_from_file (filename, str_list):
|
||||
file_text = open (filename, 'r').read ()
|
||||
for current_str in str_list:
|
||||
file_text = string.replace (file_text, current_str, '')
|
||||
open (filename, 'w').write (file_text)
|
||||
|
||||
def string_replace_in_file (filename, from_str, to_str):
|
||||
file_text = open (filename, 'r').read ()
|
||||
file_text = string.replace (file_text, from_str, to_str)
|
||||
open (filename, 'w').write (file_text)
|
||||
|
||||
def remove_regex_from_file (filename, regex_list):
|
||||
file_text = open (filename, 'r').read ()
|
||||
for regex in regex_list:
|
||||
file_text = re.sub (regex, '', file_text, re.MULTILINE | re.DOTALL)
|
||||
open (filename, 'w').write (file_text)
|
||||
|
||||
#==========================================================================
|
||||
|
||||
def find_configure_version (filename):
|
||||
# AM_INIT_AUTOMAKE(libsndfile,0.0.21pre6)
|
||||
file = open (filename)
|
||||
while 1:
|
||||
line = file.readline ()
|
||||
if re.search ("AC_INIT", line):
|
||||
x = re.sub ("[^\(]+\(", "", line)
|
||||
x = re.sub ("\).*\n", "", x)
|
||||
x = string.split (x, ",")
|
||||
package = x [0]
|
||||
version = x [1]
|
||||
break
|
||||
file.close ()
|
||||
# version = re.escape (version)
|
||||
return package, version
|
||||
|
||||
def fix_configure_ac_file (filename):
|
||||
data = open (filename, 'r').read ()
|
||||
data = string.replace (data, "AM_INIT_AUTOMAKE(libsndfile,", "AM_INIT_AUTOMAKE(libsndfile_lite,", 1)
|
||||
|
||||
file = open (filename, 'w')
|
||||
file.write (data)
|
||||
file.close ()
|
||||
|
||||
|
||||
def make_dist_file (package, version):
|
||||
print "Making dist file."
|
||||
tar_gz_file = "%s-%s.tar.gz" % (package, version)
|
||||
if os.path.exists (tar_gz_file):
|
||||
return
|
||||
if os.system ("make dist"):
|
||||
sys.exit (1)
|
||||
return
|
||||
|
||||
def delete_files (file_list):
|
||||
for file_name in file_list:
|
||||
os.remove (file_name)
|
||||
|
||||
#=======================================================================
|
||||
|
||||
source_dir = os.getcwd ()
|
||||
|
||||
conf_package, conf_version = find_configure_version ('configure.ac')
|
||||
|
||||
package_version = "%s-%s" % (conf_package, conf_version)
|
||||
lite_version = "%s_lite-%s" % (conf_package, conf_version)
|
||||
|
||||
os.system ("rm -rf %s%s.tar.gz" % (source_dir, package_version))
|
||||
|
||||
os.system ("make dist")
|
||||
|
||||
make_dist_file (conf_package, conf_version)
|
||||
|
||||
os.chdir ("/tmp")
|
||||
|
||||
print "Uncompressing .tar.gz file."
|
||||
os.system ("rm -rf %s" % package_version)
|
||||
if os.system ("tar zxf %s/%s.tar.gz" % (source_dir, package_version)):
|
||||
sys.exit (1)
|
||||
|
||||
|
||||
print "Renaming to libsndfile_lite."
|
||||
os.system ("rm -rf %s" % lite_version)
|
||||
os.rename (package_version, lite_version)
|
||||
|
||||
print "Changing into libsndfile_lite directory."
|
||||
os.chdir (lite_version)
|
||||
|
||||
print "Removing un-neeed directories."
|
||||
delete_dirs = [ 'src/G72x' ]
|
||||
|
||||
for dir_name in delete_dirs:
|
||||
os.system ("rm -rf %s" % dir_name)
|
||||
|
||||
print "Removing un-needed files."
|
||||
delete_files ([ 'src/ircam.c', 'src/nist.c',
|
||||
'src/ima_adpcm.c', 'src/ms_adpcm.c', 'src/au_g72x.c',
|
||||
'src/mat4.c', 'src/mat5.c', 'src/dwvw.c', 'src/paf.c',
|
||||
'src/ogg.c', 'src/pvf.c', 'src/xi.c', 'src/htk.c',
|
||||
'src/sd2.c', 'src/rx2.c', 'src/txw.c', 'src/wve.c',
|
||||
'src/dwd.c', 'src/svx.c', 'src/voc.c', 'src/vox_adpcm.c',
|
||||
'src/sds.c'
|
||||
])
|
||||
|
||||
|
||||
print "Hacking 'configure.ac' and 'src/Makefile.am'."
|
||||
remove_strings_from_file ('configure.ac', [ 'src/G72x/Makefile' ])
|
||||
remove_strings_from_file ('src/Makefile.am', [ 'G72x/libg72x.la', 'G72x',
|
||||
'ircam.c', 'nist.c', 'ima_adpcm.c', 'ms_adpcm.c', 'au_g72x.c', 'mat4.c',
|
||||
'mat5.c', 'dwvw.c', 'paf.c', 'ogg.c', 'pvf.c', 'xi.c', 'htk.c',
|
||||
'sd2.c', 'rx2.c', 'txw.c', 'wve.c', 'dwd.c', 'svx.c', 'voc.c',
|
||||
'vox_adpcm.c', 'sds.c'
|
||||
])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking header files."
|
||||
|
||||
remove_protos_from_file ('src/common.h', [ 'xi_open', 'sd2_open', 'ogg_open',
|
||||
'dwvw_init', 'paf_open', 'svx_open', 'nist_open', 'rx2_open', 'mat4_open',
|
||||
'voc_open', 'txw_open', 'dwd_open', 'htk_open', 'wve_open', 'mat5_open',
|
||||
'pvf_open', 'ircam_open', 'sds_open',
|
||||
'float32_init', 'double64_init', 'aiff_ima_init', 'vox_adpcm_init',
|
||||
'wav_w64_ima_init', 'wav_w64_msadpcm_init'
|
||||
])
|
||||
|
||||
remove_protos_from_file ('src/au.h',
|
||||
[ 'au_g72x_reader_init', 'au_g72x_writer_init' ])
|
||||
|
||||
remove_protos_from_file ('src/wav_w64.h', [ 'msadpcm_write_adapt_coeffs' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking case statements."
|
||||
|
||||
remove_comment_start_end ('src/sndfile.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/aiff.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/au.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/raw.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/w64.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/wav.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/double64.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
remove_comment_start_end ('src/float32.c', '/* Lite remove start */' , '/* Lite remove end */')
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/pcm.c."
|
||||
remove_funcs_from_file ('src/pcm.c', [
|
||||
'f2sc_array', 'f2sc_clip_array', 'f2uc_array', 'f2uc_clip_array',
|
||||
'f2bes_array', 'f2bes_clip_array', 'f2les_array', 'f2les_clip_array',
|
||||
'f2let_array', 'f2let_clip_array', 'f2bet_array', 'f2bet_clip_array',
|
||||
'f2bei_array', 'f2bei_clip_array', 'f2lei_array', 'f2lei_clip_array',
|
||||
'd2sc_array', 'd2sc_clip_array', 'd2uc_array', 'd2uc_clip_array',
|
||||
'd2bes_array', 'd2bes_clip_array', 'd2les_array', 'd2les_clip_array',
|
||||
'd2let_array', 'd2let_clip_array', 'd2bet_array', 'd2bet_clip_array',
|
||||
'd2bei_array', 'd2bei_clip_array', 'd2lei_array', 'd2lei_clip_array',
|
||||
])
|
||||
|
||||
remove_funcs_and_protos_from_file ('src/pcm.c', [
|
||||
'pcm_read_sc2f', 'pcm_read_uc2f', 'pcm_read_les2f', 'pcm_read_bes2f',
|
||||
'pcm_read_let2f', 'pcm_read_bet2f', 'pcm_read_lei2f', 'pcm_read_bei2f',
|
||||
'pcm_read_sc2d', 'pcm_read_uc2d', 'pcm_read_les2d', 'pcm_read_bes2d',
|
||||
'pcm_read_let2d', 'pcm_read_bet2d', 'pcm_read_lei2d', 'pcm_read_bei2d',
|
||||
'pcm_write_f2sc', 'pcm_write_f2uc', 'pcm_write_f2bes', 'pcm_write_f2les',
|
||||
'pcm_write_f2bet', 'pcm_write_f2let', 'pcm_write_f2bei', 'pcm_write_f2lei',
|
||||
'pcm_write_d2sc', 'pcm_write_d2uc', 'pcm_write_d2bes', 'pcm_write_d2les',
|
||||
'pcm_write_d2bet', 'pcm_write_d2let', 'pcm_write_d2bei', 'pcm_write_d2lei',
|
||||
|
||||
'sc2f_array', 'uc2f_array', 'bes2f_array', 'les2f_array',
|
||||
'bet2f_array', 'let2f_array', 'bei2f_array', 'lei2f_array',
|
||||
'sc2d_array', 'uc2d_array', 'bes2d_array', 'les2d_array',
|
||||
'bet2d_array', 'let2d_array', 'bei2d_array', 'lei2d_array'
|
||||
])
|
||||
|
||||
remove_includes_from_file ('src/pcm.c', [ 'float_cast.h' ])
|
||||
remove_all_assignments_from_file ('src/pcm.c', [
|
||||
'psf-\>write_float', 'psf\-\>write_double',
|
||||
'psf-\>read_float', 'psf\-\>read_double' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
print "Hacking src/ulaw.c."
|
||||
remove_funcs_and_protos_from_file ('src/ulaw.c', [
|
||||
'ulaw_read_ulaw2f', 'ulaw_read_ulaw2d',
|
||||
'ulaw_write_f2ulaw', 'ulaw_write_d2ulaw',
|
||||
'ulaw2f_array', 'ulaw2d_array', 'f2ulaw_array', 'd2ulaw_array'
|
||||
])
|
||||
|
||||
remove_includes_from_file ('src/ulaw.c', [ 'float_cast.h' ])
|
||||
remove_all_assignments_from_file ('src/ulaw.c', [
|
||||
'psf-\>write_float', 'psf\-\>write_double',
|
||||
'psf-\>read_float', 'psf\-\>read_double' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/alaw.c."
|
||||
remove_funcs_and_protos_from_file ('src/alaw.c', [
|
||||
'alaw_read_alaw2f', 'alaw_read_alaw2d',
|
||||
'alaw_write_f2alaw', 'alaw_write_d2alaw',
|
||||
'alaw2f_array', 'alaw2d_array', 'f2alaw_array', 'd2alaw_array'
|
||||
])
|
||||
|
||||
remove_includes_from_file ('src/alaw.c', [ 'float_cast.h' ])
|
||||
remove_all_assignments_from_file ('src/alaw.c', [
|
||||
'psf-\>write_float', 'psf\-\>write_double',
|
||||
'psf-\>read_float', 'psf\-\>read_double' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/gsm610.c."
|
||||
remove_funcs_and_protos_from_file ('src/gsm610.c', [
|
||||
'gsm610_read_f', 'gsm610_read_d', 'gsm610_write_f', 'gsm610_write_d'
|
||||
])
|
||||
|
||||
remove_includes_from_file ('src/gsm610.c', [ 'float_cast.h' ])
|
||||
remove_all_assignments_from_file ('src/gsm610.c', [
|
||||
'psf-\>write_float', 'psf\-\>write_double',
|
||||
'psf-\>read_float', 'psf\-\>read_double' ])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/float32.c."
|
||||
|
||||
# string_replace_in_file ('src/float32.c', '"float_cast.h"', '<math.h>')
|
||||
remove_funcs_from_file ('src/float32.c', [ 'float32_init' ])
|
||||
|
||||
remove_funcs_and_protos_from_file ('src/float32.c', [
|
||||
'host_read_f2s', 'host_read_f2i', 'host_read_f', 'host_read_f2d',
|
||||
'host_write_s2f', 'host_write_i2f', 'host_write_f', 'host_write_d2f',
|
||||
'f2s_array', 'f2i_array', 'f2d_array', 's2f_array', 'i2f_array', 'd2f_array',
|
||||
'float32_peak_update',
|
||||
'replace_read_f2s', 'replace_read_f2i', 'replace_read_f', 'replace_read_f2d',
|
||||
'replace_write_s2f', 'replace_write_i2f', 'replace_write_f', 'replace_write_d2f',
|
||||
'bf2f_array', 'f2bf_array',
|
||||
'float32_get_capability',
|
||||
])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking src/double64.c."
|
||||
remove_funcs_from_file ('src/double64.c', [ 'double64_init' ])
|
||||
|
||||
remove_funcs_and_protos_from_file ('src/double64.c', [
|
||||
'host_read_d2s', 'host_read_d2i', 'host_read_d2f', 'host_read_d',
|
||||
'host_write_s2d', 'host_write_i2d', 'host_write_f2d', 'host_write_d',
|
||||
'd2s_array', 'd2i_array', 'd2f_array',
|
||||
's2d_array', 'i2d_array', 'f2d_array',
|
||||
'double64_peak_update', 'double64_get_capability',
|
||||
'replace_read_d2s', 'replace_read_d2i', 'replace_read_d2f', 'replace_read_d',
|
||||
'replace_write_s2d', 'replace_write_i2d', 'replace_write_f2d', 'replace_write_d',
|
||||
'd2bd_read', 'bd2d_write'
|
||||
])
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Hacking test programs."
|
||||
delete_files ([ 'tests/dwvw_test.c', 'tests/floating_point_test.c',
|
||||
'tests/dft_cmp.c', 'tests/peak_chunk_test.c',
|
||||
'tests/scale_clip_test.tpl', 'tests/scale_clip_test.def'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/write_read_test.def', '/* Lite remove start */', '/* Lite remove end */')
|
||||
remove_comment_start_end ('tests/write_read_test.tpl', '/* Lite remove start */', '/* Lite remove end */')
|
||||
|
||||
remove_comment_start_end ('tests/Makefile.am', '# Lite remove start', '# Lite remove end')
|
||||
|
||||
remove_strings_from_file ('tests/Makefile.am', [
|
||||
'scale_clip_test.tpl', 'scale_clip_test.def',
|
||||
'\n\t./dwvw_test',
|
||||
'\n\t./floating_point_test', '\n\t./scale_clip_test',
|
||||
'\n\t./peak_chunk_test aiff', '\n\t./peak_chunk_test wav',
|
||||
'\n\t./command_test norm', '\n\t./command_test peak',
|
||||
'\n\t./lossy_comp_test wav_ima', '\n\t./lossy_comp_test wav_msadpcm',
|
||||
'\n\t./lossy_comp_test au_g721', '\n\t./lossy_comp_test au_g723',
|
||||
'\n\t./lossy_comp_test vox_adpcm',
|
||||
'\n\t./lossy_comp_test w64_ima', '\n\t./lossy_comp_test w64_msadpcm',
|
||||
'peak_chunk_test', 'dwvw_test', 'floating_point_test', 'scale_clip_test',
|
||||
|
||||
'paf-tests', 'svx-tests', 'nist-tests', 'ircam-tests', 'voc-tests',
|
||||
'mat4-tests', 'mat5-tests', 'pvf-tests', 'xi-tests', 'htk-tests',
|
||||
'sds-tests'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/pcm_test.c', '/* Lite remove start */', '/* Lite remove end */')
|
||||
remove_funcs_and_protos_from_file ('tests/pcm_test.c', [
|
||||
'pcm_test_float', 'pcm_test_double'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/lossy_comp_test.c', '/* Lite remove start */', '/* Lite remove end */')
|
||||
remove_funcs_and_protos_from_file ('tests/lossy_comp_test.c', [
|
||||
'lcomp_test_float', 'lcomp_test_double', 'sdlcomp_test_float', 'sdlcomp_test_double',
|
||||
'smoothed_diff_float', 'smoothed_diff_double'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/multi_file_test.c', '/* Lite remove start */', '/* Lite remove end */')
|
||||
|
||||
remove_strings_from_file ('tests/stdio_test.c', [
|
||||
'"paf",', '"svx",', '"nist",', '"ircam",', '"voc",', '"mat4",', '"mat5",', '"pvf",'
|
||||
])
|
||||
|
||||
remove_comment_start_end ('tests/pipe_test.c', '/* Lite remove start */', '/* Lite remove end */')
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
|
||||
print "Fixing configure.ac file."
|
||||
fix_configure_ac_file ('configure.ac')
|
||||
|
||||
print "Building and testing source."
|
||||
# Try --disable-shared --disable-gcc-opt
|
||||
if os.system ("./reconfigure.mk && ./configure --disable-shared --disable-gcc-opt && make check"):
|
||||
os.system ('PS1="FIX > " bash --norc')
|
||||
sys.exit (1)
|
||||
|
||||
print "Making distcheck"
|
||||
if os.system ("make distcheck"):
|
||||
os.system ('PS1="FIX > " bash --norc')
|
||||
sys.exit (1)
|
||||
|
||||
print "Copying tarball"
|
||||
if os.system ("cp %s.tar.gz %s" % (lite_version, source_dir)):
|
||||
print "??? %s.tar.gz ???" % lite_version
|
||||
os.system ('PS1="FIX > " bash --norc')
|
||||
sys.exit (1)
|
||||
|
||||
os.chdir (source_dir)
|
||||
|
||||
os.system ("rm -rf /tmp/%s" % lite_version)
|
||||
|
||||
print "Done."
|
|
@ -1,15 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
man_MANS = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \
|
||||
sndfile-metadata-get.1 sndfile-metadata-set.1 sndfile-concat.1 \
|
||||
sndfile-interleave.1 sndfile-deinterleave.1
|
||||
|
||||
EXTRA_DIST = sndfile-info.1 sndfile-play.1 sndfile-convert.1 sndfile-cmp.1 \
|
||||
sndfile-metadata-get.1 sndfile-concat.1 sndfile-interleave.1
|
||||
|
||||
# Same manpage for both programs.
|
||||
sndfile-metadata-set.1 : sndfile-metadata-get.1
|
||||
$(LN_S) $(srcdir)/sndfile-metadata-get.1 $@
|
||||
|
||||
sndfile-deinterleave.1 : sndfile-interleave.1
|
||||
$(LN_S) $(srcdir)/sndfile-interleave.1 $@
|
|
@ -1,16 +0,0 @@
|
|||
.TH SNDFILE-CMP 1 "October 5, 2009"
|
||||
.SH NAME
|
||||
sndfile-cmp \- compares two audio files
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-cmp
|
||||
.RI "file1 file2"
|
||||
.SH DESCRIPTION
|
||||
sndfile-cmp compares the audio data of two sound files. In particular most
|
||||
differences in the audio file header, particularly metadata like string info,
|
||||
are completely ignored.
|
||||
|
||||
sndfile-cmp does its work using libsndfile
|
||||
(http://www.mega-nerd.com/libsndfile/).
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
.TH SNDFILE-CONCAT 1 "December 9, 2009"
|
||||
.SH NAME
|
||||
sndfile-concat \- concatenates two or more audio files
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-concat
|
||||
.RI "infile1 infile2 .... outfile"
|
||||
.SH DESCRIPTION
|
||||
sndfile-concat generates a new output file by concatenating two or more input
|
||||
files. The format of the output file is the same as the format of the input
|
||||
file.
|
||||
|
||||
sndfile-concat does its work using libsndfile
|
||||
(http://www.mega-nerd.com/libsndfile/).
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
.TH SNDFILE-CONVERT 1 "October 09, 2002"
|
||||
.SH NAME
|
||||
sndfile-convert \- convert a sound files from one format to another
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-convert
|
||||
.RI "[encoding] input_file output_file"
|
||||
.LP
|
||||
.B sndfile-convert
|
||||
.RI --help
|
||||
.SH DESCRIPTION
|
||||
sndfile-convert converts sound files from one format to another using
|
||||
libsndfile (http://www.mega-nerd.com/libsndfile/) to read and write
|
||||
the data.
|
||||
.LP
|
||||
The format of the output file is determined by the filename extension
|
||||
of the output file.
|
||||
.LP
|
||||
The optional encoding parameter allows setting of the data encoding for
|
||||
the output file. Run "sndfile\-convert \-\-help" for more information.
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
.TH SNDFILE-INFO 1 "July 28, 2002"
|
||||
.SH NAME
|
||||
sndfile-info \- display information about a sound file
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-info
|
||||
.RI file
|
||||
.SH DESCRIPTION
|
||||
sndfile-info will display basic information about a sound file such as
|
||||
its format, its sample rate, and the number of channels. This information
|
||||
is obtained using libsndfile (http://www.mega-nerd.com/libsndfile/).
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by Joshua Haberman
|
||||
<joshua@debian.org>, for the Debian GNU/Linux system (but may be used by
|
||||
others). Further additions have been made by Erik de Castro Lopo
|
||||
<erikd@mega-nerd.com>.
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
.TH SNDFILE-INTERLEAVE 1 "December 14, 2009"
|
||||
.SH NAME
|
||||
sndfile-interleave \- convert multiple single channel files into a multi-channel file
|
||||
.br
|
||||
sndfile-deinterleave \- split a multi-channel into multiple single channel files
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-interleave
|
||||
.RI "<input 1> <input 2> ... -o <output file>"
|
||||
.br
|
||||
.B sndfile-deinterleave
|
||||
.RI "filename"
|
||||
|
||||
.SH DESCRIPTION
|
||||
sndfile-interleave and sndfile-deinterleave use libsndfile
|
||||
(http://www.mega-nerd.com/libsndfile/) to convert back and forth between multiple
|
||||
single channel files and a single multi-channel sound file.
|
||||
|
||||
Run "sndfile\-interleave \-\-help" or "sndfile\-deinterleave \-\-help" for
|
||||
more information
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
.TH SNDFILE-METADATA-GET 1 "October 6, 2009"
|
||||
.SH NAME
|
||||
sndfile-metadata-get \- retrieve metadata from a sound file
|
||||
.br
|
||||
sndfile-metadata-set \- set metadata in a sound file
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-metadata-get
|
||||
.RI "[options] file"
|
||||
.br
|
||||
.B sndfile-metadata-set
|
||||
.RI "[options] file"
|
||||
.br
|
||||
.B sndfile-metadata-set
|
||||
.RI "[options] input-file output-file"
|
||||
|
||||
.SH DESCRIPTION
|
||||
sndfile-metadata-get and sndfile-metadata-set use libsndfile
|
||||
(http://www.mega-nerd.com/libsndfile/) to retrieve metadata from or set metadata
|
||||
in a sound file.
|
||||
|
||||
Run "sndfile\-metadata\-get \-\-help" or "sndfile\-metadata\-set \-\-help" for
|
||||
more information
|
||||
|
||||
.SH AUTHOR
|
||||
This manual page was written by Erik de Castro Lopo <erikd@mega-nerd.com>.
|
||||
|
|
@ -1,36 +0,0 @@
|
|||
.de EX
|
||||
.ne 5
|
||||
.if n .sp 1
|
||||
.if t .sp .5
|
||||
.nf
|
||||
.in +.5i
|
||||
..
|
||||
.de EE
|
||||
.fi
|
||||
.in -.5i
|
||||
.if n .sp 1
|
||||
.if t .sp .5
|
||||
..
|
||||
.TH SNDFILE-PLAY 1 "July 28, 2002"
|
||||
.SH NAME
|
||||
sndfile-play \- play a sound file
|
||||
.SH SYNOPSIS
|
||||
.B sndfile-play
|
||||
.RI file
|
||||
.SH DESCRIPTION
|
||||
sndfile-play plays the specified sound file using :
|
||||
.EX
|
||||
ALSA on Linux
|
||||
/dev/dsp on systems supporting OSS (including Linux)
|
||||
/dev/audio on Sun Solaris
|
||||
CoreAudio on Apple MacOSX
|
||||
waveOut on Microsoft Win32
|
||||
.EE
|
||||
sndfile-play uses libsndfile (http://www.mega-nerd.com/libsndfile/)
|
||||
to read the file.
|
||||
.SH AUTHOR
|
||||
This manual page was originally written by Joshua Haberman
|
||||
<joshua@debian.org>, for the Debian GNU/Linux system (but may be used by
|
||||
others). Further additions have been made by Erik de Castro Lopo
|
||||
<erikd@mega-nerd.com>.
|
||||
|
|
@ -1,47 +0,0 @@
|
|||
## Process this file with automake to produce Makefile.in
|
||||
|
||||
bin_PROGRAMS = sndfile-info sndfile-play sndfile-convert sndfile-cmp \
|
||||
sndfile-metadata-set sndfile-metadata-get sndfile-interleave \
|
||||
sndfile-deinterleave sndfile-concat sndfile-salvage
|
||||
|
||||
OS_SPECIFIC_CFLAGS = @OS_SPECIFIC_CFLAGS@
|
||||
OS_SPECIFIC_LINKS = @OS_SPECIFIC_LINKS@
|
||||
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/src $(OS_SPECIFIC_CFLAGS)
|
||||
|
||||
CLEANFILES = *~ sndfile-*.exe
|
||||
|
||||
# This is the BeOS version of sndfile-play. It needs to be compiled with the C++
|
||||
# compiler.
|
||||
EXTRA_DIST = sndfile-play-beos.cpp test-sndfile-metadata-set.py
|
||||
|
||||
sndfile_info_SOURCES = sndfile-info.c common.c common.h
|
||||
sndfile_info_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_play_SOURCES = sndfile-play.c common.c common.h
|
||||
sndfile_play_LDADD = $(top_builddir)/src/libsndfile.la $(OS_SPECIFIC_LINKS) $(ALSA_LIBS) $(SNDIO_LIBS)
|
||||
|
||||
sndfile_convert_SOURCES = sndfile-convert.c common.c common.h
|
||||
sndfile_convert_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_cmp_SOURCES = sndfile-cmp.c common.c common.h
|
||||
sndfile_cmp_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_metadata_set_SOURCES = sndfile-metadata-set.c common.c common.h
|
||||
sndfile_metadata_set_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_metadata_get_SOURCES = sndfile-metadata-get.c common.c common.h
|
||||
sndfile_metadata_get_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_interleave_SOURCES = sndfile-interleave.c common.c common.h
|
||||
sndfile_interleave_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_deinterleave_SOURCES = sndfile-deinterleave.c common.c common.h
|
||||
sndfile_deinterleave_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_concat_SOURCES = sndfile-concat.c common.c common.h
|
||||
sndfile_concat_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
||||
sndfile_salvage_SOURCES = sndfile-salvage.c common.c common.h
|
||||
sndfile_salvage_LDADD = $(top_builddir)/src/libsndfile.la
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue