Codebase list libsndfile / dcb523f
Update upstream source from tag 'upstream/1.0.31' Update to upstream version '1.0.31' with Debian dir 8f7cdc3b4f184bbfc1ebf2f358424069f8def3cf LP: #1807823 LP: #1807825 LP: #1807826 LP: #900332 LP: #999994 LP: #1036831 LP: #1546685 IOhannes m zmölnig (Debian/GNU) 3 years ago
106 changed file(s) with 5454 addition(s) and 6816 deletion(s). Raw diff Collapse all Expand all
+0
-15
.gitattributes less more
0 # Set the default behavior, in case people don't have core.autocrlf set.
1 * text=auto
2
3 # Declare files that will always have CRLF line endings on checkout.
4 *.ac text eol=lf
5 *.am text eol=lf
6 *.m4 text eol=lf
7 *.pc text eol=lf
8 *.spec text eol=lf
9 *.sh text eol=lf
10
11 # Explicitly declare text files you want to always be normalized and converted
12 # to native line endings on checkout.
13 *.c text
14 *.h text
+0
-226
.github/workflows/action.yml less more
0 name: C/C++ CI
1
2 on: [push, pull_request]
3
4 jobs:
5 build:
6 strategy:
7 fail-fast: false
8 matrix:
9 name: [
10 ubuntu-gcc-autotools,
11 ubuntu-clang-autotools,
12 ubuntu-gcc-ossfuzz,
13 macos-autotools,
14 ubuntu-gcc-cmake,
15 ubuntu-gcc-cmake-shared,
16 ubuntu-clang-cmake,
17 ubuntu-clang-cmake-shared,
18 macos-cmake,
19 macos-cmake-shared,
20 windows-vs2019-x64,
21 windows-vs2019-x64-shared,
22 windows-vs2019-Win32,
23 windows-vs2019-Win32-shared
24 ]
25 include:
26 - name: ubuntu-gcc-autotools
27 os: ubuntu-latest
28 cc: gcc
29 cxx: g++
30 build-system: autotools
31
32 - name: ubuntu-clang-autotools
33 os: ubuntu-latest
34 cc: clang
35 cxx: clang++
36 build-system: autotools
37
38 - name: ubuntu-gcc-ossfuzz
39 os: ubuntu-latest
40 cc: gcc
41 cxx: g++
42 build-system: ossfuzz
43
44 - name: macos-autotools
45 os: macos-latest
46 cc: clang
47 cxx: clang++
48 build-system: autotools
49
50 - name: ubuntu-gcc-cmake
51 os: ubuntu-latest
52 cc: gcc
53 cxx: g++
54 build-system: cmake
55 cmake-generator: 'Ninja'
56 cmake-options: >-
57 -DCMAKE_BUILD_TYPE=Release
58 -DCMAKE_C_FLAGS="-Wall -Wextra"
59 -DCMAKE_VERBOSE_MAKEFILE=ON
60
61 - name: ubuntu-gcc-cmake-shared
62 os: ubuntu-latest
63 cc: gcc
64 cxx: g++
65 build-system: cmake
66 cmake-generator: 'Ninja'
67 cmake-options: >-
68 -DCMAKE_BUILD_TYPE=Release
69 -DBUILD_SHARED_LIBS=ON
70 -DCMAKE_C_FLAGS="-Wall -Wextra"
71 -DCMAKE_VERBOSE_MAKEFILE=ON
72
73 - name: ubuntu-clang-cmake
74 os: ubuntu-latest
75 cc: clang
76 cxx: clang++
77 build-system: cmake
78 cmake-generator: 'Ninja'
79 cmake-options: >-
80 -DCMAKE_BUILD_TYPE=Release
81 -DCMAKE_C_FLAGS="-Wall -Wextra"
82 -DCMAKE_VERBOSE_MAKEFILE=ON
83
84 - name: ubuntu-clang-cmake-shared
85 os: ubuntu-latest
86 cc: clang
87 cxx: clang++
88 build-system: cmake
89 cmake-generator: 'Ninja'
90 cmake-options: >-
91 -DCMAKE_BUILD_TYPE=Release
92 -DBUILD_SHARED_LIBS=ON
93 -DCMAKE_C_FLAGS="-Wall -Wextra"
94 -DCMAKE_VERBOSE_MAKEFILE=ON
95
96 - name: macos-cmake
97 os: macos-latest
98 cc: clang
99 cxx: clang++
100 build-system: cmake
101 cmake-generator: 'Unix Makefiles'
102 cmake-options: >-
103 -DCMAKE_BUILD_TYPE=Release
104 -DCMAKE_C_FLAGS="-Wall -Wextra"
105 -DCMAKE_VERBOSE_MAKEFILE=ON
106
107 - name: macos-cmake-shared
108 os: macos-latest
109 cc: clang
110 cxx: clang++
111 build-system: cmake
112 cmake-generator: 'Unix Makefiles'
113 cmake-options: >-
114 -DCMAKE_BUILD_TYPE=Release
115 -DBUILD_SHARED_LIBS=ON
116 -DCMAKE_C_FLAGS="-Wall -Wextra"
117 -DCMAKE_VERBOSE_MAKEFILE=ON
118
119 - name: windows-vs2019-x64
120 os: windows-latest
121 triplet: 'x64-windows-static'
122 build-system: cmake
123 cmake-generator: 'Visual Studio 16 2019'
124 cmake-options: >-
125 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>
126 -DCMAKE_BUILD_TYPE=Release
127 -DVCPKG_TARGET_TRIPLET=x64-windows-static
128 -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake
129
130 - name: windows-vs2019-x64-shared
131 os: windows-latest
132 triplet: 'x64-windows-static'
133 build-system: cmake
134 cmake-generator: 'Visual Studio 16 2019'
135 cmake-options: >-
136 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>
137 -DBUILD_SHARED_LIBS=ON
138 -DBUILD_REGTEST=OFF
139 -DBUILD_EXAMPLES=OFF
140 -DINSTALL_PKGCONFIG_MODULE=OFF
141 -DCPACK_PACKAGE_NAME=libsndfile
142 -DCMAKE_BUILD_TYPE=Release
143 -DVCPKG_TARGET_TRIPLET=x64-windows-static
144 -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake
145
146 - name: windows-vs2019-Win32
147 os: windows-latest
148 triplet: 'x86-windows-static'
149 build-system: cmake
150 cmake-generator: 'Visual Studio 16 2019'
151 cmake-options: >-
152 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>
153 -DCMAKE_GENERATOR_PLATFORM=Win32
154 -DCMAKE_BUILD_TYPE=Release
155 -DVCPKG_TARGET_TRIPLET=x86-windows-static
156 -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake
157
158 - name: windows-vs2019-Win32-shared
159 os: windows-latest
160 triplet: 'x86-windows-static'
161 build-system: cmake
162 cmake-generator: 'Visual Studio 16 2019'
163 cmake-options: >-
164 -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded$<$<CONFIG:Debug>:Debug>
165 -DCMAKE_GENERATOR_PLATFORM=Win32
166 -DBUILD_SHARED_LIBS=ON
167 -DBUILD_REGTEST=OFF
168 -DBUILD_EXAMPLES=OFF
169 -DINSTALL_PKGCONFIG_MODULE=OFF
170 -DCPACK_PACKAGE_NAME=libsndfile
171 -DCMAKE_BUILD_TYPE=Release
172 -DVCPKG_TARGET_TRIPLET=x86-windows-static
173 -DCMAKE_TOOLCHAIN_FILE=c:/vcpkg/scripts/buildsystems/vcpkg.cmake
174
175 runs-on: ${{ matrix.os }}
176 steps:
177 - uses: actions/checkout@v2
178
179 - name: Install MacOS dependencies
180 if: startsWith(matrix.os,'macos')
181 run: |
182 brew update
183 brew install autoconf automake libtool autogen libogg libvorbis flac opus sqlite3 speex
184
185 - name: Install Lunux dependencies
186 if: startsWith(matrix.os,'ubuntu')
187 run: sudo apt-get install -y autogen ninja-build libogg-dev libvorbis-dev libflac-dev libopus-dev libasound2-dev libsqlite3-dev libspeex-dev
188
189 - name: Install Windows dependencies
190 if: startsWith(matrix.os,'windows')
191 run: |
192 vcpkg install libvorbis libflac opus sqlite3 speex --triplet ${{matrix.triplet}}
193
194 - name: Configure, build and test with Autotools
195 env:
196 CC: ${{ matrix.cc }}
197 CXX: ${{ matrix.cxx }}
198 if: startsWith(matrix.build-system,'autotools')
199 run: |
200 ./autogen.sh
201 if [[ "${CC}" == "clang" ]]; then
202 ./configure --enable-werror && make clean all check && make distcheck
203 else
204 Scripts/asan-configure.sh --enable-werror && make clean all check && make distcheck
205 fi
206
207 - name: Configure, build and test with CMake
208 env:
209 CC: ${{ matrix.cc }}
210 CXX: ${{ matrix.cxx }}
211 if: startsWith(matrix.build-system,'cmake')
212 run: |
213 mkdir build
214 cd build
215 cmake .. -G "${{matrix.cmake-generator}}" ${{matrix.cmake-options}}
216 cmake --build . --config Release
217 ctest
218
219 - name: Configure, build and test with OSSFuzz
220 env:
221 CC: ${{ matrix.cc }}
222 CXX: ${{ matrix.cxx }}
223 if: startsWith(matrix.build-system,'ossfuzz')
224 run: |
225 ./ossfuzz/ci_oss.sh
+0
-145
.gitignore less more
0 *.user
1 *.8svx
2 *.a
3 *.aif
4 *.aifc
5 *.aiff
6 *.au
7 *.bin
8 *.caf
9 *.dll
10 *.exe
11 *.flac
12 *.la
13 *.lib
14 *.lo
15 *.loT
16 *.o
17 *.oct
18 *.oga
19 *.ogg
20 *.paf
21 *.raw
22 *.rifx
23 *.sd2
24 *.sds
25 *.svx
26 /*.so*
27 *.w64
28 *.wav
29 *.wavex
30 .DS_Store
31 .deps
32 .dirstamp
33 .libs
34 Hack
35 Hack/sndfile-fuzzbomb
36 INSTALL
37 m4/libtool.m4
38 m4/ltoptions.m4
39 m4/ltsugar.m4
40 m4/ltversion.m4
41 m4/lt~obsolete.m4
42 Makefile
43 Makefile.in
44 aclocal.m4
45 autom4te.cache
46 build-test-tarball.mk
47 config.log
48 config.status
49 configure
50 doc/AUTHORS
51 doc/ChangeLog
52 doc/NEWS
53 doc/README
54 doc/libsndfile.css
55 echo-install-dirs
56 examples/generate
57 examples/list_formats
58 examples/make_sine
59 examples/sfprocess
60 examples/sndfile-loopify
61 examples/sndfile-to-text
62 examples/sndfilehandle
63 libsndfile-1.0.*
64 libsndfile-testsuite-*
65 libsndfile.spec
66 libtool
67 man/sndfile-deinterleave.1
68 man/sndfile-metadata-set.1
69 programs/sndfile-cmp
70 programs/sndfile-concat
71 programs/sndfile-convert
72 programs/sndfile-data-trim
73 programs/sndfile-deinterleave
74 programs/sndfile-info
75 programs/sndfile-interleave
76 programs/sndfile-jackplay
77 programs/sndfile-metadata-get
78 programs/sndfile-metadata-set
79 programs/sndfile-play
80 programs/sndfile-salvage
81 regtest/sndfile-regtest
82 sndfile.pc
83 src/Ext
84 src/G72x/g72x_test
85 Symbols.darwin
86 Symbols.gnu-binutils
87 Symbols.os2
88 Symbols.static
89 src/config.h
90 src/config.h.in
91 src/config.h.in~
92 src/libsndfile.so*
93 libsndfile*.def
94 src/sndfile.h
95 src/stamp-h1
96 src/test_endswap.c
97 src/test_main
98 src/version-metadata.rc
99 tests/*_test
100 tests/benchmark
101 tests/benchmark.c
102 tests/fix_this
103 tests/floating_point_test.c
104 tests/header_test.c
105 tests/libsndfile-1.dll
106 tests/pcm_test.c
107 tests/pedantic-header-test.sh
108 tests/pipe_test.c
109 tests/rdwr_test.c
110 tests/scale_clip_test.c
111 tests/sfversion
112 tests/test_wrapper.sh
113 tests/utils.c
114 tests/utils.h
115 tests/write_read_test.c
116 *.log
117 *.trs
118 .vs/
119 packages/
120 *.vcxproj.user
121 *.VC.db
122 *.VC.opendb
123 Debug/
124 Release/
125 bin/
126 obj/
127 octave-workspace
128
129 CMakeCache.txt
130 CMakeFiles
131 CMakeScripts
132 Testing
133 Makefile
134 cmake_install.cmake
135 install_manifest.txt
136 compile_commands.json
137 CTestTestfile.cmake
138 CMakeSettings.json
139
140 /*[Bb]uild*/
141
142 /.vscode/
143 /.vs/
144 /out/
0 Original author:
1
02 The main author of libsndfile is Erik de Castro Lopo <erikd@mega-nerd.com>
13 apart from code in the following directories:
24
1113 modifications were required to integrate these files into libsndfile. The
1214 changes are listed in src/G72x/ChangeLog.
1315
16 Current maintainers:
17
18 After the release of version 1.0.30, @erikd transferred the project to
19 [the libsndfile team](https://github.com/libsndfile) consisting of:
20
21 * Erik de Castro Lopo aka @erikd
22 * David Seifert aka @SoapGentoo
23 * Arthur Taylor aka @arthurt
24 * @evpobr
25
26 Current releaser is David Seifert:
27
28 -----BEGIN PGP PUBLIC KEY BLOCK-----
29 Version: GnuPG v2
30
31 mQINBFppABgBEAC42ZiNvV7BTIgR6TQy0YnF54fx3mVRP1u8Mq00UZa7reAsNKh7
32 1H60j0W4s6+4pVVIKGfpVGxLwUdJe+KVCYw1Cd3YW6uMf5zZrC/ZWqnJiH/n6S6o
33 1l4INII2o6YbGBnzIWBPRo7PlOL+mvgKTLpBSJPnhD8XDGN5wRiV8rL2+6Dptg0F
34 nJt7oxECGF3OD3gk6HMel0o82CVkIqMtNaX1L/bhcdF7K0Rp2MXPZMmpn1izW5sI
35 asN1G9+w+Zwj7kMJzq1Aw3ac+rsX4SEYdvXjS2QhDHQUIr6LXri3D2WbcEqIZj2R
36 JVoVwblsrG11dYXFDBbgrq4NhgTBsxHYDlkr/qF2W+kbPC/nhSqTVZeCYvTBZbOQ
37 +RqyN/I0izukglnWmV1jGijFA8snyP8efx732hw/24zRYmtXOtnEITUpw8WOeZCq
38 6uiHaQ+eopnY2ojBg9BI7WZm0AFn58xxT9soMsyFOUFgXTqaWFZWlJ3fhZE8/0v8
39 JEu/kPGE5aJReT3b34B+Bojkj74XR+h2u7iJJBHMTE8RwGoUOZHer/XsL9xlcdks
40 I+7TCjiq++ShaSSt2XsJmw2BhREohrjW/2KkwmvT3b44RMpKPB4WTH+++aqJQNeM
41 IqmswOMoZvzEZezInj7WVY/r0WEei1Y6wt1tBrJ/cFf1oQBM1UmphxcrfQARAQAB
42 tB9EYXZpZCBTZWlmZXJ0IDxzb2FwQGdlbnRvby5vcmc+iQJUBBMBCgA+BQsJCAcD
43 BRUKCQgLBRYCAwEAAh4BAheAAhsBFiEEMdlcq22A0mIkShdQpHYg6AHkfpUFAl/V
44 CvoFCQkuceIACgkQpHYg6AHkfpXYxA//aiJW1NwunpmzEc62id8lRMnoLHWVjISZ
45 b+xSlm+hk4LYq+ZbthJDzKcT86/3DJOSE1zQw9wLuCao9IW2UfFJQBtR+TAfbagG
46 0Yyk/kMcLoFJxnG1ywdJWypCAauuIhia52Z7PmmjsBbFwr6LygDwSQmZAyACMAs7
47 TLQe+yERc2RNDsIEsquLSxxRF0Spk9gagWtKgrPc2XBjuNtQDwW7JgsOUoEeHyxC
48 29fRUjC3o/pG2I6iAZp17OROZI5yl4TSORrSBDGIi2sayxyxP0x+IPKtrCUcBGNx
49 wGp+56bP/V0hA6sgCPh/iwvqLoeibso6l/Kd4ltVAEQnHTd6fr8g+wLEUXfbJVTR
50 7aeFUoaFmWjSPlQrNr6HlxSLV/kRx9kVJp1Pn16vkfVBF7fG7iDLiqphwEeQg5ND
51 nmGeKAbRRNxFHyBHf0XRsaYiFZQckguO+71XSRtVx8/YP5nyNbtl9y1h/4JlT6Gy
52 t7hb5twYFQyQrKss83E/Bo1sRdHpj0ibtqb4ZbYANbh482E6yFhAkuo8YjVTJipI
53 1Ve8EBKnX3R+pDt147uyysNvtPVXML+sWpGSMVSm4NA8uT3F5nqxVwj+SeXy3Wq/
54 CHQ2VBKGBC655G+wFD5C6O7cTx2MwH+2H8tzhWm+gFlI3MFKEXa/PC+YUC/diYcb
55 BrApavriTRa5Ag0EWmkAZgEQAPXMD3mZI+ChvBysXZWksC88/uSEwFeb3XkcRm7v
56 04GN7hcz+bfrmnUTB3tuE/ZQgv+u7ZjetvH1aEKieznn/GjnWoOBoJusOYvfAQeF
57 0mQVi118QiOZRCnEZpkz+RY9TiXVgrZJg+AGqHZ3Ol4GkInEV2NWgH37Xal+HkFl
58 rwI2U7mL0kZRG+LAVCQHKzqU0R0HE1XyJ4qf0awtG5Qi/TZvgXBdZPDXgr8i9Vlf
59 UUu10c2XnXM0Av/YAlZmBFjVYrSOUCFenqSVqL+s9sTCVdWlJrGjrr3Ja4uT3kl2
60 rLva0AR4oSQoxt8adKohmFz0vzOkQtCoRzhrCwoo3JvNjKdSNoOP1nSsxlO5ji8r
61 ih5d+ajPgi580XyHLnrvG7vobR48qqscv1hizKuCgTacOTe6Db2Gqc8xF6v8HhJa
62 KwWJtmFllIfN/tIvZ6BbbgHQn0IGf4CYnWf0SksPZqpBmTRpD2jfBxcj2UEg+AR3
63 LARjuyUVpFJScyu6ExQG+6O+ByLL31iWP5MgUrza1rIpriPa3NT3rZ3DG2pvQrS3
64 ySsrPzH7VRX8L1ThSMSzjwF96aMsd14s7XzR4EzNuWwZDukfs0yavZk6l4o1M0mb
65 tbJi7hE4cz13KRHYvIkKMdZGYUnzRzZUDlsj2imakk3BR6GXnxZ1ST6062g+QxiL
66 AJFLABEBAAGJBHIEGAEKACYCGwIWIQQx2VyrbYDSYiRKF1CkdiDoAeR+lQUCX9UL
67 DQUJCS5xpwJAwXQgBBkBCgAdFiEEuNUxXaAAcsCoYIifzjbhFyAuOEIFAlppAGYA
68 CgkQzjbhFyAuOELmrQ/9H9wrWsWa21STZdxUmyU2sh9VXAWEHl1Ey0fVTznDM0Fl
69 zx5YSR/TmmnE36rpaz31Ttkx8SP914oV+mMgseecdya9Bf6uZL9Cv7V3KEsJBRL/
70 ncrOWQBHP/Xy1X+mLD6A19xq7H4RihSLj0LeK2YVjrJzJ7wMf4mKXuBayQeAHImU
71 WRCRTbmK3umh2nB5V0iPd/XZEIiYtiTPe+7E/va6+0bBvOumF3a+Z0iui7eU4hFC
72 7Jk71D0dcg09SlIaNoMOrw7cMC3j2pMdKtsj8+0I6WBv14PhhqPAsnjdf7I/4NfK
73 L7Jav8T/gDS01uA2Jxm72d+wr+eSjOBXa6x8CEbTqfkjAGxsWENThCp6zDkaXSDd
74 JsV0va47vjzG8+wTDAvPy5IxIM/KZZdl4uWM+mF5K+q+eSTOHe7aLF2OdcussoBA
75 A18zm994dAkG1COX/qpxanxx2bv/2IvCGPg+x6JtAN8ji2kncWu3dWGQdE5XbVjc
76 fDwgsUPpp04G27Mr/x+HpEbgZ5SdA0dAqJktlNvCcHALhlblCWrsh/1QNjT/2iG8
77 wsjcpEy/s4tWAuV4PTa4xvZ1JPS7Z7Eo5aBy9ZGOWG9SrHEiHnhkUsiswbHBOEjd
78 pBSkmNElDcv9fRUahVCTPfvWBATFDrQyMjJBSm+cV8c/iFQM7isVSu8W7E0eetsJ
79 EKR2IOgB5H6Vv9sP/1dxTvH0N0UoEoxIG/hnirEkbRpljdvqy4/uikYBKyQgSbo8
80 VITTjea7gIhDztil9WZYt35jbOmoaGM2Z6TP2LEDOWgljYUNq9pl9Sc2GS8cNtEO
81 WxExzGOc1Flo730dX3A85Ks3+0WPXZjLDcRRcPVkFd5WLQQDV1YVYopWkuQBC+Br
82 4q3uv+sk+bw6gDa9+zFBbDuegdsYuTXrFHoxHz2GRv9Yb7ULCMgpFeNKDgtQq91u
83 RqewoTwQp9tlp91LH/hh7R0Q4DRgeFDkLnVRXwSKjVvCrT5cBgImGwtFTGS4egoy
84 MDKd/KKjZllp1ahRCln1XfmFQyQVMVvuF/JTtt31n6KwXwK2yxIlXB01xvRH+Ees
85 AWeRYWKWXydaAY/9Ve0/PLFlgsr/XUGvt0GoEKe7odD3nZgg6015+/8JTroKw19L
86 NZkhdfFMl11Zi0j5k3UbyzjYVpFSd8K2o0VoOG1LFsPp8tlRxNoVzpId0CX1au/p
87 y1H7Wy/39mzriRG3rw+mJAQbBjN09putCltXFXpOEWk08n/N3vufCVQUoSu/2Bqw
88 2HYj8VtToQp+O5dG3XxvDHINtInP1yr2Wcw2plna0KoXLwv/lZgDm3LN+eCWpG6d
89 N/xk25DTSqTHArUQIEkhcHYK6GnyxUcvoKtG88hXtqEPYXiK08FZYAUPTnDYuQIN
90 BFppAIkBEADDjvQZUs1NoqJpxkD2QDBudU1DBCaeI1D6CancMtb5FebPUxgFlDMd
91 CBGOun48dY5i87gDhT/qS3gP/Mv9rjKJmcG9JHfhpXdW73owxrcsQ96nxxVJNEVl
92 UHJw00z8C9eGWqr0SzSoE33K/PkzSkgtsaotF6+3uCerWulweulmGa5dpVfV0mbS
93 aVw8VmrhZ5NmCeodyy/lR85rPik5pb32NT6v7xBkgkfS0VYtPB2E5gW1pXX/jEOi
94 Mfq9idOEP9lxrNXV9j49Lr0JQCwAcrYbQ2+VPe6eacJEjzJ/6HiUqhPrYdnvydmb
95 hU+xmv2NjGp2UnDZDEhzQfwm6fMx+8Nx2uPzCnXQGoyRBwiC/KcdW0F1ZPKdSXqH
96 NKoOF62pLvIMSmfI3ZVOrTohArfr1kFEYVDv9Nl7oY+qg2rZEc2srOF74a9Z46bR
97 TDPsEQzE2UMCvu3+rofhSD7aRotlKeDCvbe2s0yE4Man457Xc3LXh8Gva8CzCOLE
98 2eMhNTsHIZk68WgXp3/uvE4Xy42myrk1AV8XXDdlWgx0Kc/I6tE59O5NVPSfuGvH
99 1a15KKx0F6euEnYDKKpQ5PDR6dSn61po0tfbt96m044G/xQFjrfhHei4jji9Ogd9
100 vlXVAi2vn3+NCSHFP5l3igLByBHy9iLIdmz7yQuus/1nwRmxOHOf2QARAQABiQI8
101 BBgBCgAmAhsMFiEEMdlcq22A0mIkShdQpHYg6AHkfpUFAl/VCxkFCQkucZAACgkQ
102 pHYg6AHkfpVPSRAAmheYkYJmtDbkzPBBnj5mbCIQN1/G5PI9eixc/TXWFOXtcjU1
103 mJlJpSidHJyLRrx7r0c+N+s8vnY/JuUBsNoMJMER+Mv/CFW4iFi59V534SyAb2S0
104 7NINJnFNkXBY62CDz9KsMuv/MdSv2yLhPH2Tfrm/eDRQesj1PanE4U1cgjWyJRc/
105 IOlaRHvTasWDLgwbQi8ykt+4xUWzL/YKHzB+KyyzBK7vPBXqySX8ka4BOw7SDwG5
106 lX2gtmhk4AGBwVChLXKflqVx1WXj4DPOt0kmOKVnKFyvUijK58M0A2FMgFMXDTIS
107 DRtoZPdx/rkODXxgS+W+27NcYAnxJiM0cQqizEnQh7PQ1KzgdChPejYXMKe9lwdn
108 ssMUxrBpbuAuagEf+pebNjD2eaNR4p8kfaDdGn53q55ysDvoyxKvnVQGSk1FAR9Q
109 s4N5a4f02U7dzlyEhEfIcuUlRCfnlpn4n725YIhHheDig5zKWoEZCkNIfiRcGzDl
110 8Drj+tlZiUR+gDkIoWSBaCkKbIQlc8qCYy6Hm7oZBaol6xKlUnTMK2rjK8fR4i8r
111 bVDWBAaWj3jcDHJ0Jg3fS/qBpeya/JXMp89TR8NK5Ys7PZpWbor+puXBYyXDAVx3
112 rXQ7JBA5klHPxrgjso1S/LqwscKLENtrVjdjhryLBmPifrmofJRnrpiHIEa5Ag0E
113 WmkAswEQAL0hKwsRybQzkNGpJP+ElLSwFHd7XQhr+qIwLllpumWtnIK/DHmv8SpW
114 FqAYajmRTXipFcBHH25x2jIIliZidn0a9826l+sMzrFadMC6/W4pitP71TeqZzwn
115 pAuHs14YL7Wiy0aJQnfbCpRzPq3kYyOXmhmY7lPWO0WdUpR6W8wUbleK5XOVDDRx
116 aIC/M3hhDOxZOMzQ+pdn4BaOFQQ0ygsRkqOudbuc0R1giYRt1i6gMeT8gfzL9jlw
117 HcJ+aVnxdUQQ4uC47oKo/+lg7qh7LsiW79pQC1Bcdm8lhRmqtxe6ub60ecjax3XU
118 1ILIEfIFCv6M7LRUAwz0bqk35spgkJqrGGKkdeWEKAFHg2QWR2F0zy+HdlPLfKxO
119 uhaccpwc9EJtf744GS0SXa2AXr32j56n7CFcEjFcIQPBC6OJn6eA3hOVUYGZ7SrT
120 4fsmZiFAdGEkvLKFuNhju1Hj2EJQUY1pm4GSBco7BR8x+QqoYrt5clU3WxRMNfTR
121 0Rtuzsh4xskXNVMMgvKOahAtxENv2M2Cx6zJPVL5dmaysP7d6QRVeOQA5PwkcZ5Q
122 qK6JtDZj2jpaKQH4Za715kiIcdqMDSkwxa6avc0kARHvfFcBR4hwDm1GAlaKG7eH
123 8TOGGQIk8x2F3s4l8mTJVLWTP/uJYnkYBdqANYo5t1NIQLvwLFV3ABEBAAGJAjwE
124 GAEKACYCGyAWIQQx2VyrbYDSYiRKF1CkdiDoAeR+lQUCX9ULIwUJCS5xcAAKCRCk
125 diDoAeR+leekD/sF7aHH0W35ckWrXZlfSp0qHPWrBUaLBI9OAUHenRhgs4SbK0D4
126 wqEiu0C5iDQojpXAeALQ8g/1pUsZ1yuFqYbGYWrHkA0Pm+P3tAGB4LMZ41YfvROP
127 uaiW/+IMJbWllgRtaDt8/NtCgs30WI9I+az5M29HcGfvEwEUykrBx3dE9T+1ui3O
128 capdd+GMvdAAsX5PyVkjWgZ7GrZeH8mG7UysYfT4qthxEtQfZ/u8ceSduKA46ugh
129 C2eafIDNvluqn7BU4oKxME61u6C8BN2yHLI6LV0Tr4z5H8joVbM4BSFMwLVGlsXf
130 HhB8kLiErN6bXolxsjARlmYiD9S9H2AcYidr6RYXf2EVFSpBG59xn1WTDN+DsHQf
131 7btNPEPl/OPxa3OQjG+xn8USddiP0N0B4xsyzMNCCKDgvXXcIhX55KG9eh3Tc98S
132 fEyhxu8ybZBIGmTJysPKxijfvSgQF+RPNTsz9lvXqkoK7RTgeYMschpjJEznCLbt
133 M6eTDb5z0G5uLXh6+dYxtDOlPogI5OHd+G51LwCjvrQ+AtIUCgafuemwA9mpFT2b
134 svb/qcxSVUb44bVaNHn1JHebX2YbokGtBOm1x2PI5fT8n6YIIYz3jKYOZAYdUT7x
135 6qURyNjOfG4aPJIATwuh4GSNuxUG40+yuT+XfQF24mu1esS1J3wzRloJ7w==
136 =K3x+
137 -----END PGP PUBLIC KEY BLOCK-----
138
139 Previous releasers:
140
141 Version 1.0.29-1.0.30 - @evpobr.
142
143 The public GPG key:
144
145 -----BEGIN PGP MESSAGE-----
146
147 yMMwAnicrVJ7UFRVHF50SdiJ2AknHmYM19IhFrmPva91hnBKHMkcSyAyY7nn3nN3
148 L7AP9qVoO5Lja1YUycgJ4iUFWYluTlE4Oi6PxdhpCkesIWiAQIbXqlSs1Ex1l7H/
149 6r/OP2fOd77vm+/3za8nZqVCFVEfk/xkgPyrMiLgO+FUFIze8R5AgEUoR3QHkBK4
150 fMFSAdod+hJJQHQIiqEYBzECYByBs4AnGBYDGIYDjqEYHMc4nKB5ntICkQSAxCke
151 RTEaJ3AthWJaWccItIhyiAYRJbMB2qw2yeyQbVmA8aKAQxbHCZbXApxhIIqTIiug
152 AiZiPA8IUhQZXhYaLfawQg4HODvcKFlkTH7ol+P9C/9/zu1cthMJlJG5NM+RFEUC
153 nsIomiJIBhMIUmAwNky0Q5uZM0GZDV1WC7Ahbg0iYy6Jh+FaH/4ZJIfRCf6L7yi3
154 hoG9EOgfSvVAMgtyd7LCBW12yWJGdJjM5B1SWItpWQwjtBjOahC4zyrZoF4KM0ia
155 YlD5aBCrDbpkSxrwIkpwUO6YIHCUAjwOKEIUBFaAIsWKAJfrF7XyoJAGkIaUPD9g
156 aSBwIkUIOIqEhykzWxAdKcfkDLKlXTKYOYfTBhF3l2+PUhGhUjwSuSK8UwpVtPqf
157 TTv+gVoRyKt70PuZxj6oi7ZkZP481vcc2vJ6cV774dld3s3n3+3w+cXdW9YaVvc9
158 ni8Nv6aOUqx5b/+Lexria1wn7c1DOxVnikYSV50eY0o7Lwatz3qqg6RHWVOVF3zm
159 lai7u7ud7r7vh5Lrm+95j06OeWN+29SbkNVeW9X1Vs651NsF9K1jV7xzkRdz6N4f
160 Vy+5B37qTr18Lclk9lx7o3cmP/+6Jbbl3qvj7w/PvTnVDyYiuxtSZlvtCZ2JT6yv
161 21rw8tLXnDHhwv0/7kfnpgSNXxKLA/tyPRsunLxp8tw4e6zx6PGbwsxKsTopg9u1
162 dkdzBxWf+VVb/tbUzZNtUzUpj0l1fiSUtu1UaHxwdOnj2JlI4fdfdyAh/5GqvbY5
163 7YKy0hgabi89Ffen+qUNtZ+f90258OevKhf6S+p+qelSRh/64ZOihg87D857slVZ
164 5wqttfExWb7LymH/oVjTpcWFt4u/uP3pC8YrwfY+ad2NpDuW5oqPZrKOFCoGzqgb
165 t1jSF1Vph1c0qtZUds+PaAqpp/Mqhjo0yavKiid91emBiPaeb3s2uW8d9J6YXZiu
166 T8p7tK+8yHp3ov4dcCk3lNY28s13ZePrW8ceVGc3zOT01/ibotLjdFZn9tmd67a3
167 iCrDaJM7Y/9TY8XzHdPbTZ2wPG7bxFBg2LSx6WootqI1dF2fGutPzE0bzJzW/w3x
168 usYz
169 =XFTp
170 -----END PGP MESSAGE-----
171
172 Versions before 1.0.29 - Erik de Castro Lopo.
173
174 The public GPG key:
175
176 -----BEGIN PGP SIGNATURE-----
177
178 iQIzBAABCAAdFiEEapGlzyLCTJmjXgE/z9z5H7JCrO0FAljgv0wACgkQz9z5H7JC
179 rO2RhxAAnIuHquhkhaY8CVsIOGImMxEF8RKDyFoioV9RnckNzBb592EYxU9hS0MM
180 cT6xPZU0bJa8CvmCxEABMlkk60JP4VmmOtWxD8EEyktbHGyao80mDR82yVKYv78L
181 zTRzz/JoTncgwWz/QataMbkAfy3KpxkwDW87az0kzkqGuSm3Jg3medt+t/iBe0Wm
182 jcxIexxEZCmIhty6VyaVEkGWax0zdJHe7aD9FK2C/R3DU5Byp4e9pcp/a8v74G1n
183 dgD4S3YlqvJGuU9S6QD4PzsoWD1X8f6pHzxpRP/OkqHAe11sSRo6sSYYCjsYi9Ca
184 IJSlVC1nMx9OUxxAA8ZqtnztOo7GZcJ5NAL5X3GNV6YfQ7Bqxvtr6QG26F06MB6i
185 p08UC7NC0bxFsD3f07wY22QnbnM052rniTn5sqQZv+GVls6t1b3u1iHzEjAjlgvi
186 eOjVVt/A8iaOzMbKC/3+SZ9/GYqbSAQOCIoWAXmhV9IaMQyQeLCIC1YD5NMGBXal
187 HPfSHV0hSUDbKjAYXFigJRzFU125bXTgg+v13Kd0KklIEjoaZYZLAYs0BupXdjBf
188 jSPv8pwUaXJkv9/bGH0Ot1fvwDqPDOlGFINQbGAWdxwsdhiYBeXMFeFNTEfiqEMz
189 BhhMxKa+Mfd9fkrX4NNigGW5QgRBS+FHNLf6ZfiXSnBGjjxMcbI=
190 =UUA0
191 -----END PGP SIGNATURE-----
14192
15193 Others:
16194
22 # MSVC runtime library flags are selected by an abstraction, CMake >= 3.15
33 # This policy still need to be set even with cmake_minimum_required() command above.
44 if (POLICY CMP0091)
5 cmake_policy (SET CMP0091 NEW)
6 endif ()
7
8 project(sndfile VERSION 1.0.30)
5 if ((DEFINED ENABLE_STATIC_RUNTIME) AND (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY))
6 message (FATAL_ERROR "Both ENABLE_STATIC_RUNTIME and CMAKE_MSVC_RUNTIME_LIBRARY are set.")
7 return ()
8 endif ()
9
10 if (DEFINED CMAKE_MSVC_RUNTIME_LIBRARY)
11 cmake_policy (SET CMP0091 NEW)
12 else ()
13 cmake_policy (SET CMP0091 OLD)
14 endif ()
15 endif ()
16
17 project(libsndfile VERSION 1.0.31)
918
1019 #
1120 # Variables
1524 set (CMAKE_C_STANDARD_REQUIRED TRUE)
1625 set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1726
18 set (PACKAGE_NAME lib${PROJECT_NAME})
27 set (PACKAGE_NAME ${PROJECT_NAME})
1928 set (CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR})
2029 set (CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR})
2130 set (CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH})
2635 # System-wide includes
2736 #
2837
29 # Set proper default documentation install directory based on canonical
30 # package name, not CMake project name. This option can still be overridden.
31 if(NOT CMAKE_INSTALL_DOCDIR)
32 set(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/libsndfile")
33 endif()
3438 include (GNUInstallDirs)
3539 include (FeatureSummary)
3640 include (CMakeDependentOption)
3741 include (CTest)
42 include (CheckCCompilerFlag)
3843
3944 #
4045 # Options
5055 option (ENABLE_CPACK "Enable CPack support" ON)
5156 option (ENABLE_EXPERIMENTAL "Enable experimental code" OFF)
5257 option (ENABLE_BOW_DOCS "Enable black-on-white html docs" OFF)
53 if (MSVC AND (CMAKE_VERSION VERSION_LESS 3.15))
58 if (MSVC AND (DEFINED ENABLE_STATIC_RUNTIME))
59 option (ENABLE_STATIC_RUNTIME "Enable static runtime" ${ENABLE_STATIC_RUNTIME})
60 elseif (MINGW)
5461 option (ENABLE_STATIC_RUNTIME "Enable static runtime" OFF)
5562 endif ()
5663 option (ENABLE_PACKAGE_CONFIG "Generate and install package config file" ON)
5764 option (INSTALL_PKGCONFIG_MODULE "Generate and install pkg-config module" ON)
5865
5966 list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
67 if (CMAKE_VERSION VERSION_LESS 3.14)
68 list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sqlite")
69 endif ()
6070
6171 #
6272 # Setup definitions
7383 set (CPU_CLIPS_NEGATIVE FALSE)
7484 endif ()
7585 cmake_dependent_option (ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise" OFF "WIN32;BUILD_SHARED_LIBS" OFF)
76 cmake_dependent_option (INSTALL_MANPAGES "Install man pages for programs" ON "BUILD_PROGRAMS AND (UNIX OR MINGW OR CYGWIN)" OFF)
86 cmake_dependent_option (INSTALL_MANPAGES "Install man pages for programs" ON "BUILD_PROGRAMS" OFF)
87
88 if (NOT MSVC)
89 if (CPU_IS_X86)
90 check_c_compiler_flag (-msse2 HAVE_MSSE2_COMPILER_FLAG)
91 if (HAVE_MSSE2_COMPILER_FLAG)
92 cmake_dependent_option (ENABLE_SSE2 "Add SSE2 compiler flag" ON "HAVE_MSSE2_COMPILER_FLAG" OFF)
93 endif ()
94 endif ()
95 endif ()
96 if (ENABLE_SSE2)
97 add_compile_options (-msse2)
98 endif ()
7799
78100 set (HAVE_EXTERNAL_XIPH_LIBS ${ENABLE_EXTERNAL_LIBS})
79101 set (HAVE_SQLITE3 ${BUILD_REGTEST})
99121 add_feature_info (ENABLE_COMPATIBLE_LIBSNDFILE_NAME ENABLE_COMPATIBLE_LIBSNDFILE_NAME "Set DLL name to libsndfile-1.dll (canonical name), sndfile.dll otherwise")
100122 endif ()
101123
102 if (MSVC AND (CMAKE_VERSION VERSION_LESS 3.15))
103 add_feature_info (ENABLE_STATIC_RUNTIME ENABLE_STATIC_RUNTIME "Enable static runtime")
104 endif ()
124 if (HAVE_MSSE2_COMPILER_FLAG)
125 add_feature_info (ENABLE_SSE2 ENABLE_SSE2 "add SSE2 compiler flag")
126 endif ()
127
128
129
105130
106131 set_package_properties (Ogg PROPERTIES
107132 TYPE RECOMMENDED
223248 src/chanmap.c
224249 src/id3.c
225250 $<$<BOOL:${WIN32}>:src/windows.c>
226 $<$<AND:$<BOOL:${WIN32}>,$<BOOL:${BUILD_SHARED_LIBS}>>:src/version-metadata.rc>
227251 src/sndfile.c
228252 src/aiff.c
229253 src/au.c
352376 set (PACKAGE_VERSION ${CPACK_PACKAGE_VERSION})
353377
354378 configure_file (src/version-metadata.rc.in src/version-metadata.rc @ONLY)
379 target_sources (sndfile PRIVATE ${PROJECT_BINARY_DIR}/src/version-metadata.rc)
355380 endif ()
356381
357382 set_target_properties (sndfile PROPERTIES
461486 elseif ((NOT BEOS) AND ALSA_FOUND)
462487 target_include_directories (sndfile-play PRIVATE ${ALSA_INCLUDE_DIRS})
463488 target_link_libraries (sndfile-play PRIVATE ${ALSA_LIBRARIES})
464 elseif ((NOT BEOS) AND SNDIO_FOUND)
489 elseif (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
465490 target_link_libraries (sndfile-play PRIVATE Sndio::Sndio)
466491 endif ()
467492
660685 target_link_libraries(sndfile-regtest
661686 PRIVATE
662687 sndfile
663 SQLite3::SQLite3
688 SQLite::SQLite3
664689 $<$<BOOL:${LIBM_REQUIRED}>:m>
665690 )
666691
750775 set (HTML_BGCOLOUR "black")
751776 set (HTML_FGCOLOUR "white")
752777 endif ()
753 configure_file (doc/libsndfile.css.in doc/libsndfile.css)
754 set (html_DATA
755 doc/index.html
756 doc/libsndfile.jpg
757 "${CMAKE_CURRENT_BINARY_DIR}/doc/libsndfile.css"
758 doc/print.css
759 doc/api.html
760 doc/command.html
761 doc/bugs.html
762 doc/formats.html
763 doc/sndfile_info.html
764 doc/new_file_type.HOWTO
765 doc/win32.html
766 doc/FAQ.html
767 doc/lists.html
768 doc/embedded_files.html
769 doc/octave.html
770 doc/tutorial.html
778 set (dist_doc_DATA
779 docs/index.md
780 docs/libsndfile.jpg
781 docs/libsndfile.css
782 docs/print.css
783 docs/api.md
784 docs/command.md
785 docs/bugs.md
786 docs/formats.md
787 docs/sndfile_info.md
788 docs/new_file_type_howto.md
789 docs/win32.md
790 docs/FAQ.md
791 docs/lists.md
792 docs/embedded_files.md
793 docs/octave.md
794 docs/tutorial.md
771795 )
772 install (FILES ${html_DATA} DESTINATION ${CMAKE_INSTALL_DOCDIR})
796 install (FILES ${dist_doc_DATA} DESTINATION ${CMAKE_INSTALL_DOCDIR})
773797
774798 if (INSTALL_PKGCONFIG_MODULE)
775799 install (FILES ${CMAKE_CURRENT_BINARY_DIR}/sndfile.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)
0 # The owners of this repository. In order of suggestions as reviewers.
1 * @evpobr @SoapGentoo @arthurt @erikd
2
3 # Autotools
4 configure.ac Makefile.am @SoapGentoo @erikd
5
6 # CMake
7 CMakeLists.txt /cmake/ @evpobr
8
9 # Ogg Opus format
10 /src/ogg_opus.c @arthurt
11
12 # Documentation
13 /doc/ /man/ @evpobr
0 ## Submitting Issues.
0 # Contributing
1
2 ## Submitting Issues
13
24 * If your issue is that libsndfile is not able to or is incorrectly reading one
35 of your files, please include the output of the `sndfile-info` program run
810 your program is warning free, and that is is error free when run under Valgrind
911 or compiled with AddressSanitizer.
1012
11 ## Submitting Patches.
13 ## Submitting Patches
1214
1315 * Patches should pass all existing tests
1416 * Patches should pass all pre-commit hook tests.
00 For changes, please see the git commit history on github:
11
2 https://github.com/erikd/libsndfile/commits/master
2 https://github.com/libsndfile/libsndfile/commits/master
1818 cmake_files = cmake/ClipMode.cmake cmake/FindFLAC.cmake \
1919 cmake/CMakeAutoGen.cmake cmake/CMakeAutoGenScript.cmake \
2020 cmake/FindOgg.cmake cmake/FindVorbis.cmake cmake/FindSndio.cmake \
21 cmake/FindSpeex.cmake cmake/FindSQLite3.cmake \
21 cmake/FindSpeex.cmake cmake/sqlite/FindSQLite3.cmake \
2222 cmake/SndFileChecks.cmake cmake/TestInline.cmake \
2323 cmake/TestLargeFiles.cmake cmake/TestInline.c.in \
24 cmake/FindOpus.cmake cmake/SndFileConfig.cmake.in
24 cmake/FindOpus.cmake cmake/SndFileConfig.cmake.in \
25 cmake/CheckCPUArch.cmake cmake/CheckCPUArch.c.in
2526
2627 pkgconfig_DATA = sndfile.pc
2728
158159 AUTOHEADER=echo
159160
160161 ########
161 # doc/ #
162 # docs/ #
162163 ########
163164
164165 if FULL_SUITE
165 dist_html_DATA = doc/index.html doc/libsndfile.jpg doc/libsndfile.css doc/print.css doc/api.html \
166 doc/command.html doc/bugs.html doc/formats.html doc/sndfile_info.html doc/new_file_type.HOWTO \
167 doc/win32.html doc/FAQ.html doc/lists.html doc/embedded_files.html doc/octave.html \
168 doc/tutorial.html
166 dist_doc_DATA = docs/index.md docs/libsndfile.jpg docs/libsndfile.css docs/print.css docs/api.md \
167 docs/command.md docs/bugs.md docs/formats.md docs/sndfile_info.md docs/new_file_type_howto.md \
168 docs/win32.md docs/FAQ.md docs/lists.md docs/embedded_files.md docs/octave.md \
169 docs/tutorial.md
169170 endif
170171
171172 #############
394395 # Coerce the multiple inputs -> multiple outputs problem
395396 # into suffix rules by "linearising" the dependency graph.
396397 # Yes, this sucks, but GNU make patterns aren't portable,
397 # see also https://github.com/erikd/libsndfile/issues/369
398 # see also https://github.com/libsndfile/libsndfile/issues/369
398399
399400 SUFFIXES = .tpl .def
400401
0 Version 1.0.31 (2021-01-24)
1
2 * The releaser of libsndfile starting from this version is the libsndfile team
3 member @SoapGentoo, see AUTHORS for details.
4 * Implement fast SSE2 optimized psf_lrintf() and psf_lrintf() functions to
5 improve perfomance when libsndfile is built using Visual C++ (especially)
6 and other compilers on x86 and AMD64 platforms. See also description of
7 ENABLE_SSE2 CMake option in README.md.
8 * Documentation:
9 * Move site to new URL: http://libsndfile.github.io/libsndfile/
10 * Convert documentation pages from HTML to Markdown
11 * Use GitHub's Jekyll static site generator to generate static HTML pages
12 for site
13 * Fix api.md table error, thanks to @zodf0055980
14 * Other docuemntation fixes and updates
15 * Change CMake's project name from sndfile to libsndfile as it should be.
16 * Change behaviour of ENABLE_STATIC_RUNTIME option. In short:
17 * You can use ENABLE_STATIC_RUNTIME for CMake >= 3.15 without error.
18 * You can use your our method to set MSVC runtime library flags if none of
19 ENABLE_STATIC_RUNTIME and CMAKE_MSVC_RUNTIME_LIBRARY were set.
20 Advanced information:
21 * If this option is defined (set to ON or OFF), set CMP0091 policy to OLD
22 (we handle MSVC runtime library flags using compiler flags), set
23 corresponding compiler flags for user.
24 * NEW: If this option is not defined, set CMP0091 policy to OLD (we handle
25 MSVC runtime library flags using compiler flags), don't touch compiler
26 options, allow user to set it manually.
27 * NEW: If new CMake option CMAKE_MSVC_RUNTIME_LIBRARY is set, change
28 CMP0091 policy to NEW (we handle MSVC runtime library flags using that
29 option), don't touch compiler flags.
30 * NEW: If both ENABLE_STATIC_RUNTIME and CMAKE_MSVC_RUNTIME_LIBRARY are set,
31 terminate configuration with fatal error.
32 * For MinGW toolchain this option is experimental. If you enabled it and
33 then disabled again, you need to clear CMake cache (delete
34 CMakeCache.txt).
35 * Make CMake clip test faster.
36 * Fix CMake bug with sndio library dependency, thanks to @drhenault.
37 * Fix memory leak in wav_read_smpl_chunk() function, credit to OSS-Fuzz.
38 * Fix aiff_read_header() memory leak(), credit to OSS-Fuzz.
39 * Fix leak in wav_read_header(), credit to OSS-Fuzz.
40 * Fix leak in wavlike_read_cart_chunk(), credit to OSS-Fuzz.
41 * Fix memory leak in wav_read_acid_chunk(), credit to OSS-Fuzz.
42 * Fix memory leak in aiff_read_basc_chunk(), credit to OSS-Fuzz.
43 * Fix memory leak in wavlike_read_peak_chunk(), credit to OSS-Fuzz.
44 * Fix memory leak in aiff_read_header(), credit to OSS-Fuzz.
45 * Fix use of uninitialized value in exif_subchunk_parse(), credit to OSS-Fuzz.
46 * Fix use of uninitialized value in endswap_int64_t_array(), credit to
47 OSS-Fuzz.
48 * Fix up the fuzzer so that it can't under or overseek,
49 thanks to Max Dymond <cmeister2@gmail.com>.
50 * Fix Autotools configure on macOS, thanks to @tmcguire and @nwh.
51 * Exclude repository-configuration from git-archive, thanks to @umlaeute.
52 * Use version-script when compiling with clang on Unix with Autotools, thanks
53 to @tstellar.
54 * Improve handling of SMPL chunks in WAV files, thanks to @zodf0055980.
55
056 Version 1.0.30 (2020-09-18)
157
258 * Fix critical CMake bug with broken ABI of shared libsndfile library.
6868 libsndfile was written by Erik de Castro Lopo (erikd AT mega-nerd DOT com).
6969 The libsndfile home page is at :
7070
71 http://www.mega-nerd.com/libsndfile/
71 http://libsndfile.github.io/libsndfile/
7272
7373 Bugs and support questions can be raised at :
7474
75 https://github.com/erikd/libsndfile/
75 https://github.com/libsndfile/libsndfile/issues
00 # libsndfile
11
2 ![C/C++ CI](https://github.com/erikd/libsndfile/workflows/C/C++%20CI/badge.svg)
2 ![C/C++ CI](https://github.com/libsndfile/libsndfile/workflows/C/C++%20CI/badge.svg)
33
44 libsndfile is a C library for reading and writing files containing sampled audio
55 data.
66
7 ## Authors
8
9 The libsndfile project was originally developed and maintained by
10 Erik de Castro Lopo <erikd@mega-nerd.com> aka @erikd. The project was developed
11 on Github at <https://github.com/erikd/libsndfile>.
12
13 After the release of version 1.0.30, @erikd transferred the project to
14 [the libsndfile team](https://github.com/libsndfile), see [AUTHORS](AUTHORS)
15 for details.
16
717 ## Hacking
818
919 The canonical source code repository for libsndfile is at
10 [https://github.com/erikd/libsndfile/][github].
20 [http://libsndfile.github.io/libsndfile/][github].
1121
1222 You can grab the source code using:
1323
14 git clone git://github.com/erikd/libsndfile.git
24 git clone https://github.com/libsndfile/libsndfile.git
1525
1626 For building for Android see [BuildingForAndroid][BuildingForAndroid].
1727
133143 This option is `ON` by default.
134144 * `ENABLE_PACKAGE_CONFIG` - generate and install [package config file](https://cmake.org/cmake/help/latest/manual/cmake-packages.7.html#config-file-packages).
135145 * `INSTALL_PKGCONFIG_MODULE` - generate and install [pkg-config module](https://people.freedesktop.org/~dbn/pkg-config-guide.html).
136 * `INSTALL_MANPAGES` - install [man pages](https://en.wikipedia.org/wiki/Man_page) for programs. This option is `ON` by default
137 on Unix, MinGW and Cygwin platforms
138
139 * `ENABLE_STATIC_RUNTIME` - enable static runtime on Windows platform, `OFF` by
140 default (CMake < 3.15).
141
142 **Note**: For MSVC compiler this option is deprecated and disabled for CMake >= 3.15, see
146 * `INSTALL_MANPAGES` - install [man pages](https://en.wikipedia.org/wiki/Man_page) for programs. This option is `ON` by default
147 * `ENABLE_STATIC_RUNTIME` - enable static runtime on Windows platform (MSVC and
148 MinGW), `OFF` by default.
149
150 **Note**: For MSVC compiler this option is deprecated for CMake >= 3.15, see
143151 policy [CMP0091](https://cmake.org/cmake/help/latest/policy/CMP0091.html).
144152 Use `CMAKE_MSVC_RUNTIME_LIBRARY` option instead.
153
154 **Note**: For MinGW toolchain this option is experimental. If you enabled it
155 and then disabled again, you need to clear CMake cache (delete CMakeCache.txt).
145156 * `ENABLE_COMPATIBLE_LIBSNDFILE_NAME` - set DLL name to `libsndfile-1.dll`
146157 (canonical name) on Windows platform, `sndfile.dll` otherwise, `OFF` by
147158 default. Library name can be different depending on platform. The well known
154165 because you can search library using package manager or CMake's
155166 `find_library` command on any platform using the same `sndfile` name.
156167
168 * `ENABLE_SSE2` - add compiler flag to enable SSE2 if required, `ON` by default.
169
170 This option is for X86 and GCC compatible compilers configurations only.
171
172 If you compile for other SIMD set, e.g. AVX2, you may want to set
173 `ENABLE_SSE2` to `OFF`.
174
175 **Note**: This option is not active for X64 configuration, because SSE2 is
176 always available in this mode and all optimizations are enabled by default.
177
157178 Deprecated options:
158179
159180 * `DISABLE_EXTERNAL_LIBS` - disable Ogg, Vorbis and FLAC support. Replaced by
201222
202223 ### Notes for Windows users
203224
204 First advice - set `ENABLE_STATIC_RUNTIME` to ON. This will remove dependencies
205 on runtime DLLs.
225 #### System CRT library
226
227 First advice about Visual Studio [system CRT libraries](https://docs.microsoft.com/en-us/cpp/c-runtime-library/c-run-time-library-reference?view=vs-2019),
228 it is system code linked as static or dynamic library to every C application.
229
230 You can find related option in Visual Studio project properties:
231
232 C/C++ -> Code Generation -> Runtime Library
233
234 Dynamic version of system CRT library is defaut and it means that end user needs
235 to have the same runtime library installed on his system. Most likely it is so,
236 but if it is not, the user will see this error message using libsndfile DLL:
237
238 "The program can't start because <crt-dll-name>.dll is missing from your computer. Try reinstalling the program to fix this problem. "
239
240 To avoid this, you may want to enable static CRT library linking. In this case
241 the size of your DLL will increase slightly the size will increase slightly, but
242 you can redistribute the libsndfile DLL without having to install the correct
243 version of the system CRT library.
244
245 CMake project will use dynamic system CRT libraries by default, just like
246 Visual Studio does. But you can change it using `ENABLE_STATIC_RUNTIME` or
247 `CMAKE_MSVC_RUNTIME_LIBRARY` options.
248
249 **Note**: You cannot use both options at the same time, it will lead to a
250 configuration error.
251
252 If you have CMake >= 3.15 you should use
253 [`CMAKE_MSVC_RUNTIME_LIBRARY`](https://cmake.org/cmake/help/v3.15/variable/CMAKE_MSVC_RUNTIME_LIBRARY.html) option.
254
255 This will enable static linking:
256
257 cmake .. -D"MultiThreaded$<$<CONFIG:Debug>:Debug>"
258
259 You can use libsndfile `ENABLE_STATIC_RUNTIME` option to to control CRT library
260 linking for CMake project: `OFF` or unset (default) for dynamic, and `ON` for
261 static linking:
262
263 cmake .. -DENABLE_STATIC_RUNTIME=ON
264
265 **Note**: This option is deprecated and may be removed in far future because we
266 have standard option `CMAKE_MSVC_RUNTIME_LIBRARY` now.
267
268 #### Using Vcpkg package manager
206269
207270 Second advice is about Ogg, Vorbis FLAC and Opus support. Searching external
208271 libraries under Windows is a little bit tricky. The best way is to use
221284
222285 -DVCPKG_TARGET_TRIPLET=x64-windows-static
223286
287 **Note**: Use must use the same CRT library for external libraries and the
288 libsndfile library itself. For `*-static` triplets Vcpkg uses
289 [static CRT](https://vcpkg.readthedocs.io/en/latest/users/triplets/).
290
224291 ## Submitting Patches
225292
226293 See [CONTRIBUTING.md](CONTRIBUTING.md) for details.
227294
228295 [brew]: http://brew.sh/
229 [github]: https://github.com/erikd/libsndfile/
230 [BuildingForAndroid]: https://github.com/erikd/libsndfile/blob/master/Building-for-Android.md
296 [github]: http://libsndfile.github.io/libsndfile/
297 [BuildingForAndroid]: https://github.com/libsndfile/libsndfile/blob/master/Building-for-Android.md
0 int main(void) {
1 #if @CHECK_CPU_ARCH_DEFINES@
2 return 0;
3 #else
4 fail
5 #endif
6 }
0 macro (_CHECK_CPU_ARCH ARCH ARCH_DEFINES VARIABLE)
1 if (NOT DEFINED HAVE_${VARIABLE})
2 message (STATUS "Check CPU architecture is ${ARCH}")
3 set (CHECK_CPU_ARCH_DEFINES ${ARCH_DEFINES})
4 configure_file (${PROJECT_SOURCE_DIR}/cmake/CheckCPUArch.c.in ${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c @ONLY)
5 try_compile (HAVE_${VARIABLE} "${PROJECT_BINARY_DIR}"
6 "${PROJECT_BINARY_DIR}/CMakeFiles/CMakeTmp/CheckCPUArch.c")
7 if(HAVE_${VARIABLE})
8 message (STATUS "Check CPU architecture is ${ARCH} - yes")
9 set (${VARIABLE} 1 CACHE INTERNAL "Result of CHECK_CPU_ARCH_X64" FORCE)
10 else ()
11 message (STATUS "Check CPU architecture is ${ARCH} - no")
12 endif ()
13 endif ()
14 endmacro (_CHECK_CPU_ARCH)
15
16 macro (CHECK_CPU_ARCH_X64 VARIABLE)
17 _CHECK_CPU_ARCH (x64 "defined(__amd64__) || defined(__amd64) || defined(__x86_64__) || defined(__x86_64) || defined(_M_X64) || defined(_M_AMD64)" ${VARIABLE})
18 endmacro (CHECK_CPU_ARCH_X64)
19
20 macro (CHECK_CPU_ARCH_X86 VARIABLE)
21 _CHECK_CPU_ARCH (x86 "defined(__i386__) || defined(__i486__) || defined(__i586__) || defined(__i686__) ||defined( __i386) || defined(_M_IX86)" ${VARIABLE})
22 endmacro (CHECK_CPU_ARCH_X86)
11 include (CMakePushCheckState)
22
33 macro (CLIP_MODE)
4 if ((NOT DEFINED CPU_CLIPS_NEGATIVE) AND (NOT DEFINED CPU_CLIPS_POSITIVE))
5 set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion")
6 set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion")
47
5 set (CLIP_MODE_POSITIVE_MESSAGE "Target processor clips on positive float to int conversion")
6 set (CLIP_MODE_NEGATIVE_MESSAGE "Target processor clips on negative float to int conversion")
8 message (STATUS "Checking processor clipping capabilities...")
79
8 message (STATUS "Checking processor clipping capabilities...")
10 if (CMAKE_CROSSCOMPILING)
911
10 if (CMAKE_CROSSCOMPILING)
12 set (CLIP_MSG "disabled")
13 set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE})
14 set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE})
1115
12 set (CLIP_MSG "disabled")
13 set (CPU_CLIPS_POSITIVE FALSE CACHE BOOL ${CLIP_MODE_POSITIVE_MESSAGE})
14 set (CPU_CLIPS_NEGATIVE FALSE CACHE BOOL ${CLIP_MODE_NEGATIVE_MESSAGE})
16 else (NOT CMAKE_CROSSCOMPILING)
1517
16 else (NOT CMAKE_CROSSCOMPILING)
18 cmake_push_check_state ()
19
20 set (CMAKE_REQUIRED_QUIET TRUE)
21 if (LIBM_REQUIRED)
22 set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY})
23 endif ()
24
25 check_c_source_runs (
26 "
27 #define _ISOC9X_SOURCE 1
28 #define _ISOC99_SOURCE 1
29 #define __USE_ISOC99 1
30 #define __USE_ISOC9X 1
31 #include <math.h>
32 int main (void)
33 { double fval ;
34 int k, ival ;
1735
18 cmake_push_check_state ()
19
20 set (CMAKE_REQUIRED_QUIET TRUE)
21 if (LIBM_REQUIRED)
22 set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${M_LIBRARY})
23 endif ()
24
25 check_c_source_runs (
26 "
27 #define _ISOC9X_SOURCE 1
28 #define _ISOC99_SOURCE 1
29 #define __USE_ISOC99 1
30 #define __USE_ISOC9X 1
31 #include <math.h>
32 int main (void)
33 { double fval ;
34 int k, ival ;
36 fval = 1.0 * 0x7FFFFFFF ;
37 for (k = 0 ; k < 100 ; k++)
38 { ival = (lrint (fval)) >> 24 ;
39 if (ival != 127)
40 return 1 ;
41
42 fval *= 1.2499999 ;
43 } ;
44
45 return 0 ;
46 }
47 "
48 CPU_CLIPS_POSITIVE)
49
50 check_c_source_runs (
51 "
52 #define _ISOC9X_SOURCE 1
53 #define _ISOC99_SOURCE 1
54 #define __USE_ISOC99 1
55 #define __USE_ISOC9X 1
56 #include <math.h>
57 int main (void)
58 { double fval ;
59 int k, ival ;
3560
36 fval = 1.0 * 0x7FFFFFFF ;
37 for (k = 0 ; k < 100 ; k++)
38 { ival = (lrint (fval)) >> 24 ;
39 if (ival != 127)
40 return 1 ;
41
42 fval *= 1.2499999 ;
43 } ;
44
45 return 0 ;
46 }
47 "
48 CPU_CLIPS_POSITIVE)
49
50 check_c_source_runs (
51 "
52 #define _ISOC9X_SOURCE 1
53 #define _ISOC99_SOURCE 1
54 #define __USE_ISOC99 1
55 #define __USE_ISOC9X 1
56 #include <math.h>
57 int main (void)
58 { double fval ;
59 int k, ival ;
61 fval = -8.0 * 0x10000000 ;
62 for (k = 0 ; k < 100 ; k++)
63 { ival = (lrint (fval)) >> 24 ;
64 if (ival != -128)
65 return 1 ;
66
67 fval *= 1.2499999 ;
68 } ;
69
70 return 0 ;
71 }
72 "
73 CPU_CLIPS_NEGATIVE)
6074
61 fval = -8.0 * 0x10000000 ;
62 for (k = 0 ; k < 100 ; k++)
63 { ival = (lrint (fval)) >> 24 ;
64 if (ival != -128)
65 return 1 ;
66
67 fval *= 1.2499999 ;
68 } ;
69
70 return 0 ;
71 }
72 "
73 CPU_CLIPS_NEGATIVE)
75 cmake_pop_check_state ()
7476
75 cmake_pop_check_state ()
77 if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE))
78 set (CLIP_MSG "positive")
79 elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE))
80 set (CLIP_MSG "negative")
81 elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE)
82 set (CLIP_MSG "both")
83 else ()
84 set (CLIP_MSG "none")
85 endif ()
7686
77 if (CPU_CLIPS_POSITIVE AND (NOT CPU_CLIPS_NEGATIVE))
78 set (CLIP_MSG "positive")
79 elseif (CPU_CLIPS_NEGATIVE AND (NOT CPU_CLIPS_POSITIVE))
80 set (CLIP_MSG "negative")
81 elseif (CPU_CLIPS_POSITIVE AND CPU_CLIPS_NEGATIVE)
82 set (CLIP_MSG "both")
83 else ()
84 set (CLIP_MSG "none")
85 endif ()
87 endif (CMAKE_CROSSCOMPILING)
8688
87 endif (CMAKE_CROSSCOMPILING)
88
89 message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}")
90
89 message (STATUS "Checking processor clipping capabilities... ${CLIP_MSG}")
90 endif ()
9191 endmacro (CLIP_MODE)
+0
-56
cmake/FindSQLite3.cmake less more
0 # - Find SQLITE3
1 # Find the native SQLITE3 includes and libraries
2 #
3 # SQLITE3_INCLUDE_DIRS - where to find sqlite.h, etc.
4 # SQLITE3_LIBRARIES - List of libraries when using SQLITE3.
5 # SQLITE3_FOUND - True if SQLITE3 found.
6
7 if (SQLITE3_INCLUDE_DIR)
8 # Already in cache, be silent
9 set (SQLITE3_FIND_QUIETLY TRUE)
10 endif ()
11
12 find_package (PkgConfig QUIET)
13 pkg_check_modules (PC_SQLITE3 QUIET sqlite3)
14
15 set (SQLITE3_VERSION ${PC_SQLITE3_VERSION})
16
17 find_path (SQLITE3_INCLUDE_DIR sqlite3.h
18 HINTS
19 ${PC_SQLITE3_INCLUDEDIR}
20 ${PC_SQLITE3_INCLUDE_DIRS}
21 ${SQLITE3_ROOT}
22 )
23
24 find_library (SQLITE3_LIBRARY
25 NAMES
26 sqlite3
27 HINTS
28 ${PC_SQLITE3_LIBDIR}
29 ${PC_SQLITE3_LIBRARY_DIRS}
30 ${SQLITE3_ROOT}
31 )
32
33 include (FindPackageHandleStandardArgs)
34
35 find_package_handle_standard_args (SQLite3
36 REQUIRED_VARS
37 SQLITE3_LIBRARY
38 SQLITE3_INCLUDE_DIR
39 VERSION_VAR
40 SQLITE3_VERSION
41 )
42
43 if (SQLITE3_FOUND)
44 set (SQLITE3_INCLUDE_DIRS ${SQLITE3_INCLUDE_DIR})
45 set (SQLITE3_LIBRARIES ${SQLITE3_LIBRARY})
46 if (NOT TARGET SQLite3::SQLite3)
47 add_library (SQLite3::SQLite3 UNKNOWN IMPORTED)
48 set_target_properties (SQLite3::SQLite3 PROPERTIES
49 INTERFACE_INCLUDE_DIRECTORIES "${SQLITE3_INCLUDE_DIRS}"
50 IMPORTED_LOCATION "${SQLITE3_LIBRARIES}"
51 )
52 endif ()
53 endif ()
54
55 mark_as_advanced (SQLITE3_INCLUDE_DIR SQLITE3_LIBRARY)
66
77 include (TestInline)
88 include (ClipMode)
9 include(TestLargeFiles)
9 include (TestLargeFiles)
10 include (CheckCPUArch)
1011
1112 test_large_files (_LARGEFILES)
1213
2122 endif ()
2223 set (SF_COUNT_MAX 0x7fffffffffffffffll)
2324
24 if (NOT WIN32)
25 if (CMAKE_SYSTEM_NAME STREQUAL "OpenBSD")
26 find_package (Sndio)
27 elseif (NOT WIN32)
2528 find_package (ALSA)
26 find_package (Sndio)
2729 endif ()
2830
2931 if (VCPKG_TOOLCHAIN AND (NOT CMAKE_VERSION VERSION_LESS 3.15))
6668 check_include_file (sys/time.h HAVE_SYS_TIME_H)
6769 check_include_file (sys/types.h HAVE_SYS_TYPES_H)
6870 check_include_file (unistd.h HAVE_UNISTD_H)
71 check_include_file (immintrin.h HAVE_IMMINTRIN_H)
72
73 check_cpu_arch_x86 (CPU_IS_X86)
74 check_cpu_arch_x64 (CPU_IS_X64)
75 if ((CPU_IS_X86 OR CPU_IS_X64) AND HAVE_IMMINTRIN_H)
76 set (HAVE_SSE2 1)
77 endif ()
6978
7079 # Never checked
7180 # check_include_file (stdlib.h HAVE_STDLIB_H)
212221 add_definitions (-D_CRT_SECURE_NO_WARNINGS -D_CRT_NONSTDC_NO_DEPRECATE)
213222 endif (MSVC)
214223
215 if (MINGW)
216 if (CMAKE_C_COMPILER_ID STREQUAL GNU)
217 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
218 set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s")
219 endif ()
220 if (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
221 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
222 set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s")
223 endif ()
224 if (CMAKE_C_COMPILER_ID STREQUAL Clang)
225 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
226 set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static")
227 endif ()
228 if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
229 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
230 set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static")
231 endif ()
232 endif ()
233
234224 if (DEFINED ENABLE_STATIC_RUNTIME)
235225 if (MSVC)
236 if (CMAKE_VERSION VERSION_LESS 3.15)
237 if (ENABLE_STATIC_RUNTIME)
238 foreach (flag_var
239 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
240 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
241 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
242 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
243 )
244 if (${flag_var} MATCHES "/MD")
245 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
246 endif ()
247 endforeach (flag_var)
248 else ()
249 foreach (flag_var
250 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
251 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
252 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
253 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
254 )
255 if (${flag_var} MATCHES "/MT")
256 string (REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}")
257 endif (${flag_var} MATCHES "/MT")
258 endforeach (flag_var)
259 endif ( )
226 if (ENABLE_STATIC_RUNTIME)
227 foreach (flag_var
228 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
229 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
230 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
231 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
232 )
233 if (${flag_var} MATCHES "/MD")
234 string (REGEX REPLACE "/MD" "/MT" ${flag_var} "${${flag_var}}")
235 endif ()
236 endforeach (flag_var)
260237 else ()
261 message (FATAL_ERROR "ENABLE_STATIC_RUNTIME option is for CMake < 3.15, use CMAKE_MSVC_RUNTIME_LIBRARY standard option instead.")
238 foreach (flag_var
239 CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_RELEASE
240 CMAKE_CXX_FLAGS_MINSIZEREL CMAKE_CXX_FLAGS_RELWITHDEBINFO
241 CMAKE_C_FLAGS CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_RELEASE
242 CMAKE_C_FLAGS_MINSIZEREL CMAKE_C_FLAGS_RELWITHDEBINFO
243 )
244 if (${flag_var} MATCHES "/MT")
245 string (REGEX REPLACE "/MT" "/MD" ${flag_var} "${${flag_var}}")
246 endif (${flag_var} MATCHES "/MT")
247 endforeach (flag_var)
248 endif ( )
249 elseif (MINGW)
250 if (ENABLE_STATIC_RUNTIME)
251 if (CMAKE_C_COMPILER_ID STREQUAL GNU)
252 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static-libgcc")
253 set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static-libgcc -s")
254 endif ()
255 if (CMAKE_CXX_COMPILER_ID STREQUAL GNU)
256 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static-libgcc -static-libstdc++")
257 set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static-libgcc -static-libstdc++ -s")
258 endif ()
259 if (CMAKE_C_COMPILER_ID STREQUAL Clang)
260 set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -static")
261 set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS} -static")
262 endif ()
263 if (CMAKE_CXX_COMPILER_ID STREQUAL Clang)
264 set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -static")
265 set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS} -static")
266 endif ()
262267 endif ()
263268 else ()
264 message(AUTHOR_WARNING "ENABLE_STATIC_RUNTIME option is for MSVC compiler only.")
269 message (AUTHOR_WARNING "ENABLE_STATIC_RUNTIME option is for MSVC or MinGW only.")
265270 endif ()
266271 endif ()
267272
0 # - Find SQLite3
1 # Find the native SQLite3 includes and libraries
2 #
3 # SQLite3_INCLUDE_DIRS - where to find sqlite3.h, etc.
4 # SQLite3_LIBRARIES - List of libraries when using SQLite3.
5 # SQLite3_FOUND - True if SQLite3 found.
6
7 if (SQLite3_INCLUDE_DIR)
8 # Already in cache, be silent
9 set (SQLite3_FIND_QUIETLY TRUE)
10 endif ()
11
12 find_package (PkgConfig QUIET)
13 pkg_check_modules (PC_SQLite3 QUIET sqlite3)
14
15 set (SQLite3_VERSION ${PC_SQLite3_VERSION})
16
17 find_path (SQLite3_INCLUDE_DIR sqlite3.h
18 HINTS
19 ${PC_SQLite3_INCLUDEDIR}
20 ${PC_SQLite3_INCLUDE_DIRS}
21 ${SQLite3_ROOT}
22 )
23
24 find_library (SQLite3_LIBRARY
25 NAMES
26 sqlite3
27 HINTS
28 ${PC_SQLite3_LIBDIR}
29 ${PC_SQLite3_LIBRARY_DIRS}
30 ${SQLite3_ROOT}
31 )
32
33 include (FindPackageHandleStandardArgs)
34
35 find_package_handle_standard_args (SQLite3
36 REQUIRED_VARS
37 SQLite3_LIBRARY
38 SQLite3_INCLUDE_DIR
39 VERSION_VAR
40 SQLite3_VERSION
41 )
42
43 if (SQLite3_FOUND)
44 set (SQLite3_INCLUDE_DIRS ${SQLite3_INCLUDE_DIR})
45 set (SQLite3_LIBRARIES ${SQLite3_LIBRARY})
46 if (NOT TARGET SQLite::SQLite3)
47 add_library (SQLite::SQLite3 UNKNOWN IMPORTED)
48 set_target_properties (SQLite::SQLite3 PROPERTIES
49 INTERFACE_INCLUDE_DIRECTORIES "${SQLite3_INCLUDE_DIRS}"
50 IMPORTED_LOCATION "${SQLite3_LIBRARIES}"
51 )
52 endif ()
53 endif ()
54
55 mark_as_advanced (SQLite3_INCLUDE_DIR SQLite3_LIBRARY)
0 dnl Copyright (C) 1999-2020 Erik de Castro Lopo <erikd@mega-nerd.com>.
0 dnl Copyright (C) 1999-2021 Erik de Castro Lopo <erikd@mega-nerd.com>.
11
22 dnl Require autoconf version >= 2.69
33 AC_PREREQ([2.69])
44
5 AC_INIT([libsndfile],[1.0.30],[sndfile@mega-nerd.com],
6 [libsndfile],[http://www.mega-nerd.com/libsndfile/])
5 AC_INIT([libsndfile],[1.0.31],[sndfile@mega-nerd.com],
6 [libsndfile],[http://libsndfile.github.io/libsndfile/])
77
88 dnl Check whether we want to set defaults for CFLAGS, CXXFLAGS, CPPFLAGS and LDFLAGS
99 AC_MSG_CHECKING([whether configure should try to set CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS])
8383 dnl age.
8484 dnl 6. If any interfaces have been removed since the last public release, then set age
8585 dnl to 0.
86
87 CLEAN_VERSION=`echo $PACKAGE_VERSION | $SED "s/p.*//"`
88 VERSION_MAJOR=`echo $PACKAGE_VERSION | $SED "s/\..*//"`
89 VERSION_MINOR=`echo $CLEAN_VERSION | $SED "s/.*\.//"`
90 GEN_TOOL="autoconf"
91
92 SHARED_VERSION_INFO="$VERSION_MAJOR:$VERSION_MINOR:0"
86 SHARED_VERSION_INFO="1:31:0"
9387
9488 dnl ------------------------------------------------------------------------------------
9589
9993 AC_CHECK_HEADERS([byteswap.h])
10094 AC_CHECK_HEADERS([locale.h])
10195 AC_CHECK_HEADERS([sys/time.h])
96 AC_CHECK_HEADERS([immintrin.h])
10297
10398 AC_HEADER_SYS_WAIT
10499
608603 temp_CFLAGS=`echo $CFLAGS | $SED "s/-Wall -pedantic//" | $SED "s/-Wshadow//" | $SED "s/-Waggregate-return//"`
609604 CFLAGS=$temp_CFLAGS
610605 SHLIB_VERSION_ARG="-Wl,-exported_symbols_list -Wl,\$(top_srcdir)/src/Symbols.darwin"],
611 [linux*|kfreebsd*-gnu*|gnu*], [
612 SHLIB_VERSION_ARG="-Wl,--version-script=\$(top_srcdir)/src/Symbols.gnu-binutils"],
613606 [mingw*], [
614607 SHLIB_VERSION_ARG="-Wc,-static-libgcc -Wl,\$(top_srcdir)/src/libsndfile-1.def"
615608 win32_target_dll=1
625618 COMPILER_IS_GCC=1
626619 ])
627620
621 AS_CASE([$host_os], [linux*|kfreebsd*-gnu*|gnu*], [SHLIB_VERSION_ARG="-Wl,--version-script=\$(top_srcdir)/src/Symbols.gnu-binutils"])
622
628623 AC_DEFINE_UNQUOTED([WIN32_TARGET_DLL], [${win32_target_dll}], [Set to 1 if windows DLL is being built.])
629624 AC_DEFINE_UNQUOTED([COMPILER_IS_GCC], [${COMPILER_IS_GCC}], [Set to 1 if the compile is GNU GCC.])
630625
683678 Makefile Octave/Makefile
684679 src/version-metadata.rc include/sndfile.h
685680 tests/test_wrapper.sh tests/pedantic-header-test.sh
686 doc/libsndfile.css libsndfile.spec sndfile.pc
681 libsndfile.spec sndfile.pc
687682 Scripts/build-test-tarball.mk
688683 ])
689684 AC_OUTPUT
+0
-827
doc/FAQ.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile : Frequently Asked Questions.
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <META NAME="Description" CONTENT="The libsndfile FAQ.">
9 <META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
10 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
11 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
12 </HEAD>
13
14 <BODY>
15
16 <H1><B>libsndfile : Frequently Asked Questions.</B></H1>
17 <P>
18 <A HREF="#Q001">Q1 : Do you plan to support XYZ codec in libsndfile?</A><BR/>
19 <A HREF="#Q002">Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
20 but version 1 does not. Why?</A><BR/>
21 <A HREF="#Q003">Q3 : Compiling is really slow on MacOS X. Why?</A><BR/>
22 <A HREF="#Q004">Q4 : When trying to compile libsndfile on Solaris I get a "bad
23 substitution" error during linking. What can I do to fix this?</A><BR/>
24 <A HREF="#Q005">Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</A><BR/>
25 <A HREF="#Q006">Q6 : What's the best format for storing temporary files?</A><BR/>
26 <A HREF="#Q007">Q7 : On Linux/Unix/MacOS X, what's the best way of detecting the
27 presence of libsndfile?</A><BR/>
28 <A HREF="#Q008">Q8 : I have libsndfile installed and now I want to use it. I
29 just want a simple Makefile! What do I do?</A><BR/>
30 <A HREF="#Q009">Q9 : How about adding the ability to write/read sound files to/from
31 memory buffers?</A><BR/>
32 <A HREF="#Q010">Q10 : Reading a 16 bit PCM file as normalised floats and then
33 writing them back changes some sample values. Why?</A><BR/>
34 <A HREF="#Q011">Q11 : I'm having problems with u-law encoded WAV files generated by
35 libsndfile in Winamp. Why?</A><BR/>
36 <A HREF="#Q012">Q12 : I'm looking at sf_read*. What are items? What are frames?</A><BR/>
37 <A HREF="#Q013">Q13 : Why can't libsndfile open this Sound Designer II (SD2)
38 file?</A><BR/>
39 <A HREF="#Q014">Q14 : I'd like to statically link libsndfile to my closed source
40 application. Can I buy a license so that this is possible?</A><BR/>
41 <A HREF="#Q015">Q15 : My program is crashing during a call to a function in libsndfile.
42 Is this a bug in libsndfile?</A><BR/>
43 <A HREF="#Q016">Q16 : Will you accept a fix for compiling libsndfile with compiler X?
44 </A><BR/>
45 <A HREF="#Q017">Q17 : Can libsndfile read/write files from/to UNIX pipes?
46 </A><BR/>
47 <A HREF="#Q018">Q18 : Is it possible to build a Universal Binary on Mac OS X?
48 </A><BR/>
49 <A HREF="#Q019">Q19 : I have project files for Visual Studio / XCode / Whatever. Why
50 don't you distribute them with libsndfile?
51 </A><BR/>
52 <A HREF="#Q020">Q20 : Why doesn't libsndfile support MP3?
53 </A><BR/>
54 <A HREF="#Q021">Q21 : How do I use libsndfile in a closed source or commercial program
55 and comply with the license?
56 </A><BR/>
57 <A HREF="#Q022">Q22 : What versions of windows does libsndfile work on?
58 </A><BR/>
59 <A HREF="#Q023">Q23 : I'm cross compiling libsndfile for another platform. How can I
60 run the test suite?
61 </A><BR/>
62 <HR>
63
64 <!-- ========================================================================= -->
65 <A NAME="Q001"></A>
66 <H2><BR/><B>Q1 : Do you plan to support XYZ codec in libsndfile?</B></H2>
67 <P>
68 If source code for XYZ codec is available under a suitable license (LGPL, BSD,
69 MIT etc) then yes, I'd like to add it.
70 </P>
71 <P>
72 If suitable documentation is available on how to decode and encode the format
73 then maybe, depending on how much work is involved.
74 </P>
75 <P>
76 If XYZ is some proprietary codec where no source code or documentation is
77 available then no.
78 </P>
79 <P>
80 So if you want support for XYZ codec, first find existing source code or
81 documentation.
82 If you can't find either then the answer is no.
83 </P>
84 <!-- ========================================================================= -->
85 <A NAME="Q002"></A>
86 <H2><BR/><B>Q2 : In version 0 the SF_INFO struct had a pcmbitwidth field
87 but version 1 does not. Why?</B></H2>
88 <P>
89 This was dropped for a number of reasons:
90 </P>
91 <UL>
92 <LI> pcmbitwidth makes little sense on compressed or floating point formats
93 <LI> with the new API you really don't need to know it
94 </UL>
95 <P>
96 As documented
97 <A HREF="api.html#note1">here</A>
98 there is now a well defined behaviour which ensures that no matter what the
99 bit width of the source file, the scaling always does something sensible.
100 This makes it safe to read 8, 16, 24 and 32 bit PCM files using sf_read_short()
101 and always have the optimal behaviour.
102 </P>
103
104 <!-- ========================================================================= -->
105 <A NAME="Q003"></A>
106 <H2><BR/><B>Q3 : Compiling is really slow on MacOS X. Why?</B></H2>
107 <P>
108 When you configure and compile libsndfile, it uses the /bin/sh shell for a number
109 of tasks (ie configure script and libtool).
110 Older versions of OS X (10.2?) shipped a really crappy Bourne shell as /bin/sh
111 which resulted in <b>really</b> slow compiles.
112 Newer version of OS X ship GNU Bash as /bin/sh and this answer doesn't apply in that
113 case.
114 </P>
115 <P>
116 To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
117 /bin/sh.old and make a symlink from /bin/sh to the bash shell.
118 Bash is designed to behave as a Bourne shell when it is called as /bin/sh.
119 </P>
120 <P>
121 When I did this on my iBook running MacOS X, compile times dropped from 13 minutes
122 to 3 minutes.
123 </P>
124
125 <!-- ========================================================================= -->
126 <A NAME="Q004"></A>
127 <H2><BR/><B>Q4 : When trying to compile libsndfile on Solaris I get a "bad
128 substitution" error on linking. Why?</B></H2>
129 <P>
130 It seems that the Solaris Bourne shell disagrees with GNU libtool.
131 </P>
132 <P>
133 To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
134 /bin/sh.old and make a symlink from /bin/sh to the bash shell.
135 Bash is designed to behave as a Bourne shell when it is called as /bin/sh.
136 </P>
137
138 <!-- ========================================================================= -->
139 <A NAME="Q005"></A>
140 <H2><BR/><B>Q5 : Why doesn't libsndfile do interleaving/de-interleaving?</B></H2>
141 <P>
142 This problem is bigger than it may seem at first.
143 </P>
144 <P>
145 For a stereo file, it is a pretty safe bet that a simple interleaving/de-interleaving
146 could satisfy most users.
147 However, for files with more than 2 channels this is unlikely to be the case.
148 If the user has a 4 channel file and want to play that file on a stereo output
149 sound card they either want the first 2 channels or they want some mixed combination
150 of the 4 channels.
151 </P>
152 <P>
153 When you add more channels, the combinations grow exponentially and it becomes
154 increasingly difficult to cover even a sensible subset of the possible combinations.
155 On top of that, coding any one style of interleaver/de-interleaver is trivial, while
156 coding one that can cover all combinations is far from trivial.
157 This means that this feature will not be added any time soon.
158 </P>
159
160 <!-- ========================================================================= -->
161 <A NAME="Q006"></A>
162 <H2><BR/><B>Q6 : What's the best format for storing temporary files?</B></H2>
163
164 <P>
165 When you want to store temporary data there are a number of requirements;
166 </P>
167 <UL>
168 <LI> A simple, easy to parse header.
169 <LI> The format must provide the fastest possible read and write rates (ie
170 avoid conversions and encoding/decoding).
171 <LI> The file format must be reasonably common and playable by most players.
172 <LI> Able to store data in either endian-ness.
173 </UL>
174 <P>
175 The format which best meets these requirements is AU, which allows data to be
176 stored in any one of short, int, float and double (among others) formats.
177 </P>
178 <P>
179 For instance, if an application uses float data internally, its temporary files
180 should use a format of (SF_ENDIAN_CPU | SF_FORMAT_AU | SF_FORMAT_FLOAT) which
181 will store big endian float data in big endian CPUs and little endian float data
182 on little endian CPUs.
183 Reading and writing this format will not require any conversions or byte swapping
184 regardless of the host CPU.
185 </P>
186
187 <!-- ========================================================================= -->
188
189 <A NAME="Q007"></A>
190 <H2><BR/><B>Q7 : On Linux/Unix/MaxOS X, what's the best way of detecting the presence
191 of libsndfile using autoconf?</B></H2>
192
193 <P>
194 libsndfile uses the pkg-config (man pkg-config) method of registering itself with the
195 host system.
196 The best way of detecting its presence is using something like this in configure.ac
197 (or configure.in):
198 </P>
199 <PRE>
200 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.2, ac_cv_sndfile=1, ac_cv_sndfile=0)
201
202 AC_DEFINE_UNQUOTED([HAVE_SNDFILE],${ac_cv_sndfile},
203 [Set to 1 if you have libsndfile.])
204
205 AC_SUBST(SNDFILE_CFLAGS)
206 AC_SUBST(SNDFILE_LIBS)
207 </PRE>
208 <P>
209 This will automatically set the <B>SNDFILE_CFLAGS</B> and <B>SNDFILE_LIBS</B>
210 variables which can be used in Makefile.am like this:
211 </P>
212 <PRE>
213 SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
214 SNDFILE_LIBS = @SNDFILE_LIBS@
215 </PRE>
216 <P>
217 If you install libsndfile from source, you will probably need to set the
218 <B>PKG_CONFIG_PATH</B> environment variable as suggested at the end of the
219 libsndfile configure process. For instance on my system I get this:
220 </P>
221 <PRE>
222 -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
223
224 Configuration summary :
225
226 Version : ..................... 1.0.5
227 Experimental code : ........... no
228
229 Tools :
230
231 Compiler is GCC : ............. yes
232 GCC major version : ........... 3
233
234 Installation directories :
235
236 Library directory : ........... /usr/local/lib
237 Program directory : ........... /usr/local/bin
238 Pkgconfig directory : ......... /usr/local/lib/pkgconfig
239
240 Compiling some other packages against libsndfile may require
241 the addition of "/usr/local/lib/pkgconfig" to the
242 PKG_CONFIG_PATH environment variable.
243 </PRE>
244
245 <!-- ========================================================================= -->
246
247 <A NAME="Q008"></A>
248 <H2><BR/><B>Q8 : I have libsndfile installed and now I want to use it. I just want
249 a simple Makefile! What do I do?</B></H2>
250
251 <P>
252 The <B>pkg-config</B> program makes finding the correct compiler flag values and
253 library location far easier.
254 During the installation of libsndfile, a file named <B>sndfile.pc</B> is installed
255 in the directory <B>${libdir}/pkgconfig</B> (ie if libsndfile is installed in
256 <B>/usr/local/lib</B>, <B>sndfile.pc</B> will be installed in
257 <B>/usr/local/lib/pkgconfig/</B>).
258 </P>
259 <P>
260 In order for pkg-config to find sndfile.pc it may be necessary to point the
261 environment variable <B>PKG_CONFIG_PATH</B> in the right direction.
262 </P>
263 <PRE>
264 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
265 </PRE>
266
267 <P>
268 Then, to compile a C file into an object file, the command would be:
269 </P>
270 <PRE>
271 gcc `pkg-config --cflags sndfile` -c somefile.c
272 </PRE>
273 <P>
274 and to link a number of objects into an executable that links against libsndfile,
275 the command would be:
276 </P>
277 <PRE>
278 gcc `pkg-config --libs sndfile` obj1.o obj2.o -o program
279 </PRE>
280
281 <!-- ========================================================================= -->
282
283 <A NAME="Q009"></A>
284 <H2><BR/><B>Q9 : How about adding the ability to write/read sound files to/from
285 memory buffers?</B></H2>
286
287 <P>
288 This has been added for version 1.0.13.
289 </P>
290
291 <!-- ========================================================================= -->
292
293 <A NAME="Q010"></A>
294 <H2><BR/><B>Q10 : Reading a 16 bit PCM file as normalised floats and then
295 writing them back changes some sample values. Why?</B></H2>
296
297 <P>
298 This is caused by the fact that the conversion from 16 bit short to float is
299 done by dividing by 32768 (0x8000 in hexadecimal) while the conversion from
300 float to 16 bit short is done by multiplying by 32767 (0x7FFF in hex).
301 So for instance, a value in a 16 bit PCM file of 20000 gets read as a floating
302 point number of 0.6103515625 (20000.0 / 0x8000).
303 Converting that back to a 16 bit short results in a value of 19999.3896484375
304 (0.6103515625 * 0x7FFF) which then gets rounded down to 19999.
305 </P>
306 <P>
307 You will notice that for this particular case, the error is 1 in 20000 or
308 0.005%.
309 Interestingly, for values of less than 16369, dividing by 0x8000 followed
310 by multiplying by 0x7FFF and then rounding the result, gives back the
311 original value.
312 It turns out that as long as the host operating system supplies the 1999 ISO
313 C Standard functions <B>lrintf</B> and <B>lrint</B> (or a replacement has
314 been supplied) then the maximum possible error is 1 in 16369 or about 0.006%.
315 </P>
316 <P>
317 Regardless of the size of the error, the reason why this is done is rather
318 subtle.
319 </P>
320 <P>
321 In a file containing 16 bit PCM samples, the values are restricted to the range
322 [-32768, 32767] while we want floating point values in the range [-1.0, 1.0].
323 The only way to do this conversion is to do a floating point division by a value
324 of 0x8000.
325 Converting the other way, the only way to ensure that floating point values in
326 the range [-1.0, 1.0] are within the valid range allowed by a 16 bit short is
327 to multiply by 0x7FFF.
328 </P>
329 <P>
330 Some people would say that this is a severe short-coming of libsndfile.
331 I would counter that anybody who is constantly converting back and forth
332 between 16 bit shorts and normalised floats is going to suffer other losses
333 in audio quality that they should also be concerned about.
334 </P>
335 <P>
336 Since this problem only occurs when converting between integer data on disk and
337 normalized floats in the application, it can be avoided by using something
338 other than normalized floats in the application.
339 Alternatives to normalized floats are the <b>short</b> and <b>int</b> data
340 types (ie using sf_read_short or sf_read_int) or using un-normalized floats
341 (see
342 <a href="command.html#SFC_SET_NORM_FLOAT">
343 SFC_SET_NORM_FLOAT</a>).
344 </P>
345 <P>
346 Another way to deal with this problem is to consider 16 bit short data as a
347 final destination format only, not as an intermediate storage format.
348 All intermediate data (ie which is going to be processed further) should be
349 stored in floating point format which is supported by all of the most common
350 file formats.
351 If floating point files are considered too large (2 times the size of a 16 bit
352 PCM file), it would also be possible to use 24 bit PCM as an intermediate
353 storage format (and which is also supported by most common file types).
354 </P>
355
356 <!-- ========================================================================= -->
357
358 <A NAME="Q011"></A>
359 <H2><BR/><B>Q11 : I'm having problems with u-law encoded WAV files generated by
360 libsndfile in Winamp. Why?
361 </B></H2>
362
363 <P>
364 This is actually a Winamp problem.
365 The official Microsoft spec suggests that the 'fmt ' chunk should be 18 bytes.
366 Unfortunately at least one of Microsoft's own applications (Sound Recorder on
367 Win98 I believe) did not accept 18 bytes 'fmt ' chunks.
368 </P>
369 <P>
370 Michael Lee did some experimenting and found that:
371 </P>
372 <PRE>
373 I have checked that Windows Media Player 9, QuickTime Player 6.4,
374 RealOne Player 2.0 and GoldWave 5.06 can all play u-law files with
375 16-byte or 18-byte 'fmt ' chunk. Only Winamp (2.91) and foobar2000
376 are unable to play u-law files with 16-byte 'fmt ' chunk.
377 </PRE>
378
379 <P>
380 Even this is a very small sampling of all the players out there.
381 For that reason it is probably not a good idea to change this now because there
382 is the risk of breaking something that currently works.
383 </P>
384
385 <!-- ========================================================================= -->
386
387 <A NAME="Q012"></A>
388 <H2><BR/><B>Q12 : I'm looking at sf_read*. What are items? What are frames?
389 </B></H2>
390
391 <P>
392 An <tt>item</tt> is a single sample of the data type you are reading; ie a
393 single <tt>short</tt> value for <tt>sf_read_short</tt> or a single <tt>float</tt>
394 for <tt>sf_read_float</tt>.
395 </P>
396
397 <P>
398 For a sound file with only one channel, a frame is the same as a item (ie a
399 single sample) while for multi channel sound files, a single frame contains a
400 single item for each channel.
401 </P>
402
403 <P>
404 Here are two simple, correct examples, both of which are assumed to be working
405 on a stereo file, first using items:
406 </P>
407
408 <PRE>
409 #define CHANNELS 2
410 short data [CHANNELS * 100] ;
411 sf_count items_read = sf_read_short (file, data, 200) ;
412 assert (items_read == 200) ;
413 </PRE>
414
415 <P>
416 and now reading the exact same amount of data using frames:
417 </P>
418
419 <PRE>
420 #define CHANNELS 2
421 short data [CHANNELS * 100] ;
422 sf_count frames_read = sf_readf_short (file, data, 100) ;
423 assert (frames_read == 100) ;
424 </PRE>
425
426 <!-- ========================================================================= -->
427
428 <A NAME="Q013"></A>
429 <H2><BR/><B>Q13 : Why can't libsndfile open this Sound Designer II (SD2) file?
430 </B></H2>
431
432 <P>
433 This is somewhat complicated.
434 First some background.
435 </P>
436
437 <P>
438 SD2 files are native to the Apple Macintosh platform and use features of
439 the Mac filesystem (file resource forks) to store the file's sample rate,
440 number of channels, sample width and more.
441 When you look at a file and its resource fork on Mac OS X it looks like
442 this:
443 </P>
444
445 <PRE>
446 -rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2
447 -rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 file.sd2/rsrc
448 </PRE>
449
450 <P>
451 Notice how the file itself looks like a directory containing a single file
452 named <B>rsrc</B>.
453 When libsndfile is compiled for MacOS X, it should open (for write and read)
454 SD2 file with resource forks like this without any problems.
455 It will also handle files with the resource fork in a separate file as
456 described below.
457 </P>
458
459 <P>
460 When SD2 files are moved to other platforms, the resource fork of the file
461 can sometimes be dropped altogether.
462 All that remains is the raw audio data and no information about the number
463 of channels, sample rate or bit width which makes it a little difficult for
464 libsndfile to open the file.
465 </P>
466
467 <P>
468 However, it is possible to safely move an SD2 file to a Linux or Windows
469 machine.
470 For instance, when an SD2 file is copied from inside MacOS X to a windows
471 shared directory or a Samba share (ie Linux), MacOS X is clever enough to
472 store the resource fork of the file in a separate hidden file in the
473 same directory like this:
474 </P>
475 <PRE>
476 -rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 ._file.sd2
477 -rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2
478 </PRE>
479
480 <P>
481 Regardless of what platform it is running on, when libsndfile is asked to
482 open a file named <B>"foo"</B> and it can't recognize the file type from
483 the data in the file, it will attempt to open the resource fork and if
484 that fails, it then tries to open a file named <B>"._foo"</B> to see if
485 the file has a valid resource fork.
486 This is the same regardless of whether the file is being opened for read
487 or write.
488 </P>
489
490 <P>
491 In short, libsndfile should open SD2 files with a valid resource fork on
492 all of the platforms that libsndfile supports.
493 If a file has lost its resource fork, the only option is the open the file
494 using the SF_FORMAT_RAW option and guessing its sample rate, channel count
495 and bit width.
496 </P>
497
498 <P>
499 Occasionally, when SD2 files are moved to other systems, the file is
500 <A HREF="http://www.macdisk.com/binhexen.php3">BinHexed</A>
501 which wraps the resource fork and the data fork together.
502 For these files, it would be possible to write a BinHex parser but
503 there is not a lot to gain considering how rare these BinHexed SD2
504 files are.
505 </P>
506
507 <!-- ========================================================================= -->
508 <A NAME="Q014"></A>
509 <H2><BR/><B>Q14 : I'd like to statically link libsndfile to my closed source
510 application. Can I buy a license so that this is possible?
511 </B></H2>
512
513 <P>
514 Unfortunately no.
515 libsndfile contains code written by other people who have agreed that their
516 code be used under the GNU LGPL but no more.
517 Even if they were to agree, there would be significant difficulties in
518 dividing up the payments fairly.
519 </P>
520
521 <P>
522 The <B>only</B> way you can legally use libsndfile as a statically linked
523 library is if your application is released under the GNU GPL or LGPL.
524 </P>
525
526 <!-- ========================================================================= -->
527 <A NAME="Q015"></A>
528 <H2><BR/><B>Q15 : My program is crashing during a call to a function in libsndfile.
529 Is this a bug in libsndfile?
530 </B></H2>
531
532 <P>
533 libsndfile is being used by large numbers of people all over the world
534 without any problems like this. That means that it is much more likely
535 that your code has a bug than libsndfile. However, it is still possible
536 that there is a bug in libsndfile.
537 </P>
538 <P>
539 To figure out whether it is your code or libsndfile you should do the
540 following:
541 </P>
542 <UL>
543 <LI>Make sure you are compiling your code with warnings switched on and
544 that you fix as many warnings as possible.
545 With the GNU compiler (gcc) I would recommend at least
546 <B>-W -Wall -Werror</B> which will force you to fix all warnings
547 before you can run the code.
548 <LI>Try using a memory debugger.
549 <A HREF="http://valgrind.kde.org/">Valgrind</A> on x86 Linux is excellent.
550 <A HREF="http://www.ibm.com/software/awdtools/purify/">Purify</A> also
551 has a good reputation.
552 <LI>If the code is clean after the above two steps and you still get
553 a crash in libsndfile, then send me a small snippet of code (no
554 more than 30-40 lines) which includes the call to sf_open() and
555 also shows how all variables passed to/returned from sf_open()
556 are defined.
557 </UL>
558
559 <!-- ========================================================================= -->
560 <A NAME="Q016"></A>
561 <H2><BR/><B>Q16 : Will you accept a fix for compiling libsndfile with compiler X?
562 </B></H2>
563
564 <P>
565 If compiler X is a C++ compiler then no.
566 C and C++ are different enough to make writing code that compiles as valid C
567 and valid C++ too difficult.
568 I would rather spend my time fixing bugs and adding features.
569 </P>
570
571 <P>
572 If compiler X is a C compiler then I will do what I can as long as that does
573 not hamper the correctness, portability and maintainability of the existing
574 code.
575 It should be noted however that libsndfile uses features specified by the 1999
576 ISO C Standard.
577 This can make compiling libsndfile with some older compilers difficult.
578 </P>
579
580 <!-- ========================================================================= -->
581 <A NAME="Q017"></A>
582 <H2><BR/><B>Q17 : Can libsndfile read/write files from/to UNIX pipes?
583 </B></H2>
584
585 <P>
586 Yes, libsndfile can read files from pipes.
587 Unfortunately, the write case is much more complicated.
588 </P>
589
590 <P>
591 File formats like AIFF and WAV have information at the start of the file (the
592 file header) which states the length of the file, the number of sample frames
593 etc.
594 This information must be filled in correctly when the file header is written,
595 but this information is not reliably known until the file is closed.
596 This means that libsndfile cannot write AIFF, WAV and many other file types
597 to a pipe.
598 </P>
599
600 <P>
601 However, there is at least one file format (AU) which is specifically designed
602 to be written to a pipe.
603 Like AIFF and WAV, AU has a header with a sample frames field, but it is
604 specifically allowable to set that frames field to 0x7FFFFFFF if the file
605 length is not known when the header is written.
606 The AU file format can also hold data in many of the standard formats (ie
607 SF_FORMAT_PCM_16, SF_FORMAT_PCM_24, SF_FORMAT_FLOAT etc) as well as allowing
608 data in both big and little endian format.
609 </P>
610
611 <P>
612 See also <A HREF="#Q006">FAQ Q6</A>.
613 </P>
614
615 <!-- ========================================================================= -->
616 <A NAME="Q018"></A>
617 <H2><BR/><B>Q18 : Is it possible to build a Universal Binary on Mac OS X?
618 </B></H2>
619
620 <P>
621 Yes, but you must do two separate configure/build/test runs; one on PowerPC
622 and one on Intel.
623 It is then possible to merge the binaries into a single universal binary using
624 one of the programs in the Apple tool chain.
625 </P>
626
627 <P>
628 It is <b>not</b> possible to build a working universal binary via a single
629 compile/build run on a single CPU.
630 </P>
631
632 <P>
633 The problem is that the libsndfile build process detects features of the CPU its
634 being built for during the configure process and when building a universal binary,
635 configure is only run once and that data is then used for both CPUs.
636 That configure data will be wrong for one of those CPUs.
637 You will still be able to compile libsndfile, and the test suite will pass on
638 the machine you compiled it on.
639 However, if you take the universal binary test suite programs compiled on one
640 CPU and run them on the other, the test suite will fail.
641 </P>
642
643 <P>
644 Part of the problem is that the CPU endian-ness is detected at configure time.
645 Yes, I know the Apple compiler defines one of the macros __LITTLE_ENDIAN__
646 and __BIG_ENDIAN__, but those macros are not part of the 1999 ISO C Standard
647 and they are not portable.
648 </P>
649
650 <P>
651 Endian issues are not the only reason why the cross compiled binary will fail.
652 The configure script also detects other CPU specific idiosyncrasies to provide
653 more optimized code.
654 </P>
655
656 <P>
657 Finally, the real show stopper problem with universal binaries is the problem
658 with the test suite.
659 libsndfile contains a huge, comprehensive test suite.
660 When you compile a universal binary and run the test suite, you only test the
661 native compile.
662 The cross compiled binary (the one with the much higher chance of having
663 problems) cannot be tested.
664 </P>
665
666 <P>
667 Now, if you have read this far you're probably thinking there must be a way
668 to fix this and there probably is.
669 The problem is that its a hell of a lot of work and would require significant
670 changes to the configure process, the internal code and the test suite.
671 In addition, these changes must not break compilation on any of the platforms
672 libsndfile is currently working on.
673 </p>
674
675
676 <!-- ========================================================================= -->
677 <A NAME="Q019"></A>
678 <H2><BR/><B>Q19 : I have project files for Visual Studio / XCode / Whatever. Why
679 don't you distribute them with libsndfile?
680 </B></H2>
681
682 <P>
683 There's a very good reason for this.
684 I will only distribute things that I actually have an ability to test and
685 maintain.
686 Project files for a bunch of different compilers and Integrated Development
687 Environments are simply too difficult to maintain.
688 </P>
689
690 <P>
691 The problem is that every time I add a new file to libsndfile or rename an
692 existing file I would have to modify all the project files and then test that
693 libsndfile still built with all the different compilers.
694 </P>
695
696 <P>
697 Maintaining these project files is also rather difficult if I don't have access
698 to the required compiler/IDE.
699 If I just edit the project files without testing them I will almost certainly
700 get it wrong.
701 If I release a version of libsndfile with broken project files, I'll get a bunch
702 of emails from people complaining about it not building and have no way of
703 fixing or even testing it.
704 </P>
705
706 <P>
707 I currently release sources that I personally test on Win32, Linux and
708 MacOS X (PowerPC) using the compiler I trust (GNU GCC).
709 Supporting one compiler on three (actually much more because GCC is available
710 almost everywhere) platforms is doable without too much pain.
711 I also release binaries for Win32 with instructions on how to use those
712 binaries with Visual Studio.
713 As a guy who is mainly interested in Linux, I'm not to keen to jump through
714 a bunch of hoops to support compilers and operating systems I don't use.
715 </P>
716
717 <P>
718 So, I hear you want to volunteer to maintain the project files for Some Crappy
719 Compiler 2007?
720 Well sorry, that won't work either.
721 I have had numerous people over the years offer to maintaining the project
722 files for Microsoft's Visual Studio.
723 Every single time that happened, they maintained it for a release or two and
724 then disappeared off the face of the earth.
725 Hence, I'm not willing to enter into an arrangement like that again.
726 </P>
727
728 <!-- ========================================================================= -->
729 <A NAME="Q020"></A>
730 <H2><BR/><B>Q20 : Why doesn't libsndfile support MP3?
731 </B></H2>
732
733 <P>
734 In the past, MP3 was not supported because the technology behind MP3 was
735 patented.
736 Those patents have now expired and there is an
737 <a href="https://github.com/erikd/libsndfile/issues/258">
738 open ticket</a>
739 to implement MP3 support.
740 </P>
741
742 <!-- ========================================================================= -->
743 <A NAME="Q021"></A>
744 <H2><BR/><B>Q21 : How do I use libsndfile in a closed source or commercial program
745 and comply with the license?
746 </B></H2>
747
748 <p>
749 Here is a checklist of things you need to do to make sure your use of libsndfile
750 in a closed source or commercial project complies with the license libsndfile is
751 released under, the GNU Lesser General Public License (LGPL):
752 </p>
753
754 <ul>
755 <li>Make sure you are linking to libsndfile as a shared library (Linux and Unix
756 systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OS X).
757 If you are using some other operating system that doesn't allow dynamically
758 linked libraries, you will not be able to use libsndfile unless you release
759 the source code to your program.
760 <li>In the licensing documentation for your program, add a statement that your
761 software depends on libsndfile and that libsndfile is released under the GNU
762 Lesser General Public License, either
763 <a href="http://www.gnu.org/licenses/lgpl-2.1.txt">version 2.1</a>
764 or optionally
765 <a href="http://www.gnu.org/licenses/lgpl.txt">version 3</a>.
766 <li>Include the text for both versions of the license, possibly as separate
767 files named libsndfile_lgpl_v2_1.txt and libsndfile_lgpl_v3.txt.
768 </ul>
769
770 <!-- ========================================================================= -->
771 <A NAME="Q022"></A>
772 <H2><BR/><B>Q22 : What versions of Windows does libsndfile work on?
773 </B></H2>
774
775 <p>
776 Currently the precompiled windows binaries are thoroughly tested on Windows XP.
777 As such, they should also work on Win2k and Windows Vista.
778 They may also work on earlier versions of Windows.
779 </p>
780
781 <p>
782 Since version 0.1.18 I have also been releasing precompiled binaries for Win64,
783 the 64 bit version of Windows.
784 These binaries have received much less testing than the 32 bit versions, but
785 should work as expected.
786 I'd be very interested in receiving feedback on these binaries.
787 </p>
788
789 <!-- ========================================================================= -->
790 <A NAME="Q023"></A>
791 <H2><BR/><B>Q23 : I'm cross compiling libsndfile for another platform. How can I
792 run the test suite?
793 </B></H2>
794
795 <p>
796 </p>
797
798 <p>
799 Since version 1.0.21 the top level Makefile has an extra make target,
800 'test-tarball'.
801 Building this target creates a tarball called called:
802 </p>
803
804 <center><tt>
805 libsndfile-testsuite-${host_triplet}-${version}.tar.gz
806 </tt></center>
807
808 <p>
809 in the top level directory.
810 This tarball can then be copied to the target platform.
811 Once untarred and test script <tt>test_wrapper.sh</tt> can be run from
812 the top level of the extracted tarball.
813 </p>
814
815 <!-- ========================================================================= -->
816 <HR>
817 <P>
818 The libsndfile home page is here :
819 <A HREF="http://www.mega-nerd.com/libsndfile/">
820 http://www.mega-nerd.com/libsndfile/</A>.
821 <BR/>
822 Version : 1.0.29
823 </P>
824
825 </BODY>
826 </HTML>
+0
-1012
doc/api.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 The libsndfile API
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <META NAME="Description" CONTENT="The libsndfile API.">
9 <META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
10 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
11 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
12 </HEAD>
13
14 <BODY>
15
16 <BR>
17 <H1><B>libsndfile</B></H1>
18 <P>
19 Libsndfile is a library designed to allow the reading and writing of many
20 different sampled sound file formats (such as MS Windows WAV and the Apple/SGI
21 AIFF format) through one standard library interface.
22 </P>
23 <!-- pepper -->
24 <P>
25 During read and write operations, formats are seamlessly converted between the
26 format the application program has requested or supplied and the file's data
27 format. The application programmer can remain blissfully unaware of issues
28 such as file endian-ness and data format. See <A HREF="#note1">Note 1</A> and
29 <A HREF="#note2">Note 2</A>.
30 </P>
31 <!-- pepper -->
32 <P>
33 Every effort is made to keep these documents up-to-date, error free and
34 unambiguous.
35 However, since maintaining the documentation is the least fun part of working
36 on libsndfile, these docs can and do fall behind the behaviour of the library.
37 If any errors, omissions or ambiguities are found, please notify me (erikd)
38 at mega-nerd dot com.
39 </P>
40 <!-- pepper -->
41 <P>
42 To supplement this reference documentation, there are simple example programs
43 included in the source code tarball.
44 The test suite which is also part of the source code tarball is also a good
45 place to look for the correct usage of the library functions.
46 </P>
47 <!-- pepper -->
48 <P>
49 <B> Finally, if you think there is some feature missing from libsndfile, check that
50 it isn't already implemented (and documented)
51 <A HREF="command.html">here</A>.
52 </B>
53 </P>
54
55 <H2><B>Synopsis</B></H2>
56 <P>
57 The functions of libsndfile are defined as follows:
58 </P>
59 <!-- pepper -->
60 <PRE>
61 #include &lt;stdio.h&gt;
62 #include &lt;sndfile.h&gt;
63
64 SNDFILE* <A HREF="#open">sf_open</A> (const char *path, int mode, SF_INFO *sfinfo) ;
65 SNDFILE* <A HREF="#open">sf_wchar_open</A> (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;
66 SNDFILE* <A HREF="#open_fd">sf_open_fd</A> (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
67 SNDFILE* <A HREF="#open_virtual">sf_open_virtual</A> (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
68 int <A HREF="#check">sf_format_check</A> (const SF_INFO *info) ;
69
70 sf_count_t <A HREF="#seek">sf_seek</A> (SNDFILE *sndfile, sf_count_t frames, int whence) ;
71
72 int <A HREF="command.html">sf_command</A> (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
73
74 int <A HREF="#error">sf_error</A> (SNDFILE *sndfile) ;
75 const char* <A HREF="#error">sf_strerror</A> (SNDFILE *sndfile) ;
76 const char* <A HREF="#error">sf_error_number</A> (int errnum) ;
77
78 int <A HREF="#error">sf_perror</A> (SNDFILE *sndfile) ;
79 int <A HREF="#error">sf_error_str</A> (SNDFILE *sndfile, char* str, size_t len) ;
80
81 int <A HREF="#close">sf_close</A> (SNDFILE *sndfile) ;
82 void <A HREF="#write_sync">sf_write_sync</A> (SNDFILE *sndfile) ;
83
84 sf_count_t <A HREF="#read">sf_read_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
85 sf_count_t <A HREF="#read">sf_read_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
86 sf_count_t <A HREF="#read">sf_read_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
87 sf_count_t <A HREF="#read">sf_read_double</A> (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
88
89 sf_count_t <A HREF="#readf">sf_readf_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
90 sf_count_t <A HREF="#readf">sf_readf_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
91 sf_count_t <A HREF="#readf">sf_readf_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
92 sf_count_t <A HREF="#readf">sf_readf_double</A> (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
93
94 sf_count_t <A HREF="#write">sf_write_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
95 sf_count_t <A HREF="#write">sf_write_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
96 sf_count_t <A HREF="#write">sf_write_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
97 sf_count_t <A HREF="#write">sf_write_double</A> (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
98
99 sf_count_t <A HREF="#writef">sf_writef_short</A> (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
100 sf_count_t <A HREF="#writef">sf_writef_int</A> (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
101 sf_count_t <A HREF="#writef">sf_writef_float</A> (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
102 sf_count_t <A HREF="#writef">sf_writef_double</A> (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
103
104 sf_count_t <A HREF="#raw">sf_read_raw</A> (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
105 sf_count_t <A HREF="#raw">sf_write_raw</A> (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
106
107 const char* <A HREF="#string">sf_get_string</A> (SNDFILE *sndfile, int str_type) ;
108 int <A HREF="#string">sf_set_string</A> (SNDFILE *sndfile, int str_type, const char* str) ;
109
110 const char* <A HREF="#version_string">sf_set_string</A> (void) ;
111
112 int <A HREF="#current_byterate">sf_current_byterate</A> (SNDFILE *sndfile) ;
113
114 int <A HREF="#set_chunk">sf_set_chunk</A> (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ;
115 SF_CHUNK_ITERATOR * <A HREF="#get_chunk_iterator">sf_get_chunk_iterator</A> (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ;
116 SF_CHUNK_ITERATOR * <A HREF="#next_chunk_iterator">sf_next_chunk_iterator</A> (SF_CHUNK_ITERATOR * iterator) ;
117 int <A HREF="#get_chunk_size">sf_get_chunk_size</A> (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ;
118 int <A HREF="#get_chunk_data">sf_get_chunk_data</A> (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ;
119 </PRE>
120 <!-- pepper -->
121 <P>
122 SNDFILE* is an anonymous pointer to data which is private to the library.
123 </P>
124
125
126 <A NAME="open"></A>
127 <H2><B>File Open Function</B></H2>
128
129 <PRE>
130 SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ;
131 </PRE>
132
133 <P>
134 The sf_open() function opens the sound file at the specified path.
135 The filename is byte encoded, but may be utf-8 on Linux, while on Mac OS X it
136 will use the filesystem character set.
137 On Windows, there is also a Windows specific sf_wchar_open() that takes a
138 UTF16_BE encoded filename.
139 </P>
140
141 <PRE>
142 SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;
143 </PRE>
144
145 <P>
146 The SF_INFO structure is for passing data between the calling function and the library
147 when opening a file for reading or writing. It is defined in sndfile.h as follows:
148 </P>
149 <!-- pepper -->
150 <PRE>
151 typedef struct
152 { sf_count_t frames ; /* Used to be called samples. */
153 int samplerate ;
154 int channels ;
155 int format ;
156 int sections ;
157 int seekable ;
158 } SF_INFO ;
159 </PRE>
160
161 <P>
162 The mode parameter for this function can be any one of the following three values:
163 </P>
164 <!-- pepper -->
165 <PRE>
166 SFM_READ - read only mode
167 SFM_WRITE - write only mode
168 SFM_RDWR - read/write mode
169 </PRE>
170
171 <P>
172 When opening a file for read, the <b>format</B> field should be set to zero before
173 calling sf_open().
174 The only exception to this is the case of RAW files where the caller has to set
175 the samplerate, channels and format fields to valid values.
176 All other fields of the structure are filled in by the library.
177 </P>
178 <!-- pepper -->
179 <P>
180 When opening a file for write, the caller must fill in structure members samplerate,
181 channels, and format.
182 </P>
183 <!-- pepper -->
184 <P>
185 The format field in the above SF_INFO structure is made up of the bit-wise OR of a
186 major format type (values between 0x10000 and 0x08000000), a minor format type
187 (with values less than 0x10000) and an optional endian-ness value.
188 The currently understood formats are listed in sndfile.h as follows and also include
189 bitmasks for separating major and minor file types.
190 Not all combinations of endian-ness and major and minor file types are valid.
191 </P>
192 <!-- pepper -->
193 <PRE>
194 enum
195 { /* Major formats. */
196 SF_FORMAT_WAV = 0x010000, /* Microsoft WAV format (little endian). */
197 SF_FORMAT_AIFF = 0x020000, /* Apple/SGI AIFF format (big endian). */
198 SF_FORMAT_AU = 0x030000, /* Sun/NeXT AU format (big endian). */
199 SF_FORMAT_RAW = 0x040000, /* RAW PCM data. */
200 SF_FORMAT_PAF = 0x050000, /* Ensoniq PARIS file format. */
201 SF_FORMAT_SVX = 0x060000, /* Amiga IFF / SVX8 / SV16 format. */
202 SF_FORMAT_NIST = 0x070000, /* Sphere NIST format. */
203 SF_FORMAT_VOC = 0x080000, /* VOC files. */
204 SF_FORMAT_IRCAM = 0x0A0000, /* Berkeley/IRCAM/CARL */
205 SF_FORMAT_W64 = 0x0B0000, /* Sonic Foundry's 64 bit RIFF/WAV */
206 SF_FORMAT_MAT4 = 0x0C0000, /* Matlab (tm) V4.2 / GNU Octave 2.0 */
207 SF_FORMAT_MAT5 = 0x0D0000, /* Matlab (tm) V5.0 / GNU Octave 2.1 */
208 SF_FORMAT_PVF = 0x0E0000, /* Portable Voice Format */
209 SF_FORMAT_XI = 0x0F0000, /* Fasttracker 2 Extended Instrument */
210 SF_FORMAT_HTK = 0x100000, /* HMM Tool Kit format */
211 SF_FORMAT_SDS = 0x110000, /* Midi Sample Dump Standard */
212 SF_FORMAT_AVR = 0x120000, /* Audio Visual Research */
213 SF_FORMAT_WAVEX = 0x130000, /* MS WAVE with WAVEFORMATEX */
214 SF_FORMAT_SD2 = 0x160000, /* Sound Designer 2 */
215 SF_FORMAT_FLAC = 0x170000, /* FLAC lossless file format */
216 SF_FORMAT_CAF = 0x180000, /* Core Audio File format */
217 SF_FORMAT_WVE = 0x190000, /* Psion WVE format */
218 SF_FORMAT_OGG = 0x200000, /* Xiph OGG container */
219 SF_FORMAT_MPC2K = 0x210000, /* Akai MPC 2000 sampler */
220 SF_FORMAT_RF64 = 0x220000, /* RF64 WAV file */
221
222 /* Subtypes from here on. */
223
224 SF_FORMAT_PCM_S8 = 0x0001, /* Signed 8 bit data */
225 SF_FORMAT_PCM_16 = 0x0002, /* Signed 16 bit data */
226 SF_FORMAT_PCM_24 = 0x0003, /* Signed 24 bit data */
227 SF_FORMAT_PCM_32 = 0x0004, /* Signed 32 bit data */
228
229 SF_FORMAT_PCM_U8 = 0x0005, /* Unsigned 8 bit data (WAV and RAW only) */
230
231 SF_FORMAT_FLOAT = 0x0006, /* 32 bit float data */
232 SF_FORMAT_DOUBLE = 0x0007, /* 64 bit float data */
233
234 SF_FORMAT_ULAW = 0x0010, /* U-Law encoded. */
235 SF_FORMAT_ALAW = 0x0011, /* A-Law encoded. */
236 SF_FORMAT_IMA_ADPCM = 0x0012, /* IMA ADPCM. */
237 SF_FORMAT_MS_ADPCM = 0x0013, /* Microsoft ADPCM. */
238
239 SF_FORMAT_GSM610 = 0x0020, /* GSM 6.10 encoding. */
240 SF_FORMAT_VOX_ADPCM = 0x0021, /* OKI / Dialogix ADPCM */
241
242 SF_FORMAT_NMS_ADPCM_16 = 0x0022, /* 16kbs NMS G721-variant encoding. */
243 SF_FORMAT_NMS_ADPCM_24 = 0x0023, /* 24kbs NMS G721-variant encoding. */
244 SF_FORMAT_NMS_ADPCM_32 = 0x0024, /* 32kbs NMS G721-variant encoding. */
245
246 SF_FORMAT_G721_32 = 0x0030, /* 32kbs G721 ADPCM encoding. */
247 SF_FORMAT_G723_24 = 0x0031, /* 24kbs G723 ADPCM encoding. */
248 SF_FORMAT_G723_40 = 0x0032, /* 40kbs G723 ADPCM encoding. */
249
250 SF_FORMAT_DWVW_12 = 0x0040, /* 12 bit Delta Width Variable Word encoding. */
251 SF_FORMAT_DWVW_16 = 0x0041, /* 16 bit Delta Width Variable Word encoding. */
252 SF_FORMAT_DWVW_24 = 0x0042, /* 24 bit Delta Width Variable Word encoding. */
253 SF_FORMAT_DWVW_N = 0x0043, /* N bit Delta Width Variable Word encoding. */
254
255 SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
256 SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
257
258 SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */
259 SF_FORMAT_OPUS = 0x0064, /* Xiph/Skype Opus encoding. */
260
261 SF_FORMAT_ALAC_16 = 0x0070, /* Apple Lossless Audio Codec (16 bit). */
262 SF_FORMAT_ALAC_20 = 0x0071, /* Apple Lossless Audio Codec (20 bit). */
263 SF_FORMAT_ALAC_24 = 0x0072, /* Apple Lossless Audio Codec (24 bit). */
264 SF_FORMAT_ALAC_32 = 0x0073, /* Apple Lossless Audio Codec (32 bit). */
265
266 /* Endian-ness options. */
267
268 SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
269 SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */
270 SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */
271 SF_ENDIAN_CPU = 0x30000000, /* Force CPU endian-ness. */
272
273 SF_FORMAT_SUBMASK = 0x0000FFFF,
274 SF_FORMAT_TYPEMASK = 0x0FFF0000,
275 SF_FORMAT_ENDMASK = 0x30000000
276 } ;
277 </PRE>
278 <!-- pepper -->
279 <P>
280 Every call to sf_open() should be matched with a call to sf_close() to free up
281 memory allocated during the call to sf_open().
282 </P>
283 <!-- pepper -->
284 <P>
285 On success, the sf_open function returns a non-NULL pointer which should be
286 passed as the first parameter to all subsequent libsndfile calls dealing with
287 that audio file.
288 On fail, the sf_open function returns a NULL pointer.
289 An explanation of the error can obtained by passing NULL to
290 <A HREF="#error">sf_strerror</A>.
291 </P>
292
293 <A NAME="open_fd"></A>
294 <H3><B>File Descriptor Open</B></H3>
295
296 <PRE>
297 SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
298 </PRE>
299
300 <P>
301 <b>Note:</b> On Microsoft Windows, this function does not work if the
302 application and the libsndfile DLL are linked to different versions of the
303 Microsoft C runtime DLL.
304 </P>
305 <P>
306 The second open function takes a file descriptor of a file that has already been
307 opened.
308 Care should be taken to ensure that the mode of the file represented by the
309 descriptor matches the mode argument.
310 This function is useful in the following circumstances:
311 </P>
312
313 <UL>
314 <LI>Opening temporary files securely (ie use the tmpfile() to return a
315 FILE* pointer and then using fileno() to retrieve the file descriptor
316 which is then passed to libsndfile).
317 <LI>Opening files with file names using OS specific character encodings
318 and then passing the file descriptor to sf_open_fd().
319 <LI>Opening sound files embedded within larger files.
320 <A HREF="embedded_files.html">More info</A>.
321 </UL>
322
323 <P>
324 Every call to sf_open_fd() should be matched with a call to sf_close() to free up
325 memory allocated during the call to sf_open_fd().
326 </P>
327
328 <P>
329 When sf_close() is called, the file descriptor is only closed if the <B>close_desc</B>
330 parameter was TRUE when the sf_open_fd() function was called.
331 </P>
332
333 <P>
334 On success, the sf_open_fd function returns a non-NULL pointer which should be
335 passed as the first parameter to all subsequent libsndfile calls dealing with
336 that audio file.
337 On fail, the sf_open_fd function returns a NULL pointer.
338 </P>
339
340 <A NAME="open_virtual"></A>
341 <h3><b>Virtual File Open Function</b></h3>
342 <pre>
343 SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
344 </pre>
345 <p>
346 Opens a soundfile from a virtual file I/O context which is provided
347 by the caller. This is usually used to interface libsndfile to a stream or buffer
348 based system. Apart from the sfvirtual and the user_data parameters this function behaves
349 like <a href="#open">sf_open</a>.
350 </p>
351
352 <pre>
353 typedef struct
354 { sf_vio_get_filelen get_filelen ;
355 sf_vio_seek seek ;
356 sf_vio_read read ;
357 sf_vio_write write ;
358 sf_vio_tell tell ;
359 } SF_VIRTUAL_IO ;
360 </pre>
361 <p>
362 Libsndfile calls the callbacks provided by the SF_VIRTUAL_IO structure when opening, reading
363 and writing to the virtual file context. The user_data pointer is a user defined context which
364 will be available in the callbacks.
365 </p>
366 <pre>
367 typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
368 typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
369 typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
370 typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
371 typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
372 </pre>
373 <h4>sf_vio_get_filelen</h4>
374 <pre>
375 typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
376 </pre>
377 <p>
378 The virtual file contex must return the length of the virtual file in bytes.<br>
379 </p>
380 <h4>sf_vio_seek</h4>
381 <pre>
382 typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
383 </pre>
384 <p>
385 The virtual file context must seek to offset using the seek mode provided by whence which is one of<br>
386 </p>
387 <pre>
388 SEEK_CUR
389 SEEK_SET
390 SEEK_END
391 </pre>
392 <p>
393 The return value must contain the new offset in the file.
394 </p>
395 <h4>sf_vio_read</h4>
396 <pre>
397 typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
398 </pre>
399 <p>
400 The virtual file context must copy ("read") "count" bytes into the
401 buffer provided by ptr and return the count of actually copied bytes.
402 </p>
403 <h4>sf_vio_write</h4>
404 <pre>
405 typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
406 </pre>
407 <p>
408 The virtual file context must process "count" bytes stored in the
409 buffer passed with ptr and return the count of actually processed bytes.<br>
410 </p>
411 <h4>sf_vio_tell</h4>
412 <pre>
413 typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
414 </pre>
415 <p>
416 Return the current position of the virtual file context.<br>
417 </p>
418
419
420 <A NAME="check"></A>
421 <BR><H2><B>Format Check Function</B></H2>
422
423 <PRE>
424 int sf_format_check (const SF_INFO *info) ;
425 </PRE>
426 <!-- pepper -->
427 <P>
428 This function allows the caller to check if a set of parameters in the SF_INFO struct
429 is valid before calling sf_open (SFM_WRITE).
430 </P>
431 <P>
432 sf_format_check returns TRUE if the parameters are valid and FALSE otherwise.
433 </P>
434
435 <A NAME="seek"></A>
436 <BR><H2><B>File Seek Functions</B></H2>
437
438 <PRE>
439 sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ;
440 </PRE>
441
442 <P>
443 The file seek functions work much like lseek in unistd.h with the exception that
444 the non-audio data is ignored and the seek only moves within the audio data section of
445 the file.
446 In addition, seeks are defined in number of (multichannel) frames.
447 Therefore, a seek in a stereo file from the current position forward with an offset
448 of 1 would skip forward by one sample of both channels.
449 </P>
450
451 <P>
452 like lseek(), the whence parameter can be any one of the following three values:
453 </P>
454
455 <PRE>
456 SEEK_SET - The offset is set to the start of the audio data plus offset (multichannel) frames.
457 SEEK_CUR - The offset is set to its current location plus offset (multichannel) frames.
458 SEEK_END - The offset is set to the end of the data plus offset (multichannel) frames.
459 </PRE>
460 <!-- pepper -->
461 <P>
462 Internally, libsndfile keeps track of the read and write locations using separate
463 read and write pointers.
464 If a file has been opened with a mode of SFM_RDWR, bitwise OR-ing the standard whence
465 values above with either SFM_READ or SFM_WRITE allows the read and write pointers to
466 be modified separately.
467 If the SEEK_* values are used on their own, the read and write pointers are
468 both modified.
469 </P>
470
471 <P>
472 Note that the frames offset can be negative and in fact should be when SEEK_END is used for the
473 whence parameter.
474 </P>
475 <P>
476 sf_seek will return the offset in (multichannel) frames from the start of the audio data
477 or -1 if an error occured (ie an attempt is made to seek beyond the start or end of the file).
478 </P>
479
480 <A NAME="error"></A>
481 <H2><BR><B>Error Reporting Functions</B></H2>
482
483
484 <PRE>
485 int sf_error (SNDFILE *sndfile) ;
486 </PRE>
487 <P>
488 This function returns the current error number for the given SNDFILE.
489 The error number may be one of the following:
490 </P>
491 <PRE>
492 enum
493 { SF_ERR_NO_ERROR = 0,
494 SF_ERR_UNRECOGNISED_FORMAT = 1,
495 SF_ERR_SYSTEM = 2,
496 SF_ERR_MALFORMED_FILE = 3,
497 SF_ERR_UNSUPPORTED_ENCODING = 4
498 } ;
499 </PRE>
500 <!-- pepper -->
501 <P>
502 or any one of many other internal error values.
503 Applications should only test the return value against error values defined in
504 &lt;sndfile.h&gt; as the internal error values are subject to change at any
505 time.
506 For errors not in the above list, the function sf_error_number() can be used to
507 convert it to an error string.
508 </P>
509
510 <PRE>
511 const char* sf_strerror (SNDFILE *sndfile) ;
512 const char* sf_error_number (int errnum) ;
513 </PRE>
514
515 <P>
516 The error functions sf_strerror() and sf_error_number() convert the library's internal
517 error enumerations into text strings.
518 </P>
519 <PRE>
520 int sf_perror (SNDFILE *sndfile) ;
521 int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ;
522 </PRE>
523
524 <P>
525 The functions sf_perror() and sf_error_str() are deprecated and will be dropped
526 from the library at some later date.
527 </P>
528
529 <A NAME="close"></A>
530 <H2><BR><B>File Close Function</B></H2>
531
532 <PRE>
533 int sf_close (SNDFILE *sndfile) ;
534 </PRE>
535 <!-- pepper -->
536 <P>
537 The close function closes the file, deallocates its internal buffers and returns
538 0 on success or an error value otherwise.
539 </P>
540 <BR>
541
542 <A NAME="write_sync"></A>
543 <H2><BR><B>Write Sync Function</B></H2>
544
545 <PRE>
546 void sf_write_sync (SNDFILE *sndfile) ;
547 </PRE>
548 <!-- pepper -->
549 <P>
550 If the file is opened SFM_WRITE or SFM_RDWR, call the operating system's function
551 to force the writing of all file cache buffers to disk. If the file is opened
552 SFM_READ no action is taken.
553 </P>
554 <BR>
555
556
557 <A NAME="read"></A>
558 <H2><BR><B>File Read Functions</B></H2>
559
560 <PRE>
561 sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
562 sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
563 sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
564 sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
565 </PRE>
566
567 <A NAME="readf"></A>
568 <PRE>
569 sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
570 sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
571 sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
572 sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
573 </PRE>
574 <!-- pepper -->
575 <P>
576 The file read functions fill the array pointed to by ptr with the
577 requested number of items or frames.
578 </P>
579
580 <P>
581 For the frames-count functions, the frames parameter specifies the number
582 of frames. A frame is just a block of samples, one for each
583 channel. <B>Care must be taken to ensure that there is enough space
584 in the array pointed to by ptr, to take (frames * channels) number of
585 items (shorts, ints, floats or doubles).
586 </B></P>
587
588 <P>
589 For the items-count functions, the items parameter must be an integer product
590 of the number of channels or an error will occur. Here, an item is just a
591 sample.
592 </P>
593
594 <P>
595 Note: The only difference between the "items" and "frames" versions of
596 each read function is the units in which the object count is specified
597 - calling sf_readf_short with a count argument of N, on a SNDFILE with
598 C channels, is the same as calling sf_read_short with a count argument
599 of N*C. The buffer pointed to by "ptr" should be the same number of
600 bytes in each case.
601 </P>
602
603 <!-- pepper -->
604 <P>
605 Note: The data type used by the calling program and the data format of
606 the file do not need to be the same. For instance, it is possible to
607 open a 16 bit PCM encoded WAV file and read the data using
608 sf_read_float(). The library seamlessly converts between the two
609 formats on-the-fly. See
610 <A HREF="#note1">Note 1</A>.
611 </P>
612 <!-- pepper -->
613 <P>
614 The sf_read_XXXX and sf_readf_XXXX functions return the number of
615 items or frames read, respectively. Unless the end of the file was
616 reached during the read, the return value should equal the number of
617 objects requested. Attempts to read beyond the end of the file will
618 not result in an error but will cause the read functions to return
619 less than the number of objects requested or 0 if already at the end
620 of the file. When the buffer is not is not completely filled, unused
621 buffer space is filled by zeroes.
622 </P>
623
624 <A NAME="write"></A>
625 <H2><BR><B>File Write Functions</B></H2>
626
627 <PRE>
628 sf_count_t sf_write_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
629 sf_count_t sf_write_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
630 sf_count_t sf_write_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
631 sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
632 </PRE>
633
634 <A NAME="writef"></A>
635 <PRE>
636 sf_count_t sf_writef_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
637 sf_count_t sf_writef_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
638 sf_count_t sf_writef_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
639 sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
640 </PRE>
641
642 <P>
643 The file write functions write the data in the array pointed to by ptr to the file.
644 </P>
645
646 <P>
647 For items-count functions, the items parameter specifies the size of
648 the array and must be an integer product of the number of channels or
649 an error will occur.
650 </P>
651
652 <P>
653 For the frames-count functions, the array is expected to be large enough
654 to hold a number of items equal to the product of frames and the
655 number of channels.
656 </P>
657
658 <P>As with the read functions <A HREF="#read">above</A>, the only
659 difference in the items and frames version of each write function is
660 the units in which the buffer size is specified. Again, the data type
661 used by the calling program and the data format of the file do not
662 need to be the same (<A HREF="#note1">Note 1</A>).
663 </P>
664
665 <P>
666 The sf_write_XXXX and sf_writef_XXXX functions respectively return the
667 number of items or frames written (which should be the same as the
668 items or frames parameter).
669 </P>
670
671
672 <A NAME="raw"></A>
673 <H2><BR><B>Raw File Read and Write Functions</B></H2>
674 <!-- pepper -->
675 <PRE>
676 sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
677 sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
678 </PRE>
679
680 <P>
681 <b>Note:</b> Unless you are writing an external decoder/encode that uses
682 libsndfile to handle the file headers, you should not be using these
683 functions.
684 </P>
685
686 <P>
687 The raw read and write functions read raw audio data from the audio file (not to be
688 confused with reading RAW header-less PCM files). The number of bytes read or written
689 must always be an integer multiple of the number of channels multiplied by the number
690 of bytes required to represent one sample from one channel.
691 </P>
692 <!-- pepper -->
693 <P>
694 The raw read and write functions return the number of bytes read or written (which
695 should be the same as the bytes parameter).
696 </P>
697
698 <P>
699 <B>
700 Note : The result of using of both regular reads/writes and raw reads/writes on
701 compressed file formats other than SF_FORMAT_ALAW and SF_FORMAT_ULAW is undefined.
702 </B>
703 </P>
704
705 <p>
706 See also : <a href="command.html#SFC_RAW_NEEDS_ENDSWAP">SFC_RAW_NEEDS_ENDSWAP</a>
707 </p>
708
709 <A NAME="string"></A>
710 <H2><BR><B>Functions for Reading and Writing String Data</B></H2>
711
712
713 <PRE>
714 const char* sf_get_string (SNDFILE *sndfile, int str_type) ;
715 int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ;
716 </PRE>
717
718 <P>
719 These functions allow strings to be set on files opened for write and to be
720 retrieved from files opened for read where supported by the given file type.
721 The <B>str_type</B> parameter can be any one of the following string types:
722 </P>
723
724 <PRE>
725 enum
726 { SF_STR_TITLE,
727 SF_STR_COPYRIGHT,
728 SF_STR_SOFTWARE,
729 SF_STR_ARTIST,
730 SF_STR_COMMENT,
731 SF_STR_DATE,
732 SF_STR_ALBUM,
733 SF_STR_LICENSE,
734 SF_STR_TRACKNUMBER,
735 SF_STR_GENRE
736 } ;
737 </PRE>
738
739 <P>
740 The sf_get_string() function returns the specified string if it exists and a
741 NULL pointer otherwise.
742 In addition to the string ids above, SF_STR_FIRST (== SF_STR_TITLE) and
743 SF_STR_LAST (always the same as the highest numbers string id) are also
744 available to allow iteration over all the available string ids.
745 </P>
746
747 <P>
748 The sf_set_string() function sets the string data.
749 It returns zero on success and non-zero on error.
750 The error code can be converted to a string using sf_error_number().
751 </P>
752
753 <P>
754 Strings passed to and retrieved from these two functions are assumed to be
755 utf-8.
756 However, while formats like Ogg/Vorbis and FLAC fully support utf-8, others
757 like WAV and AIFF officially only support ASCII.
758 Writing utf-8 strings to WAV and AIF files with libsndfile will work when read
759 back with libsndfile, but may not work with other programs.
760 </P>
761
762 <P>
763 The suggested method of dealing with tags retrived using sf_get_string() is to
764 assume they are utf-8.
765 Similarly if you have a string in some exotic format like utf-16, it should be
766 encoded to utf-8 before being written using libsndfile.
767 </P>
768
769 <div id="version_string">
770 <h2>Function for retrieving library version</h2>
771 <pre>
772 const char * sf_version_string (void) ;
773 </pre>
774 <p>
775 Return the library version string.
776 </p>
777 </div>
778
779 <div id="current_byterate">
780 <h2>Function for retrieving current byterate</h2>
781 <pre>
782 int sf_current_byterate (SNDFILE *sndfile) ;
783 </pre>
784 <p>
785 Return the current byterate at this point in the file. The byte rate in this
786 case is the number of bytes per second of audio data. For instance, for a
787 stereo, 18 bit PCM encoded file with an 16kHz sample rate, the byte rate
788 would be 2 (stereo) * 2 (two bytes per sample) * 16000 => 64000 bytes/sec.
789 </p>
790 <p>
791 For some file formats the returned value will be accurate and exact, for some
792 it will be a close approximation, for some it will be the average bitrate for
793 the whole file and for some it will be a time varying value that was accurate
794 when the file was most recently read or written.
795 </p>
796 <p>
797 To get the bitrate, multiple this value by 8.
798 </p>
799 <p>
800 <code>sf_current_byterate</code> returns byte per second or -1 if byterate is
801 unknown.
802 </p>
803 </div>
804
805 <div id="chunk">
806 <h2>Functions to get and set chunks from within a sound file</h2>
807 <p>
808 These functions allow the getting and setting of chunks within a sound file
809 (for those formats which allow it).
810 </p>
811 <p>
812 These functions fail safely. Specifically, they will not allow you to overwrite
813 existing chunks or add extra versions of format specific reserved chunks but
814 should allow you to retrieve any and all chunks (may not be implemented for
815 all chunks or all file formats).
816 </p>
817 <div id="set_chunk">
818 <h3>sf_set_chunk</h3>
819 <pre>
820 int sf_set_chunk (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ;
821 </pre>
822 <p>
823 Set the specified chunk info (must be done before any audio data is written
824 to the file). This will fail for format specific reserved chunks.
825 The <code>chunk_info->data</code> pointer must be valid until the file is
826 closed.
827 </p>
828 <p>
829 The <code>SF_CHUNK_INFO</code> struct is documented as follows:
830 </p>
831 <pre>
832 struct SF_CHUNK_INFO
833 { char id [64] ; /* The chunk identifier. */
834 unsigned id_size ; /* The size of the chunk identifier. */
835 unsigned datalen ; /* The size of that data. */
836 void *data ; /* Pointer to the data. */
837 } ;
838
839 typedef struct SF_CHUNK_INFO SF_CHUNK_INFO ;
840 </pre>
841 <p>
842 <code>sf_set_chunk</code> returns <code>SF_ERR_NO_ERROR</code> on success or
843 non-zero on failure.
844 </p>
845 </div>
846 <div id="get_chunk_iterator">
847 <h3>sf_get_chunk_iterator</h3>
848 <pre>
849 SF_CHUNK_ITERATOR *
850 sf_get_chunk_iterator (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ;
851 </pre>
852 <p>
853 Get an iterator for all chunks matching <code>chunk_info</code>.
854 </p>
855 <p><code>SF_CHUNK_ITERATOR</code> is an opaque structure to an iterator over
856 the all chunks of a given id and defined as follows:</p>
857 <pre>
858 typedef struct SF_CHUNK_ITERATOR SF_CHUNK_ITERATOR ;
859 </pre>
860 <p>The iterator will point to the first chunk matching <code>chunk_info</code>.
861 Chunks are matching, if (<code>chunk_info->id</code>) matches the first (
862 <code>chunk_info->id_size</code>) bytes of a chunk found in the
863 <code>SNDFILE*</code> handle. If <code>chunk_info</code> is <code>NULL</code>,
864 an iterator to all chunks in the <code>SNDFILE*</code> handle is returned. The
865 values of <code>chunk_info->datalen</code> and <code>chunk_info->data</code>
866 are ignored. If no matching chunks are found in the sndfile, <code>NULL</code>
867 is returned.
868 </p>
869 <p>
870 The returned iterator will stay valid until one of the following occurs:
871 </p>
872 <ol type="a">
873 <li>The sndfile is closed.</li>
874 <li>A new chunk is added using <a href="#set_chunk"><code>sf_set_chunk()</code>
875 </a>.</li>
876 <li>Another chunk iterator function is called on the same <code>SNDFILE*</code>
877 handle that causes the iterator to be modified.</li>
878 </ol>
879 <p>The memory for the iterator belongs to the SNDFILE* handle and is freed when
880 <a href="#close">sf_close()</code></a> is called.</p>
881 </div>
882 <div id="next_chunk_iterator">
883 <h3>sf_next_chunk_iterator</h3>
884 <pre>
885 sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) ;
886 </pre>
887 <p>
888 Iterate through chunks by incrementing the iterator.
889 </p>
890 <p>
891 Increments the iterator and returns a handle to the new one. After this call,
892 iterator will no longer be valid, and you must use the newly returned handle
893 from now on. The returned handle can be used to access the next chunk matching
894 the criteria as defined in <a href="#get_chunk_iterator"><code>
895 sf_get_chunk_iterator()</code></a>. If iterator points to the last chunk, this
896 will free all resources associated with iterator and return <code>NULL</code>.
897 The returned iterator will stay valid until <code>sf_get_next_chunk_iterator
898 </code> is called again, the sndfile is closed or a new chunk us added.
899 </p>
900 </div>
901 <div id="get_chunk_size">
902 <h3>sf_get_chunk_size</h3>
903 <pre>
904 int
905 sf_get_chunk_size (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ;
906 </pre>
907 <p>
908 Get the size of the specified chunk.
909 </p>
910 <p>
911 If the specified chunk exists, the size will be returned in the <code>datalen
912 </code> field of the <code>SF_CHUNK_INFO</code> struct. Additionally, the id of
913 the chunk will be copied to the <code>id</code> field of the <code>
914 SF_CHUNK_INFO</code> struct and it's <code>id_size</code> field will be updated
915 accordingly.
916 </p>
917 <p>
918 If the chunk doesn't exist <code>chunk_info->datalen</code> will be zero, and
919 the <code>id</code> and <code>id_size</code> fields will be undefined.
920 </p>
921 <p>
922 The function will return <code>SF_ERR_NO_ERROR</code> on success or non-zero on
923 failure.
924 </p>
925 </div>
926 <div id="get_chunk_data">
927 <h3>sf_get_chunk_data</h3>
928 <pre>
929 int
930 sf_get_chunk_data (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ;
931 </pre>
932 <p>
933 Get the specified chunk data.
934 </p>
935 <p>
936 If the specified chunk exists, up to <code>chunk_info->datalen</code> bytes of
937 the chunk data will be copied into the <code>chunk_info->data</code> buffer
938 (allocated by the caller) and the <code>chunk_info->datalen</code> field
939 updated to reflect the size of the data. The <code>id</code> and <code>id_size
940 </code> field will be updated according to the retrieved chunk. If the chunk
941 doesn't exist <code>chunk_info->datalen</code> will be zero, and the <code>id
942 </code> and <code>id_size</code> fields will be undefined.
943 </p>
944 <p>
945 The function will return <code>SF_ERR_NO_ERROR</code> on success or non-zero on
946 failure.
947 </p>
948 </div>
949 </div>
950
951 <HR>
952
953 <A NAME="note1"></A>
954 <H2><BR><B>Note 1</B></H2>
955 <!-- pepper -->
956 <P>
957 When converting between integer PCM formats of differing size
958 (e.g. using sf_read_int() to read a 16 bit PCM encoded WAV file)
959 libsndfile obeys one simple rule:
960 </P>
961
962 <P CLASS=indent_block>
963 Whenever integer data is moved from one sized container to another sized container,
964 the most significant bit in the source container will become the most significant bit
965 in the destination container.
966 </P>
967
968 <P>
969 When converting between integer data and floating point data, different rules apply.
970 The default behaviour when reading floating point data (sf_read_float() or
971 sf_read_double ()) from a file with integer data is normalisation. Regardless of
972 whether data in the file is 8, 16, 24 or 32 bit wide, the data will be read as
973 floating point data in the range [-1.0, 1.0]. Similarly, data in the range [-1.0, 1.0]
974 will be written to an integer PCM file so that a data value of 1.0 will be the largest
975 allowable integer for the given bit width. This normalisation can be turned on or off
976 using the <A HREF="command.html">sf_command</A> interface.
977 </P>
978
979 <A NAME="note2"></A>
980 <H2><BR><B>Note 2</B></H2>
981
982 <P>
983 Reading a file containg floating point data (allowable with WAV, AIFF, AU and other
984 file formats) using integer read methods (sf_read_short() or sf_read_int()) can
985 produce unexpected results.
986 For instance the data in the file may have a maximum absolute value &lt; 1.0 which
987 would mean that all sample values read from the file will be zero.
988 In order to read these files correctly using integer read methods, it is recommended
989 that you use the
990 <A HREF="command.html">sf_command</A>
991 interface, a command of
992 <A HREF="command.html#SFC_SET_SCALE_FLOAT_INT_READ">SFC_SET_SCALE_FLOAT_INT_READ</A>
993 and a parameter of SF_TRUE to force correct scaling.
994 </P>
995 <!-- pepper -->
996 <HR>
997 <!-- pepper -->
998 <P>
999 The libsndfile home page is
1000 <A HREF="http://www.mega-nerd.com/libsndfile/">here</A>.
1001 </P>
1002 <P>
1003 Version : 1.0.30
1004 </P>
1005 <!-- pepper -->
1006 <!-- pepper -->
1007 <!-- pepper -->
1008 <!-- pepper -->
1009
1010 </BODY>
1011 </HTML>
+0
-76
doc/bugs.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 Bug Reporting
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
9 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
10 </HEAD>
11
12 <BODY>
13
14 <CENTER>
15 <H1><B>Reporting Bugs in libsndfile</B></H1>
16 </CENTER>
17 <P>
18 Before even attempting to report a bug in libsndfile please make sure you have
19 read the
20 <A HREF="FAQ.html">Frequently Asked Questions</A>.
21 If you are having a problem writing code using libsndfile make sure you read
22 the
23 <A HREF="api.html">Application Programming Interface</A>
24 documentation.
25 </P>
26 <P>
27 That said, I am interested in finding and fixing all genuine bugs in libsndfile.
28 Bugs I want to fix include any of the following problems (and probably others) :
29 </P>
30 <UL>
31 <LI> Compilation problems on new platforms.
32 <LI> Errors being detected during the `make check' process.
33 <LI> Segmentation faults occuring inside libsndfile.
34 <LI> libsndfile hanging when opening a file.
35 <LI> Supported sound file types being incorrectly read or written.
36 <LI> Omissions, errors or spelling mistakes in the documentation.
37 </UL>
38
39 <P>
40 When submitting a bug report you must include :
41 </P>
42 <UL>
43 <LI> Your system (CPU and memory size should be enough).
44 <LI> The operating system you are using.
45 <LI> Whether you are using a package provided by your distribution or you
46 compiled it youself.
47 <LI> If you compiled it yourself, the compiler you are using. (Also make
48 sure to run 'make check'.)
49 <LI> A description of the problem.
50 <LI> Information generated by the sndfile-info program (see next paragraph).
51 <LI> If you are having problems with sndfile-play and ALSA on Linux, I will
52 need information about your kernel, ALSA version, compiler version,
53 whether you compiled the kernel/ALSA your self or installed from a
54 package etc.
55 </UL>
56
57 <P>
58 If libsndfile compiles and installs correctly but has difficulty reading a particular
59 file or type of file you should run the <B>sndfile-info</B> program (from the examples
60 directory of the libsndfile distribution) on the file. See
61 <A HREF="sndfile_info.html">here</A>
62 for an example of the use of the <B>sndfile-info</B> program.
63 </P>
64 <P>
65 Please do not send me a sound file which fails to open under libsndfile unless I
66 specifically ask you to. The above information should usually suffice for most
67 problems.
68 </P>
69 <P>
70 Once you have the above information you should submit a ticket on the libsnfile
71 <A HREF="https://github.com/erikd/libsndfile/issues">github issue tracker</A>.
72
73 </P>
74 </BODY>
75 </HTML>
+0
-2093
doc/command.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile : the sf_command function.
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <!-- Another version at the bottom of the page. -->
9 <META NAME="Description" CONTENT="The libsndfile API.">
10 <META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
11 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
12 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
13 </HEAD>
14
15 <BODY>
16
17 <H1><B>sf_command</B></H1>
18 <PRE>
19
20 int sf_command (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
21 </PRE>
22 <P>
23 This function allows the caller to retrieve information from or change aspects of the
24 library behaviour.
25 Examples include retrieving a string containing the library version or changing the
26 scaling applied to floating point sample data during read and write.
27 Most of these operations are performed on a per-file basis.
28 </P>
29 <P>
30 The cmd parameter is an integer identifier which is defined in &lt;sndfile.h&gt;.
31 All of the valid command identifiers have names beginning with "SFC_".
32 Data is passed to and returned from the library by use of a void pointer.
33 The library will not read or write more than datasize bytes from the void pointer.
34 For some calls no data is required in which case data should be NULL and datasize
35 may be used for some other purpose.
36 </P>
37 <P>
38 The available commands are as follows:
39 </P>
40
41 <CENTER>
42 <TABLE BORDER="0" WIDTH="90%" CELLPADDING="4">
43 <TR>
44 <TD><A HREF="#SFC_GET_LIB_VERSION">SFC_GET_LIB_VERSION</A></TD>
45 <TD>Retrieve the version of the library.</TD>
46 </TR>
47 <TR>
48 <TD><A HREF="#SFC_GET_LOG_INFO">SFC_GET_LOG_INFO</A></TD>
49 <TD>Retrieve the internal per-file operation log.</TD>
50 </TR>
51 <TR>
52 <TD><A HREF="#SFC_GET_CURRENT_SF_INFO">SFC_GET_CURRENT_SF_INFO</A></TD>
53 <TD>Retrieve <CODE>SF_INFO</CODE> struct of opened file.</TD>
54 </TR>
55 <TR>
56 <TD><A HREF="#SFC_CALC_SIGNAL_MAX">SFC_CALC_SIGNAL_MAX</A></TD>
57 <TD>Calculate the measured maximum signal value.</TD>
58 </TR>
59 <TR>
60 <TD><A HREF="#SFC_CALC_NORM_SIGNAL_MAX">SFC_CALC_NORM_SIGNAL_MAX</A></TD>
61 <TD>Calculate the measured normalised maximum signal value.</TD>
62 </TR>
63 <TR>
64 <TD><A HREF="#SFC_CALC_MAX_ALL_CHANNELS">SFC_CALC_MAX_ALL_CHANNELS</A></TD>
65 <TD>Calculate the peak value for each channel.</TD>
66 </TR>
67 <TR>
68 <TD><A HREF="#SFC_CALC_NORM_MAX_ALL_CHANNELS">SFC_CALC_NORM_MAX_ALL_CHANNELS</A></TD>
69 <TD>Calculate the normalised peak for each channel.</TD>
70 </TR>
71
72 <TR>
73 <TD><A HREF="#SFC_GET_SIGNAL_MAX">SFC_GET_SIGNAL_MAX</A></TD>
74 <TD>Retrieve the peak value for the file (as stored in the file header).</TD>
75 </TR>
76 <TR>
77 <TD><A HREF="#SFC_GET_MAX_ALL_CHANNELS">SFC_GET_MAX_ALL_CHANNELS</A></TD>
78 <TD>Retrieve the peak value for each channel (as stored in the file header).</TD>
79 </TR>
80
81 <TR>
82 <TD><A HREF="#SFC_SET_NORM_FLOAT">SFC_SET_NORM_FLOAT</A></TD>
83 <TD>Modify the normalisation behaviour of the floating point reading and writing functions.</TD>
84 </TR>
85 <TR>
86 <TD><A HREF="#SFC_SET_NORM_DOUBLE">SFC_SET_NORM_DOUBLE</A></TD>
87 <TD>Modify the normalisation behaviour of the double precision floating point reading and writing functions.</TD>
88 </TR>
89 <TR>
90 <TD><A HREF="#SFC_GET_NORM_FLOAT">SFC_GET_NORM_FLOAT</A></TD>
91 <TD>Retrieve the current normalisation behaviour of the floating point reading and writing functions.</TD>
92 </TR>
93 <TR>
94 <TD><A HREF="#SFC_GET_NORM_DOUBLE">SFC_GET_NORM_DOUBLE</A></TD>
95 <TD>Retrieve the current normalisation behaviour of the double precision floating point reading and writing functions.</TD>
96 </TR>
97 <TR>
98 <TD><A HREF="#SFC_SET_SCALE_FLOAT_INT_READ">SFC_SET_SCALE_FLOAT_INT_READ</A></TD>
99 <TD>Set/clear the scale factor when integer (short/int) data is read from a file
100 containing floating point data.</TD>
101 </TR>
102
103 <TR>
104 <TD><A HREF="#SFC_SET_SCALE_INT_FLOAT_WRITE">SFC_SET_SCALE_INT_FLOAT_WRITE</A></TD>
105 <TD>Set/clear the scale factor when integer (short/int) data is written to a file
106 as floating point data.</TD>
107 </TR>
108
109 <TR>
110 <TD><A HREF="#SFC_GET_SIMPLE_FORMAT_COUNT">SFC_GET_SIMPLE_FORMAT_COUNT</A></TD>
111 <TD>Retrieve the number of simple formats supported by libsndfile.</TD>
112 </TR>
113 <TR>
114 <TD><A HREF="#SFC_GET_SIMPLE_FORMAT">SFC_GET_SIMPLE_FORMAT</A></TD>
115 <TD>Retrieve information about a simple format.</TD>
116 </TR>
117
118 <TR>
119 <TD><A HREF="#SFC_GET_FORMAT_INFO">SFC_GET_FORMAT_INFO</A></TD>
120 <TD>Retrieve information about a major or subtype format.</TD>
121 </TR>
122
123 <TR>
124 <TD><A HREF="#SFC_GET_FORMAT_MAJOR_COUNT">SFC_GET_FORMAT_MAJOR_COUNT</A></TD>
125 <TD>Retrieve the number of major formats.</TD>
126 </TR>
127 <TR>
128 <TD><A HREF="#SFC_GET_FORMAT_MAJOR">SFC_GET_FORMAT_MAJOR</A></TD>
129 <TD>Retrieve information about a major format type.</TD>
130 </TR>
131 <TR>
132 <TD><A HREF="#SFC_GET_FORMAT_SUBTYPE_COUNT">SFC_GET_FORMAT_SUBTYPE_COUNT</A></TD>
133 <TD>Retrieve the number of subformats.</TD>
134 </TR>
135 <TR>
136 <TD><A HREF="#SFC_GET_FORMAT_SUBTYPE">SFC_GET_FORMAT_SUBTYPE</A></TD>
137 <TD>Retrieve information about a subformat.</TD>
138 </TR>
139
140 <TR>
141 <TD><A HREF="#SFC_SET_ADD_PEAK_CHUNK">SFC_SET_ADD_PEAK_CHUNK</A></TD>
142 <TD>Switch the code for adding the PEAK chunk to WAV and AIFF files on or off.</TD>
143 </TR>
144
145 <TR>
146 <TD><A HREF="#SFC_UPDATE_HEADER_NOW">SFC_UPDATE_HEADER_NOW</A></TD>
147 <TD>Used when a file is open for write, this command will update the file
148 header to reflect the data written so far.</TD>
149 </TR>
150 <TR>
151 <TD><A HREF="#SFC_SET_UPDATE_HEADER_AUTO">SFC_SET_UPDATE_HEADER_AUTO</A></TD>
152 <TD>Used when a file is open for write, this command will cause the file header
153 to be updated after each write to the file.</TD>
154 </TR>
155
156 <TR>
157 <TD><A HREF="#SFC_FILE_TRUNCATE">SFC_FILE_TRUNCATE</A></TD>
158 <TD>Truncate a file open for write or for read/write.</TD>
159 </TR>
160
161 <TR>
162 <TD><A HREF="#SFC_SET_RAW_START_OFFSET">SFC_SET_RAW_START_OFFSET</A></TD>
163 <TD>Change the data start offset for files opened up as SF_FORMAT_RAW.</TD>
164 </TR>
165
166 <TR>
167 <TD><A HREF="#SFC_SET_CLIPPING">SFC_SET_CLIPPING</A></TD>
168 <TD>Turn on/off automatic clipping when doing floating point to integer
169 conversion.</TD>
170 </TR>
171
172 <TR>
173 <TD><A HREF="#SFC_GET_CLIPPING">SFC_GET_CLIPPING</A></TD>
174 <TD>Retrieve current clipping setting.</TD>
175 </TR>
176
177 <TR>
178 <TD><A HREF="#SFC_GET_EMBED_FILE_INFO">SFC_GET_EMBED_FILE_INFO</A></TD>
179 <TD>Retrieve information about audio files embedded inside other files.</TD>
180 </TR>
181
182 <TR>
183 <TD><A HREF="#SFC_WAVEX_GET_AMBISONIC">SFC_WAVEX_GET_AMBISONIC</A></TD>
184 <TD>Test a WAVEX file for Ambisonic format</TD>
185 </TR>
186
187 <TR>
188 <TD><A HREF="#SFC_WAVEX_SET_AMBISONIC">SFC_WAVEX_SET_AMBISONIC</A></TD>
189 <TD>Modify a WAVEX header for Ambisonic format</TD>
190 </TR>
191
192 <TR>
193 <TD><A HREF="#SFC_SET_VBR_ENCODING_QUALITY">SFC_SET_VBR_ENCODING_QUALITY</A></TD>
194 <TD>Set the Variable Bit Rate encoding quality</TD>
195 </TR>
196
197 <TR>
198 <TD><A HREF="#SFC_SET_OGG_PAGE_LATENCY_MS">SFC_SET_OGG_PAGE_LATENCY_MS</A></TD>
199 <TD>Set Ogg page latency for Opus file.</TD>
200 </TR>
201
202 <TR>
203 <TD><A HREF="#SFC_SET_COMPRESSION_LEVEL">SFC_SET_COMPRESSION_LEVEL</A></TD>
204 <TD>Set the compression level.</TD>
205 </TR>
206
207 <TR>
208 <TD><A HREF="#SFC_RAW_DATA_NEEDS_ENDSWAP">SFC_RAW_DATA_NEEDS_ENDSWAP</a></td>
209 <TD>Determine if raw data needs endswapping</TD>
210 </TR>
211
212 <TR>
213 <TD><A HREF="#SFC_GET_BROADCAST_INFO">SFC_GET_BROADCAST_INFO</A></TD>
214 <TD>Retrieve the Broadcast Chunk info</TD>
215 </TR>
216
217 <TR>
218 <TD><A HREF="#SFC_SET_BROADCAST_INFO">SFC_SET_BROADCAST_INFO</A></TD>
219 <TD>Set the Broadcast Chunk info</TD>
220 </TR>
221
222 <TR>
223 <TD><A HREF="#SFC_GET_CHANNEL_MAP_INFO">SFC_GET_CHANNEL_MAP_INFO</A></TD>
224 <TD>Retrieve the channel map info</TD>
225 </TR>
226
227 <TR>
228 <TD><A HREF="#SFC_SET_CHANNEL_MAP_INFO">SFC_SET_CHANNEL_MAP_INFO</A></TD>
229 <TD>Set the channel map info</TD>
230 </TR>
231
232 <TR>
233 <TD><A HREF="#SFC_SET_CART_INFO">SFC_SET_CART_INFO</A></TD>
234 <TD>Set the Cart Chunk info</TD>
235 </TR>
236
237 <TR>
238 <TD><A HREF="#SFC_GET_CART_INFO">SFC_GET_CART_INFO</A></TD>
239 <TD>Retrieve the Cart Chunk info</TD>
240 </TR>
241
242 <TR>
243 <TD><A HREF="#SFC_GET_LOOP_INFO">SFC_GET_LOOP_INFO</A></TD>
244 <TD>Get loop info</TD>
245 </TR>
246
247 <TR>
248 <TD><A HREF="#SFC_GET_INSTRUMENT">SFC_GET_INSTRUMENT</A></TD>
249 <TD>Get instrument info</TD>
250 </TR>
251
252 <TR>
253 <TD><A HREF="#SFC_SET_INSTRUMENT">SFC_SET_INSTRUMENT</A></TD>
254 <TD>Set instrument info</TD>
255 </TR>
256
257 <TR>
258 <TD><A HREF="#SFC_GET_CUE_COUNT">SFC_GET_CUE_COUNT</A></TD>
259 <TD>Get the cue marker count</TD>
260 </TR>
261
262 <TR>
263 <TD><A HREF="#SFC_GET_CUE">SFC_GET_CUE</A></TD>
264 <TD>Get cue marker info</TD>
265 </TR>
266
267 <TR>
268 <TD><A HREF="#SFC_SET_CUE">SFC_SET_CUE</A></TD>
269 <TD>Set cue marker info</TD>
270 </TR>
271
272 <TR>
273 <TD><A HREF="#SFC_RF64_AUTO_DOWNGRADE">SFC_RF64_AUTO_DOWNGRADE</A></TD>
274 <TD>Enable auto downgrade from RF64 to WAV</TD>
275 </TR>
276 <TR>
277 <TD><A HREF="#SFC_GET_ORIGINAL_SAMPLERATE">SFC_GET_ORIGINAL_SAMPLERATE</A></TD>
278 <TD>Get original samplerate</TD>
279 </TR>
280 <TR>
281 <TD><A HREF="#SFC_SET_ORIGINAL_SAMPLERATE">SFC_SET_ORIGINAL_SAMPLERATE</A></TD>
282 <TD>Set original samplerate</TD>
283 </TR>
284 <!--
285 <TR>
286 <TD><A HREF="#add-dither">add dither</A></TD>
287 <TD>Add dither to output on write.</TD>
288 </TR>
289 -->
290 </TABLE>
291 </CENTER>
292
293 <BR><BR>
294
295 <HR>
296
297 <!-- ========================================================================= -->
298 <A NAME="SFC_GET_LIB_VERSION"></A>
299 <H2><BR><B>SFC_GET_LIB_VERSION</B></H2>
300 <P>
301 Retrieve the version of the library as a string.
302 </P>
303 <P>
304 Parameters:
305 <PRE>
306 sndfile : Not used
307 cmd : SFC_GET_LIB_VERSION
308 data : A pointer to a char buffer
309 datasize : The size of the buffer
310 </PRE>
311 <P>
312 Example:
313 </P>
314 <PRE>
315 char buffer [128] ;
316 sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
317 </PRE>
318
319 <DL>
320 <DT>Return value:</DT>
321 <DD><DD>This call will return the length of the retrieved version string.
322 </DL>
323 <DL>
324 <DT>Notes:</DT>
325 <DD>
326 The string returned in the buffer passed to this function will not overflow
327 the buffer and will always be null terminated .
328 </DL>
329
330 <!-- ========================================================================= -->
331 <A NAME="SFC_GET_LOG_INFO"></A>
332 <H2><BR><B>SFC_GET_LOG_INFO</B></H2>
333 <P>
334 Retrieve the log buffer generated when opening a file as a string. This log
335 buffer can often contain a good reason for why libsndfile failed to open a
336 particular file.
337 </P>
338 <P>
339 Parameters:
340 <PRE>
341 sndfile : A valid SNDFILE* pointer
342 cmd : SFC_GET_LOG_INFO
343 data : A pointer to a char buffer
344 datasize : The size of the buffer
345 </PRE>
346 <P>
347 Example:
348 </P>
349 <PRE>
350 char buffer [2048] ;
351 sf_command (sndfile, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ;
352 </PRE>
353
354 <DL>
355 <DT>Return value:</DT>
356 <DD><DD>This call will return the length of the retrieved version string.
357 </DL>
358 <DL>
359 <DT>Notes:</DT>
360 <DD>
361 The string returned in the buffer passed to this function will not overflow
362 the buffer and will always be null terminated .
363 </DL>
364
365 <!-- ========================================================================= -->
366 <A NAME="SFC_GET_CURRENT_SF_INFO"></A>
367 <H2><BR><B>SFC_GET_CURRENT_SF_INFO</B></H2>
368 <P>
369 Retrieve <CODE>SF_INFO</CODE> struct of opened file.
370 </P>
371 <P>
372 <CODE>SFC_GET_CURRENT_SF_INFO</CODE> command copies <CODE>SF_INFO</CODE> struct of
373 <CODE>sndfile</CODE> object to provided buffer.
374 </P>
375
376 <P>
377 Parameters:
378 <PRE>
379 sndfile : A valid SNDFILE* pointer
380 cmd : SFC_GET_CURRENT_SF_INFO
381 data : A pointer to a valid SF_INFO* pointer
382 datasize : sizeof (SF_INFO)
383 </PRE>
384 <P>
385 Example:
386 </P>
387 <PRE>
388 SF_INFO sfinfo ;
389 sf_command (sndfile, SFC_GET_CURRENT_SF_INFO, sfinfo, sizeof (SF_INFO)) ;
390 </PRE>
391
392 <DL>
393 <DT>Return value:</DT>
394 <DD><DD>Zero on success, non-zero otherwise.
395 </DL>
396
397 <!-- ========================================================================= -->
398 <A NAME="SFC_CALC_SIGNAL_MAX"></A>
399 <H2><BR><B>SFC_CALC_SIGNAL_MAX</B></H2>
400 <P>
401 Retrieve the measured maximum signal value. This involves reading through
402 the whole file which can be slow on large files.
403 </P>
404 <P>
405 Parameters:
406 <PRE>
407 sndfile : A valid SNDFILE* pointer
408 cmd : SFC_CALC_SIGNAL_MAX
409 data : A pointer to a double
410 datasize : sizeof (double)
411 </PRE>
412 <P>
413 Example:
414 </P>
415 <PRE>
416 double max_val ;
417 sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &amp;max_val, sizeof (max_val)) ;
418 </PRE>
419
420 <DL>
421 <DT>Return value:</DT>
422 <DD><DD>Zero on success, non-zero otherwise.
423 </DL>
424
425 <!-- ========================================================================= -->
426 <A NAME="SFC_CALC_NORM_SIGNAL_MAX"></A>
427 <H2><BR><B>SFC_CALC_NORM_SIGNAL_MAX</B></H2>
428 <P>
429 Retrieve the measured normalised maximum signal value. This involves reading
430 through the whole file which can be slow on large files.
431 </P>
432 <P>
433 Parameters:
434 <PRE>
435 sndfile : A valid SNDFILE* pointer
436 cmd : SFC_CALC_NORM_SIGNAL_MAX
437 data : A pointer to a double
438 datasize : sizeof (double)
439 </PRE>
440 <P>
441 Example:
442 </P>
443 <PRE>
444 double max_val ;
445 sf_command (sndfile, SFC_CALC_NORM_SIGNAL_MAX, &amp;max_val, sizeof (max_val)) ;
446 </PRE>
447
448 <DL>
449 <DT>Return value:</DT>
450 <DD><DD>Zero on success, non-zero otherwise.
451 </DL>
452
453 <!-- ========================================================================= -->
454 <A NAME="SFC_CALC_MAX_ALL_CHANNELS"></A>
455 <H2><BR><B>SFC_CALC_MAX_ALL_CHANNELS</B></H2>
456 <P>
457 Calculate the peak value (ie a single number) for each channel.
458 This involves reading through the whole file which can be slow on large files.
459 </P>
460 <P>
461 Parameters:
462 <PRE>
463 sndfile : A valid SNDFILE* pointer
464 cmd : SFC_CALC_MAX_ALL_CHANNELS
465 data : A pointer to a double
466 datasize : sizeof (double) * number_of_channels
467 </PRE>
468 <P>
469 Example:
470 </P>
471 <PRE>
472 double peaks [number_of_channels] ;
473 sf_command (sndfile, SFC_CALC_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
474 </PRE>
475 <DL>
476 <DT>Return value:</DT>
477 <DD>Zero if peaks have been calculated successfully and non-zero otherwise.
478 </DL>
479
480
481 <!-- ========================================================================= -->
482 <A NAME="SFC_CALC_NORM_MAX_ALL_CHANNELS"></A>
483 <H2><BR><B>SFC_CALC_NORM_MAX_ALL_CHANNELS</B></H2>
484 <P>
485 Calculate the normalised peak for each channel.
486 This involves reading through the whole file which can be slow on large files.
487 </P>
488 <P>
489 Parameters:
490 <PRE>
491 sndfile : A valid SNDFILE* pointer
492 cmd : SFC_CALC_NORM_MAX_ALL_CHANNELS
493 data : A pointer to a double
494 datasize : sizeof (double) * number_of_channels
495 </PRE>
496 <P>
497 Example:
498 </P>
499 <PRE>
500 double peaks [number_of_channels] ;
501 sf_command (sndfile, SFC_CALC_NORM_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
502 </PRE>
503 <DL>
504 <DT>Return value:</DT>
505 <DD>Zero if peaks have been calculated successfully and non-zero otherwise.
506 </DL>
507
508
509
510
511 <!-- ========================================================================= -->
512 <A NAME="SFC_GET_SIGNAL_MAX"></A>
513 <H2><BR><B>SFC_GET_SIGNAL_MAX</B></H2>
514 <P>
515 Retrieve the peak value for the file as stored in the file header.
516 </P>
517 <P>
518 Parameters:
519 <PRE>
520 sndfile : A valid SNDFILE* pointer
521 cmd : SFC_GET_SIGNAL_MAX
522 data : A pointer to a double
523 datasize : sizeof (double)
524 </PRE>
525 <P>
526 Example:
527 </P>
528 <PRE>
529 double max_peak ;
530 sf_command (sndfile, SFC_GET_SIGNAL_MAX, &amp;max_peak, sizeof (max_peak)) ;
531 </PRE>
532 <DL>
533 <DT>Return value:</DT>
534 <DD>SF_TRUE if the file header contained the peak value. SF_FALSE otherwise.
535 </DL>
536
537 <!-- ========================================================================= -->
538 <A NAME="SFC_GET_MAX_ALL_CHANNELS"></A>
539 <H2><BR><B>SFC_GET_MAX_ALL_CHANNELS</B></H2>
540 <P>
541 Retrieve the peak value for the file as stored in the file header.
542 </P>
543 <P>
544 Parameters:
545 <PRE>
546 sndfile : A valid SNDFILE* pointer
547 cmd : SFC_GET_SIGNAL_MAX
548 data : A pointer to an array of doubles
549 datasize : sizeof (double) * number_of_channels
550 </PRE>
551 <P>
552 Example:
553 </P>
554 <PRE>
555 double peaks [number_of_channels] ;
556 sf_command (sndfile, SFC_GET_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
557 </PRE>
558 <DL>
559 <DT>Return value:</DT>
560 <DD>SF_TRUE if the file header contains per channel peak values for the file.
561 SF_FALSE otherwise.
562 </DL>
563
564
565 <!-- ========================================================================= -->
566 <A NAME="SFC_SET_NORM_FLOAT"></A>
567 <H2><BR><B>SFC_SET_NORM_FLOAT</B></H2>
568 <P>
569 This command only affects data read from or written to using the floating point functions:
570 </P>
571 <PRE>
572 size_t <A HREF="api.html#read">sf_read_float</A> (SNDFILE *sndfile, float *ptr, size_t items) ;
573 size_t <A HREF="api.html#readf">sf_readf_float</A> (SNDFILE *sndfile, float *ptr, size_t frames) ;
574
575 size_t <A HREF="api.html#write">sf_write_float</A> (SNDFILE *sndfile, float *ptr, size_t items) ;
576 size_t <A HREF="api.html#writef">sf_writef_float</A> (SNDFILE *sndfile, float *ptr, size_t frames) ;
577 </PRE>
578 <P>
579 Parameters:
580 </P>
581 <PRE>
582 sndfile : A valid SNDFILE* pointer
583 cmd : SFC_SET_NORM_FLOAT
584 data : NULL
585 datasize : SF_TRUE or SF_FALSE
586 </PRE>
587 <P>
588 For read operations setting normalisation to SF_TRUE means that the data from all
589 subsequent reads will be be normalised to the range [-1.0, 1.0].
590 </P>
591 <P>
592 For write operations, setting normalisation to SF_TRUE means than all data supplied
593 to the float write functions should be in the range [-1.0, 1.0] and will be scaled
594 for the file format as necessary.
595 </P>
596 <P>
597 For both cases, setting normalisation to SF_FALSE means that no scaling will take place.
598 </P>
599 <P>
600 Example:
601 </P>
602 <PRE>
603 sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE) ;
604
605 sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ;
606 </PRE>
607 <DL>
608 <DT>Return value: </DT>
609 <DD>Returns the previous float normalisation mode.
610 </DL>
611
612 <!-- ========================================================================= -->
613 <A NAME="SFC_SET_NORM_DOUBLE"></A>
614 <H2><BR><B>SFC_SET_NORM_DOUBLE</B></H2>
615 <P>
616 This command only affects data read from or written to using the double precision
617 floating point functions:
618 </P>
619 <PRE>
620 size_t <A HREF="api.html#read">sf_read_double</A> (SNDFILE *sndfile, double *ptr, size_t items) ;
621 size_t <A HREF="api.html#readf">sf_readf_double</A> (SNDFILE *sndfile, double *ptr, size_t frames) ;
622
623 size_t <A HREF="api.html#write">sf_write_double</A> (SNDFILE *sndfile, double *ptr, size_t items) ;
624 size_t <A HREF="api.html#writef">sf_writef_double</A> (SNDFILE *sndfile, double *ptr, size_t frames) ;
625 </PRE>
626 <P>
627 Parameters:
628 </P>
629 <PRE>
630 sndfile : A valid SNDFILE* pointer
631 cmd : SFC_SET_NORM_DOUBLE
632 data : NULL
633 datasize : SF_TRUE or SF_FALSE
634 </PRE>
635 <P>
636 For read operations setting normalisation to SF_TRUE means that the data
637 from all subsequent reads will be be normalised to the range [-1.0, 1.0].
638 </P>
639 <P>
640 For write operations, setting normalisation to SF_TRUE means than all data supplied
641 to the double write functions should be in the range [-1.0, 1.0] and will be scaled
642 for the file format as necessary.
643 </P>
644 <P>
645 For both cases, setting normalisation to SF_FALSE means that no scaling will take place.
646 </P>
647 <P>
648 Example:
649 </P>
650 <PRE>
651 sf_command (sndfile, SFC_SET_NORM_DOUBLE, NULL, SF_TRUE) ;
652
653 sf_command (sndfile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
654 </PRE>
655 <DL>
656 <DT>Return value: </DT>
657 <DD>Returns the previous double normalisation mode.
658 </DL>
659
660 <!-- ========================================================================= -->
661 <A NAME="SFC_GET_NORM_FLOAT"></A>
662 <H2><BR><B>SFC_GET_NORM_FLOAT</B></H2>
663 <P>
664 Retrieve the current float normalisation mode.
665 </P>
666 <P>
667 Parameters:
668 </P>
669 <PRE>
670 sndfile : A valid SNDFILE* pointer
671 cmd : SFC_GET_NORM_FLOAT
672 data : NULL
673 datasize : anything
674 </PRE>
675 <P>
676 Example:
677 </P>
678 <PRE>
679 normalisation = sf_command (sndfile, SFC_GET_NORM_FLOAT, NULL, 0) ;
680 </PRE>
681 <DL>
682 <DT>Return value: </DT>
683 <DD>Returns TRUE if normalisation is on and FALSE otherwise.
684 </DL>
685
686 <!-- ========================================================================= -->
687 <A NAME="SFC_GET_NORM_DOUBLE"></A>
688 <H2><BR><B>SFC_GET_NORM_DOUBLE</B></H2>
689 <P>
690 Retrieve the current float normalisation mode.
691 </P>
692 <P>
693 Parameters:
694 </P>
695 <PRE>
696 sndfile : A valid SNDFILE* pointer
697 cmd : SFC_GET_NORM_DOUBLE
698 data : NULL
699 datasize : anything
700 </PRE>
701 <P>
702 Example:
703 </P>
704 <PRE>
705 normalisation = sf_command (sndfile, SFC_GET_NORM_DOUBLE, NULL, 0) ;
706 </PRE>
707 <DL>
708 <DT>Return value: </DT>
709 <DD>Returns TRUE if normalisation is on and FALSE otherwise.
710 </DL>
711
712
713 <!-- ========================================================================= -->
714 <A NAME="SFC_SET_SCALE_FLOAT_INT_READ"></A>
715 <H2><BR><B>SFC_SET_SCALE_FLOAT_INT_READ</B></H2>
716 <P>
717 Set/clear the scale factor when integer (short/int) data is read from a file
718 containing floating point data.
719 </P>
720 <P>
721 Parameters:
722 </P>
723 <PRE>
724 sndfile : A valid SNDFILE* pointer
725 cmd : SFC_SET_SCALE_FLOAT_INT_READ
726 data : NULL
727 datasize : TRUE or FALSE
728 </PRE>
729 <P>
730 Example:
731 </P>
732 <PRE>
733 sf_command (sndfile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
734 </PRE>
735 <DL>
736 <DT>Return value: </DT>
737 <DD>Returns the previous SFC_SET_SCALE_FLOAT_INT_READ setting for this file.
738 </DL>
739
740
741 <!-- ========================================================================= -->
742 <A NAME="SFC_SET_SCALE_INT_FLOAT_WRITE"></A>
743 <H2><BR><B>SFC_SET_SCALE_INT_FLOAT_WRITE</B></H2>
744 <P>
745 Set/clear the scale factor when integer (short/int) data is written to a file
746 as floating point data.
747 </P>
748 <P>
749 Parameters:
750 </P>
751 <PRE>
752 sndfile : A valid SNDFILE* pointer
753 cmd : SFC_SET_SCALE_INT_FLOAT_WRITE
754 data : NULL
755 datasize : TRUE or FALSE
756 </PRE>
757 <P>
758 Example:
759 </P>
760 <PRE>
761 sf_command (sndfile, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
762 </PRE>
763 <DL>
764 <DT>Return value: </DT>
765 <DD>Returns the previous SFC_SET_SCALE_INT_FLOAT_WRITE setting for this file.
766 </DL>
767
768 <!-- ========================================================================= -->
769 <A NAME="SFC_GET_SIMPLE_FORMAT_COUNT"></A>
770 <H2><BR><B>SFC_GET_SIMPLE_FORMAT_COUNT</B></H2>
771 <P>
772 Retrieve the number of simple formats supported by libsndfile.
773 </P>
774 <P>
775 Parameters:
776 </P>
777 <PRE>
778 sndfile : Not used.
779 cmd : SFC_GET_SIMPLE_FORMAT_COUNT
780 data : a pointer to an int
781 datasize : sizeof (int)
782 </PRE>
783 <P>
784 Example:
785 </P>
786 <PRE>
787 int count ;
788 sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &amp;count, sizeof (int)) ;
789 </PRE>
790 <DL>
791 <DT>Return value: </DT>
792 <DD>0
793 </DL>
794
795 <!-- ========================================================================= -->
796 <A NAME="SFC_GET_SIMPLE_FORMAT"></A>
797 <H2><BR><B>SFC_GET_SIMPLE_FORMAT</B></H2>
798 <P>
799 Retrieve information about a simple format.
800 </P>
801 <P>
802 Parameters:
803 </P>
804 <PRE>
805 sndfile : Not used.
806 cmd : SFC_GET_SIMPLE_FORMAT
807 data : a pointer to an SF_FORMAT_INFO struct
808 datasize : sizeof (SF_FORMAT_INFO)
809 </PRE>
810 <P>
811 The SF_FORMAT_INFO struct is defined in &lt;sndfile.h&gt; as:
812 </P>
813 <PRE>
814 typedef struct
815 { int format ;
816 const char *name ;
817 const char *extension ;
818 } SF_FORMAT_INFO ;
819 </PRE>
820 <P>
821 When sf_command() is called with SF_GET_SIMPLE_FORMAT, the value of the format
822 field should be the format number (ie 0 &lt;= format &lt;= count value obtained using
823 SF_GET_SIMPLE_FORMAT_COUNT).
824 </P>
825 <P>
826 Example:
827 </P>
828 <PRE>
829 SF_FORMAT_INFO format_info ;
830 int k, count ;
831
832 sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &amp;count, sizeof (int)) ;
833
834 for (k = 0 ; k &lt; count ; k++)
835 { format_info.format = k ;
836 sf_command (sndfile, SFC_GET_SIMPLE_FORMAT, &amp;format_info, sizeof (format_info)) ;
837 printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
838 } ;
839 </PRE>
840 <DL>
841 <DT>Return value: </DT>
842 <DD>0 on success and non-zero otherwise.
843 <DD>The value of the format field of the SF_FORMAT_INFO struct will be a value which
844 can be placed in the format field of an SF_INFO struct when a file is to be opened
845 for write.
846 <DD>The name field will contain a char* pointer to the name of the string, eg. "WAV (Microsoft 16 bit PCM)".
847 <DD>The extension field will contain the most commonly used file extension for that file type.
848 </DL>
849
850 <!-- ========================================================================= -->
851 <A NAME="SFC_GET_FORMAT_INFO"></A>
852 <H2><BR><B>SFC_GET_FORMAT_INFO</B></H2>
853 <P>
854 Retrieve information about a major or subtype format.
855 </P>
856 <P>
857 Parameters:
858 </P>
859 <PRE>
860 sndfile : Not used.
861 cmd : SFC_GET_FORMAT_INFO
862 data : a pointer to an SF_FORMAT_INFO struct
863 datasize : sizeof (SF_FORMAT_INFO)
864 </PRE>
865 <P>
866 The SF_FORMAT_INFO struct is defined in &lt;sndfile.h&gt; as:
867 </P>
868 <PRE>
869 typedef struct
870 { int format ;
871 const char *name ;
872 const char *extension ;
873 } SF_FORMAT_INFO ;
874 </PRE>
875 <P>
876 When sf_command() is called with SF_GET_FORMAT_INFO, the format field is
877 examined and if (format &amp; SF_FORMAT_TYPEMASK) is a valid format then the struct
878 is filled in with information about the given major type.
879 If (format &amp; SF_FORMAT_TYPEMASK) is FALSE and (format &amp; SF_FORMAT_SUBMASK) is a
880 valid subtype format then the struct is filled in with information about the given
881 subtype.
882 </P>
883 <P>
884 Example:
885 </P>
886 <PRE>
887 SF_FORMAT_INFO format_info ;
888
889 format_info.format = SF_FORMAT_WAV ;
890 sf_command (sndfile, SFC_GET_FORMAT_INFO, &amp;format_info, sizeof (format_info)) ;
891 printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
892
893 format_info.format = SF_FORMAT_ULAW ;
894 sf_command (sndfile, SFC_GET_FORMAT_INFO, &amp;format_info, sizeof (format_info)) ;
895 printf ("%08x %s\n", format_info.format, format_info.name) ;
896 </PRE>
897 <DL>
898 <DT>Return value: </DT>
899 <DD>0 on success and non-zero otherwise.
900 </DL>
901 <!-- ========================================================================= -->
902 <A NAME="SFC_GET_FORMAT_MAJOR_COUNT"></A>
903 <H2><BR><B>SFC_GET_FORMAT_MAJOR_COUNT</B></H2>
904 <P>
905 Retrieve the number of major formats.
906 </P>
907 <P>
908 Parameters:
909 </P>
910 <PRE>
911 sndfile : Not used.
912 cmd : SFC_GET_FORMAT_MAJOR_COUNT
913 data : a pointer to an int
914 datasize : sizeof (int)
915 </PRE>
916 <P>
917 Example:
918 </P>
919 <PRE>
920 int count ;
921 sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &amp;count, sizeof (int)) ;
922 </PRE>
923 <DL>
924 <DT>Return value: </DT>
925 <DD>0
926 </DL>
927
928 <!-- ========================================================================= -->
929 <A NAME="SFC_GET_FORMAT_MAJOR"></A>
930 <H2><BR><B>SFC_GET_FORMAT_MAJOR</B></H2>
931 <P>
932 Retrieve information about a major format type.
933 </P>
934 <P>
935 Parameters:
936 </P>
937 <PRE>
938 sndfile : Not used.
939 cmd : SFC_GET_FORMAT_MAJOR
940 data : a pointer to an SF_FORMAT_INFO struct
941 datasize : sizeof (SF_FORMAT_INFO)
942 </PRE>
943 <P>
944 Example:
945 </P>
946 <PRE>
947 SF_FORMAT_INFO format_info ;
948 int k, count ;
949
950 sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &amp;count, sizeof (int)) ;
951
952 for (k = 0 ; k &lt; count ; k++)
953 { format_info.format = k ;
954 sf_command (sndfile, SFC_GET_FORMAT_MAJOR, &amp;format_info, sizeof (format_info)) ;
955 printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
956 } ;
957 </PRE>
958 <P>
959 For a more comprehensive example, see the program list_formats.c in the examples/
960 directory of the libsndfile source code distribution.
961 </P>
962 <DL>
963 <DT>Return value: </DT>
964 <DD>0 on success and non-zero otherwise.
965 <DD>The value of the format field will be one of the major format identifiers such as
966 SF_FORMAT_WAV or SF_FORMAT_AIFF.
967 <DD>The name field will contain a char* pointer to the name of the string, eg. "WAV (Microsoft)".
968 <DD>The extension field will contain the most commonly used file extension for that file type.
969 </DL>
970
971 <!-- ========================================================================= -->
972 <A NAME="SFC_GET_FORMAT_SUBTYPE_COUNT"></A>
973 <H2><BR><B>SFC_GET_FORMAT_SUBTYPE_COUNT</B></H2>
974 <P>
975 Retrieve the number of subformats.
976 </P>
977 <P>
978 Parameters:
979 </P>
980 <PRE>
981 sndfile : Not used.
982 cmd : SFC_GET_FORMAT_SUBTYPE_COUNT
983 data : a pointer to an int
984 datasize : sizeof (int)
985 </PRE>
986 <P>
987 Example:
988 </P>
989 <PRE>
990 int count ;
991 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &amp;count, sizeof (int)) ;
992 </PRE>
993 <DL>
994 <DT>Return value: </DT>
995 <DD>0
996 </DL>
997
998 <!-- ========================================================================= -->
999 <A NAME="SFC_GET_FORMAT_SUBTYPE"></A>
1000 <H2><BR><B>SFC_GET_FORMAT_SUBTYPE</B></H2>
1001 <P>
1002 Enumerate the subtypes (this function does not translate a subtype into
1003 a string describing that subtype).
1004 A typical use case might be retrieving a string description of all subtypes
1005 so that a dialog box can be filled in.
1006 </P>
1007 <P>
1008
1009 </P>
1010 <P>
1011 Parameters:
1012 </P>
1013 <PRE>
1014 sndfile : Not used.
1015 cmd : SFC_GET_FORMAT_SUBTYPE
1016 data : a pointer to an SF_FORMAT_INFO struct
1017 datasize : sizeof (SF_FORMAT_INFO)
1018 </PRE>
1019 <P>
1020 Example 1: Retrieve all sybtypes supported by the WAV format.
1021 </P>
1022 <PRE>
1023 SF_FORMAT_INFO format_info ;
1024 int k, count ;
1025
1026 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &amp;count, sizeof (int)) ;
1027
1028 for (k = 0 ; k &lt; count ; k++)
1029 { format_info.format = k ;
1030 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &amp;format_info, sizeof (format_info)) ;
1031 if (! sf_format_check (format_info.format | SF_FORMAT_WAV))
1032 continue ;
1033 printf ("%08x %s\n", format_info.format, format_info.name) ;
1034 } ;
1035 </PRE>
1036 <P>
1037 Example 2: Print a string describing the SF_FORMAT_PCM_16 subtype.
1038 </P>
1039 <PRE>
1040 SF_FORMAT_INFO format_info ;
1041 int k, count ;
1042
1043 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &amp;count, sizeof (int)) ;
1044
1045 for (k = 0 ; k &lt; count ; k++)
1046 { format_info.format = k ;
1047 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &amp;format_info, sizeof (format_info)) ;
1048 if (format_info.format == SF_FORMAT_PCM_16)
1049 { printf ("%08x %s\n", format_info.format, format_info.name) ;
1050 break ;
1051 } ;
1052 } ;
1053 </PRE>
1054 <P>
1055 For a more comprehensive example, see the program list_formats.c in the examples/
1056 directory of the libsndfile source code distribution.
1057 </P>
1058 <DL>
1059 <DT>Return value: </DT>
1060 <DD>0 on success and non-zero otherwise.
1061 <DD>The value of the format field will be one of the major format identifiers such as
1062 SF_FORMAT_WAV or SF_FORMAT_AIFF.
1063 <DD>The name field will contain a char* pointer to the name of the string; for instance
1064 "WAV (Microsoft)" or "AIFF (Apple/SGI)".
1065 <DD>The extension field will be a NULL pointer.
1066 </DL>
1067
1068 <!-- ========================================================================= -->
1069 <A NAME="SFC_SET_ADD_PEAK_CHUNK"></A>
1070 <H2><BR><B>SFC_SET_ADD_PEAK_CHUNK</B></H2>
1071 <P>
1072 By default, WAV and AIFF files which contain floating point data (subtype SF_FORMAT_FLOAT
1073 or SF_FORMAT_DOUBLE) have a PEAK chunk.
1074 By using this command, the addition of a PEAK chunk can be turned on or off.
1075 </P>
1076 <P>
1077 Note : This call must be made before any data is written to the file.
1078 </P>
1079 <P>
1080 Parameters:
1081 <PRE>
1082 sndfile : A valid SNDFILE* pointer
1083 cmd : SFC_SET_ADD_PEAK_CHUNK
1084 data : Not used (should be NULL)
1085 datasize : TRUE or FALSE.
1086 </PRE>
1087 <P>
1088 Example:
1089 </P>
1090 <PRE>
1091 /* Turn on the PEAK chunk. */
1092 sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;
1093
1094 /* Turn off the PEAK chunk. */
1095 sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ;
1096 </PRE>
1097 <DL>
1098 <DT>Return value:</DT>
1099 <DD>Returns SF_TRUE if the peak chunk will be written after this call.
1100 <DD>Returns SF_FALSE if the peak chunk will not be written after this call.
1101 </DL>
1102
1103 <!-- ========================================================================= -->
1104 <A NAME="SFC_UPDATE_HEADER_NOW"></A>
1105 <H2><BR><B>SFC_UPDATE_HEADER_NOW</B></H2>
1106 <P>
1107 The header of an audio file is normally written by libsndfile when the file is
1108 closed using <B>sf_close()</B>.
1109 </P>
1110 <P>
1111 There are however situations where large files are being generated and it would
1112 be nice to have valid data in the header before the file is complete.
1113 Using this command will update the file header to reflect the amount of data written
1114 to the file so far.
1115 Other programs opening the file for read (before any more data is written) will
1116 then read a valid sound file header.
1117 </P>
1118 <P>
1119 Parameters:
1120 <PRE>
1121 sndfile : A valid SNDFILE* pointer
1122 cmd : SFC_UPDATE_HEADER_NOW
1123 data : Not used (should be NULL)
1124 datasize : Not used.
1125 </PRE>
1126 <P>
1127 Example:
1128 </P>
1129 <PRE>
1130 /* Update the header now. */
1131 sf_command (sndfile, SFC_UPDATE_HEADER_NOW, NULL, 0) ;
1132 </PRE>
1133 <DL>
1134 <DT>Return value:</DT>
1135 <DD>0
1136 </DL>
1137
1138 <!-- ========================================================================= -->
1139 <A NAME="SFC_SET_UPDATE_HEADER_AUTO"></A>
1140 <H2><BR><B>SFC_SET_UPDATE_HEADER_AUTO</B></H2>
1141 <P>
1142 Similar to SFC_UPDATE_HEADER_NOW but updates the header at the end of every call
1143 to the <B>sf_write*</B> functions.
1144 </P>
1145 <P>
1146 Parameters:
1147 <PRE>
1148 sndfile : A valid SNDFILE* pointer
1149 cmd : SFC_SET_UPDATE_HEADER_AUTO
1150 data : Not used (should be NULL)
1151 datasize : SF_TRUE or SF_FALSE
1152 </PRE>
1153 <P>
1154 Example:
1155 </P>
1156 <PRE>
1157 /* Turn on auto header update. */
1158 sf_command (sndfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) ;
1159
1160 /* Turn off auto header update. */
1161 sf_command (sndfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_FALSE) ;
1162 </PRE>
1163 <DL>
1164 <DT>Return value:</DT>
1165 <DD>TRUE if auto update header is now on; FALSE otherwise.
1166 </DL>
1167
1168 <!-- ========================================================================= -->
1169 <A NAME="SFC_FILE_TRUNCATE"></A>
1170 <H2><BR><B>SFC_FILE_TRUNCATE</B></H2>
1171 <P>
1172 Truncate a file that was opened for write or read/write.
1173 </P>
1174 <P>
1175 Parameters:
1176 <PRE>
1177 sndfile : A valid SNDFILE* pointer
1178 cmd : SFC_FILE_TRUNCATE
1179 data : A pointer to an sf_count_t.
1180 datasize : sizeof (sf_count_t)
1181 </PRE>
1182
1183 <P>
1184 Truncate the file to the number of frames specified by the sf_count_t pointed
1185 to by data.
1186 After this command, both the read and the write pointer will be
1187 at the new end of the file.
1188 This command will fail (returning non-zero) if the requested truncate position
1189 is beyond the end of the file.
1190 </P>
1191 <P>
1192 Example:
1193 </P>
1194 <PRE>
1195 /* Truncate the file to a length of 20 frames. */
1196 sf_count_t frames = 20 ;
1197 sf_command (sndfile, SFC_FILE_TRUNCATE, &amp;frames, sizeof (frames)) ;
1198 </PRE>
1199 <DL>
1200 <DT>Return value:</DT>
1201 <DD>Zero on sucess, non-zero otherwise.
1202 </DL>
1203
1204 <!-- ========================================================================= -->
1205 <A NAME="SFC_SET_RAW_START_OFFSET"></A>
1206 <H2><BR><B>SFC_SET_RAW_START_OFFSET</B></H2>
1207 <P>
1208 Change the data start offset for files opened up as SF_FORMAT_RAW.
1209 </P>
1210 <P>
1211 Parameters:
1212 <PRE>
1213 sndfile : A valid SNDFILE* pointer
1214 cmd : SFC_SET_RAW_START_OFFSET
1215 data : A pointer to an sf_count_t.
1216 datasize : sizeof (sf_count_t)
1217 </PRE>
1218
1219 <P>
1220 For a file opened as format SF_FORMAT_RAW, set the data offset to the value
1221 given by data.
1222 </P>
1223 <P>
1224 Example:
1225 </P>
1226 <PRE>
1227 /* Reset the data offset to 5 bytes from the start of the file. */
1228 sf_count_t offset = 5 ;
1229 sf_command (sndfile, SFC_SET_RAW_START_OFFSET, &amp;offset, sizeof (offset)) ;
1230 </PRE>
1231 <DL>
1232 <DT>Return value:</DT>
1233 <DD>Zero on success, non-zero otherwise.
1234 </DL>
1235
1236 <!-- ========================================================================= -->
1237 <A NAME="SFC_SET_CLIPPING"></A>
1238 <H2><BR><B>SFC_SET_CLIPPING</B></H2>
1239 <P>
1240 Turn on/off automatic clipping when doing floating point to integer conversion.
1241 </P>
1242 <P>
1243 Parameters:
1244 <PRE>
1245 sndfile : A valid SNDFILE* pointer
1246 cmd : SFC_SET_CLIPPING
1247 data : NULL
1248 datasize : SF_TRUE or SF_FALSE.
1249 </PRE>
1250
1251 <P>
1252 Turn on (datasize == SF_TRUE) or off (datasize == SF_FALSE) clipping.
1253 </P>
1254 <P>
1255 Example:
1256 </P>
1257 <PRE>
1258 sf_command (sndfile, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
1259 </PRE>
1260 <DL>
1261 <DT>Return value:</DT>
1262 <DD>Clipping mode (SF_TRUE or SF_FALSE).
1263 </DL>
1264
1265
1266 <!-- ========================================================================= -->
1267 <A NAME="SFC_GET_CLIPPING"></A>
1268 <H2><BR><B>SFC_GET_CLIPPING</B></H2>
1269 <P>
1270 Turn on/off automatic clipping when doing floating point to integer conversion.
1271 </P>
1272 <P>
1273 Parameters:
1274 <PRE>
1275 sndfile : A valid SNDFILE* pointer
1276 cmd : SFC_GET_CLIPPING
1277 data : NULL
1278 datasize : 0
1279 </PRE>
1280
1281 <P>
1282 Retrieve the current cliiping setting.
1283 </P>
1284 <P>
1285 Example:
1286 </P>
1287 <PRE>
1288 sf_command (sndfile, SFC_GET_CLIPPING, NULL, 0) ;
1289 </PRE>
1290 <DL>
1291 <DT>Return value:</DT>
1292 <DD>Clipping mode (SF_TRUE or SF_FALSE).
1293 </DL>
1294
1295 <!-- ========================================================================= -->
1296 <A NAME="SFC_GET_EMBED_FILE_INFO"></A>
1297 <H2><BR><B>SFC_GET_EMBED_FILE_INFO</B></H2>
1298 <P>
1299 Get the file offset and file length of a file enbedded within another
1300 larger file.
1301 </P>
1302 <P>
1303 Parameters:
1304 <PRE>
1305 sndfile : A valid SNDFILE* pointer
1306 cmd : SFC_GET_EMBED_FILE_INFO
1307 data : a pointer to an SF_EMBED_FILE_INFO struct
1308 datasize : sizeof (SF_EMBED_FILE_INFO)
1309 </PRE>
1310 <P>
1311 The SF_EMBED_FILE_INFO struct is defined in &lt;sndfile.h&gt; as:
1312 </P>
1313 <PRE>
1314 typedef struct
1315 { sf_count_t offset ;
1316 sf_count_t length ;
1317 } SF_EMBED_FILE_INFO ;
1318 </PRE>
1319 <DL>
1320 <DT>Return value: </DT>
1321 <DD>0 on success and non-zero otherwise.
1322 <DD>The value of the offset field of the SF_EMBED_FILE_INFO struct will be
1323 the offsets in bytes from the start of the outer file to the start of
1324 the audio file.
1325 <DD>The value of the offset field of the SF_EMBED_FILE_INFO struct will be
1326 the length in bytes of the embedded file.
1327 </DL>
1328
1329
1330
1331 <!-- ========================================================================= -->
1332 <A NAME="SFC_WAVEX_GET_AMBISONIC"></A>
1333 <H2><BR><B>SFC_WAVEX_GET_AMBISONIC</B></H2>
1334 <P>
1335 Test if the current file has the GUID of a WAVEX file for any of the Ambisonic
1336 formats.
1337 </P>
1338 <P>
1339 Parameters:
1340 <PRE>
1341 sndfile : A valid SNDFILE* pointer
1342 cmd : SFC_WAVEX_GET_AMBISONIC
1343 data : NULL
1344 datasize : 0
1345 </PRE>
1346 <P>
1347 The Ambisonic WAVEX formats are defined here :
1348 <A HREF="http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html">
1349 http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html</A>.
1350 </P>
1351 <DL>
1352 <DT>Return value: </DT>
1353 <DD>SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT or zero if the file format
1354 does not support ambisonic formats.
1355 </DL>
1356
1357 <!-- ========================================================================= -->
1358 <A NAME="SFC_WAVEX_SET_AMBISONIC"></A>
1359 <H2><BR><B>SFC_WAVEX_SET_AMBISONIC</B></H2>
1360 <P>
1361 Set the GUID of a new WAVEX file to indicate an Ambisonics format.
1362 </P>
1363 <P>
1364 Parameters:
1365 <PRE>
1366 sndfile : A valid SNDFILE* pointer
1367 cmd : SFC_WAVEX_SET_AMBISONIC
1368 data : NULL
1369 datasize : SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT
1370 </PRE>
1371 <P>
1372 Turn on (SF_AMBISONIC_B_FORMAT) or off (SF_AMBISONIC_NONE) encoding.
1373 This command is currently only supported for files with SF_FORMAT_WAVEX format.
1374 </P>
1375 <P>
1376 The Ambisonic WAVEX formats are defined here :
1377 <A HREF="http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html">
1378 http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html</A>.
1379 </P>
1380 <DL>
1381 <DT>Return value: </DT>
1382 <DD>Return the ambisonic value that has just been set or zero if the file
1383 format does not support ambisonic encoding.
1384 </DL>
1385
1386 <!-- ========================================================================= -->
1387 <A NAME="SFC_SET_VBR_ENCODING_QUALITY"></A>
1388 <H2><BR><B>SFC_SET_VBR_ENCODING_QUALITY</B></H2>
1389 <P>
1390 Set the Variable Bit Rate encoding quality.
1391 The encoding quality value should be between 0.0 (lowest quality) and 1.0
1392 (highest quality).
1393 Currenly this command is only implemented for FLAC and Ogg/Vorbis files.
1394 It has no effect on un-compressed file formats.
1395 </P>
1396 <P>
1397 Parameters:
1398 <PRE>
1399 sndfile : A valid SNDFILE* pointer
1400 cmd : SFC_SET_VBR_ENCODING_QUALITY
1401 data : A pointer to a double value
1402 datasize : sizeof (double)
1403 </PRE>
1404 <P>
1405 The command must be sent before any audio data is written to the file.
1406 </P>
1407 <P>
1408 </P>
1409 <DL>
1410 <DT>Return value:</DT>
1411 <dd>SF_TRUE if VBR encoding quality was set.
1412 SF_FALSE otherwise.
1413 </DL>
1414
1415 <!-- ========================================================================= -->
1416 <A NAME="SFC_SET_OGG_PAGE_LATENCY_MS"></A>
1417 <H2><BR><B>SFC_SET_OGG_PAGE_LATENCY_MS</B></H2>
1418 <P>
1419 Set page latency for Ogg Opus file in milliseconds.
1420 The value should be between 50.0 and 1600.0.
1421 This command is only implemented for Ogg Opus files.
1422 </P>
1423 <P>
1424 Parameters:
1425 <PRE>
1426 sndfile : A valid SNDFILE* pointer
1427 cmd : SFC_SET_OGG_PAGE_LATENCY_MS
1428 data : A pointer to a double value
1429 datasize : sizeof (double)
1430 </PRE>
1431 <P>
1432 </P>
1433 <DL>
1434 <DT>Return value:</DT>
1435 <dd>0 on success and non-zero otherwise.
1436 </DL>
1437
1438 <!-- ========================================================================= -->
1439 <A NAME="SFC_SET_COMPRESSION_LEVEL"></A>
1440 <H2><BR><B>SFC_SET_COMPRESSION_LEVEL</B></H2>
1441 <P>
1442 Set the compression level.
1443 The compression level should be between 0.0 (minimum compression level) and 1.0
1444 (highest compression level).
1445 Currenly this command is only implemented for FLAC and Ogg/Vorbis files.
1446 It has no effect on un-compressed file formats.
1447 </P>
1448 <P>
1449 Parameters:
1450 <PRE>
1451 sndfile : A valid SNDFILE* pointer
1452 cmd : SFC_SET_COMPRESSION_LEVEL
1453 data : A pointer to a double value
1454 datasize : sizeof (double)
1455 </PRE>
1456 <P>
1457 The command must be sent before any audio data is written to the file.
1458 </P>
1459 <P>
1460 </P>
1461 <DL>
1462 <DT>Return value:</DT>
1463 <dd>SF_TRUE if compression level was set.
1464 SF_FALSE otherwise.
1465 </DL>
1466
1467 <!-- ========================================================================= -->
1468 <A NAME="SFC_RAW_DATA_NEEDS_ENDSWAP"></A>
1469 <H2><BR><B>SFC_RAW_DATA_NEEDS_ENDSWAP</B></H2>
1470 <P>
1471 Determine if raw data read using
1472 <a href="api.html#raw">
1473 sf_read_raw</a>
1474 needs to be end swapped on the host CPU.
1475 </P>
1476 <P>
1477 For instance, will return SF_TRUE on when reading WAV containing
1478 SF_FORMAT_PCM_16 data on a big endian machine and SF_FALSE on a little endian
1479 machine.
1480 </P>
1481 <P>
1482 Parameters:
1483 <PRE>
1484 sndfile : A valid SNDFILE* pointer
1485 cmd : SFC_RAW_DATA_NEEDS_ENDSWAP
1486 data : NULL
1487 datasize : 0
1488 </PRE>
1489
1490 <DL>
1491 <DT>Return value: </DT>
1492 <DD>SF_TRUE or SF_FALSE
1493 </DL>
1494
1495
1496 <!-- ========================================================================= -->
1497 <A NAME="SFC_GET_BROADCAST_INFO"></A>
1498 <H2><BR><B>SFC_GET_BROADCAST_INFO</B></H2>
1499 <P>
1500 Retrieve the Broadcast Extension Chunk from WAV (and related) files.
1501 </P>
1502 <p>
1503 Parameters:
1504 </p>
1505 <PRE>
1506 sndfile : A valid SNDFILE* pointer
1507 cmd : SFC_GET_BROADCAST_INFO
1508 data : a pointer to an SF_BROADCAST_INFO struct
1509 datasize : sizeof (SF_BROADCAST_INFO)
1510 </PRE>
1511 <P>
1512 The SF_BROADCAST_INFO struct is defined in &lt;sndfile.h&gt; as:
1513 </P>
1514 <PRE>
1515 typedef struct
1516 { char description [256] ;
1517 char originator [32] ;
1518 char originator_reference [32] ;
1519 char origination_date [10] ;
1520 char origination_time [8] ;
1521 unsigned int time_reference_low ;
1522 unsigned int time_reference_high ;
1523 short version ;
1524 char umid [64] ;
1525 char reserved [190] ;
1526 unsigned int coding_history_size ;
1527 char coding_history [256] ;
1528 } SF_BROADCAST_INFO ;
1529 </PRE>
1530
1531 <DL>
1532 <DT>Return value: </DT>
1533 <DD>SF_TRUE if the file contained a Broadcast Extension chunk or SF_FALSE
1534 otherwise.
1535 </DL>
1536
1537 <!-- ========================================================================= -->
1538 <A NAME="SFC_SET_BROADCAST_INFO"></A>
1539 <H2><BR><B>SFC_SET_BROADCAST_INFO</B></H2>
1540 <P>
1541 Set the Broadcast Extension Chunk for WAV (and related) files.
1542 </P>
1543 <p>
1544 Parameters:
1545 </p>
1546 <PRE>
1547 sndfile : A valid SNDFILE* pointer
1548 cmd : SFC_SET_BROADCAST_INFO
1549 data : a pointer to an SF_BROADCAST_INFO struct
1550 datasize : sizeof (SF_BROADCAST_INFO)
1551 </PRE>
1552
1553 <DL>
1554 <DT>Return value: </DT>
1555 <DD>SF_TRUE if setting the Broadcast Extension chunk was successful and SF_FALSE
1556 otherwise.
1557
1558 </DL>
1559
1560 <!-- ========================================================================= -->
1561 <A NAME="SFC_GET_CHANNEL_MAP_INFO"></A>
1562 <H2><BR><B>SFC_GET_CHANNEL_MAP_INFO</B></H2>
1563 <P>
1564 Retrieve the channel map contained in an AIFF or CAF Channel Layout chunk.
1565 </P>
1566 <p>
1567 Parameters:
1568 </p>
1569 <PRE>
1570 sndfile : A valid SNDFILE* pointer
1571 cmd : SFC_GET_CHANNEL_MAP_INFO
1572 data : a pointer to an array of int, the same size as the number of channels in the file
1573 datasize : number of channels * sizeof (int)
1574 </PRE>
1575 <P>
1576 Channel map positions are defined in an enum in &lt;sndfile.h&gt;.
1577 </P>
1578
1579 <DL>
1580 <DT>Return value: </DT>
1581 <DD>SF_TRUE if the file contained a Channel Layout chunk or SF_FALSE otherwise.
1582 </DL>
1583
1584 <!-- ========================================================================= -->
1585 <A NAME="SFC_SET_CHANNEL_MAP_INFO"></A>
1586 <H2><BR><B>SFC_SET_CHANNEL_MAP_INFO</B></H2>
1587 <P>
1588 Set the channel map contained in an AIFF or CAF Channel Layout chunk.
1589 </P>
1590 <p>
1591 Parameters:
1592 </p>
1593 <PRE>
1594 sndfile : A valid SNDFILE* pointer
1595 cmd : SFC_SET_CHANNEL_MAP_INFO
1596 data : a pointer to an array of int, the same size as the number of channels in the file
1597 datasize : number of channels * sizeof (int)
1598 </PRE>
1599
1600 <DL>
1601 <DT>Return value: </DT>
1602 <DD>SF_TRUE if setting the Channel Layout chunk was successful and SF_FALSE otherwise.
1603
1604 </DL>
1605
1606
1607 <!-- ========================================================================= -->
1608 <A NAME="SFC_GET_CART_INFO"></A>
1609 <H2><BR><B>SFC_GET_CART_INFO</B></H2>
1610 <P>Retrieve the Cart Chunk from WAV (and related) files. Based on AES46 standard for CartChunk (see <a href="http://www.cartchunk.org/">CartChunk.org</a> for more information.
1611 </P>
1612 <p>
1613 Parameters:
1614 </p>
1615 <PRE>
1616 sndfile : A valid SNDFILE* pointer
1617 cmd : SFC_GET_CART_INFO
1618 data : a pointer to an SF_CART_INFO struct
1619 datasize : sizeof (SF_CART_INFO)
1620 </PRE>
1621 <P>
1622 The SF_CART_INFO struct is defined in &lt;sndfile.h&gt; as:
1623 </P>
1624 <PRE>
1625 #define SF_CART_INFO_VAR(p_tag_text_size) \
1626 struct
1627 { char version [4] ;
1628 char title [64] ;
1629 char artist [64] ;
1630 char cut_id [64] ;
1631 char client_id [64] ;
1632 char category [64] ;
1633 char classification [64] ;
1634 char out_cue [64] ;
1635 char start_date [10] ;
1636 char start_time [8] ;
1637 char end_date [10] ;
1638 char end_time [8] ;
1639 char producer_app_id [64] ;
1640 char producer_app_version [64] ;
1641 char user_def [64] ;
1642 long level_reference ;
1643 SF_CART_TIMER post_timers [8] ;
1644 char reserved [276] ;
1645 char url [1024] ;
1646 unsigned int tag_text_size ;
1647 char tag_text[p_tag_text_size] ;
1648 }
1649 </PRE>
1650
1651 <DL>
1652 <DT>Return value: </DT>
1653 <DD>SF_TRUE if the file contained a Cart chunk or SF_FALSE
1654 otherwise.
1655 </DL>
1656
1657 <!-- ========================================================================= -->
1658 <A NAME="SFC_SET_CART_INFO"></A>
1659 <H2><BR><B>SFC_SET_CART_INFO</B></H2>
1660 <P>
1661 Set the Cart Chunk for WAV (and related) files.
1662 </P>
1663 <p>
1664 Parameters:
1665 </p>
1666 <PRE>
1667 sndfile : A valid SNDFILE* pointer
1668 cmd : SFC_SET_CART_INFO
1669 data : a pointer to an SF_CART_INFO struct
1670 datasize : sizeof (SF_CART_INFO)
1671 </PRE>
1672
1673 <DL>
1674 <DT>Return value: </DT>
1675 <DD>SF_TRUE if setting the Cart chunk was successful and SF_FALSE
1676 otherwise.
1677 </DL>
1678 <!-- ========================================================================= -->
1679
1680 <A NAME="SFC_GET_LOOP_INFO"></A>
1681 <H2><BR><B>SFC_GET_LOOP_INFO</B></H2>
1682 <P>
1683 Retrieve loop information for file including time signature, length in
1684 beats and original MIDI base note
1685 </P>
1686 <p>
1687 Parameters:
1688 </p>
1689 <PRE>
1690 sndfile : A valid SNDFILE* pointer
1691 cmd : SFC_GET_LOOP_INFO
1692 data : a pointer to an SF_LOOP_INFO struct
1693 datasize : sizeof (SF_LOOP_INFO)
1694 </PRE>
1695 <P>
1696 The SF_BROADCAST_INFO struct is defined in &lt;sndfile.h&gt; as:
1697 </P>
1698 <PRE>
1699 typedef struct
1700 { short time_sig_num ; /* any positive integer > 0 */
1701 short time_sig_den ; /* any positive power of 2 > 0 */
1702 int loop_mode ; /* see SF_LOOP enum */
1703
1704 int num_beats ; /* this is NOT the amount of quarter notes !!!*/
1705 /* a full bar of 4/4 is 4 beats */
1706 /* a full bar of 7/8 is 7 beats */
1707
1708 float bpm ; /* suggestion, as it can be calculated using other fields:*/
1709 /* file's lenght, file's sampleRate and our time_sig_den*/
1710 /* -> bpms are always the amount of _quarter notes_ per minute */
1711
1712 int root_key ; /* MIDI note, or -1 for None */
1713 int future [6] ;
1714 } SF_LOOP_INFO ;
1715 </PRE>
1716 <P>
1717 Example:
1718 </P>
1719 <PRE>
1720 SF_LOOP_INFO loop;
1721 sf_command (sndfile, SFC_GET_LOOP_INFO, &amp;loop, sizeof (loop)) ;
1722 </PRE>
1723 <DL>
1724 <DT>Return value:</DT>
1725 <DD>SF_TRUE if the file header contains loop information for the file.
1726 SF_FALSE otherwise.
1727 </DL>
1728
1729 <!-- ========================================================================= -->
1730
1731
1732 <A NAME="SFC_GET_INSTRUMENT"></A>
1733 <H2><BR><B>SFC_GET_INSTRUMENT</B></H2>
1734 <P>
1735 Retrieve instrument information from file including MIDI base note,
1736 keyboard mapping and looping informations(start/stop and mode).
1737 </P>
1738 <p>
1739 Parameters:
1740 </p>
1741 <PRE>
1742 sndfile : A valid SNDFILE* pointer
1743 cmd : SFC_GET_INSTRUMENT
1744 data : a pointer to an SF_INSTRUMENT struct
1745 datasize : sizeof (SF_INSTRUMENT)
1746 </PRE>
1747
1748 <P>
1749 The SF_INSTRUMENT struct is defined in &lt;sndfile.h&gt; as:
1750 </P>
1751 <PRE>
1752 enum
1753 { /*
1754 ** The loop mode field in SF_INSTRUMENT will be one of the following.
1755 */
1756 SF_LOOP_NONE = 800,
1757 SF_LOOP_FORWARD,
1758 SF_LOOP_BACKWARD,
1759 SF_LOOP_ALTERNATING
1760 } ;
1761
1762 typedef struct
1763 { int gain ;
1764 char basenote, detune ;
1765 char velocity_lo, velocity_hi ;
1766 char key_lo, key_hi ;
1767 int loop_count ;
1768
1769 struct
1770 { int mode ;
1771 unsigned int start ;
1772 unsigned int end ;
1773 unsigned int count ;
1774 } loops [16] ; /* make variable in a sensible way */
1775 } SF_INSTRUMENT ;
1776 </PRE>
1777
1778 <P>
1779 Example:
1780 </P>
1781 <PRE>
1782 SF_INSTRUMENT inst ;
1783 sf_command (sndfile, SFC_GET_INSTRUMENT, &amp;inst, sizeof (inst)) ;
1784 </PRE>
1785 <DL>
1786 <DT>Return value:</DT>
1787 <dd>SF_TRUE if the file header contains instrument information for the
1788 file. SF_FALSE otherwise.
1789 </DL>
1790
1791 <!-- ========================================================================= -->
1792
1793
1794 <A NAME="SFC_SET_INSTRUMENT"></A>
1795 <H2><BR><B>SFC_SET_INSTRUMENT</B></H2>
1796 <P>
1797 Set the instrument information for the file.
1798 </P>
1799 <p>
1800 Parameters:
1801 </p>
1802 <PRE>
1803 sndfile : A valid SNDFILE* pointer
1804 cmd : SFC_SET_INSTRUMENT
1805 data : a pointer to an SF_INSTRUMENT struct
1806 datasize : sizeof (SF_INSTRUMENT)
1807 </PRE>
1808 <P>
1809 Example:
1810 </P>
1811 <PRE>
1812 SF_INSTRUMENT inst ;
1813 sf_command (sndfile, SFC_SET_INSTRUMENT, &amp;inst, sizeof (inst)) ;
1814 </PRE>
1815 <DL>
1816 <DT>Return value:</DT>
1817 <dd>SF_TRUE if the file header contains instrument information for the
1818 file. SF_FALSE otherwise.
1819 </DL>
1820
1821
1822 <!-- ========================================================================= -->
1823
1824 <A NAME="SFC_GET_CUE_COUNT"></A>
1825 <H2><BR><B>SFC_GET_CUE_COUNT</B></H2>
1826 <P>
1827 Retrieve the number of cue markers available for retrieval using the
1828 SFC_GET_CUE command.
1829 </P>
1830 <P>
1831 Parameters:
1832 </P>
1833 <PRE>
1834 sndfile : A valid SNDFILE* pointer
1835 cmd : SFC_GET_CUE_COUNT
1836 data : a pointer to a uint32_t
1837 datasize : sizeof (uint32_t)
1838 </PRE>
1839
1840
1841 <P>
1842 Example:
1843 </P>
1844 <PRE>
1845 uint32_t cue_count ;
1846 sf_command (sndfile, SFC_GET_CUE_COUNT, &amp;cue_count, sizeof (cue_count)) ;
1847 </PRE>
1848 <DL>
1849 <DT>Return value:</DT>
1850 <dd>SF_TRUE if the file header contains cue marker information for the
1851 file. SF_FALSE otherwise.
1852 </DL>
1853
1854 <!-- ========================================================================= -->
1855
1856 <A NAME="SFC_GET_CUE"></A>
1857 <H2><BR><B>SFC_GET_CUE</B></H2>
1858 <P>
1859 Retrieve cue marker information from file.
1860 </P>
1861 <P>
1862 Parameters:
1863 </P>
1864 <PRE>
1865 sndfile : A valid SNDFILE* pointer
1866 cmd : SFC_GET_CUE
1867 data : a pointer to an SF_CUES struct
1868 datasize : sizeof (SF_CUES)
1869 </PRE>
1870
1871 <P>
1872 The SF_CUES struct is defined in &lt;sndfile.h&gt; as:
1873 </P>
1874 <PRE>
1875 typedef struct
1876 { int cue_count ;
1877
1878 struct
1879 { int32_t indx ;
1880 uint32_t position ;
1881 int32_t fcc_chunk ;
1882 int32_t chunk_start ;
1883 int32_t block_start ;
1884 uint32_t sample_offset ;
1885 char name [256] ;
1886 } cue_points [100] ;
1887 } SF_CUES ;
1888 </PRE>
1889
1890 <P>
1891 There is also an SF_CUES_VAR #define that allows reading/writing more than 100
1892 cue markers.
1893 </P>
1894
1895 <P>
1896 Example:
1897 </P>
1898 <PRE>
1899 SF_CUES cues ;
1900 sf_command (sndfile, SFC_GET_CUE, &amp;cues, sizeof (cues)) ;
1901 </PRE>
1902 <DL>
1903 <DT>Return value:</DT>
1904 <dd>SF_TRUE if the file header contains cue marker information for the
1905 file. SF_FALSE otherwise.
1906 </DL>
1907
1908
1909 <!-- ========================================================================= -->
1910
1911
1912 <A NAME="SFC_SET_CUE"></A>
1913 <H2><BR><B>SFC_SET_CUE</B></H2>
1914 <P>
1915 Set the cue marker information for the file.
1916 </P>
1917 <P>
1918 Parameters:
1919 </P>
1920 <PRE>
1921 sndfile : A valid SNDFILE* pointer
1922 cmd : SFC_SET_CUE
1923 data : a pointer to an SF_CUES struct
1924 datasize : sizeof (SF_CUES)
1925 </PRE>
1926 <P>
1927 Example:
1928 </P>
1929 <PRE>
1930 SF_CUES cues ;
1931 sf_command (sndfile, SFC_SET_CUE, &amp;cues, sizeof (cues)) ;
1932 </PRE>
1933 <DL>
1934 <DT>Return value:</DT>
1935 <dd>SF_TRUE if the file header contains cue marker information for the
1936 file. SF_FALSE otherwise.
1937 </DL>
1938
1939
1940 <!-- ========================================================================= -->
1941
1942
1943 <A NAME="SFC_RF64_AUTO_DOWNGRADE"></A>
1944 <H2><BR><B>SFC_RF64_AUTO_DOWNGRADE</B></H2>
1945 <P>
1946 Enable auto downgrade from RF64 to WAV.
1947 </P>
1948 <P>
1949 The EBU recomendation is that when writing RF64 files and the resulting file is
1950 less than 4Gig in size, it should be downgraded to a WAV file (WAV files have a
1951 maximum size of 4Gig).
1952 libsndfile doesn't follow the EBU recommendations exactly, , mainly because the
1953 test suite needs to be able test reading/writing RF64 files without having to
1954 generate files larger than 4 gigabytes.
1955 </P>
1956 <p>
1957 Note: This command should be issued before the first bit of audio data has been
1958 written to the file.
1959 Calling this command after audio data has been written will return the current
1960 value of this setting, but will not allow it to be changed.
1961 </p>
1962 <p>
1963 Parameters:
1964 </p>
1965 <PRE>
1966 sndfile : A valid SNDFILE* pointer
1967 cmd : SFC_RF64_AUTO_DOWNGRADE
1968 data : NULL
1969 datasize : SF_TRUE or SF_FALSE
1970 </PRE>
1971 <P>
1972 Example:
1973 </P>
1974 <PRE>
1975 /* Enable auto downgrade on file close. */
1976 sf_command (sndfile, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) ;
1977 </PRE>
1978 <DL>
1979 <DT>Return value:</DT>
1980 <dd>Returns SF_TRUE if SFC_RF64_AUTO_DOWNGRADE is set and SF_FALSE
1981 otherwise.
1982 </DL>
1983
1984
1985 <!-- ========================================================================= -->
1986 <A NAME="SFC_GET_ORIGINAL_SAMPLERATE"></A>
1987 <H2><BR><B>SFC_GET_ORIGINAL_SAMPLERATE</B></H2>
1988 <P>
1989 Get original samplerate metadata.
1990 </P>
1991 <P>
1992 The Opus audio codec stores audio data independent of samplerate, but only
1993 supports encoding or decoding at 8000Hz, 12000Hz, 16000Hz, 24000HZ or 48000Hz.
1994 Opus includes a header field to record the original source input samplerate, and
1995 a samplerate converter may be used if needed.
1996 </p>
1997 <P>
1998 This command gets the original samplerate header field. It does not enable any
1999 (non-existent) samplerate conversion, nor change the current decoder samplerate.
2000 </P>
2001 <p>
2002 Parameters:
2003 </p>
2004 <PRE>
2005 sndfile : A valid SNDFILE* pointer
2006 cmd : SFC_GET_ORIGINAL_SAMPLERATE
2007 data : pointer to an integer
2008 datasize : sizeof (int)
2009 </PRE>
2010 <P>
2011 Example:
2012 </P>
2013 <PRE>
2014 /* Get the original sample rate */
2015 int original_samplerate ;
2016 sf_command (sndfile, SFC_GET_ORIGINAL_SAMPLERATE, &amp;original_samplerate, sizeof (original_samplerate)) ;
2017 </PRE>
2018 <DL>
2019 <DT>Return value:</DT>
2020 <dd>Returns SF_TRUE on success, SF_FALSE otherwise.
2021 <dd>The passed integer is set to the value of the original samplerate.
2022 </DL>
2023
2024
2025 <!-- ========================================================================= -->
2026 <A NAME="SFC_SET_ORIGINAL_SAMPLERATE"></A>
2027 <H2><BR><B>SFC_SET_ORIGINAL_SAMPLERATE</B></H2>
2028 <P>
2029 Set original samplerate metadata.
2030 </P>
2031 <P>
2032 The Opus audio codec stores audio data independent of samplerate, but only
2033 supports encoding or decoding at 8000Hz, 12000Hz, 16000Hz, 24000HZ or 48000Hz.
2034 Opus includes a header field to record the original source input samplerate, and
2035 a samplerate converter may be used if needed.
2036 </p>
2037 <p>
2038 When writing an Opus file this command sets the original samplerate header field
2039 to the provided value, which is then stored in the file. This has no effect on
2040 the current encoder samplerate.
2041 </p>
2042 <p>
2043 When reading an Opus file this command overrides the original samplerate value
2044 as read from the file. libsndfile uses this value to choose what samplerate
2045 to decode at, rounding up to the nearest valid Opus samplerate. After a
2046 successful call, the file samplerate and frames count may have changed.
2047 </p>
2048 <p>
2049 Note: This command should be issued before the first bit of audio data has been
2050 read from or written to the file.
2051 </p>
2052 <p>
2053 Parameters:
2054 </p>
2055 <PRE>
2056 sndfile : A valid SNDFILE* pointer
2057 cmd : SFC_SET_ORIGINAL_SAMPLERATE
2058 data : pointer to an integer
2059 datasize : sizeof (int)
2060 </PRE>
2061 <P>
2062 Example:
2063 </P>
2064 <PRE>
2065 /* Store the original sample rate as 44100 */
2066 int original_samplerate 44100;
2067 sf_command (sndfile, SFC_SET_ORIGINAL_SAMPLERATE, &amp;original_samplerate, sizeof (input_samplerate)) ;
2068 </PRE>
2069 <DL>
2070 <DT>Return value:</DT>
2071 <dd>Returns SF_TRUE on success, SF_FALSE otherwise.
2072 <dd>On write, can only succeed if no data has been written.
2073 <dd>On read, if successful, <a HREF="#SFC_GET_CURRENT_SF_INFO">SFC_GET_CURRENT_SF_INFO</a>
2074 should be called to determine the new frames count and samplerate
2075 </DL>
2076
2077
2078
2079 <!-- ========================================================================= -->
2080
2081
2082 <HR>
2083 <P>
2084 The libsndfile home page is here :
2085 <A HREF="http://www.mega-nerd.com/libsndfile/">
2086 http://www.mega-nerd.com/libsndfile/</A>.
2087 <BR>
2088 Version : 1.0.30
2089 </P>
2090
2091 </BODY>
2092 </HTML>
+0
-42
doc/development.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile Development
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
9 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
10 </HEAD>
11
12 <BODY>
13 <!-- pepper -->
14 <H1><BR>libsndfile Development</H1>
15 <!-- pepper -->
16 <P>
17 libsndfile is being developed by a small community of users and hackers.
18 People interested in helping can join the libsndfile-devel
19 <A HREF="lists.html">mailing list</A>
20 or raise an issue on Github.
21 </P>
22 <!-- pepper -->
23 <P>
24 The main repository can be found on Github:
25 </P>
26 <!-- pepper -->
27 <center>
28 <A HREF="https://github.com/erikd/libsndfile/">
29 https://github.com/erikd/libsndfile/</A>
30 </center>
31 <!-- pepper -->
32 <P>
33 and includes
34 <a href="https://github.com/erikd/libsndfile/blob/master/README.md">
35 instuctions</a>
36 on how to build libsndfile from the Git repo.
37 </P>
38 <!-- pepper -->
39 </BODY>
40 </HTML>
41
+0
-112
doc/donate.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile : donate.
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <!-- Another version at the bottom of the page. -->
9 <META NAME="Description" CONTENT="The libsndfile API.">
10 <META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
11 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
12 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
13 </HEAD>
14
15 <BODY>
16
17 <br/>
18 <!-- pepper -->
19 <center>
20 <IMG SRC="libsndfile.jpg" HEIGHT=98 WIDTH=367 ALT="libsndfile.jpg">
21 </center>
22 <!-- pepper -->
23 <br/>
24
25 <p>
26 Dear libsndfile user,
27 </p>
28 <!-- pepper -->
29 <p>
30 This library was developed on Linux for Linux. I am not a Windows user and
31 maintaining this library for Windows costs me significant amounts of time above
32 and beyond the time taken to make it work on Linux and Unix-like systems.
33 </p>
34 <!-- pepper -->
35 <p>
36 I therefore ask Windows users of libsndfile to donate to ensure that libsndfile's
37 support for Windows continues. As long as donations continue to flow in at a decent
38 rate, I will continue to release precompiled Windows binaries in sync with the
39 Linux/Unix version. If donations are poor, support for windows will fall behind.
40 </p>
41 <!-- pepper -->
42
43 <p>
44 You are free to donate any amount you chose.
45 As a guideline:
46 </p>
47 <!-- pepper -->
48 <ul>
49 <li>If you are simply a user of libsndfile that would like to ensure that
50 the development of libsndfile continues, a donation of $10US would be more
51 than adequate.
52 </li>
53 <li>If you are shareware author that distributes libsndfile with your app and
54 makes more than $1000 a year from your shareware, a one off donation of $50
55 would be appropriate.
56 </li>
57 <li>If your company is a commercial software house that distributes one or more
58 products that ship with libsndfile, a donation of $100 every second or third
59 year would be appropriate.
60 </li>
61 </ul>
62
63 <!-- pepper -->
64 <p>
65 Donations can be made in Bitcoin to the Bitcoin address
66 <b>15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ</b>
67
68 which can be verified by checking the following GPG signature.
69 </p>
70
71 <pre>
72 -----BEGIN PGP SIGNED MESSAGE-----
73 Hash: SHA256
74
75 libsndfile Bitcoin address : 15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ
76 -----BEGIN PGP SIGNATURE-----
77 Version: GnuPG v1.4.12 (GNU/Linux)
78
79 iQIcBAEBCAAGBQJSK7MUAAoJEEXYQ7zIiotIgXEP/R8hy65tlV7TiPw9bY9BklXS
80 /Vl8FU2RhDkBt61ZmxbfDTybyQ5Vce/3wWph15L4RvpoX1OyeintQFmwwuPjOGiq
81 eIz0nT9vDorG37Xdo5NZNBu9Tp1Od9MNtxFaAsRWFrDfvKEKljBHrcfM972cYrAp
82 DaFd0Ik+bHKom9iQXFB7TFd0w2V4uszVMQDUGqb/vRNeRURZS7ypeMNwc8tZyTKR
83 waEGMTa5sxxRjs7MqGRxSovnFT7JV3TNfdkBInUliIR/XvrudFR9J4Fiv+8Dk9P8
84 WNjm6uFxvgIqiu1G9bjrwwr+DsBju93ljGNcZoayAKw5vwbX6KTcCbc31k9dP8Hf
85 p6YdmPlZVKZmva+P3nLSJBTlxNu24Jm+ha+ZM/svDXTaPFWC8l5FP17kK0Bj8wCq
86 N7pDz6RchEn10u+HdhfT1XiUjxj0zNXrr0GGj9apjl0RlT0O49eBttV0oXIdBRLi
87 nTEaOWITpCgu7ggw1kWXHIWEncuiaSuJy/iH8PgNepWVj/6PxQRMrTqG4ux2Snk8
88 Ua4vO8YHLMZX/XvSUS7eMtgfM7AO6YjJ/ac9bQif9bh6LsYEVVklysMUin6ZRS7Z
89 Cms23FnqeQKtJOzdvqSJiV06lK6fP+tYdM4WSYn+AfL4IfYl2v48xXVU8XOOK9BH
90 bJPKMDcz1ZvfYtX5mSW1
91 =WXGB
92 -----END PGP SIGNATURE-----
93 </pre>
94
95 <p>
96 Thanks and regards,
97 <br/>
98 Erik de Castro Lopo
99 <br/>
100 Main libsndfile author and maintainer
101 </p>
102
103 <!-- pepper -->
104
105 <img src=
106 "/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"
107 HEIGHT=0 WIDTH=0 ALT="">
108
109
110 </BODY>
111 </HTML>
+0
-47
doc/embedded_files.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile : Embedded Sound Files.
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <META NAME="Description" CONTENT="The libsndfile API.">
9 <META NAME="Keywords" CONTENT="WAV AIFF AU libsndfile sound audio dsp Linux">
10 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
11 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
12 </HEAD>
13 <!-- pepper -->
14 <BODY>
15 <!-- pepper -->
16 <H1><B>Embedded Sound Files.</B></H1>
17
18 <P>
19 By using the open SNDFILE with a file descriptor function:
20 </P>
21 <!-- pepper -->
22 <PRE>
23 SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
24 </PRE>
25 <!-- pepper -->
26 <P>
27 it is possible to open sound files embedded within larger files.
28 There are however a couple of caveats:
29 <P>
30 <!-- pepper -->
31 <UL>
32 <LI> Read/Write mode (SFM_RDWR) is not supported.
33 <LI> Writing of embedded files is only supported at the end of the file.
34 <LI> Reading of embedded files is only supported at file offsets greater
35 than zero.
36 <LI> Not all file formats are supported (currently only WAV, AIFF and AU).
37 </UL>
38 <!-- pepper -->
39 <P>
40 The test program <B>multi_file_test.c</B> in the <B>tests/</B> directory of the
41 source code tarball shows how this functionality is used to read and write
42 embedded files.
43 </P>
44 <!-- pepper -->
45 </BODY>
46 </HTML>
+0
-545
doc/formats.html less more
0 <!DOCTYPE html>
1 <html lang="en">
2
3 <head>
4 <TITLE>
5 libsndfile: Supported formats
6 </TITLE>
7 <meta name="Author" content="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <meta name="Version" content="libsndfile-1.0.30">
9 <meta name="viewport" content="width=device-width, initial-scale=1.0">
10 <meta charset="UTF-8">
11 <link rel="stylesheet" href="libsndfile.css" type="text/css" media="all">
12 <link rel="stylesheet" href="print.css" type="text/css" media="print">
13 <style type="text/css">
14 td,
15 th {
16 text-align: center;
17 font-size: small;
18 }
19
20 td:first-child {
21 text-align: left
22 }
23 </style>
24 </head>
25
26 <body>
27 <h1>libsndfile : Supported formats</h1>
28 <p>
29 The following table lists the file formats and encodings that libsndfile
30 can read and write.
31 The file formats are arranged across the top and encodings along the left
32 edge.
33 </p>
34
35 <table border="1" cellpadding="2">
36 <thead>
37 <tr>
38 <td>&nbsp;</td>
39 <td>Microsoft WAV</td>
40 <td>SGI / Apple AIFF / AIFC</td>
41 <td>Sun / DEC / NeXT AU / SND</td>
42 <td>Headerless RAW</td>
43 <td>Paris Audio File PAF</td>
44 <td>Commodore Amiga IFF / SVX</td>
45 <td>Sphere Nist WAV</td>
46 <td>IRCAM SF</td>
47 <td>Creative VOC</td>
48 <td>Soundforge W64</td>
49 <td><a href="octave.html">GNU Octave&nbsp;2.0</a> MAT4</td>
50 <td><a href="octave.html">GNU Octave&nbsp;2.1</a> MAT5</td>
51 <td>Portable Voice Format PVF</td>
52 <td>Fasttracker&nbsp;2 XI</td>
53 <td>HMM Tool Kit HTK</td>
54 <td>Apple CAF</td>
55 <td>Sound Designer&nbsp;II SD2</td>
56 <td>Free Lossless Audio Codec FLAC</td>
57 </tr>
58 </thead>
59 <tbody>
60 <tr>
61 <td>Unsigned 8 bit PCM</td>
62 <td>R/W</td>
63 <td>R/W</td>
64 <td>&nbsp;</td>
65 <td>R/W</td>
66 <td>&nbsp;</td>
67 <td>&nbsp;</td>
68 <td>&nbsp;</td>
69 <td>&nbsp;</td>
70 <td>R/W</td>
71 <td>R/W</td>
72 <td>&nbsp;</td>
73 <td>R/W</td>
74 <td>&nbsp;</td>
75 <td>&nbsp;</td>
76 <td>&nbsp;</td>
77 <td>&nbsp;</td>
78 <td>&nbsp;</td>
79 <td>&nbsp;</td>
80 </tr>
81
82 <tr>
83 <td>Signed 8 bit PCM</td>
84 <td>&nbsp;</td>
85 <td>R/W</td>
86 <td>R/W</td>
87 <td>R/W</td>
88 <td>R/W</td>
89 <td>R/W</td>
90 <td>R/W</td>
91 <td>&nbsp;</td>
92 <td>&nbsp;</td>
93 <td>&nbsp;</td>
94 <td>&nbsp;</td>
95 <td>&nbsp;</td>
96 <td>R/W</td>
97 <td>&nbsp;</td>
98 <td>&nbsp;</td>
99 <td>R/W</td>
100 <td>R/W</td>
101 <td>R/W</td>
102 </tr>
103
104 <tr>
105 <td>Signed 16 bit PCM</td>
106 <td>R/W</td>
107 <td>R/W</td>
108 <td>R/W</td>
109 <td>R/W</td>
110 <td>R/W</td>
111 <td>R/W</td>
112 <td>R/W</td>
113 <td>R/W</td>
114 <td>R/W</td>
115 <td>R/W</td>
116 <td>R/W</td>
117 <td>R/W</td>
118 <td>R/W</td>
119 <td>&nbsp;</td>
120 <td>R/W</td>
121 <td>R/W</td>
122 <td>R/W</td>
123 <td>R/W</td>
124 </tr>
125
126 <tr>
127 <td>Signed 24 bit PCM</td>
128 <td>R/W</td>
129 <td>R/W</td>
130 <td>R/W</td>
131 <td>R/W</td>
132 <td>R/W</td>
133 <td>&nbsp;</td>
134 <td>R/W</td>
135 <td>&nbsp;</td>
136 <td>&nbsp;</td>
137 <td>R/W</td>
138 <td>&nbsp;</td>
139 <td>&nbsp;</td>
140 <td>&nbsp;</td>
141 <td>&nbsp;</td>
142 <td>&nbsp;</td>
143 <td>R/W</td>
144 <td>R/W</td>
145 <td>R/W</td>
146 </tr>
147
148 <tr>
149 <td>Signed 32 bit PCM</td>
150 <td>R/W</td>
151 <td>R/W</td>
152 <td>R/W</td>
153 <td>R/W</td>
154 <td>&nbsp;</td>
155 <td>&nbsp;</td>
156 <td>R/W</td>
157 <td>R/W</td>
158 <td>&nbsp;</td>
159 <td>R/W</td>
160 <td>R/W</td>
161 <td>R/W</td>
162 <td>R/W</td>
163 <td>&nbsp;</td>
164 <td>&nbsp;</td>
165 <td>R/W</td>
166 <td>&nbsp;</td>
167 <td>&nbsp;</td>
168 </tr>
169
170 <tr>
171 <td>32 bit float</td>
172 <td>R/W</td>
173 <td>R/W</td>
174 <td>R/W</td>
175 <td>R/W</td>
176 <td>&nbsp;</td>
177 <td>&nbsp;</td>
178 <td>&nbsp;</td>
179 <td>R/W</td>
180 <td>&nbsp;</td>
181 <td>R/W</td>
182 <td>R/W</td>
183 <td>R/W</td>
184 <td>&nbsp;</td>
185 <td>&nbsp;</td>
186 <td>&nbsp;</td>
187 <td>R/W</td>
188 <td>&nbsp;</td>
189 <td>&nbsp;</td>
190 </tr>
191
192 <tr>
193 <td>64 bit double</td>
194 <td>R/W</td>
195 <td>R/W</td>
196 <td>R/W</td>
197 <td>R/W</td>
198 <td>&nbsp;</td>
199 <td>&nbsp;</td>
200 <td>&nbsp;</td>
201 <td>&nbsp;</td>
202 <td>&nbsp;</td>
203 <td>R/W</td>
204 <td>R/W</td>
205 <td>R/W</td>
206 <td>&nbsp;</td>
207 <td>&nbsp;</td>
208 <td>&nbsp;</td>
209 <td>R/W</td>
210 <td>&nbsp;</td>
211 <td>&nbsp;</td>
212 </tr>
213
214 <tr>
215 <td>u-law encoding</td>
216 <td>R/W</td>
217 <td>R/W</td>
218 <td>R/W</td>
219 <td>R/W</td>
220 <td>&nbsp;</td>
221 <td>&nbsp;</td>
222 <td>R/W</td>
223 <td>R/W</td>
224 <td>R/W</td>
225 <td>R/W</td>
226 <td>&nbsp;</td>
227 <td>&nbsp;</td>
228 <td>&nbsp;</td>
229 <td>&nbsp;</td>
230 <td>&nbsp;</td>
231 <td>R/W</td>
232 <td>&nbsp;</td>
233 <td>&nbsp;</td>
234 </tr>
235 <tr>
236 <td>A-law encoding</td>
237 <td>R/W</td>
238 <td>R/W</td>
239 <td>R/W</td>
240 <td>R/W</td>
241 <td>&nbsp;</td>
242 <td>&nbsp;</td>
243 <td>R/W</td>
244 <td>R/W</td>
245 <td>R/W</td>
246 <td>R/W</td>
247 <td>&nbsp;</td>
248 <td>&nbsp;</td>
249 <td>&nbsp;</td>
250 <td>&nbsp;</td>
251 <td>&nbsp;</td>
252 <td>R/W</td>
253 <td>&nbsp;</td>
254 <td>&nbsp;</td>
255 </tr>
256
257 <tr>
258 <td>IMA ADPCM</td>
259 <td>R/W</td>
260 <td>&nbsp;</td>
261 <td>&nbsp;</td>
262 <td>&nbsp;</td>
263 <td>&nbsp;</td>
264 <td>&nbsp;</td>
265 <td>&nbsp;</td>
266 <td>&nbsp;</td>
267 <td>&nbsp;</td>
268 <td>R/W</td>
269 <td>&nbsp;</td>
270 <td>&nbsp;</td>
271 <td>&nbsp;</td>
272 <td>&nbsp;</td>
273 <td>&nbsp;</td>
274 <td>&nbsp;</td>
275 <td>&nbsp;</td>
276 <td>&nbsp;</td>
277 </tr>
278
279 <tr>
280 <td>MS ADPCM</td>
281 <td>R/W</td>
282 <td>&nbsp;</td>
283 <td>&nbsp;</td>
284 <td>&nbsp;</td>
285 <td>&nbsp;</td>
286 <td>&nbsp;</td>
287 <td>&nbsp;</td>
288 <td>&nbsp;</td>
289 <td>&nbsp;</td>
290 <td>R/W</td>
291 <td>&nbsp;</td>
292 <td>&nbsp;</td>
293 <td>&nbsp;</td>
294 <td>&nbsp;</td>
295 <td>&nbsp;</td>
296 <td>&nbsp;</td>
297 <td>&nbsp;</td>
298 <td>&nbsp;</td>
299 </tr>
300
301 <tr>
302 <td>GSM 6.10</td>
303 <td>R/W</td>
304 <td>R/W</td>
305 <td>&nbsp;</td>
306 <td>R/W</td>
307 <td>&nbsp;</td>
308 <td>&nbsp;</td>
309 <td>&nbsp;</td>
310 <td>&nbsp;</td>
311 <td>&nbsp;</td>
312 <td>R/W</td>
313 <td>&nbsp;</td>
314 <td>&nbsp;</td>
315 <td>&nbsp;</td>
316 <td>&nbsp;</td>
317 <td>&nbsp;</td>
318 <td>&nbsp;</td>
319 <td>&nbsp;</td>
320 <td>&nbsp;</td>
321 </tr>
322
323 <tr>
324 <td>G721 ADPCM 32kbps</td>
325 <td>R/W</td>
326 <td>&nbsp;</td>
327 <td>R/W</td>
328 <td>&nbsp;</td>
329 <td>&nbsp;</td>
330 <td>&nbsp;</td>
331 <td>&nbsp;</td>
332 <td>&nbsp;</td>
333 <td>&nbsp;</td>
334 <td>&nbsp;</td>
335 <td>&nbsp;</td>
336 <td>&nbsp;</td>
337 <td>&nbsp;</td>
338 <td>&nbsp;</td>
339 <td>&nbsp;</td>
340 <td>&nbsp;</td>
341 <td>&nbsp;</td>
342 <td>&nbsp;</td>
343 </tr>
344
345 <tr>
346 <td>G723 ADPCM 24kbps</td>
347 <td>&nbsp;</td>
348 <td>&nbsp;</td>
349 <td>R/W</td>
350 <td>&nbsp;</td>
351 <td>&nbsp;</td>
352 <td>&nbsp;</td>
353 <td>&nbsp;</td>
354 <td>&nbsp;</td>
355 <td>&nbsp;</td>
356 <td>&nbsp;</td>
357 <td>&nbsp;</td>
358 <td>&nbsp;</td>
359 <td>&nbsp;</td>
360 <td>&nbsp;</td>
361 <td>&nbsp;</td>
362 <td>&nbsp;</td>
363 <td>&nbsp;</td>
364 <td>&nbsp;</td>
365 </tr>
366
367 <tr>
368 <td>G723 ADPCM 40kbps</td>
369 <td>&nbsp;</td>
370 <td>&nbsp;</td>
371 <td>R/W</td>
372 <td>&nbsp;</td>
373 <td>&nbsp;</td>
374 <td>&nbsp;</td>
375 <td>&nbsp;</td>
376 <td>&nbsp;</td>
377 <td>&nbsp;</td>
378 <td>&nbsp;</td>
379 <td>&nbsp;</td>
380 <td>&nbsp;</td>
381 <td>&nbsp;</td>
382 <td>&nbsp;</td>
383 <td>&nbsp;</td>
384 <td>&nbsp;</td>
385 <td>&nbsp;</td>
386 <td>&nbsp;</td>
387 </tr>
388
389 <tr>
390 <td>12 bit DWVW</td>
391 <td>&nbsp;</td>
392 <td>R/W</td>
393 <td>&nbsp;</td>
394 <td>R/W</td>
395 <td>&nbsp;</td>
396 <td>&nbsp;</td>
397 <td>&nbsp;</td>
398 <td>&nbsp;</td>
399 <td>&nbsp;</td>
400 <td>&nbsp;</td>
401 <td>&nbsp;</td>
402 <td>&nbsp;</td>
403 <td>&nbsp;</td>
404 <td>&nbsp;</td>
405 <td>&nbsp;</td>
406 <td>&nbsp;</td>
407 <td>&nbsp;</td>
408 <td>&nbsp;</td>
409 </tr>
410
411 <tr>
412 <td>16 bit DWVW</td>
413 <td>&nbsp;</td>
414 <td>R/W</td>
415 <td>&nbsp;</td>
416 <td>R/W</td>
417 <td>&nbsp;</td>
418 <td>&nbsp;</td>
419 <td>&nbsp;</td>
420 <td>&nbsp;</td>
421 <td>&nbsp;</td>
422 <td>&nbsp;</td>
423 <td>&nbsp;</td>
424 <td>&nbsp;</td>
425 <td>&nbsp;</td>
426 <td>&nbsp;</td>
427 <td>&nbsp;</td>
428 <td>&nbsp;</td>
429 <td>&nbsp;</td>
430 <td>&nbsp;</td>
431 </tr>
432
433 <tr>
434 <td>24 bit DWVW</td>
435 <td>&nbsp;</td>
436 <td>R/W</td>
437 <td>&nbsp;</td>
438 <td>R/W</td>
439 <td>&nbsp;</td>
440 <td>&nbsp;</td>
441 <td>&nbsp;</td>
442 <td>&nbsp;</td>
443 <td>&nbsp;</td>
444 <td>&nbsp;</td>
445 <td>&nbsp;</td>
446 <td>&nbsp;</td>
447 <td>&nbsp;</td>
448 <td>&nbsp;</td>
449 <td>&nbsp;</td>
450 <td>&nbsp;</td>
451 <td>&nbsp;</td>
452 <td>&nbsp;</td>
453 </tr>
454 <tr>
455 <td>Ok Dialogic ADPCM</td>
456 <td>&nbsp;</td>
457 <td>&nbsp;</td>
458 <td>&nbsp;</td>
459 <td>R/W</td>
460 <td>&nbsp;</td>
461 <td>&nbsp;</td>
462 <td>&nbsp;</td>
463 <td>&nbsp;</td>
464 <td>&nbsp;</td>
465 <td>&nbsp;</td>
466 <td>&nbsp;</td>
467 <td>&nbsp;</td>
468 <td>&nbsp;</td>
469 <td>&nbsp;</td>
470 <td>&nbsp;</td>
471 <td>&nbsp;</td>
472 <td>&nbsp;</td>
473 <td>&nbsp;</td>
474 </tr>
475 <tr>
476 <td>8 bit DPCM</td>
477 <td>&nbsp;</td>
478 <td>&nbsp;</td>
479 <td>&nbsp;</td>
480 <td>&nbsp;</td>
481 <td>&nbsp;</td>
482 <td>&nbsp;</td>
483 <td>&nbsp;</td>
484 <td>&nbsp;</td>
485 <td>&nbsp;</td>
486 <td>&nbsp;</td>
487 <td>&nbsp;</td>
488 <td>&nbsp;</td>
489 <td>&nbsp;</td>
490 <td>R/W</td>
491 <td>&nbsp;</td>
492 <td>&nbsp;</td>
493 <td>&nbsp;</td>
494 <td>&nbsp;</td>
495 </tr>
496 <tr>
497 <td>16 bit DPCM</td>
498 <td>&nbsp;</td>
499 <td>&nbsp;</td>
500 <td>&nbsp;</td>
501 <td>&nbsp;</td>
502 <td>&nbsp;</td>
503 <td>&nbsp;</td>
504 <td>&nbsp;</td>
505 <td>&nbsp;</td>
506 <td>&nbsp;</td>
507 <td>&nbsp;</td>
508 <td>&nbsp;</td>
509 <td>&nbsp;</td>
510 <td>&nbsp;</td>
511 <td>R/W</td>
512 <td>&nbsp;</td>
513 <td>&nbsp;</td>
514 <td>&nbsp;</td>
515 <td>&nbsp;</td>
516 </tr>
517 </tbody>
518 </table>
519
520 <p>
521 From version 1.0.18, libsndfile also reads and writes
522 <a href="https://xiph.org/flac/">FLAC</a>
523 and
524 <a href="https://xiph.org/vorbis/">Ogg/Vorbis</a>.
525 </p>
526
527 <p>
528 From version 1.0.29, libsndfile can read and write
529 <a href="https://opus-codec.org/">Ogg/Opus</a>.
530 </p>
531 <p>
532 Some of the file formats I am also interested in adding are:
533 </p>
534 <ul>
535 <li> Kurzweil K2000 sampler files.</li>
536 <li> Ogg Speex.</li>
537 <li> MPEG Layer 3 (commonly known as MP3)</li>
538 </ul>
539 <p>
540 Other file formats may also be added on request.
541 </p>
542 </body>
543
544 </html>
+0
-290
doc/index.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <META NAME="Version" CONTENT="libsndfile-1.0.30">
9 <META NAME="Description" CONTENT="The libsndfile Home Page">
10 <META NAME="Keywords" CONTENT="WAV AIFF AU SVX PAF NIST W64 libsndfile sound audio dsp Linux">
11 <META NAME="ROBOTS" CONTENT="NOFOLLOW">
12 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
13 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
14 </HEAD>
15
16 <BODY>
17 <!-- pepper -->
18 <CENTER>
19 <IMG SRC="libsndfile.jpg" HEIGHT=98 WIDTH=367 ALT="libsndfile.jpg">
20 </CENTER>
21 <!-- pepper -->
22 <CENTER>
23 <A HREF="#History">History</A> -+-
24 <A HREF="#Features">Features</A> -+-
25 <A HREF="#Similar">Similar or Related Projects</A> -+-
26 <A HREF="NEWS">News</A>
27 <br>
28 <A HREF="development.html">Development</A> -+-
29 <A HREF="api.html">Programming Interface</A> -+-
30 <A HREF="bugs.html">Bug Reporting</A> -+-
31 <A HREF="#Download">Download</A>
32 <br>
33 <A HREF="FAQ.html">FAQ</A> -+-
34 <A HREF="lists.html">Mailing Lists</A> -+-
35 <A HREF="ChangeLog">Change Log</A> -+-
36 <A HREF="#Licensing">Licensing Information</A> -+-
37 <A HREF="#SeeAlso">See Also</A>
38 </CENTER>
39
40 <br><br>
41 <P>
42 Libsndfile is a C library for reading and writing files containing sampled sound
43 (such as MS Windows WAV and the Apple/SGI AIFF format) through one standard
44 library interface. It is released in source code format under the
45 <A HREF="http://www.gnu.org/copyleft/lesser.html">Gnu Lesser General Public License</A>.
46 </P>
47 <!-- pepper -->
48 <P>
49 The library was written to compile and run on a Linux system but should compile
50 and run on just about any Unix (including MacOS X).
51 There are also pre-compiled binaries available for 32 and 64 bit windows.
52 </P>
53 <P>
54 It was designed to handle both little-endian (such as WAV) and big-endian
55 (such as AIFF) data, and to compile and run correctly on little-endian (such as Intel
56 and DEC/Compaq Alpha) processor systems as well as big-endian processor systems such
57 as Motorola 68k, Power PC, MIPS and Sparc.
58 Hopefully the design of the library will also make it easy to extend for reading and
59 writing new sound file formats.
60 </P>
61 <!-- pepper -->
62 <P>
63 It has been compiled and tested (at one time or another) on the following systems:
64 </P>
65 <!-- pepper -->
66 <UL>
67 <LI>Every platform supported by Debian GNU/Linux including x86_64-linux-gnu,
68 i486-linux-gnu, powerpc-linux-gnu, sparc-linux-gnu, alpha-linux-gnu,
69 mips-linux-gnu and armel-linux-gnu.</LI>
70 <LI>powerpc-apple-darwin7.0 (Mac OS X 10.3)</LI>
71 <LI>sparc-sun-solaris2.8 (using gcc)</LI>
72 <LI>mips-sgi-irix5.3 (using gcc)</LI>
73 <LI>QNX 6.0</LI>
74 <LI>i386-unknown-openbsd2.9</LI>
75 </UL>
76 <!-- pepper -->
77 <P>
78 At the moment, each new release is being tested on i386 Linux, x86_64 Linux,
79 PowerPC Linux, Win32 and Win64.
80 </P>
81 <!-- pepper -->
82
83 <A NAME="Capabilities"></A>
84 <A NAME="Features"></A>
85 <H1><B>Features</B></H1>
86 <P>
87 libsndfile has the following main features :
88 </P>
89 <UL>
90 <lI> Ability to read and write a large number of <A HREF="formats.html">
91 file formats</A>.
92 <LI> A simple, elegant and easy to use Applications Programming Interface.
93 <LI> Usable on Unix, Win32, MacOS and others.
94 <LI> On the fly format conversion, including endian-ness swapping, type conversion
95 and bitwidth scaling.
96 <LI> Optional normalisation when reading floating point data from files containing
97 integer data.
98 <LI> Ability to open files in read/write mode.
99 <LI> The ability to write the file header without closing the file (only on files
100 open for write or read/write).
101 <LI> Ability to query the library about all supported formats and retrieve text
102 strings describing each format.
103 </UL>
104 <P>
105 libsndfile has a comprehensive test suite so that each release is as bug free
106 as possible.
107 When new bugs are found, new tests are added to the test suite to ensure that
108 these bugs don't creep back into the code.
109 When new features are added, tests are added to the test suite to make sure that
110 these features continue to work correctly even when they are old features.
111 </P>
112 <!-- pepper -->
113
114 <A NAME="History"></A>
115 <H1><B>History</B></H1>
116 <P>
117 My first attempt at reading and writing WAV files was in 1990 or so under Windows
118 3.1.
119 I started using Linux in early 1995 and contributed some code to the
120 <A HREF="http://www.vaxxine.com/ve3wwg/gnuwave.html">wavplay</A>
121 program.
122 That contributed code would eventually mutate into this library.
123 As one of my interests is Digital Signal Processing (DSP) I decided that as well as
124 reading data from an audio file in the native format (typically 16 bit short integers)
125 it would also be useful to be able to have the library do the conversion to floating
126 point numbers for DSP applications.
127 It then dawned on me that whatever file format (anything from 8 bit unsigned chars,
128 to 32 bit floating point numbers) the library should be able to convert the data to
129 whatever format the library user wishes to use it in.
130 For example, in a sound playback program, the library caller typically wants the sound
131 data in 16 bit short integers to dump into a sound card even though the data in the
132 file may be 32 bit floating point numbers (ie Microsoft's WAVE_FORMAT_IEEE_FLOAT
133 format).
134 Another example would be someone doing speech recognition research who has recorded
135 some speech as a 16 bit WAV file but wants to process it as double precision floating
136 point numbers.
137 </P>
138 <P>
139 Here is the release history for libsndfile :
140 </P>
141 <UL>
142 <LI>Version 0.0.8 (Feb 15 1999) First official release.
143 <LI>Version 0.0.28 (Apr 26 2002) Final release of version 0 of libsndfile.
144 <LI>Version 1.0.0rc1 (Jun 24 2002) Release candidate 1 of version 1 of libsndfile.
145 <LI>Version 1.0.0rc6 (Aug 14 2002) MacOS 9 fixes.
146 <LI>Version 1.0.0 (Aug 16 2002) First 1.0.X release.
147 <LI>Version 1.0.1 (Sep 14 2002) Added MAT4 and MAT5 file formats.
148 <LI>Version 1.0.2 (Nov 24 2002) Added VOX ADPCM format.
149 <LI>Version 1.0.3 (Dec 09 2002) Fixes for Linux on ia64 CPUs.
150 <LI>Version 1.0.4 (Feb 02 2003) New file formats and functionality.
151 <LI>Version 1.0.5 (May 03 2003) One new file format and new functionality.
152 <LI>Version 1.0.6 (Feb 08 2004) Large file fix for Linux/Solaris, new functionality
153 and Win32 improvements.
154 <LI>Version 1.0.7 (Feb 24 2004) Fix build problems on MacOS X and fix ia64/MIPS etc
155 clip mode detction.
156 <LI>Version 1.0.8 (Mar 14 2004) Minor bug fixes.
157 <LI>Version 1.0.9 (Mar 30 2004) Add AVR format. Improve handling of some WAV files.
158 <LI>Version 1.0.10 (Jun 15 2004) Minor bug fixes. Fix support for Win32 MinGW compiler.
159 <LI>Version 1.0.11 (Nov 15 2004) Add SD2 file support, reading of loop data in WAV and AIFF.
160 Minor bug fixes.
161 <LI>Version 1.0.12 (Sep 30 2005) Add FLAC and CAF file support, virtual I/O interface.
162 Minor bug fixes and cleanups.
163 <LI>Version 1.0.13 (Jan 21 2006) Add read/write of instrument chunks. Minor bug fixes.
164 <LI>Version 1.0.14 (Feb 19 2006) Minor bug fixes. Start shipping windows binary/source ZIP.
165 <LI>Version 1.0.15 (Mar 16 2006) Minor bug fixes.
166 <LI>Version 1.0.16 (Apr 30 2006) Add support for RIFX. Other minor feature enhancements and
167 bug fixes.
168 <LI>Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and cleanups.
169 <LI>Version 1.0.18 (Feb 07 2009) Add Ogg/Vorbis suppport, remove captive libraries, many
170 new features and bug fixes. Generate Win32 and Win64 pre-compiled binaries.
171 <LI>Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes as a
172 result of static analysis.
173 <LI>Version 1.0.20 (May 14 2009) Fix for potential heap overflow.
174 <LI>Version 1.0.21 (December 13 2009) Bunch of minor bug fixes.
175 <LI>Version 1.0.22 (October 04 2010) Bunch of minor bug fixes.
176 <LI>Version 1.0.23 (October 10 2010) Minor bug fixes.
177 <LI>Version 1.0.24 (March 23 2011) Minor bug fixes.
178 <LI>Version 1.0.25 (July 13 2011) Fix for Secunia Advisory SA45125. Minor bug fixes and
179 improvements.
180 <LI>Version 1.0.26 (November 22 2015) Fix for CVE-2014-9496, CVE-2014-9756 and CVE-2015-7805.
181 Add ALAC/CAF support. Minor bug fixes and improvements.
182 <LI>Version 1.0.27 (June 19 2016) Fix a seek regression in 1.0.26. Add metadata read/write
183 for CAF and RF64. FIx PAF endian-ness issue.
184 <LI>Version 1.0.28 (April 2 2017) Fix buffer overruns in FLAC and ID3 handling code. Reduce default
185 header memory requirements. Fix detection of Large File Support for 32 bit systems.
186 <LI>Version 1.0.29 (August 15 2020) Opus support, build system improvements and bug fixes.
187 <LI>Version 1.0.30 (September 19 2020) Bugfix release. Fix file descriptor leaks in sf_open_fd ()
188 function. Fix critical CMake bug leading to broken ABI on Linux platforms. Other
189 numerous fixes to CMake build system, consider it stable now. Fix some memory leaks.
190 Fix handling of some SD2 files. Update documentation. Integrate GitHub Actions for
191 faster test builds and Oss-Fuzz for fuzzing tests. Move sndfile.h.in from src/
192 to include/ directory. To avoid problems, delete old generated sndfile.h from
193 $(top_builddir)/src.
194 </UL>
195
196 <A NAME="Similar"></A>
197 <H1><B>Similar or Related Projects</B></H1>
198
199 <UL>
200 <LI><A HREF="http://sox.sourceforge.net/">SoX</A> is a program for
201 converting between sound file formats.
202 <LI><A HREF="http://www.hitsquad.com/smm/programs/WavPlay/">Wavplay</A> started out
203 as a minimal WAV file player under Linux and has mutated into Gnuwave, a client/server
204 application for more general multimedia and games sound playback.
205 <LI><A HREF="http://www.68k.org/~michael/audiofile/">Audiofile</A> (libaudiofile) is
206 a library similar to libsndfile but with a different programming interface. The
207 author Michael Pruett has set out to clone (and fix some bugs in) the libaudiofile
208 library which ships with SGI's IRIX OS.
209 <LI><A HREF="ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz">sndlib.tar.gz</A> is
210 another library written by Bill Schottstaedt of CCRMA.
211 </UL>
212
213 <A NAME="Licensing"></A>
214 <H1><B>Licensing</B></H1>
215 <P>
216 libsndfile is released under the terms of the GNU Lesser General Public License,
217 of which there are two versions;
218 <a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">version 2.1</a>
219 and
220 <a href="http://www.gnu.org/copyleft/lesser.html">version 3</a>.
221 To maximise the compatibility of libsndfile, the user may choose to use libsndfile
222 under either of the above two licenses.
223 You can also read a simple explanation of the ideas behind the GPL and the LGPL
224 <A HREF="http://www.gnu.org/copyleft/copyleft.html">here</A>.
225 </P>
226 <P>
227 You can use libsndfile with
228 <A HREF="http://www.gnu.org/">Free Software</A>,
229 <A HREF="http://www.opensource.org/">Open Source</A>,
230 proprietary, shareware or other closed source applications as long as libsndfile
231 is used as a dynamically loaded library and you abide by a small number of other
232 conditions (read the LGPL for more info).
233 With applications released under the GNU GPL you can also use libsndfile statically
234 linked to your application.
235 </P>
236 <P>
237 I would like to see libsndfile used as widely as possible but I would prefer it
238 if you released software that uses libsndfile as
239 <A HREF="http://www.gnu.org/">Free Software</A>
240 or
241 <A HREF="http://www.opensource.org/">Open Source</A>.
242 However, if you put in a great deal of effort building a significant application
243 which simply uses libsndfile for file I/O, then I have no problem with you releasing
244 that as closed source and charging as much money as you want for it as long as you
245 abide by <A HREF="http://www.gnu.org/copyleft/lesser.html">the license</A>.
246 </P>
247
248 <A NAME="Download"></A>
249 <H1><B>Download</B></H1>
250 <P>
251 Check latest version on <A HREF="https://github.com/erikd/libsndfile/releases">GitHub Releases page</A>.
252 </P>
253
254 <A NAME="SeeAlso"></A>
255 <H1><B>See Also</B></H1>
256 <UL>
257 <LI><a href="http://www.mega-nerd.com/libsndfile/tools/">
258 sndfile-tools</a>
259 : a small collection of programs which use libsndfile.
260 </UL>
261
262 <br><br>
263
264 <hr>
265
266 <P>
267 The latest version of this document can be found
268 <A HREF="http://www.mega-nerd.com/libsndfile/">here</A>.
269 </P>
270 <P>
271 Author :
272 <A HREF="m&#97;ilt&#111;:&#101;rikd&#64;&#109;eg&#97;-&#110;erd.&#99;om">
273 Erik de Castro Lopo</a>
274 </P>
275 <!-- pepper -->
276 <P>
277 This page has been accessed
278 <IMG SRC=
279 "/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"
280 HEIGHT=30 WIDTH=100 ALT="counter.gif">
281 times.
282 </P>
283 <!-- pepper -->
284 <!-- pepper -->
285 <!-- pepper -->
286
287 <br><br>
288 </BODY>
289 </HTML>
+0
-99
doc/libsndfile.css.in less more
0 body {
1 background : @HTML_BGCOLOUR@ ;
2 color : @HTML_FGCOLOUR@ ;
3 font-family : arial, helvetica, sans-serif ;
4 line-height: 1.5 ;
5 }
6 td {
7 font-family : arial, helvetica, sans-serif ;
8 background : @HTML_BGCOLOUR@ ;
9 color : @HTML_FGCOLOUR@ ;
10 }
11 center {
12 font-family : arial, helvetica, sans-serif ;
13 }
14 p {
15 font-family : arial, helvetica, sans-serif ;
16 text-align : left ;
17 margin-left : 3% ;
18 margin-right : 3% ;
19 }
20 .indent_block {
21 font-family : arial, helvetica, sans-serif ;
22 text-align : left ;
23 margin-left : 10% ;
24 margin-right : 10% ;
25 }
26 br {
27 font-family : arial, helvetica, sans-serif ;
28 }
29 form {
30 font-family : arial, helvetica, sans-serif ;
31 }
32 ul {
33 font-family : arial, helvetica, sans-serif ;
34 text-align : left ;
35 margin-left : 3% ;
36 margin-right : 6% ;
37 }
38 ol {
39 font-family : arial, helvetica, sans-serif ;
40 text-align : left ;
41 margin-left : 3% ;
42 margin-right : 6% ;
43 }
44 dl {
45 font-family : arial, helvetica, sans-serif ;
46 text-align : left ;
47 margin-left : 3% ;
48 margin-right : 3% ;
49 }
50 h1 {
51 font-size : xx-large ;
52 background : @HTML_BGCOLOUR@ ;
53 color : #5050FF ;
54 text-align : left ;
55 margin-left : 3% ;
56 margin-right : 3% ;
57 }
58 h2 {
59 font-size : x-large ;
60 background : @HTML_BGCOLOUR@ ;
61 color : #5050FF ;
62 text-align : left ;
63 margin-left : 3% ;
64 margin-right : 3% ;
65 }
66 h3 {
67 font-size : large ;
68 background : @HTML_BGCOLOUR@ ;
69 color : #5050FF ;
70 text-align : left ;
71 margin-left : 3% ;
72 margin-right : 3% ;
73 }
74 h4 {
75 font-size : medium ;
76 background : @HTML_BGCOLOUR@ ;
77 color : #5050FF ;
78 text-align : left ;
79 margin-left : 3% ;
80 margin-right : 3% ;
81 }
82 pre {
83 font-family : courier, monospace ;
84 font-size : medium ;
85 margin-left : 6% ;
86 margin-right : 6% ;
87 }
88 code,
89 kbd,
90 samp,
91 var {
92 font-family: "Courier New", monospace, serif;
93 font-size: 1em;
94 }
95 a:link { color : #9090FF ; }
96 a:visited { color : #5050FF ; }
97 a:active { color : #FF00FF ; }
98 a:hover { background-color : #202080 ; }
doc/libsndfile.jpg less more
Binary diff not shown
+0
-434
doc/linux_games_programming.txt less more
0 # Here are some some emails I exchanged with a guy trying to use
1 # libsndfile version 1 with code from the book "Linux Games Programming"
2 # by John Hall. The email addresses have been changed to foil the spam
3 # bots.
4
5 Date: Tue, 20 Jul 2004 22:49:21 +0100
6 From: Paul <paul@fake-domain-name.co.uk>
7 To: erikd@fake-domain-name.com
8 Subject: Can you help with a problem?
9 Date: Tue, 20 Jul 2004 22:49:21 +0100
10
11 Hi,
12
13 I'm trying to get the source examples in the "Programming Linux Games"
14 (NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile.
15
16 While I can guess some of the newer versions of function calls and
17 enumerations, there are some which I cannot guess.
18
19 Would you be able to translate them to the current version of
20 enumeration and function calls so that I can update the source?
21
22 These are the three currently failing me:
23
24 sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,SFM_READ, &sfinfo))
25 SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
26 SF_INFO.pcmbitwidth (guess: no idea!)
27
28 There are probably more. I'm happy to send you the source files for
29 sound calls, scan the pages or anything else. Failing that, is there
30 somewhere with the changes listed so I can try and fix the code for myself?
31
32 Thanks
33
34 TTFN
35
36 Paul
37
38 ================================================================================
39
40 Date: Wed, 21 Jul 2004 17:38:08 +1000
41 From: Erik de Castro Lopo <erikd@fake-domain-name.com>
42 To: Paul <paul@fake-domain-name.co.uk>
43 Subject: Re: Can you help with a problem?
44
45 On Tue, 20 Jul 2004 22:49:21 +0100
46 Paul <paul@fake-domain-name.co.uk> wrote:
47
48 > Hi,
49 >
50 > I'm trying to get the source examples in the "Programming Linux Games"
51 > (NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile.
52 >
53 > While I can guess some of the newer versions of function calls and
54 > enumerations, there are some which I cannot guess.
55 >
56 > Would you be able to translate them to the current version of
57 > enumeration and function calls so that I can update the source?
58 >
59 > These are the three currently failing me:
60 >
61 > sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,
62 > SFM_READ, &sfinfo))
63
64 yes.
65
66 > SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
67
68 Actually this list:
69
70 SF_FORMAT_PCM_U8
71 SF_FORMAT_PCM_S8
72 SF_FORMAT_PCM_16
73 SF_FORMAT_PCM_24
74 SF_FORMAT_PCM_32
75
76 > SF_INFO.pcmbitwidth (guess: no idea!)
77
78 WIth the above change, pcmbitwidth becomes redundant.
79
80 > There are probably more. I'm happy to send you the source files for
81 > sound calls, scan the pages or anything else. Failing that, is there
82 > somewhere with the changes listed so I can try and fix the code for
83 > myself?
84
85 Version 1.0.0 came out some time ago, but I think this:
86
87 http://www.mega-nerd.com/libsndfile/version-1.html
88
89 lists most of the changes. You should also look at the API docs:
90
91 http://www.mega-nerd.com/libsndfile/api.html
92
93 HTH,
94 Erik
95 --
96 +-----------------------------------------------------------+
97 Erik de Castro Lopo nospam@fake-domain-name.com
98 +-----------------------------------------------------------+
99 "There is no reason why anyone would want a computer in their home"
100 Ken Olson, DEC, 1977
101
102 ================================================================================
103
104 From: PFJ <paul@fake-domain-name.co.uk>
105 To: Erik de Castro Lopo <erikd@fake-domain-name.com>
106 Subject: Re: Can you help with a problem?
107 Date: Wed, 21 Jul 2004 09:07:39 +0100
108
109
110 Hi Erik,
111
112 Thanks for getting back to me.
113
114 > > sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename, SFM_READ, &sfinfo))
115 >
116 > yes.
117
118 Yay!
119
120 > > SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
121 >
122 > Actually this list:
123 >
124 > SF_FORMAT_PCM_U8
125 > SF_FORMAT_PCM_S8
126 > SF_FORMAT_PCM_16
127 > SF_FORMAT_PCM_24
128 > SF_FORMAT_PCM_32
129
130 I know, but the source code explicitly has SF_FORMAT_PCM which given the
131 code afterwards would equate to one of the above, but given that PCM
132 files can have a varied bitwidth the author probably wanted to cover all
133 bases.
134
135 > Version 1.0.0 came out some time ago, but I think this:
136 >
137 > http://www.mega-nerd.com/libsndfile/version-1.html
138 >
139 > lists most of the changes. You should also look at the API docs:
140 >
141 > http://www.mega-nerd.com/libsndfile/api.html
142
143 I'll download them and see what I can gleen.
144
145 Thanks again for getting back to me
146
147 TTFN
148
149 Paul
150
151 ================================================================================
152
153 Date: Wed, 21 Jul 2004 18:20:29 +1000
154 From: Erik de Castro Lopo <erikd@fake-domain-name.com>
155 To: PFJ <paul@fake-domain-name.co.uk>
156 Subject: Re: Can you help with a problem?
157
158 On Wed, 21 Jul 2004 09:07:39 +0100
159 PFJ <paul@fake-domain-name.co.uk> wrote:
160
161 > I know, but the source code explicitly has SF_FORMAT_PCM which given the
162 > code afterwards would equate to one of the above, but given that PCM
163 > files can have a varied bitwidth the author probably wanted to cover all
164 > bases.
165
166 But surely the existing code does something like:
167
168 sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
169 sfinfo.pcmbitwidth = 16;
170
171 which can be directly translated to:
172
173 sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
174
175 and the same for pcmbitwitdhs of 24 and 32. For pcmbitwidth of 8
176 you need to know that WAV files use SF_FORMAT_PCM_U8 and AIFF
177 files use SF_FORMAT_PCM_S8. Thats all there is to it.
178
179 Erik
180 --
181 +-----------------------------------------------------------+
182 Erik de Castro Lopo nospam@fake-domain-name.com
183 +-----------------------------------------------------------+
184 "Python addresses true pseudocode's two major failings: that it
185 isn't standardized, and it isn't executable."
186 - Grant R. Griffin in comp.dsp
187
188 ================================================================================
189
190 Subject: Re: Can you help with a problem?
191 From: PFJ <paul@fake-domain-name.co.uk>
192 To: Erik de Castro Lopo <erikd@fake-domain-name.com>
193 Date: Wed, 21 Jul 2004 09:50:55 +0100
194
195 Hi Erik,
196
197 > > I know, but the source code explicitly has SF_FORMAT_PCM which given the
198 > > code afterwards would equate to one of the above, but given that PCM
199 > > files can have a varied bitwidth the author probably wanted to cover all
200 > > bases.
201 >
202 > But surely the existing code does something like:
203 >
204 > sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
205 > sfinfo.pcmbitwidth = 16;
206
207 If only!
208
209 The actual code is this
210
211 int LoadSoundFile(char *filename, sound_p sound)
212 {
213 SNDFILE *file;
214 SF_INFO file_info;
215 short *buffer_short = NULL;
216 u_int8_t *buffer_8 = NULL;
217 int16_t *buffer_16 = NULL;
218 unsigned int i;
219
220 /* Open the file and retrieve sample information. */
221 file = sf_open_read(filename, &file_info);
222 // I've sorted this one already - PFJ
223
224 /* Make sure the format is acceptable. */
225 if ((file_info.format & 0x0F) != SF_FORMAT_PCM) {
226 printf("'%s' is not a PCM-based audio file.\n", filename);
227 sf_close(file);
228 return -1;
229 }
230
231 if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) {
232 sound->format = AL_FORMAT_MONO8;
233 } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) {
234 sound->format = AL_FORMAT_STEREO8;
235 } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) {
236 sound->format = AL_FORMAT_MONO16;
237 } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) {
238 sound->format = AL_FORMAT_STEREO16;
239 } else {
240 printf("Unknown sample format in %s.\n", filename);
241 sf_close(file);
242 return -1;
243 }
244
245 /* Allocate buffers. */
246 buffer_short = (short *)malloc(file_info.samples * file_info.channels * sizeof (short));
247
248 buffer_8 = (u_int8_t *)malloc(file_info.samples * file_info.channels * file_info.pcmbitwidth / 8);
249
250 buffer_16 = (int16_t *)buffer_8;
251
252 if (buffer_short == NULL || buffer_8 == NULL) {
253 printf("Unable to allocate enough memory for '%s'.\n", filename);
254 goto error_cleanup;
255 }
256
257 /* Read the entire sound file. */
258 if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)-1) {
259 printf("Error while reading samples from '%s'.\n", filename);
260 goto error_cleanup;
261 }
262
263 <minor snip>
264
265 /* Fill in the sound data structure. */
266 sound->freq = file_info.samplerate;
267 sound->size = file_info.samples * file_info.channels * file_info.pcmbitwidth / 8;
268
269 /* Give our sound data to OpenAL. */
270 alGenBuffers(1, &sound->name);
271 if (alGetError() != AL_NO_ERROR) {
272 printf("Error creating an AL buffer name for %s.\n", filename);
273 goto error_cleanup;
274 }
275
276 alBufferData(sound->name, sound->format, buffer_8, sound->size,sound->freq);
277 if (alGetError() != AL_NO_ERROR) {
278 printf("Error sending buffer data to OpenAL for %s.\n", filename);
279 goto error_cleanup;
280 }
281
282 /* Close the file and return success. */
283 sf_close(file);
284 free(buffer_short);
285 free(buffer_8);
286
287 return 0;
288
289 error_cleanup:
290 if (file != NULL) fclose(file);
291 free(buffer_short);
292 free(buffer_8);
293 return -1;
294 }
295
296 As you can see, the PCM material in the listing will not currently
297 compile and for the other sndfile material, it probably won't either.
298
299 Any help would be appreciated.
300
301 TTFN
302
303 Paul
304
305 ================================================================================
306
307 From: Erik de Castro Lopo <erikd@fake-domain-name.com>
308 To: PFJ <paul@fake-domain-name.co.uk>
309 Subject: Re: Can you help with a problem?
310 Date: Wed, 21 Jul 2004 19:36:46 +1000
311
312 On Wed, 21 Jul 2004 09:50:55 +0100
313 PFJ <paul@fake-domain-name.co.uk> wrote:
314
315 > Hi Erik,
316 >
317 > > > I know, but the source code explicitly has SF_FORMAT_PCM which given the
318 > > > code afterwards would equate to one of the above, but given that PCM
319 > > > files can have a varied bitwidth the author probably wanted to cover all
320 > > > bases.
321 > >
322 > > But surely the existing code does something like:
323 > >
324 > > sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
325 > > sfinfo.pcmbitwidth = 16;
326 >
327 > If only!
328
329 No, really.
330
331 Drop this completely:
332
333 > /* Make sure the format is acceptable. */
334 > if ((file_info.format & 0x0F) != SF_FORMAT_PCM) {
335 > printf("'%s' is not a PCM-based audio file.\n", filename);
336 > sf_close(file);
337 > return -1;
338 > }
339
340 Replace this block:
341
342 > if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) {
343 > sound->format = AL_FORMAT_MONO8;
344 > } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) {
345 > sound->format = AL_FORMAT_STEREO8;
346 > } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) {
347 > sound->format = AL_FORMAT_MONO16;
348 > } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) {
349 > sound->format = AL_FORMAT_STEREO16;
350 > } else {
351 > printf("Unknown sample format in %s.\n", filename);
352 > sf_close(file);
353 > return -1;
354 > }
355
356 with:
357
358 int pcmbitwidth = 0;
359
360 if (file_info.format & SF_FORMAT_SUBMASK != SF_FORMAT_PCM_16)
361 { printf("'%s' is not a PCM-based audio file.\n", filename);
362 sf_close(file);
363 return -1;
364 }
365
366 if (file_info.channels < 1 || file_info.channels > 2)
367 { printf("'%s' bad channel count.\n", filename);
368 sf_close(file);
369 return -1;
370 }
371
372 switch (file_info.format & SF_FORMAT_SUBMASK + file_info.channels << 16)
373 { case (SF_FORMAT_PCM_U8 + 1 << 16):
374 sound->format = AL_FORMAT_MONO8;
375 pcmbitwidth = 8;
376 break;
377 case (SF_FORMAT_PCM_U8 + 2 << 16):
378 sound->format = AL_FORMAT_STEREO8;
379 pcmbitwidth = 8;
380 break;
381 case (SF_FORMAT_PCM_16 + 1 << 16):
382 sound->format = AL_FORMAT_MONO16;
383 pcmbitwidth = 16;
384 break;
385 case (SF_FORMAT_PCM_16 + 2 << 16):
386 sound->format = AL_FORMAT_STEREO16;
387 pcmbitwidth = 16;
388 break;
389 default:
390 printf("Unknown sample format in %s.\n", filename);
391 sf_close(file);
392 return -1;
393 }
394
395 > /* Allocate buffers. */
396 > buffer_short = (short *)malloc(file_info.samples *
397 > file_info.channels *
398 > sizeof (short));
399 >
400 > buffer_8 = (u_int8_t *)malloc(file_info.samples *
401 > file_info.channels *
402 > file_info.pcmbitwidth / 8);
403
404 Use pcmbitwidth as calculated above.
405
406 > buffer_16 = (int16_t *)buffer_8;
407 >
408 > if (buffer_short == NULL || buffer_8 == NULL) {
409 > printf("Unable to allocate enough memory for '%s'.\n", filename);
410 > goto error_cleanup;
411 > }
412 >
413 > /* Read the entire sound file. */
414 > if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)- 1) {
415
416 Replace "(size_t) - 1" with " < 0".
417
418 > As you can see, the PCM material in the listing will not currently
419 > compile and for the other sndfile material, it probably won't either.
420
421 None of the changes above should have been very difficult to figure
422 out.
423
424 Erik
425 --
426 +-----------------------------------------------------------+
427 Erik de Castro Lopo nospam@fake-domain-name.com
428 +-----------------------------------------------------------+
429 Microsoft is finally bringing all of its Windows operating system families
430 under one roof. It will combine all of the features of CE, stability and
431 support of ME and the speed of NT.
432 It will be called Windows CEMENT...
433
+0
-52
doc/lists.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile Mailing Lists
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
9 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
10 </HEAD>
11
12 <BODY>
13 <!-- pepper -->
14 <H1><BR>libsndfile Mailing Lists</H1>
15 <!-- pepper -->
16 <P>
17 There are three mailing lists for libsndfile:
18 </P>
19 <!-- pepper -->
20 <UL>
21 <LI> <B>libsndfile-announce&#64;mega-nerd.com</B>&nbsp;&nbsp;<!-- pepper -->
22 <A HREF="m&#97;ilt&#111;:li&#98;sndfile-announce-request@meg&#97;-nerd.&#99;om?subject=subscribe">Subscribe</A>
23 <BR>
24 A list which will announce each new release of libsndfile.
25 Noone can post to this list except the author.
26 <BR><BR>
27
28 <LI> <B>libsndfile-devel&#64;mega-nerd.com</B>&nbsp;&nbsp;<!-- pepper -->
29 <A HREF="m&#97;ilt&#111;:li&#98;sndfile-devel-request@meg&#97;-nerd.&#99;om?subject=subscribe">Subscribe</A>
30 <BR>
31 A list for discussing bugs, porting issues and feature requests.
32 Posting is restricted to subscribers.
33 <BR><BR>
34
35 <LI> <B>libsndfile-users&#64;mega-nerd.com</B>&nbsp;&nbsp;<!-- pepper -->
36 <A HREF="m&#97;ilt&#111;:li&#98;sndfile-users-request@meg&#97;-nerd.&#99;om?subject=subscribe">Subscribe</A>
37 <BR>
38 A list for discussing the use of libsndfile in other programs.
39 Posting is restricted to subscribers.
40 <!-- pepper -->
41 <BR><BR>
42 </UL>
43 <!-- pepper -->
44 <P>
45 The libsndfile-devel and libsndfile-users list will automatically receive a
46 copy of all emails to the libsndfile-announce list.
47 </P>
48 <BR>
49 <!-- pepper -->
50 </BODY>
51 </HTML>
+0
-135
doc/new_file_type.HOWTO less more
0 new_file_type.HOWTO
1 ===================
2
3 Original : Wed May 23 19:05:07 EST 2001
4 Update 1 : Fri Jul 11 22:12:38 EST 2003
5
6 This document will attempt to explain as fully as possible how to add code to
7 libsndfile to allow the reading and writing of new file types. By new file
8 type I particularly mean a new header type rather than a new encoding method
9 for an existing file type.
10
11 This HOWTO will take the form of a step by step guide. It will assume that you
12 have all required tools including :
13
14 - gcc
15 - make (should really be the GNU version)
16 - autoconf
17 - automake
18 - libtool
19
20 These should all be available on the GNU ftp site: ftp://ftp.gnu.org/pub/gnu/.
21
22 To help make these steps clearer let's suppose we are adding support for the
23 Whacky file format whose files contain 'W','A','C' and 'K' as the first four
24 bytes of the file format. Lets also assume that Whacky files contain PCM encoded
25 data.
26
27 Step 1
28 ------
29 Create a new .c file in the src/ directory of the libsndfile source tree. The
30 file name should be reasonable descriptive so that is is obvious that files of
31 the new type are handled by this file. In this particular case the file might
32 be named 'whacky.c'.
33
34 Step 2
35 ------
36 Add your new source code file to the build process.
37
38 Edit the file src/Makefile.am and add the name of your file handler to the
39 FILESPECIFIC list of handlers. This list looks something like this:
40
41 FILESPECIFIC = aiff.c au.c au_g72x.c nist.c paf.c raw.c samplitude.c \
42 svx.c wav.c wav_float.c wav_gsm610.c wav_ima_adpcm.c \
43 wav_ms_adpcm.c
44
45 Then, run the script named 'reconf' in the libsndfile top level directory,
46 which will run autoconf and other associated tools. Finally run "./configure"
47 in the top level directory. You may want to use the "--disable-gcc-opt" option
48 to disable gcc optimisations and make debugging with gdb/ddd easier.
49
50 Step 3
51 ------
52 Add a unique identifier for the new file type.
53
54 Edit src/sndfile.h.in and find the enum containing the SF_FORMAT_XXX identifiers.
55 Since you will be adding a major file type you should add your identifier to the
56 top part of the list where the values are above 0x10000 in value. The easiest
57 way to do this is to find the largest value in the list, add 0x10000 to it and
58 make that your new identifier value. The identifier should be something like
59 SF_FORMAT_WACK.
60
61 Step 4
62 ------
63 Add code to the file type recogniser function.
64
65 Edit src/sndfile.c and find the function guess_file_type (). This function
66 reads the first 3 ints of the file and from that makes a guess at the file
67 type. In our case we would add:
68
69
70 if (buffer [0] == MAKE_MARKER ('W','A','C','K'))
71 return SF_FORMAT_WACK ;
72
73 The use of the MAKE_MARKER macro should be pretty obvious and it is defined at the
74 top of file should you need to have a look at it.
75
76 Step 5
77 ------
78 Add a call to your open function from psf_open_file ().
79
80 Edit src/sndfile.c and find the switch statement in psf_open_file (). It starts
81 like this:
82
83 switch (filetype)
84 { case SF_FORMAT_WAV :
85 error = wav_open (psf) ;
86 break ;
87
88 case SF_FORMAT_AIFF :
89 error = aiff_open (psf) ;
90 break ;
91
92 Towards the bottom of this switch statement your should add one for the new file
93 type. Something like:
94
95 case SF_FORMAT_WACK :
96 sf_errno = whacky_open (psf) ;
97 break ;
98
99 Setp 6
100 ------
101 Add prototypes for new open read and open write functions.
102
103 Edit src/common.h, go to the bottom of the file and add something like
104
105 int whacky_open (SF_PRIVATE *psf) ;
106
107 Step 7
108 ------
109
110 Implement your open read function. The best way to do this is by coding
111 something much like one of the other file formats. The file src/au.c might be
112 a good place to start.
113
114 In src/whacky.c you should now implement the function whacky_open() which
115 was prototyped in src/common.h. This function should return 0 on success and
116 a non-zero number on error.
117
118 Error values are defined in src/common.h in a enum which starts at SFE_NO_ERROR.
119 When adding a new error value, you also need to add an error string to the
120 SndfileErrors array in src/sndfile.c.
121
122 To parse the header of your new file type you should avoid using standard read/
123 write/seek functions (and the fread/fwrite/fseek etc) and instead use
124 psf_binheader_readf () which is implemented and documented in src/common.h.
125
126 During the parsing process, you should also print logging information to
127 libsndfile's internal log buffer using the psf_log_printf() function.
128
129 At the end of the open read process, you should have set a number of fields in the
130 SF_PRIVATE structure pointed to by psf.
131
132
133
134 *** THIS FILE IS INCOMPLETE ***
+0
-118
doc/octave.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile and GNU Octave
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
9 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
10 </HEAD>
11
12 <BODY>
13
14 <BR>
15 <H1><B>libsndfile and GNU Octave</B></H1>
16 <P>
17 <A HREF="http://www.octave.org/">GNU Octave</A> is a high-level interactive
18 language for numerical computations.
19 There are currently two development streams, a stable 2.0.X series and a
20 development 2.1.X series.
21 Octave reads and writes data in binary formats that were originally developed
22 for
23 <A HREF="http://www.mathworks.com/">MATLAB</A>.
24 Version 2.0.X of Octave uses binary data files compatible with MATLAB
25 version 4.2 while Octave 2.1.X uses binary data files compatible
26 with MATLAB version 5.0 as well as being able to read the older MATLAB 4.2
27 format.
28 </P>
29 <P>
30 From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading
31 and writing a small subset of the binary data files used by both versions
32 of GNU Octave.
33 This gives people using GNU Octave for audio based work an easy method of
34 moving audio data between GNU Octave and other programs which use libsndfile.
35 </P>
36 <P>
37 For instance it is now possible to do the following:
38 </P>
39
40 <UL>
41 <LI> Load a WAV file into a sound file editor such as
42 <A HREF="http://www.metadecks.org/software/sweep/">Sweep</A>.
43 <LI> Save it as a MAT4 file.
44 <LI> Load the data into Octave for manipulation.
45 <LI> Save the modified data.
46 <LI> Reload it in Sweep.
47 </UL>
48 <P>
49 Another example would be using the MAT4 or MAT5 file formats as a format which
50 can be easily loaded into Octave for viewing/analyzing as well as a format
51 which can be played with command line players such as the one included with
52 libsndfile.
53 </P>
54
55 <H2><B>Details</B></H2>
56 <P>
57 Octave, like most programming languages, uses variables to store data, and
58 Octave variables can contain both arrays and matrices.
59 It is also able to store one or more of these variables in a file.
60 When reading Octave files, libsndfile expects a file to contain two
61 variables and their associated data.
62 The first variable should contain a variable holding the file sample rate
63 while the second variable contains the audio data.
64 </P>
65 <P>
66 For example, to generate a sine wave and store it as a binary file which
67 is compatible with libsndfile, do the following:
68 </P>
69 <PRE>
70 octave:1 > samplerate = 44100 ;
71 octave:2 > wavedata = sin ((0:1023)*2*pi/1024) ;
72 octave:3 > save sine.mat samplerate wavedata
73 </PRE>
74
75 <P>
76 The process of reading and writing files compatible with libsndfile can be
77 made easier by use of two Octave script files :
78 </P>
79 <PRE>
80 octave:4 > [data fs] = sndfile_load ("sine.mat") ;
81 octave:5 > sndfile_save ("sine2.mat", data, fs) ;
82 </PRE>
83 <P>
84 In addition, libsndfile contains a command line program which which is able
85 to play the correct types of Octave files.
86 Using this command line player <B>sndfile-play</B> and a third Octave script
87 file allows Octave data to be played from within Octave on any of the platforms
88 which <B>sndfile-play</B> supports (at the moment: Linux, MacOS X, Solaris and
89 Win32).
90 </P>
91 <PRE>
92 octave:6 > sndfile_play (data, fs) ;
93 </PRE>
94 <P>
95 These three Octave scripts are installed automatically in Octave's site
96 script directory when libsndfile is installed (except on Win32) ie when
97 libsndfile is being installed into /usr/local, the Octave scripts will
98 be installed in /usr/local/share/octave/site/m/.
99 </P>
100
101 <P>
102 There are some other Octave scripts for audio to be found
103 <A HREF="http://octave.sourceforge.net/audio/index.html">here</A>.
104 </P>
105
106 <BR>
107 <!-- ========================================================================= -->
108
109 <HR>
110 <P>
111 The libsndfile home page is here :
112 <A HREF="http://www.mega-nerd.com/libsndfile/">
113 http://www.mega-nerd.com/libsndfile/</A>.
114 </P>
115
116 </BODY>
117 </HTML>
+0
-14
doc/print.css less more
0 body {
1 background:white;
2 color:black;
3 }
4
5 h1{
6 background:white;
7 color:black;
8 }
9
10 h2 {
11 background:white;
12 color:#666;
13 }
+0
-53
doc/sndfile_info.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 sndfile-info
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
9 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
10 </HEAD>
11
12 <BODY>
13
14 <P>
15 Here is an example of the output from the <B>sndfile-info</B> program distributed with
16 libsndfile.
17 </P>
18
19 <P>
20 This file was opened and parsed correctly but had been truncated so that the values
21 in the <B>FORM</B> and <B>SSND</B> chunks were incorrect.
22 </P>
23 <PRE>
24 <B>erikd@hendrix ></B> examples/sndfile-info truncated.aiff
25 truncated.aiff
26 size : 200000
27 FORM : 307474 (should be 199992)
28 AIFF
29 COMM : 18
30 Sample Rate : 16000
31 Samples : 76857
32 Channels : 2
33 Sample Size : 16
34 SSND : 307436 (should be 199946)
35 Offset : 0
36 Block Size : 0
37
38 --------------------------------
39 Sample Rate : 16000
40 Frames : 76857
41 Channels : 2
42 Bit Width : 16
43 Format : 0x00020001
44 Sections : 1
45 Seekable : TRUE
46 Signal Max : 32766
47
48 </PRE>
49
50
51 </BODY>
52 </HTML>
+0
-34
doc/tutorial.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 libsndfile Tutorial
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
9 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
10 </HEAD>
11
12 <BODY>
13 <!-- pepper -->
14 <H1><BR>libsndfile Tutorial</H1>
15 <!-- pepper -->
16 <P>
17 <b>More coming soon.</b>
18 </P>
19 <!-- pepper -->
20 <P>
21 For now, the best place to look for example code is the <tt>examples/</tt>
22 directory of the source code distribution and the libsndfile test suite which
23 is located in the <tt>tests/</tt> directory of the source code distribution.
24 </P>
25 <!-- pepper -->
26 <!-- pepper -->
27 <!-- pepper -->
28 <!-- pepper -->
29 <!-- pepper -->
30 <!-- pepper -->
31 </BODY>
32 </HTML>
33
+0
-52
doc/win32.html less more
0 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
1 <HTML>
2
3 <HEAD>
4 <TITLE>
5 Building libsndfile on Win32
6 </TITLE>
7 <META NAME="Author" CONTENT="Erik de Castro Lopo (erikd AT mega-nerd DOT com)">
8 <LINK REL="stylesheet" HREF="libsndfile.css" TYPE="text/css" MEDIA="all">
9 <LINK REL="stylesheet" HREF="print.css" TYPE="text/css" MEDIA="print">
10 </HEAD>
11
12 <BODY>
13 <!-- pepper -->
14 <H1><BR>Building libsndfile on Win32</H1>
15
16 <P><B>
17 Note : For pre-compiled binaries for windows, both for win32 and win64, see the
18 main web page.
19 </B></P>
20
21 <P>
22 There are currently two build systems; the official GNU autotool based one and
23 a more limited and experimental CMake based build system.
24 </P>
25
26 <P>
27 libsndfile is written to be compiled by a compiler which supports large
28 chunks of the 1999 ISO C Standard (tested with GCC, Clang and Visual
29 Studio 2015).
30 </P>
31
32 <P>
33 It is recommended to use CMake and Visual Studio to build libsndfile on Windows
34 but you can try the
35 <a href="http://www.mingw.org/">MinGW</a>
36 compiler suite with Autotools or CMake buildsystem.
37 </P>
38
39 <!--===========================================================================-->
40
41 <!-- pepper -->
42 <!-- pepper -->
43 <!-- pepper -->
44 <BR>
45 <!-- pepper -->
46 <!-- pepper -->
47 <!-- pepper -->
48 <!-- pepper -->
49
50 </BODY>
51 </HTML>
0 ---
1 layout: default
2 title: libsndfile : Frequently Asked Questions.
3 ---
4
5 # libsndfile : Frequently Asked Questions
6
7 1. [Do you plan to support XYZ codec in libsndfile?](#Q001)
8 2. [In version 0 the SF\_INFO struct had a pcmbitwidth field but version 1 does not. Why?](#Q002)
9 3. [Compiling is really slow on MacOS X. Why?](#Q003)
10 4. [When trying to compile libsndfile on Solaris I get a "bad substitution" error during linking. What can I do to fix this?](#Q004)
11 5. [Why doesn't libsndfile do interleaving/de-interleaving?](#Q005)
12 6. [What's the best format for storing temporary files?](#Q006)
13 7. [On Linux/Unix/MacOS X, what's the best way of detecting the presence of libsndfile?](#Q007)
14 8. [I have libsndfile installed and now I want to use it. I just want a simple Makefile\! What do I do?](#Q008)
15 9. [How about adding the ability to write/read sound files to/from memory buffers?](#Q009)
16 10. [Reading a 16 bit PCM file as normalised floats and then writing them back changes some sample values. Why?](#Q010)
17 11. [I'm having problems with u-law encoded WAV files generated by libsndfile in Winamp. Why?](#Q011)
18 12. [I'm looking at sf\_read\*. What are items? What are frames?](#Q012)
19 13. [Why can't libsndfile open this Sound Designer II (SD2) file?](#Q013)
20 14. [I'd like to statically link libsndfile to my closed source application. Can I buy a license so that this is possible?](#Q014)
21 15. [My program is crashing during a call to a function in libsndfile. Is this a bug in libsndfile?](#Q015)
22 16. [Will you accept a fix for compiling libsndfile with compiler X?](#Q016)
23 17. [Can libsndfile read/write files from/to UNIX pipes?](#Q017)
24 18. [Is it possible to build a Universal Binary on Mac OS X?](#Q018)
25 19. [I have project files for Visual Studio / XCode / Whatever. Why don't you distribute them with libsndfile?](#Q019)
26 20. [Why doesn't libsndfile support MP3?](#Q020)
27 21. [How do I use libsndfile in a closed source or commercial program and comply with the license?](#Q021)
28 22. [What versions of windows does libsndfile work on?](#Q022)
29 23. [I'm cross compiling libsndfile for another platform. How can I run the test suite?](#Q023)
30
31 -----
32
33 ## Q1 : Do you plan to support XYZ codec in libsndfile? {#Q001}
34
35 If source code for XYZ codec is available under a suitable license (LGPL, BSD,
36 MIT etc) then yes, I'd like to add it.
37
38 If suitable documentation is available on how to decode and encode the format
39 then maybe, depending on how much work is involved.
40
41 If XYZ is some proprietary codec where no source code or documentation is
42 available then no.
43
44 So if you want support for XYZ codec, first find existing source code or
45 documentation. If you can't find either then the answer is no.
46
47 ## Q2 : In version 0 the SF\_INFO struct had a pcmbitwidth field but version 1 does not. Why? {#Q002}
48
49 This was dropped for a number of reasons:
50
51 - pcmbitwidth makes little sense on compressed or floating point formats
52 - with the new API you really don't need to know it
53
54 As documented [here](api.md#note-1) there is now a well defined behaviour which
55 ensures that no matter what the bit width of the source file, the scaling always
56 does something sensible. This makes it safe to read 8, 16, 24 and 32 bit PCM
57 files using `sf_read_short()` and always have the optimal behaviour.
58
59 ## Q3 : Compiling is really slow on MacOS X. Why? {#Q003}
60
61 When you configure and compile libsndfile, it uses the /bin/sh shell for a
62 number of tasks (ie configure script and libtool). Older versions of OS X
63 (10.2?) shipped a really crappy Bourne shell as /bin/sh which resulted in
64 **really** slow compiles. Newer version of OS X ship GNU Bash as /bin/sh and
65 this answer doesn't apply in that case.
66
67 To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
68 /bin/sh.old and make a symlink from /bin/sh to the bash shell. Bash is designed
69 to behave as a Bourne shell when it is called as /bin/sh.
70
71 When I did this on my iBook running MacOS X, compile times dropped from 13
72 minutes to 3 minutes.
73
74 ## Q4 : When trying to compile libsndfile on Solaris I get a "bad substitution" error on linking. Why? {#Q004}
75
76 It seems that the Solaris Bourne shell disagrees with GNU libtool.
77
78 To fix this I suggest that you install the GNU Bash shell, rename /bin/sh to
79 /bin/sh.old and make a symlink from /bin/sh to the bash shell. Bash is designed
80 to behave as a Bourne shell when it is called as /bin/sh.
81
82 ## Q5 : Why doesn't libsndfile do interleaving/de-interleaving? {#Q005}
83
84 This problem is bigger than it may seem at first.
85
86 For a stereo file, it is a pretty safe bet that a simple interleaving/
87 de-interleaving could satisfy most users. However, for files with more than 2
88 channels this is unlikely to be the case. If the user has a 4 channel file and
89 want to play that file on a stereo output sound card they either want the first
90 2 channels or they want some mixed combination of the 4 channels.
91
92 When you add more channels, the combinations grow exponentially and it becomes
93 increasingly difficult to cover even a sensible subset of the possible
94 combinations. On top of that, coding any one style of interleaver/de-interleaver
95 is trivial, while coding one that can cover all combinations is far from
96 trivial. This means that this feature will not be added any time soon.
97
98 ## Q6 : What's the best format for storing temporary files? {#Q006}
99
100 When you want to store temporary data there are a number of requirements:
101
102 - A simple, easy to parse header.
103 - The format must provide the fastest possible read and write rates (ie avoid
104 conversions and encoding/decoding).
105 - The file format must be reasonably common and playable by most players.
106 - Able to store data in either endian-ness.
107
108 The format which best meets these requirements is AU, which allows data to be
109 stored in any one of short, int, float and double (among others) formats.
110
111 For instance, if an application uses float data internally, its temporary files
112 should use a format of (SF_ENDIAN_CPU | SF_FORMAT_AU | SF_FORMAT_FLOAT) which
113 will store big endian float data in big endian CPUs and little endian float data
114 on little endian CPUs. Reading and writing this format will not require any
115 conversions or byte swapping regardless of the host CPU.
116
117 ## Q7 : On Linux/Unix/MaxOS X, what's the best way of detecting the presence of libsndfile using autoconf? {#Q007}
118
119 libsndfile uses the pkg-config (man pkg-config) method of registering itself
120 with the host system. The best way of detecting its presence is using something
121 like this in configure.ac (or configure.in):
122
123 PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.2, ac_cv_sndfile=1, ac_cv_sndfile=0)
124
125 AC_DEFINE_UNQUOTED([HAVE_SNDFILE],${ac_cv_sndfile},
126 [Set to 1 if you have libsndfile.])
127
128 AC_SUBST(SNDFILE_CFLAGS)
129 AC_SUBST(SNDFILE_LIBS)
130
131 This will automatically set the **SNDFILE_CFLAGS** and **SNDFILE_LIBS**
132 variables which can be used in Makefile.am like this:
133
134 SNDFILE_CFLAGS = @SNDFILE_CFLAGS@
135 SNDFILE_LIBS = @SNDFILE_LIBS@
136
137 If you install libsndfile from source, you will probably need to set the
138 **PKG_CONFIG_PATH** environment variable as suggested at the end of the
139 libsndfile configure process. For instance on my system I get this:
140
141 -=-=-=-=-=-=-=-=-=-= Configuration Complete =-=-=-=-=-=-=-=-=-=-
142
143 Configuration summary :
144
145 Version : ..................... 1.0.5
146 Experimental code : ........... no
147
148 Tools :
149
150 Compiler is GCC : ............. yes
151 GCC major version : ........... 3
152
153 Installation directories :
154
155 Library directory : ........... /usr/local/lib
156 Program directory : ........... /usr/local/bin
157 Pkgconfig directory : ......... /usr/local/lib/pkgconfig
158
159 Compiling some other packages against libsndfile may require
160 the addition of "/usr/local/lib/pkgconfig" to the
161 PKG_CONFIG_PATH environment variable.
162
163 ## Q8 : I have libsndfile installed and now I want to use it. I just want a simple Makefile\! What do I do? {#Q008}
164
165 The **pkg-config** program makes finding the correct compiler flag values and
166 library location far easier. During the installation of libsndfile, a file named
167 **sndfile.pc** is installed in the directory **${libdir}/pkgconfig** (ie if
168 libsndfile is installed in **/usr/local/lib**, **sndfile.pc** will be installed
169 in **/usr/local/lib/pkgconfig/**).
170
171 In order for pkg-config to find sndfile.pc it may be necessary to point the
172 environment variable **PKG_CONFIG_PATH** in the right direction.
173
174 export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig
175
176 Then, to compile a C file into an object file, the command would be:
177
178 gcc `pkg-config --cflags sndfile` -c somefile.c
179
180 and to link a number of objects into an executable that links against
181 libsndfile, the command would be:
182
183 gcc `pkg-config --libs sndfile` obj1.o obj2.o -o program
184
185 ## Q9 : How about adding the ability to write/read sound files to/from memory buffers? {#Q009}
186
187 This has been [added](api.md#open_virtual) for version 1.0.12.
188
189 ## Q10 : Reading a 16 bit PCM file as normalised floats and then writing them back changes some sample values. Why? {#Q010}
190
191 This is caused by the fact that the conversion from 16 bit short to float is
192 done by dividing by 32768 (0x8000 in hexadecimal) while the conversion from
193 float to 16 bit short is done by multiplying by 32767 (0x7FFF in hex). So for
194 instance, a value in a 16 bit PCM file of 20000 gets read as a floating point
195 number of 0.6103515625 (20000.0 / 0x8000). Converting that back to a 16 bit
196 short results in a value of 19999.3896484375 (0.6103515625 \* 0x7FFF) which then
197 gets rounded down to 19999.
198
199 You will notice that for this particular case, the error is 1 in 20000 or
200 0.005%. Interestingly, for values of less than 16369, dividing by 0x8000
201 followed by multiplying by 0x7FFF and then rounding the result, gives back the
202 original value. It turns out that as long as the host operating system supplies
203 the 1999 ISO C Standard functions **lrintf** and **lrint** (or a replacement has
204 been supplied) then the maximum possible error is 1 in 16369 or about 0.006%.
205
206 Regardless of the size of the error, the reason why this is done is rather
207 subtle.
208
209 In a file containing 16 bit PCM samples, the values are restricted to the range
210 [-32768, 32767] while we want floating point values in the range [-1.0, 1.0].
211 The only way to do this conversion is to do a floating point division by a value
212 of 0x8000. Converting the other way, the only way to ensure that floating point
213 values in the range [-1.0, 1.0] are within the valid range allowed by a 16 bit
214 short is to multiply by 0x7FFF.
215
216 Some people would say that this is a severe short-coming of libsndfile. I would
217 counter that anybody who is constantly converting back and forth between 16 bit
218 shorts and normalised floats is going to suffer other losses in audio quality
219 that they should also be concerned about.
220
221 Since this problem only occurs when converting between integer data on disk and
222 normalized floats in the application, it can be avoided by using something other
223 than normalized floats in the application. Alternatives to normalized floats are
224 the **short** and **int** data types (ie using sf_read_short or sf_read_int) or
225 using un-normalized floats (see
226 [SFC_SET_NORM_FLOAT](command.html#sfc_set_norm_float)).
227
228 Another way to deal with this problem is to consider 16 bit short data as a
229 final destination format only, not as an intermediate storage format. All
230 intermediate data (ie which is going to be processed further) should be stored
231 in floating point format which is supported by all of the most common file
232 formats. If floating point files are considered too large (2 times the size of a
233 16 bit PCM file), it would also be possible to use 24 bit PCM as an intermediate
234 storage format (and which is also supported by most common file types).
235
236 ## Q11 : I'm having problems with u-law encoded WAV files generated by libsndfile in Winamp. Why? {#Q011}
237
238 This is actually a Winamp problem. The official Microsoft spec suggests that the
239 'fmt ' chunk should be 18 bytes. Unfortunately at least one of Microsoft's own
240 applications (Sound Recorder on Win98 I believe) did not accept 18 bytes 'fmt '
241 chunks.
242
243 Michael Lee did some experimenting and found that:
244
245 > I have checked that Windows Media Player 9, QuickTime Player 6.4, RealOne
246 > Player 2.0 and GoldWave 5.06 can all play u-law files with 16-byte or 18-byte
247 > 'fmt ' chunk. Only Winamp (2.91) and foobar2000 are unable to play u-law files
248 > with 16-byte 'fmt ' chunk.
249
250 Even this is a very small sampling of all the players out there. For that reason
251 it is probably not a good idea to change this now because there is the risk of
252 breaking something that currently works.
253
254 ## Q12 : I'm looking at sf_read*. What are items? What are frames? {#Q012}
255
256 An `item` is a single sample of the data type you are reading; ie a single
257 `short` value for `sf_read_short` or a single `float` for `sf_read_float`.
258
259 For a sound file with only one channel, a frame is the same as a item (ie a
260 single sample) while for multi channel sound files, a single frame contains a
261 single item for each channel.
262
263 Here are two simple, correct examples, both of which are assumed to be working
264 on a stereo file, first using items:
265
266 ```c
267 #define CHANNELS 2
268 short data [CHANNELS * 100] ;
269 sf_count items_read = sf_read_short (file, data, 200) ;
270 assert (items_read == 200) ;
271 ```
272
273 and now reading the exact same amount of data using frames:
274
275 ```c
276 #define CHANNELS 2
277 short data [CHANNELS * 100] ;
278 sf_count frames_read = sf_readf_short (file, data, 100) ;
279 assert (frames_read == 100) ;
280 ```
281
282 ## Q13 : Why can't libsndfile open this Sound Designer II (SD2) file? {#Q013}
283
284 This is somewhat complicated. First some background.
285
286 SD2 files are native to the Apple Macintosh platform and use features of the Mac
287 filesystem (file resource forks) to store the file's sample rate, number of
288 channels, sample width and more. When you look at a file and its resource fork
289 on Mac OS X it looks like this:
290
291 -rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2
292 -rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 file.sd2/rsrc
293
294 Notice how the file itself looks like a directory containing a single file named
295 **rsrc**. When libsndfile is compiled for MacOS X, it should open (for write and
296 read) SD2 file with resource forks like this without any problems. It will also
297 handle files with the resource fork in a separate file as described below.
298
299 When SD2 files are moved to other platforms, the resource fork of the file can
300 sometimes be dropped altogether. All that remains is the raw audio data and no
301 information about the number of channels, sample rate or bit width which makes
302 it a little difficult for libsndfile to open the file.
303
304 However, it is possible to safely move an SD2 file to a Linux or Windows
305 machine. For instance, when an SD2 file is copied from inside MacOS X to a
306 windows shared directory or a Samba share (ie Linux), MacOS X is clever enough
307 to store the resource fork of the file in a separate hidden file in the same
308 directory like this:
309
310 -rw-r--r-- 1 erikd erikd 538 Oct 18 22:57 ._file.sd2
311 -rw-r--r-- 1 erikd erikd 46512 Oct 18 22:57 file.sd2
312
313 Regardless of what platform it is running on, when libsndfile is asked to open a
314 file named **"foo"** and it can't recognize the file type from the data in the
315 file, it will attempt to open the resource fork and if that fails, it then tries
316 to open a file named **"._foo"** to see if the file has a valid resource fork.
317 This is the same regardless of whether the file is being opened for read or
318 write.
319
320 In short, libsndfile should open SD2 files with a valid resource fork on all of
321 the platforms that libsndfile supports. If a file has lost its resource fork,
322 the only option is the open the file using the SF_FORMAT_RAW option and guessing
323 its sample rate, channel count and bit width.
324
325 Occasionally, when SD2 files are moved to other systems, the file is
326 [BinHexed](http://www.macdisk.com/binhexen.php3) which wraps the resource fork
327 and the data fork together. For these files, it would be possible to write a
328 BinHex parser but there is not a lot to gain considering how rare these BinHexed
329 SD2 files are.
330
331 ## Q14 : I'd like to statically link libsndfile to my closed source application. Can I buy a license so that this is possible? {#Q014}
332
333 Unfortunately no. libsndfile contains code written by other people who have
334 agreed that their code be used under the GNU LGPL but no more. Even if they were
335 to agree, there would be significant difficulties in dividing up the payments
336 fairly.
337
338 The **only** way you can legally use libsndfile as a statically linked library
339 is if your application is released under the GNU GPL or LGPL.
340
341 ## Q15 : My program is crashing during a call to a function in libsndfile. Is this a bug in libsndfile? {#Q015}
342
343 libsndfile is being used by large numbers of people all over the world without
344 any problems like this. That means that it is much more likely that your code
345 has a bug than libsndfile. However, it is still possible that there is a bug in
346 libsndfile.
347
348 To figure out whether it is your code or libsndfile you should do the following:
349
350 - Make sure you are compiling your code with warnings switched on and that you
351 fix as many warnings as possible. With the GNU compiler (gcc) I would
352 recommend at least **-W -Wall -Werror** which will force you to fix all
353 warnings before you can run the code.
354 - Try using a memory debugger. [Valgrind](http://valgrind.kde.org/) on x86 Linux
355 is excellent. [Purify](http://www.ibm.com/software/awdtools/purify/) also has
356 a good reputation.
357 - If the code is clean after the above two steps and you still get a crash in
358 libsndfile, then send me a small snippet of code (no more than 30-40 lines)
359 which includes the call to sf_open() and also shows how all variables passed
360 to/returned from sf_open() are defined.
361
362 ## Q16 : Will you accept a fix for compiling libsndfile with compiler X? {#Q016}
363
364 If compiler X is a C++ compiler then no. C and C++ are different enough to make
365 writing code that compiles as valid C and valid C++ too difficult. I would
366 rather spend my time fixing bugs and adding features.
367
368 If compiler X is a C compiler then I will do what I can as long as that does not
369 hamper the correctness, portability and maintainability of the existing code. It
370 should be noted however that libsndfile uses features specified by the 1999 ISO
371 C Standard. This can make compiling libsndfile with some older compilers
372 difficult.
373
374 ## Q17 : Can libsndfile read/write files from/to UNIX pipes? {#Q017}
375
376 Yes, libsndfile can read files from pipes. Unfortunately, the write case is much
377 more complicated.
378
379 File formats like AIFF and WAV have information at the start of the file (the
380 file header) which states the length of the file, the number of sample frames
381 etc. This information must be filled in correctly when the file header is
382 written, but this information is not reliably known until the file is closed.
383 This means that libsndfile cannot write AIFF, WAV and many other file types to a
384 pipe.
385
386 However, there is at least one file format (AU) which is specifically designed
387 to be written to a pipe. Like AIFF and WAV, AU has a header with a sample frames
388 field, but it is specifically allowable to set that frames field to 0x7FFFFFFF
389 if the file length is not known when the header is written. The AU file format
390 can also hold data in many of the standard formats (ie SF_FORMAT_PCM_16,
391 SF_FORMAT_PCM_24, SF_FORMAT_FLOAT etc) as well as allowing data in both big and
392 little endian format.
393
394 See also [FAQ Q6](#Q006).
395
396 ## Q18 : Is it possible to build a Universal Binary on Mac OS X? {#Q018}
397
398 Yes, but you must do two separate configure/build/test runs; one on PowerPC and
399 one on Intel. It is then possible to merge the binaries into a single universal
400 binary using one of the programs in the Apple tool chain.
401
402 It is **not** possible to build a working universal binary via a single
403 compile/build run on a single CPU.
404
405 The problem is that the libsndfile build process detects features of the CPU its
406 being built for during the configure process and when building a universal
407 binary, configure is only run once and that data is then used for both CPUs.
408 That configure data will be wrong for one of those CPUs. You will still be able
409 to compile libsndfile, and the test suite will pass on the machine you compiled
410 it on. However, if you take the universal binary test suite programs compiled on
411 one CPU and run them on the other, the test suite will fail.
412
413 Part of the problem is that the CPU endian-ness is detected at configure time.
414 Yes, I know the Apple compiler defines one of the macros \_\_LITTLE\_ENDIAN\_\_
415 and \_\_BIG\_ENDIAN\_\_, but those macros are not part of the 1999 ISO C
416 Standard and they are not portable.
417
418 Endian issues are not the only reason why the cross compiled binary will fail.
419 The configure script also detects other CPU specific idiosyncrasies to provide
420 more optimized code.
421
422 Finally, the real show stopper problem with universal binaries is the problem
423 with the test suite. libsndfile contains a huge, comprehensive test suite. When
424 you compile a universal binary and run the test suite, you only test the native
425 compile. The cross compiled binary (the one with the much higher chance of
426 having problems) cannot be tested.
427
428 Now, if you have read this far you're probably thinking there must be a way to
429 fix this and there probably is. The problem is that its a hell of a lot of work
430 and would require significant changes to the configure process, the internal
431 code and the test suite. In addition, these changes must not break compilation
432 on any of the platforms libsndfile is currently working on.
433
434 ## Q19 : I have project files for Visual Studio / XCode / Whatever. Why don't you distribute them with libsndfile? {#Q019}
435
436 Use CMake project.
437
438 ## Q20 : Why doesn't libsndfile support MP3? {#Q020}
439
440 In the past, MP3 was not supported because the technology behind MP3 was
441 patented. Those patents have now expired and there is an
442 [open ticket](https://github.com/libsndfile/libsndfile/issues/258) to implement
443 MP3 support.
444
445 ## Q21 : How do I use libsndfile in a closed source or commercial program and comply with the license? {#Q021}
446
447 Here is a checklist of things you need to do to make sure your use of libsndfile
448 in a closed source or commercial project complies with the license libsndfile is
449 released under, the GNU Lesser General Public License (LGPL):
450
451 - Make sure you are linking to libsndfile as a shared library (Linux and Unix
452 systems), Dynamic Link Library (Microsoft Windows) or dynlib (Mac OS X). If
453 you are using some other operating system that doesn't allow dynamically
454 linked libraries, you will not be able to use libsndfile unless you release
455 the source code to your program.
456 - In the licensing documentation for your program, add a statement that your
457 software depends on libsndfile and that libsndfile is released under the GNU
458 Lesser General Public License, either
459 [version 2.1](http://www.gnu.org/licenses/lgpl-2.1.txt) or optionally
460 [version 3](http://www.gnu.org/licenses/lgpl.txt).
461 - Include the text for both versions of the license, possibly as separate files
462 named libsndfile_lgpl_v2_1.txt and libsndfile_lgpl_v3.txt.
463
464 ## Q22 : What versions of Windows does libsndfile work on? {#Q022}
465
466 New versions of libsndfile binary releases require Wiindows Vista. If you need
467 Windows XP support, you can build DLL from sources, we don't use specific WinXP
468 features.
469
470 ## Q23 : I'm cross compiling libsndfile for another platform. How can I run the test suite? {#Q023}
471
472 Since version 1.0.21 the top level Makefile has an extra make target,
473 'test-tarball'. Building this target creates a tarball called called:
474
475 ` libsndfile-testsuite-${host_triplet}-${version}.tar.gz`
476
477 in the top level directory. This tarball can then be copied to the target
478 platform. Once untarred and test script `test_wrapper.sh` can be run from the
479 top level of the extracted tarball.
0 ---
1 author: "The libsndfile team"
2 version: "1.0.31"
3
4 markdown: kramdown
5 plugins:
6 - jekyll-default-layout
7 ---
0 <img src="libsndfile.jpg" class="image-logo" height=98 width=367 alt="Logo">
0 <!DOCTYPE html>
1 <html lang="en">
2 <head>
3 <meta charset="utf-8">
4 <meta name="viewport" content="width=device-width, initial-scale=1.0">
5 <title>{{ page.title }}</title>
6 <link rel="stylesheet" href="libsndfile.css" type="text/css" media="all">
7 <link rel="stylesheet" href="print.css" type="text/css" media="print">
8 </head>
9 <body>
10 {{ content }}
11 <footer>
12 <hr>
13 <p>The libsndfile home page is <a href="http://libsndfile.github.io/libsndfile/">here</a>.</p>
14 <p>The libsndfile version: {{ site.version }}.</p>
15 </footer>
16 </body>
17 </html>
0 ---
1 layout: default
2 keywords: WAV AIFF AU SVX PAF NIST W64 libsndfile sound audio dsp Linux
3 robots: nofollow
4 title: libsndfile home page
5 ---
6
7 <footer>
8 {% include logo.html %}
9
10 <nav>
11 <a href="#history">History</a> -+-
12 <a href="#features">Features</a> -+-
13 <a href="#similar-or-related-projects">Similar or related projects</a> -+-
14 <a href="https://github.com/libsndfile/libsndfile/blob/master/NEWS">News</a>
15 <br>
16 <a href="development.html">Development</a> -+-
17 <a href="api.html">Programming interface</a> -+-
18 <a href="bugs.html">Bug reporting</a> -+-
19 <a href="#download">Download</a>
20 <br>
21 <a href="FAQ.html">FAQ</a> -+-
22 <a href="lists.html">Mailing lists</a> -+-
23 <a href="#licensing">Licensing information</a> -+-
24 <a href="#see-also">See also</a>
25 </nav>
26 <br><br>
27 </footer>
28
29 <main>
30 <article>
31 {{ content }}
32 </article>
33 </main>
0 ---
1 layout: default
2 ---
3
4
5 <main>
6 <article>
7 {{ content }}
8 </article>
9 </main>
0 ---
1 layout: page
2 title: The libsndfile API
3 ---
4
5 # libsndfile
6
7 Libsndfile is a library designed to allow the reading and writing of many different sampled sound file formats (such as
8 MS Windows WAV and the Apple/SGI AIFF format) through one standard library interface.
9
10 During read and write operations, formats are seamlessly converted between the format the application program has
11 requested or supplied and the file's data format. The application programmer can remain blissfully unaware of issues
12 such as file endian-ness and data format. See [Note 1](#note-1) and [Note 2](#note-2).
13
14 Every effort is made to keep these documents up-to-date, error free and unambiguous. However, since maintaining the
15 documentation is the least fun part of working on libsndfile, these docs can and do fall behind the behaviour of the
16 library. If any errors, omissions or ambiguities are found, please notify me (erikd) at mega-nerd dot com.
17
18 To supplement this reference documentation, there are simple example programs included in the source code tarball. The
19 test suite which is also part of the source code tarball is also a good place to look for the correct usage of the
20 library functions.
21
22 **Finally, if you think there is some feature missing from libsndfile, check that it isn't already implemented (and
23 documented) [here](command.md).**
24
25 ## Synopsis
26
27 ```c
28 #include <stdio.h>;
29 #include <sndfile.h>;
30 ```
31
32 | Name | Description |
33 |:------------------------------------------------------------------------------------------------------------|:--------------------------------------- |
34 | [sf_open, sf_wchar_open](#open) | File open functions. |
35 | [sf_open_fd](#open_fd) | Open sound file using file descriptor. |
36 | [sf_open_virtual](#open_virtual) | Open sound file using virtual API. |
37 | [sf_format_check](#check) | Validate sound file info. |
38 | [sf_seek](#seek) | Seek position in sound file. |
39 | [sf_command](command.md) | Command interface. |
40 | [sf_error, sf_strerror, sf_error_number, sf_perror, sf_error_str](#error) | Error functions. |
41 | [sf_close](#close) | File close function. |
42 | [sf_write_sync](#write_sync) | Write sync function. |
43 | [sf_read_short, sf_read_int, sf_read_float, sf_read_double](#read) | File items read functions. |
44 | [sf_readf_short, sf_readf_int, sf_readf_float, sf_readf_double](#readf) | File frames read functions. |
45 | [sf_write_short, sf_write_int, sf_write_float, sf_write_double](#write) | File items write functions. |
46 | [sf_writef_short, sf_writef_int, sf_writef_float, sf_writef_double](#writef) | File frames write functions. |
47 | [sf_read_raw, sf_write_raw](#raw) | Raw read/write functions. |
48 | [sf_get_string, sf_set_string](#string) | Functions for reading and writing string data. |
49 | [sf_version_string](#version_string) | Retrive library version string. |
50 | [sf_current_byterate](#current_byterate) | Retrieve current byterate. |
51 | [sf_set_chunk, sf_get_chunk_iterator, sf_next_chunk_iterator, sf_get_chunk_size, sf_get_chunk_data](#chunk) | RIFF chunks API. |
52
53 SNDFILE* is an anonymous pointer to data which is private to the library.
54
55 ## File Open Function {#open}
56
57 ```c
58 SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ;
59 ```
60
61 The sf_open() function opens the sound file at the specified path. The filename is byte encoded, but may be utf-8 on
62 Linux, while on Mac OS X it will use the filesystem character set. On Windows, there is also a Windows specific
63 sf_wchar_open() that takes a UTF16_BE encoded filename.
64
65 ```c
66 SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;
67 ```
68
69 The SF_INFO structure is for passing data between the calling function and the library when opening a file for reading
70 or writing. It is defined in sndfile.h as follows:
71
72 ```c
73 typedef struct
74 { sf_count_t frames ; /* Used to be called samples. */
75 int samplerate ;
76 int channels ;
77 int format ;
78 int sections ;
79 int seekable ;
80 } SF_INFO ;
81 ```
82
83 The mode parameter for this function can be any one of the following three values:
84
85 SFM_READ
86 : read only mode
87
88 SFM_WRITE
89 : write only mode
90
91 SFM_RDWR
92 : read/write mode
93
94 When opening a file for read, the **format** field should be set to zero before
95 calling **sf_open**(). The only exception to this is the case of RAW files where
96 the caller has to set the **samplerate**, **channels** and **format** fields to
97 valid values. All other fields of the structure are filled in by the library.
98
99 When opening a file for write, the caller must fill in structure members
100 **samplerate**, **channels**, and **format**.
101
102 The **format** field in the above **SF_INFO** structure is made up of the
103 bit-wise OR of a major format type (values between 0x10000 and 0x08000000), a
104 minor format type (with values less than 0x10000) and an optional endian-ness
105 value. The currently understood formats are listed in *sndfile.h* as follows and
106 also include bitmasks for separating major and minor file types. Not all
107 combinations of endian-ness and major and minor file types are valid.
108
109 | Name | Value | Description |
110 |:-----------------------|:-----------|:-------------------------------------------|
111 | **Major formats.** |
112 | SF_FORMAT_WAV | 0x010000 | Microsoft WAV format (little endian). |
113 | SF_FORMAT_AIFF | 0x020000 | Apple/SGI AIFF format (big endian). |
114 | SF_FORMAT_AU | 0x030000 | Sun/NeXT AU format (big endian). |
115 | SF_FORMAT_RAW | 0x040000 | RAW PCM data. |
116 | SF_FORMAT_PAF | 0x050000 | Ensoniq PARIS file format. |
117 | SF_FORMAT_SVX | 0x060000 | Amiga IFF / SVX8 / SV16 format. |
118 | SF_FORMAT_NIST | 0x070000 | Sphere NIST format. |
119 | SF_FORMAT_VOC | 0x080000 | VOC files. |
120 | SF_FORMAT_IRCAM | 0x0A0000 | Berkeley/IRCAM/CARL |
121 | SF_FORMAT_W64 | 0x0B0000 | Sonic Foundry's 64 bit RIFF/WAV |
122 | SF_FORMAT_MAT4 | 0x0C0000 | Matlab (tm) V4.2 / GNU Octave 2.0 |
123 | SF_FORMAT_MAT5 | 0x0D0000 | Matlab (tm) V5.0 / GNU Octave 2.1 |
124 | SF_FORMAT_PVF | 0x0E0000 | Portable Voice Format |
125 | SF_FORMAT_XI | 0x0F0000 | Fasttracker 2 Extended Instrument |
126 | SF_FORMAT_HTK | 0x100000 | HMM Tool Kit format |
127 | SF_FORMAT_SDS | 0x110000 | Midi Sample Dump Standard |
128 | SF_FORMAT_AVR | 0x120000 | Audio Visual Research |
129 | SF_FORMAT_WAVEX | 0x130000 | MS WAVE with WAVEFORMATEX |
130 | SF_FORMAT_SD2 | 0x160000 | Sound Designer 2 |
131 | SF_FORMAT_FLAC | 0x170000 | FLAC lossless file format |
132 | SF_FORMAT_CAF | 0x180000 | Core Audio File format |
133 | SF_FORMAT_WVE | 0x190000 | Psion WVE format |
134 | SF_FORMAT_OGG | 0x200000 | Xiph OGG container |
135 | SF_FORMAT_MPC2K | 0x210000 | Akai MPC 2000 sampler |
136 | SF_FORMAT_RF64 | 0x220000 | RF64 WAV file |
137 | **Subtypes.** |
138 | SF_FORMAT_PCM_S8 | 0x0001 | Signed 8 bit data |
139 | SF_FORMAT_PCM_16 | 0x0002 | Signed 16 bit data |
140 | SF_FORMAT_PCM_24 | 0x0003 | Signed 24 bit data |
141 | SF_FORMAT_PCM_32 | 0x0004 | Signed 32 bit data |
142 | SF_FORMAT_PCM_U8 | 0x0005 | Unsigned 8 bit data (WAV and RAW only) |
143 | SF_FORMAT_FLOAT | 0x0006 | 32 bit float data |
144 | SF_FORMAT_DOUBLE | 0x0007 | 64 bit float data |
145 | SF_FORMAT_ULAW | 0x0010 | U-Law encoded. |
146 | SF_FORMAT_ALAW | 0x0011 | A-Law encoded. |
147 | SF_FORMAT_IMA_ADPCM | 0x0012 | IMA ADPCM. |
148 | SF_FORMAT_MS_ADPCM | 0x0013 | Microsoft ADPCM. |
149 | SF_FORMAT_GSM610 | 0x0020 | GSM 6.10 encoding. |
150 | SF_FORMAT_VOX_ADPCM | 0x0021 | OKI / Dialogix ADPCM |
151 | SF_FORMAT_NMS_ADPCM_16 | 0x0022 | 16kbs NMS G721-variant encoding. |
152 | SF_FORMAT_NMS_ADPCM_24 | 0x0023 | 24kbs NMS G721-variant encoding. |
153 | SF_FORMAT_NMS_ADPCM_32 | 0x0024 | 32kbs NMS G721-variant encoding. |
154 | SF_FORMAT_G721_32 | 0x0030 | 32kbs G721 ADPCM encoding. |
155 | SF_FORMAT_G723_24 | 0x0031 | 24kbs G723 ADPCM encoding. |
156 | SF_FORMAT_G723_40 | 0x0032 | 40kbs G723 ADPCM encoding. |
157 | SF_FORMAT_DWVW_12 | 0x0040 | 12 bit Delta Width Variable Word encoding. |
158 | SF_FORMAT_DWVW_16 | 0x0041 | 16 bit Delta Width Variable Word encoding. |
159 | SF_FORMAT_DWVW_24 | 0x0042 | 24 bit Delta Width Variable Word encoding. |
160 | SF_FORMAT_DWVW_N | 0x0043 | N bit Delta Width Variable Word encoding. |
161 | SF_FORMAT_DPCM_8 | 0x0050 | 8 bit differential PCM (XI only) |
162 | SF_FORMAT_DPCM_16 | 0x0051 | 16 bit differential PCM (XI only) |
163 | SF_FORMAT_VORBIS | 0x0060 | Xiph Vorbis encoding. |
164 | SF_FORMAT_OPUS | 0x0064 | Xiph/Skype Opus encoding. |
165 | SF_FORMAT_ALAC_16 | 0x0070 | Apple Lossless Audio Codec (16 bit). |
166 | SF_FORMAT_ALAC_20 | 0x0071 | Apple Lossless Audio Codec (20 bit). |
167 | SF_FORMAT_ALAC_24 | 0x0072 | Apple Lossless Audio Codec (24 bit). |
168 | SF_FORMAT_ALAC_32 | 0x0073 | Apple Lossless Audio Codec (32 bit). |
169 | **Endian-ness options.** |
170 | SF_ENDIAN_FILE | 0x00000000 | Default file endian-ness. |
171 | SF_ENDIAN_LITTLE | 0x10000000 | Force little endian-ness. |
172 | SF_ENDIAN_BIG | 0x20000000 | Force big endian-ness. |
173 | SF_ENDIAN_CPU | 0x30000000 | Force CPU endian-ness. |
174 | SF_FORMAT_SUBMASK | 0x0000FFFF | |
175 | SF_FORMAT_TYPEMASK | 0x0FFF0000 | |
176 | SF_FORMAT_ENDMASK | 0x30000000 | |
177
178 Every call to **sf_open**() should be matched with a call to
179 [**sf_close**()](#close) to free up memory allocated during the call to **sf_open**().
180
181 On success, the sf_open function returns a non-NULL pointer which should be passed as the first parameter to all
182 subsequent libsndfile calls dealing with that audio file. On fail, the sf_open function returns a NULL pointer. An
183 explanation of the error can obtained by passing NULL to [**sf_strerror**()](#error).
184
185 ### File Descriptor Open {#open_fd}
186
187 ```c
188 SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
189 ```
190
191 **Note:** On Microsoft Windows, this function does not work if the application
192 and the libsndfile DLL are linked to different versions of the Microsoft C
193 runtime DLL.
194
195 The second open function takes a file descriptor of a file that has already been
196 opened. Care should be taken to ensure that the mode of the file represented by
197 the descriptor matches the mode argument. This function is useful in the
198 following circumstances:
199
200 * Opening temporary files securely (ie use the **tmpfile**() to return a FILE*
201 pointer and then using fileno() to retrieve the file descriptor which is then
202 passed to libsndfile).
203 * Opening files with file names using OS specific character encodings and then
204 passing the file descriptor to **sf_open_fd**().
205 * Opening sound files embedded within larger files. [More info](embedded_files.md).
206
207 Every call to `sf_open_fd`() should be matched with a call to sf_close() to free
208 up memory allocated during the call to sf_open_fd().
209
210 When sf_close() is called, the file descriptor is only closed if the
211 **close_desc** parameter was TRUE when the sf_open_fd() function was called.
212
213 On success, the sf_open_fd() function returns a non-NULL pointer which should be
214 passed as the first parameter to all subsequent libsndfile calls dealing with
215 that audio file. On fail, the sf_open_fd() function returns a NULL pointer.
216
217 ### Virtual File Open Function {#open_virtual}
218
219 ```c
220 SNDFILE* sf_open_virtual (SF_VIRTUAL_IO *sfvirtual, int mode, SF_INFO *sfinfo, void *user_data) ;
221 ```
222
223 Opens a soundfile from a virtual file I/O context which is provided by the
224 caller. This is usually used to interface libsndfile to write/read from memory
225 with a stream or buffer based system. Apart from the sfvirtual and the user_data
226 parameters this function behaves like [sf_open()](#open).
227
228 ```c
229 typedef struct
230 { sf_vio_get_filelen get_filelen ;
231 sf_vio_seek seek ;
232 sf_vio_read read ;
233 sf_vio_write write ;
234 sf_vio_tell tell ;
235 } SF_VIRTUAL_IO ;
236 ```
237
238 Libsndfile calls the callbacks provided by the SF_VIRTUAL_IO structure when
239 opening, reading and writing to the virtual file context. The user_data pointer
240 is a user defined context which will be available in the callbacks.
241
242 ```c
243 typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
244 typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
245 typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
246 typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
247 typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
248 ```
249
250 #### sf_vio_get_filelen
251
252 ```c
253 typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
254 ```
255
256 The virtual file contex must return the length of the virtual file in bytes.
257
258 #### sf_vio_seek
259
260 ```c
261 typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
262 ```
263
264 The virtual file context must seek to offset using the seek mode provided by
265 whence which is one of SEEK_CUR, SEEK_SET, SEEK_END.
266
267 The return value must contain the new offset in the file.
268
269 #### sf_vio_read
270
271 ```c
272 typedef sf_count_t (*sf_vio_read) (void *ptr, sf_count_t count, void *user_data) ;
273 ```
274
275 The virtual file context must copy ("read") "count" bytes into the buffer
276 provided by ptr and return the count of actually copied bytes.
277
278 #### sf_vio_write
279
280 ```c
281 typedef sf_count_t (*sf_vio_write) (const void *ptr, sf_count_t count, void *user_data) ;
282 ```
283
284 The virtual file context must process "count" bytes stored in the buffer passed
285 with ptr and return the count of actually processed bytes.
286
287 #### sf_vio_tell
288
289 ```c
290 typedef sf_count_t (*sf_vio_tell) (void *user_data) ;
291 ```
292
293 Return the current position of the virtual file context.
294
295 ## Format Check Function {#chek}
296
297 ```c
298 int sf_format_check (const SF_INFO *info) ;
299 ```
300
301 This function allows the caller to check if a set of parameters in the SF_INFO
302 struct is valid before calling [sf_open](#open) (SFM_WRITE).
303
304 sf_format_check() returns TRUE if the parameters are valid and FALSE otherwise.
305
306 ## File Seek Functions
307
308 ```c
309 sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ;
310 ```
311
312 The file seek functions work much like lseek in unistd.h with the exception that
313 the non-audio data is ignored and the seek only moves within the audio data
314 section of the file. In addition, seeks are defined in number of (multichannel)
315 frames. Therefore, a seek in a stereo file from the current position forward
316 with an offset of 1 would skip forward by one sample of both channels.
317
318 like lseek(), the whence parameter can be any one of the following three values:
319
320 SEEK_SET
321 : The offset is set to the start of the audio data plus offset (multichannel)
322 frames.
323
324 SEEK_CUR
325 : The offset is set to its current location plus offset (multichannel) frames.
326
327 SEEK_END
328 : The offset is set to the end of the data plus offset (multichannel) frames.
329
330 Internally, libsndfile keeps track of the read and write locations using
331 separate read and write pointers. If a file has been opened with a mode of
332 SFM_RDWR, bitwise OR-ing the standard whence values above with either SFM_READ
333 or SFM_WRITE allows the read and write pointers to be modified separately.
334 If the SEEK_* values are used on their own, the read and write pointers are
335 both modified.
336
337 Note that the frames offset can be negative and in fact should be when SEEK_END
338 is used for the whence parameter.
339
340 sf_seek will return the offset in (multichannel) frames from the start of the
341 audio data or -1 if an error occured (ie an attempt is made to seek beyond the
342 start or end of the file).
343
344 ## Error Reporting Functions {#error}
345
346 ```c
347 int sf_error (SNDFILE *sndfile) ;
348 ```
349
350 This function returns the current error number for the given SNDFILE.
351
352 The error number may be one of the following:
353
354 | Name | Value |
355 |:----------------------------|:------|
356 | SF_ERR_NO_ERROR | 0 |
357 | SF_ERR_UNRECOGNISED_FORMAT | 1 |
358 | SF_ERR_SYSTEM | 2 |
359 | SF_ERR_MALFORMED_FILE | 3 |
360 | SF_ERR_UNSUPPORTED_ENCODING | 4 |
361
362 or any one of many other internal error values.
363 Applications should only test the return value against error values defined in
364 \<sndfile.h\>; as the internal error values are subject to change at any time.
365 For errors not in the above list, the function sf_error_number() can be used to
366 convert it to an error string.
367
368 ```c
369 const char* sf_strerror (SNDFILE *sndfile) ;
370 const char* sf_error_number (int errnum) ;
371 ```
372
373 The error functions sf_strerror () and sf_error_number () convert the library's
374 internal error enumerations into text strings.
375
376 ```c
377 int sf_perror (SNDFILE *sndfile) ;
378 int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ;
379 ```
380
381 The functions sf_perror() and sf_error_str() are deprecated and will be dropped
382 from the library at some later date.
383
384 ## File Close Function {#close}
385
386 ```c
387 int sf_close (SNDFILE *sndfile) ;
388 ```
389
390 The close function closes the file, deallocates its internal buffers and returns
391 0 on success or an error value otherwise.
392
393 ## Write Sync Function {#write_sync}
394
395 ```c
396 void sf_write_sync (SNDFILE *sndfile) ;
397 ```
398
399 If the file is opened SFM_WRITE or SFM_RDWR, call the operating system's
400 function to force the writing of all file cache buffers to disk. If the file is
401 opened SFM_READ no action is taken.
402
403 ## File Read Functions {#read}
404
405 ```c
406 sf_count_t sf_read_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
407 sf_count_t sf_read_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
408 sf_count_t sf_read_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
409 sf_count_t sf_read_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
410 ```
411
412 {: #readf}
413 ```c
414 sf_count_t sf_readf_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
415 sf_count_t sf_readf_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
416 sf_count_t sf_readf_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
417 sf_count_t sf_readf_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
418 ```
419
420 The file read functions fill the array pointed to by ptr with the requested
421 number of items or frames.
422
423 For the frames-count functions, the frames parameter specifies the number of
424 frames. A frame is just a block of samples, one for each channel.
425
426 **Care must be taken to ensure that there is enough space in the array pointed
427 to by ptr, to take (frames \* channels) number of items (shorts, ints, floats or
428 doubles).**
429
430 For the items-count functions, the items parameter must be an integer product
431 of the number of channels or an error will occur. Here, an item is just a
432 sample.
433
434 Note: The only difference between the "items" and "frames" versions of each read
435 function is the units in which the object count is specified - calling
436 sf_readf_short() with a count argument of N, on a SNDFILE with C channels, is
437 the same as calling sf_read_short with a count argument of N\*C. The buffer
438 pointed to by "ptr" should be the same number of bytes in each case.
439
440 Note: The data type used by the calling program and the data format of the file
441 do not need to be the same. For instance, it is possible to open a 16 bit PCM
442 encoded WAV file and read the data using sf_read_float(). The library seamlessly
443 converts between the two formats on-the-fly. See [Note 1](#note-1).
444
445 The sf_read_XXXX and sf_readf_XXXX functions return the number of items or
446 frames read, respectively. Unless the end of the file was reached during the
447 read, the return value should equal the number of objects requested. Attempts to
448 read beyond the end of the file will not result in an error but will cause the
449 read functions to return less than the number of objects requested or 0 if
450 already at the end of the file. When the buffer is not is not completely filled,
451 unused buffer space is filled by zeroes.
452
453 ## File Write Functions {#write}
454
455 ```c
456 sf_count_t sf_write_short (SNDFILE *sndfile, short *ptr, sf_count_t items) ;
457 sf_count_t sf_write_int (SNDFILE *sndfile, int *ptr, sf_count_t items) ;
458 sf_count_t sf_write_float (SNDFILE *sndfile, float *ptr, sf_count_t items) ;
459 sf_count_t sf_write_double (SNDFILE *sndfile, double *ptr, sf_count_t items) ;
460 ```
461
462 {: #writef}
463 ```c
464 sf_count_t sf_writef_short (SNDFILE *sndfile, short *ptr, sf_count_t frames) ;
465 sf_count_t sf_writef_int (SNDFILE *sndfile, int *ptr, sf_count_t frames) ;
466 sf_count_t sf_writef_float (SNDFILE *sndfile, float *ptr, sf_count_t frames) ;
467 sf_count_t sf_writef_double (SNDFILE *sndfile, double *ptr, sf_count_t frames) ;
468 ```
469
470 The file write functions write the data in the array pointed to by ptr to the
471 file.
472
473 For items-count functions, the items parameter specifies the size of the array
474 and must be an integer product of the number of channels or an error will occur.
475
476 For the frames-count functions, the array is expected to be large enough to hold
477 a number of items equal to the product of frames and the number of channels.
478
479 As with the read functions [above](#read), the only difference in the items and
480 frames version of each write function is the units in which the buffer size is
481 specified. Again, the data type used by the calling program and the data format
482 of the file do not need to be the same ([Note 1](#note-1)).
483
484 The sf_write_XXXX and sf_writef_XXXX functions respectively return the number of
485 items or frames written (which should be the same as the items or frames
486 parameter).
487
488 ## Raw File Read and Write Functions {#raw}
489
490 ```c
491 sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
492 sf_count_t sf_write_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
493 ```
494
495 **Note:** Unless you are writing an external decoder/encode that uses libsndfile
496 to handle the file headers, you should not be using these functions.
497
498 The raw read and write functions read raw audio data from the audio file (not to
499 be confused with reading RAW header-less PCM files). The number of bytes read or
500 written must always be an integer multiple of the number of channels multiplied
501 by the number of bytes required to represent one sample from one channel.
502
503 The raw read and write functions return the number of bytes read or written
504 (which should be the same as the bytes parameter).
505
506 **Note : The result of using of both regular reads/writes and raw reads/writes
507 on compressed file formats other than SF_FORMAT_ALAW and SF_FORMAT_ULAW is
508 undefined.**
509
510 See also : [SFC_RAW_NEEDS_ENDSWAP](command.md#sfc_raw_needs_endswap).
511
512 ## Functions for Reading and Writing String Data {#string}
513
514 ```c
515 const char* sf_get_string (SNDFILE *sndfile, int str_type) ;
516 int sf_set_string (SNDFILE *sndfile, int str_type, const char* str) ;
517 ```
518
519 These functions allow strings to be set on files opened for write and to be
520 retrieved from files opened for read where supported by the given file type. The
521 **str_type** parameter can be any one of the following string types:
522
523 | Name | Value | Description |
524 |:-------------------|:------|:--------------|
525 | SF_STR_TITLE | 0x01 | Title. |
526 | SF_STR_COPYRIGHT | 0x02 | Copyright. |
527 | SF_STR_SOFTWARE | 0x03 | Software. |
528 | SF_STR_ARTIST | 0x04 | Artist. |
529 | SF_STR_COMMENT | 0x05 | Comment. |
530 | SF_STR_DATE | 0x06 | Date. |
531 | SF_STR_ALBUM | 0x07 | Album. |
532 | SF_STR_LICENSE | 0x08 | License. |
533 | SF_STR_TRACKNUMBER | 0x09 | Track number. |
534 | SF_STR_GENRE | 0x10 | Genre. |
535
536 The sf_get_string() function returns the specified string if it exists and a
537 NULL pointer otherwise. In addition to the string ids above, SF_STR_FIRST (==
538 SF_STR_TITLE) and SF_STR_LAST (always the same as the highest numbers string id)
539 are also available to allow iteration over all the available string ids.
540
541 The sf_set_string() function sets the string data. It returns zero on success
542 and non-zero on error.The error code can be converted to a string using
543 sf_error_number().
544
545 Strings passed to and retrieved from these two functions are assumed to be
546 utf-8. However, while formats like Ogg/Vorbis and FLAC fully support utf-8,
547 others like WAV and AIFF officially only support ASCII. Writing utf-8 strings to
548 WAV and AIF files with libsndfile will work when read back with libsndfile, but
549 may not work with other programs.
550
551 The suggested method of dealing with tags retrived using sf_get_string() is to
552 assume they are utf-8. Similarly if you have a string in some exotic format like
553 utf-16, it should be encoded to utf-8 before being written using libsndfile.
554
555 ## Function for retrieving library version {#version_string}
556
557 ```c
558 const char *sf_version_string (void) ;
559 ```
560
561 Return the library version string.
562
563 ## Function for retrieving current byterate {#current_byterate}
564
565 ```c
566 int sf_current_byterate (SNDFILE *sndfile) ;
567 ```
568
569 Return the current byterate at this point in the file. The byte rate in this
570 case is the number of bytes per second of audio data. For instance, for a
571 stereo, 18 bit PCM encoded file with an 16kHz sample rate, the byte rate
572 would be 2 (stereo) \* 2 (two bytes per sample) * 16000 => 64000 bytes/sec.
573
574 For some file formats the returned value will be accurate and exact, for some
575 it will be a close approximation, for some it will be the average bitrate for
576 the whole file and for some it will be a time varying value that was accurate
577 when the file was most recently read or written.
578
579 To get the bitrate, multiple this value by 8.
580
581 `sf_current_byterate` returns byte per second or -1 if byterate is
582 unknown.
583
584 ## Functions to get and set chunks from within a sound file
585
586 These functions allow the getting and setting of chunks within a sound file (for
587 those formats which allow it).
588
589 These functions fail safely. Specifically, they will not allow you to overwrite
590 existing chunks or add extra versions of format specific reserved chunks but
591 should allow you to retrieve any and all chunks (may not be implemented for all
592 chunks or all file formats).
593
594 ### sf_set_chunk
595
596 ```c
597 int sf_set_chunk (SNDFILE *sndfile, const SF_CHUNK_INFO *chunk_info) ;
598 ```
599
600 Set the specified chunk info (must be done before any audio data is written to
601 the file). This will fail for format specific reserved chunks. The
602 `chunk_info->data` pointer must be valid until the file is closed.
603
604 The `SF_CHUNK_INFO` struct is documented as follows:
605
606 ```c
607 struct SF_CHUNK_INFO
608 { char id [64] ; /* The chunk identifier. */
609 unsigned id_size ; /* The size of the chunk identifier. */
610 unsigned datalen ; /* The size of that data. */
611 void *data ; /* Pointer to the data. */
612 } ;
613 typedef struct SF_CHUNK_INFO SF_CHUNK_INFO ;
614 ```
615
616 `sf_set_chunk` returns `SF_ERR_NO_ERROR` on success or non-zero on failure.
617
618 ### sf_get_chunk_iterator
619
620 ```c
621 SF_CHUNK_ITERATOR *
622 sf_get_chunk_iterator (SNDFILE *sndfile, const SF_CHUNK_INFO *chunk_info) ;
623 ```
624
625 Get an iterator for all chunks matching `chunk_info`.
626
627 `SF_CHUNK_ITERATOR` is an opaque structure to an iterator over the all chunks of
628 a given id and defined as follows:
629
630 ```c
631 typedef struct SF_CHUNK_ITERATOR SF_CHUNK_ITERATOR ;
632 ```
633
634 The iterator will point to the first chunk matching `chunk_info`. Chunks are
635 matching, if (`chunk_info->id`) matches the first (`chunk_info->id_size`) bytes
636 of a chunk found in the `SNDFILE*` handle. If `chunk_info` is `NULL`, an
637 iterator to all chunks in the `SNDFILE*` handle is returned. The values of
638 `chunk_info->datalen` and `chunk_info->data` are ignored. If no matching chunks
639 are found in the sndfile, `NULL` is returned.
640
641 The returned iterator will stay valid until one of the following occurs:
642
643 * The sndfile is closed.
644 * A new chunk is added using [`sf_set_chunk()`](#sf_set_chunk).
645 * Another chunk iterator function is called on the same `SNDFILE*`
646 handle that causes the iterator to be modified.
647
648 The memory for the iterator belongs to the SNDFILE* handle and is freed when
649 [sf_close](#close) is called.
650
651 ### sf_next_chunk_iterator
652
653 ```c
654 sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) ;
655 ```
656
657 Iterate through chunks by incrementing the iterator.
658
659 Increments the iterator and returns a handle to the new one. After this call,
660 iterator will no longer be valid, and you must use the newly returned handle
661 from now on. The returned handle can be used to access the next chunk matching
662 the criteria as defined in [sf_get_chunk_iterator](#sf_get_chunk_iterator).
663 If iterator points to the last chunk, this will free all resources associated
664 with iterator and return `NULL`. The returned iterator will stay valid until
665 `sf_get_next_chunk_iterator` is called again, the sndfile is closed or a new
666 chunk us added.
667
668 ### sf_get_chunk_size
669
670 ```c
671 int
672 sf_get_chunk_size (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ;
673 ```
674
675 Get the size of the specified chunk.
676
677 If the specified chunk exists, the size will be returned in the `datalen` field
678 of the `SF_CHUNK_INFO` struct. Additionally, the id of the chunk will be copied
679 to the `id` field of the `SF_CHUNK_INFO` struct and it's `id_size` field will be
680 updated accordingly.
681
682 If the chunk doesn't exist `chunk_info->datalen` will be zero, and the `id` and
683 `id_size` fields will be undefined.
684
685 The function will return `SF_ERR_NO_ERROR` on success or non-zero on failure.
686
687 ### sf_get_chunk_data
688
689 ```c
690 int
691 sf_get_chunk_data (const SF_CHUNK_ITERATOR *it, SF_CHUNK_INFO *chunk_info) ;
692 ```
693
694 Get the specified chunk data.
695
696 If the specified chunk exists, up to `chunk_info->datalen` bytes of the chunk
697 data will be copied into the `chunk_info->data` buffer (allocated by the caller)
698 and the `chunk_info->datalen` field updated to reflect the size of the data. The
699 `id` and `id_size` field will be updated according to the retrieved chunk. If
700 the chunk doesn't exist `chunk_info->datalen` will be zero, and the `id` and
701 `id_size` fields will be undefined.
702
703 The function will return `SF_ERR_NO_ERROR` on success or non-zero on failure.
704
705 ## Note 1
706
707 When converting between integer PCM formats of differing size (e.g. using
708 sf_read_int() to read a 16 bit PCM encoded WAV file) libsndfile obeys one simple
709 rule:
710
711 Whenever integer data is moved from one sized container to another sized
712 container, the most significant bit in the source container will become the most
713 significant bit in the destination container.
714
715 When converting between integer data and floating point data, different rules
716 apply. The default behaviour when reading floating point data (sf_read_float()
717 or sf_read_double ()) from a file with integer data is normalisation. Regardless
718 of whether data in the file is 8, 16, 24 or 32 bit wide, the data will be read
719 as floating point data in the range [-1.0, 1.0]. Similarly, data in the range
720 [-1.0, 1.0] will be written to an integer PCM file so that a data value of 1.0
721 will be the largest allowable integer for the given bit width. This
722 normalisation can be turned on or off using the [sf_command](command.md)
723 interface.
724
725 ## Note 2
726
727 Reading a file containg floating point data (allowable with WAV, AIFF, AU and
728 other file formats) using integer read methods (sf_read_short() or
729 sf_read_int()) can produce unexpected results. For instance the data in the file
730 may have a maximum absolute value &lt; 1.0 which would mean that all sample
731 values read from the file will be zero. In order to read these files correctly
732 using integer read methods, it is recommended that you use the
733 [sf_command](command.md) interface, a command of
734 [SFC_SET_SCALE_FLOAT_INT_READ](command.md#sfc_set_scale_float_int_read) and a
735 parameter of SF_TRUE to force correct scaling.
0 ---
1 layout: page
2 ---
3
4 # Reporting Bugs in libsndfile
5
6 Before even attempting to report a bug in libsndfile please make sure you have
7 read the [Frequently Asked Questions](FAQ.md). If you are having a problem
8 writing code using libsndfile make sure you read the
9 [Application Programming Interface](api.md) documentation.
10
11 That said, I am interested in finding and fixing all genuine bugs in libsndfile.
12 Bugs I want to fix include any of the following problems (and probably others):
13
14 - Compilation problems on new platforms.
15 - Errors being detected during the `make check` process.
16 - Segmentation faults occuring inside libsndfile.
17 - libsndfile hanging when opening a file.
18 - Supported sound file types being incorrectly read or written.
19 - Omissions, errors or spelling mistakes in the documentation.
20
21 When submitting a bug report you must include:
22
23 - Your system (CPU and memory size should be enough).
24 - The operating system you are using.
25 - Whether you are using a package provided by your distribution or you compiled
26 it youself.
27 - If you compiled it yourself, the compiler you are using. (Also make sure to
28 run `make check`.)
29 - A description of the problem.
30 - Information generated by the sndfile-info program (see next paragraph).
31 - If you are having problems with sndfile-play and ALSA on Linux, I will need
32 information about your kernel, ALSA version, compiler version, whether you
33 compiled the kernel/ALSA your self or installed from a package etc.
34
35 If libsndfile compiles and installs correctly but has difficulty reading a
36 particular file or type of file you should run the **sndfile-info** program
37 (from the examples directory of the libsndfile distribution) on the file. See
38 [here](sndfile_info.md) for an example of the use of the **sndfile-info**
39 program.
40
41 Please do not send me a sound file which fails to open under libsndfile unless
42 I specifically ask you to. The above information should usually suffice for most
43 problems.
44
45 Once you have the above information you should submit a ticket on the libsndfile
46 [GitHub issue tracker](https://github.com/libsndfile/libsndfile/issues).
0 ---
1 layout: page
2 title: libsndfile : the sf_command function.
3 ---
4
5 # sf_command
6
7 ```c
8 int sf_command (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
9 ```
10
11 This function allows the caller to retrieve information from or change aspects
12 of the library behaviour. Examples include retrieving a string containing the
13 library version or changing the scaling applied to floating point sample data
14 during read and write. Most of these operations are performed on a per-file
15 basis.
16
17 The cmd parameter is an integer identifier which is defined in *sndfile.h*. All
18 of the valid command identifiers have names beginning with "SFC_". Data is
19 passed to and returned from the library by use of a void pointer. The library
20 will not read or write more than datasize bytes from the void pointer. For some
21 calls no data is required in which case data should be NULL and datasize may be
22 used for some other purpose.
23
24 The available commands are as follows:
25
26 | Name | Description |
27 |:------------------------------------------------------------------|:--------------------------------------------------------|
28 | [SFC_GET_LIB_VERSION](#sfc_get_lib_version) | Retrieve the version of the library as a string. |
29 | [SFC_GET_LOG_INFO](#sfc_get_log_info) | Retrieve the internal per-file operation log. |
30 | [SFC_GET_CURRENT_SF_INFO](#sfc_get_current_sf_info) | Retrieve `SF_INFO` struct of opened file. |
31 | [SFC_CALC_SIGNAL_MAX](#sfc_calc_signal_max) | Calculate the measured maximum signal value. |
32 | [SFC_CALC_NORM_SIGNAL_MAX](#sfc_calc_norm_signal_max) | Calculate the measured normalised maximum signal value. |
33 | [SFC_CALC_MAX_ALL_CHANNELS](#sfc_calc_max_all_channels) | Calculate the peak value for each channel. |
34 | [SFC_CALC_NORM_MAX_ALL_CHANNELS](#sfc_calc_norm_max_all_channels) | Calculate the normalised peak for each channel. |
35 | [SFC_GET_SIGNAL_MAX](#sfc_get_signal_max) | Retrieve the peak value for the file. |
36 | [SFC_GET_MAX_ALL_CHANNELS](#sfc_get_max_all_channels) | Retrieve the peak value for each channel. |
37 | [SFC_SET_NORM_FLOAT](#sfc_set_norm_float) | Set float normalisation behaviour. |
38 | [SFC_SET_NORM_DOUBLE](#sfc_set_norm_double) | Set double normalisation behaviour. |
39 | [SFC_GET_NORM_FLOAT](#sfc_get_norm_float) | Get float normalisation behaviour. |
40 | [SFC_GET_NORM_DOUBLE](#sfc_get_norm_double) | Get double normalisation behaviour. |
41 | [SFC_SET_SCALE_FLOAT_INT_READ](#sfc_set_scale_float_int_read) | Control scale factor on read. |
42 | [SFC_SET_SCALE_INT_FLOAT_WRITE](#sfc_set_scale_int_float_write) | Control scale factor on write. |
43 | [SFC_GET_SIMPLE_FORMAT_COUNT](#sfc_get_simple_format_count) | Get simple formats count. |
44 | [SFC_GET_SIMPLE_FORMAT](#sfc_get_simple_format) | Get information about a simple format. |
45 | [SFC_GET_FORMAT_INFO](#sfc_get_format_info) | Get information about a major or subtype format. |
46 | [SFC_GET_FORMAT_MAJOR_COUNT](#sfc_get_format_major_count) | Get the number of major formats. |
47 | [SFC_GET_FORMAT_MAJOR](#sfc_get_format_major) | Get information about a major format type. |
48 | [SFC_GET_FORMAT_SUBTYPE_COUNT](#sfc_get_format_subtype_count) | Get the number of subformats. |
49 | [SFC_GET_FORMAT_SUBTYPE](#sfc_get_format_subtype) | Get information about a subformat. |
50 | [SFC_SET_ADD_PEAK_CHUNK](#sfc_set_add_peak_chunk) | Control PEAK chunk write to WAV and AIFF. |
51 | [SFC_UPDATE_HEADER_NOW](#sfc_update_header_now) | Update the file header in write mode on demand. |
52 | [SFC_SET_UPDATE_HEADER_AUTO](#sfc_set_update_header_auto) | Update the file header on each write. |
53 | [SFC_FILE_TRUNCATE](#sfc_file_truncate) | Truncate a file open for write or for read/write. |
54 | [SFC_SET_RAW_START_OFFSET](#sfc_set_raw_start_offset) | Change the data start offset for raw files. |
55 | SFC_SET_DITHER_ON_WRITE | Not implemented. |
56 | SFC_SET_DITHER_ON_READ | Not implemented. |
57 | SFC_GET_DITHER_INFO_COUNT | Not implemented. |
58 | SFC_GET_DITHER_INFO | Not implemented. |
59 | [SFC_SET_CLIPPING](#sfc_set_clipping) | Control automatic clipping behaviour. |
60 | [SFC_GET_CLIPPING](#sfc_get_clipping) | Get current clipping setting. |
61 | [SFC_GET_EMBED_FILE_INFO](#sfc_get_embed_file_info) | Get information about embedded audio files. |
62 | [SFC_WAVEX_GET_AMBISONIC](#sfc_wavex_get_ambisonic) | Test a WAVEX file for Ambisonic format. |
63 | [SFC_WAVEX_SET_AMBISONIC](#sfc_wavex_set_ambisonic) | Modify a WAVEX header for Ambisonic format. |
64 | [SFC_SET_VBR_ENCODING_QUALITY](#sfc_set_vbr_encoding_quality) | Set the Variable Bit Rate encoding quality. |
65 | [SFC_SET_OGG_PAGE_LATENCY_MS](#sfc_set_ogg_page_latency_ms) | Set Ogg page latency for Opus file. |
66 | [SFC_SET_COMPRESSION_LEVEL](#sfc_set_compression_level) | Set the compression level. |
67 | [SFC_RAW_DATA_NEEDS_ENDSWAP](#sfc_raw_data_needs_endswap) | Determine if raw data needs endswapping. |
68 | [SFC_GET_BROADCAST_INFO](#sfc_get_broadcast_info) | Get the Broadcast Chunk info. |
69 | [SFC_SET_BROADCAST_INFO](#sfc_set_broadcast_info) | Set the Broadcast Chunk info. |
70 | [SFC_GET_CHANNEL_MAP_INFO](#sfc_get_channel_map_info) | Get the channel map info. |
71 | [SFC_SET_CHANNEL_MAP_INFO](#sfc_set_channel_map_info) | Set the channel map info. |
72 | [SFC_SET_CART_INFO](#sfc_set_cart_info) | Set the Cart Chunk info. |
73 | [SFC_GET_CART_INFO](#sfc_get_cart_info) | Get the Cart Chunk info. |
74 | [SFC_GET_LOOP_INFO](#sfc_get_loop_info) | Get loop info. |
75 | [SFC_GET_INSTRUMENT](#sfc_get_instrument) | Get instrument info. |
76 | [SFC_SET_INSTRUMENT](#sfc_set_instrument) | Set instrument info. |
77 | [SFC_GET_CUE_COUNT](#sfc_get_cue_count) | Get the cue marker count. |
78 | [SFC_GET_CUE](#sfc_get_cue) | Get cue marker info. |
79 | [SFC_SET_CUE](#sfc_set_cue) | Set cue marker info. |
80 | [SFC_RF64_AUTO_DOWNGRADE](#sfc_rf64_auto_downgrade) | Set auto downgrade from RF64 to WAV. |
81 | [SFC_GET_ORIGINAL_SAMPLERATE](#sfc_get_original_samplerate) | Get original samplerate metadata. |
82 | [SFC_SET_ORIGINAL_SAMPLERATE](#sfc_set_original_samplerate) | Set original samplerate metadata. |
83
84 ---
85
86 ## SFC_GET_LIB_VERSION
87
88 Retrieve the version of the library as a string.
89
90 ### Parameters
91
92 sndfile
93 : Not used
94
95 cmd
96 : SFC_GET_LIB_VERSION
97
98 data
99 : A pointer to a char buffer
100
101 datasize
102 : The size of the buffer
103
104 ### Examples
105
106 ```c
107 char buffer [128] ;
108 sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
109 ```
110
111 ### Return value
112
113 This call will return the length of the retrieved version string.
114
115 ### Notes
116
117 The string returned in the buffer passed to this function will not overflow the
118 buffer and will always be null terminated .
119
120 ## SFC_GET_LOG_INFO
121
122 Retrieve the internal per-file operation log.
123
124 This log buffer can often contain a good reason for why libsndfile failed to
125 open a particular file.
126
127 ### Parameters
128
129 sndfile
130 : A valid SNDFILE* pointer
131
132 cmd
133 : SFC_GET_LOG_INFO
134
135 data
136 : A pointer to a char buffer
137
138 datasize
139 : The size of the buffer
140
141 Example:
142
143 ```c
144 char buffer [2048] ;
145 sf_command (sndfile, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ;
146 ```
147
148 ### Return value
149
150 This call will return the length of the retrieved version string.
151
152 ### Notes
153
154 The string returned in the buffer passed to this function will not overflow the
155 buffer and will always be null terminated.
156
157 ## SFC_GET_CURRENT_SF_INFO
158
159 Retrieve `SF_INFO` struct of opened file.
160
161 `SFC_GET_CURRENT_SF_INFO` command copies `SF_INFO` struct of `sndfile` object to
162 provided buffer.
163
164 ### Parameters
165
166 sndfile
167 : A valid SNDFILE* pointer
168
169 cmd
170 : SFC_GET_CURRENT_SF_INFO
171
172 data
173 : A pointer to a valid SF_INFO* pointer
174
175 datasize
176 : sizeof (SF_INFO)
177
178 ### Examples
179
180 ```c
181 SF_INFO sfinfo ;
182 sf_command (sndfile, SFC_GET_CURRENT_SF_INFO, sfinfo, sizeof (SF_INFO)) ;
183 ```
184
185 ### Return value
186
187 Zero on success, non-zero otherwise.
188
189 ## SFC_CALC_SIGNAL_MAX
190
191 Retrieve the measured maximum signal value. This involves reading through the
192 whole file which can be slow on large files.
193
194 ### Parameters
195
196 sndfile
197 : A valid SNDFILE* pointer
198
199 cmd
200 : SFC_CALC_SIGNAL_MAX
201
202 data
203 : A pointer to a double
204
205 datasize
206 : sizeof (double)
207
208 ### Examples
209
210 ```c
211 double max_val ;
212 sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &max_val, sizeof (max_val)) ;
213 ```
214
215 ### Return value
216
217 Zero on success, non-zero otherwise.
218
219 ## SFC_CALC_NORM_SIGNAL_MAX
220
221 Retrieve the measured normalised maximum signal value. This involves reading
222 through the whole file which can be slow on large files.
223
224 ### Parameters
225
226 sndfile
227 : A valid SNDFILE* pointer
228
229 cmd
230 : SFC_CALC_NORM_SIGNAL_MAX
231
232 data
233 : A pointer to a double
234
235 datasize
236 : sizeof (double)
237
238 ### Examples
239
240 ```c
241 double max_val ;
242 sf_command (sndfile, SFC_CALC_NORM_SIGNAL_MAX, &max_val, sizeof (max_val)) ;
243 ```
244
245 ### Return value
246
247 Zero on success, non-zero otherwise.
248
249 ## SFC_CALC_MAX_ALL_CHANNELS
250
251 Calculate the peak value (ie a single number) for each channel. This involves
252 reading through the whole file which can be slow on large files.
253
254 ### Parameters
255
256 sndfile
257 : A valid SNDFILE* pointer
258
259 cmd
260 : SFC_CALC_MAX_ALL_CHANNELS
261
262 data
263 : A pointer to a double
264
265 datasize
266 : sizeof (double) * number_of_channels
267
268 ### Examples
269
270 ```c
271 double peaks [number_of_channels] ;
272 sf_command (sndfile, SFC_CALC_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
273 ```
274
275 ### Return value
276
277 Zero if peaks have been calculated successfully and non-zero otherwise.
278
279 ## SFC_CALC_NORM_MAX_ALL_CHANNELS
280
281 Calculate the normalised peak for each channel. This involves reading through
282 the whole file which can be slow on large files.
283
284 ### Parameters
285
286 sndfile
287 : A valid SNDFILE* pointer
288
289 cmd
290 : SFC_CALC_NORM_MAX_ALL_CHANNELS
291
292 data
293 : A pointer to a double
294
295 datasize
296 : sizeof (double) * number_of_channels
297
298 ### Examples
299
300 ```c
301 double peaks [number_of_channels] ;
302 sf_command (sndfile, SFC_CALC_NORM_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
303 ```
304
305 ### Return value
306
307 Zero if peaks have been calculated successfully and non-zero otherwise.
308
309 ## SFC_GET_SIGNAL_MAX
310
311 Retrieve the peak value for the file as stored in the file header.
312
313 ### Parameters
314
315 sndfile
316 : A valid SNDFILE* pointer
317
318 cmd
319 : SFC_GET_SIGNAL_MAX
320
321 data
322 : A pointer to a double
323
324 datasize
325 : sizeof (double)
326
327 ### Examples
328
329 ```c
330 double max_peak ;
331 sf_command (sndfile, SFC_GET_SIGNAL_MAX, &max_peak, sizeof (max_peak)) ;
332 ```
333
334 ### Return value
335
336 SF_TRUE if the file header contained the peak value. SF_FALSE
337 otherwise.
338
339 ## SFC_GET_MAX_ALL_CHANNELS
340
341 Retrieve the peak value for the file as stored in the file header.
342
343 ### Parameters
344
345 sndfile
346 : A valid SNDFILE* pointer
347
348 cmd
349 : SFC_GET_SIGNAL_MAX
350
351 data
352 : A pointer to an array of doubles
353
354 datasize
355 : sizeof (double) * number_of_channels
356
357 ### Example
358
359 ```c
360 double peaks [number_of_channels] ;
361 sf_command (sndfile, SFC_GET_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
362 ```
363
364 ### Return value
365
366 SF_TRUE if the file header contains per channel peak values for the file,
367 SF_FALSE otherwise.
368
369 ## SFC_SET_NORM_FLOAT
370
371 This command only affects data read from or written to using the
372 floating point
373 functions:
374
375 ```c
376 size_t sf_read_float (SNDFILE *sndfile, float *ptr, size_t items) ;
377 size_t sf_readf_float (SNDFILE *sndfile, float *ptr, size_t frames) ;
378
379 size_t sf_write_float (SNDFILE *sndfile, float *ptr, size_t items) ;
380 size_t sf_writef_float (SNDFILE *sndfile, float *ptr, size_t frames) ;
381 ```
382
383 ### Parameters
384
385 sndfile
386 : A valid SNDFILE* pointer
387
388 cmd
389 : SFC_SET_NORM_FLOAT
390
391 data
392 : NULL
393
394 datasize
395 : SF_TRUE or SF_FALSE
396
397 For read operations setting normalisation to SF_TRUE means that the data from
398 all subsequent reads will be be normalised to the range [-1.0, 1.0].
399
400 For write operations, setting normalisation to SF_TRUE means than all data
401 supplied to the float write functions should be in the range [-1.0, 1.0] and
402 will be scaled for the file format as necessary.
403
404 For both cases, setting normalisation to SF_FALSE means that no scaling will
405 take place.
406
407 ### Examples
408
409 ```c
410 sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE) ;
411
412 sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ;
413 ```
414
415 ### Return value
416
417 Returns the previous float normalisation mode.
418
419 ## SFC_SET_NORM_DOUBLE
420
421 This command only affects data read from or written to using the double
422 precision floating point
423 functions:
424
425 ```c
426 size_t sf_read_double (SNDFILE *sndfile, double *ptr, size_t items) ;
427 size_t sf_readf_double (SNDFILE *sndfile, double *ptr, size_t frames) ;
428
429 size_t sf_write_double (SNDFILE *sndfile, double *ptr, size_t items) ;
430 size_t sf_writef_double (SNDFILE *sndfile, double *ptr, size_t frames) ;
431 ```
432
433 ### Parameters
434
435 sndfile
436 : A valid SNDFILE* pointer
437
438 cmd
439 : SFC_SET_NORM_DOUBLE
440
441 data
442 : NULL
443
444 datasize
445 : SF_TRUE or SF_FALSE
446
447 For read operations setting normalisation to SF_TRUE means that the data from
448 all subsequent reads will be be normalised to the range [-1.0, 1.0].
449
450 For write operations, setting normalisation to SF_TRUE means than all data
451 supplied to the double write functions should be in the range [-1.0, 1.0] and
452 will be scaled for the file format as necessary.
453
454 For both cases, setting normalisation to SF_FALSE means that no scaling will
455 take place.
456
457 ### Examples
458
459 ```c
460 sf_command (sndfile, SFC_SET_NORM_DOUBLE, NULL, SF_TRUE) ;
461
462 sf_command (sndfile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
463 ```
464
465 ### Return value
466
467 Returns the previous double normalisation mode.
468
469 ## SFC_GET_NORM_FLOAT
470
471 Retrieve the current float normalisation mode.
472
473 ### Parameters
474
475 sndfile
476 : A valid SNDFILE* pointer
477
478 cmd
479 : SFC_GET_NORM_FLOAT
480
481 data
482 : NULL
483
484 datasize
485 : anything
486
487 ### Examples
488
489 ```c
490 normalisation = sf_command (sndfile, SFC_GET_NORM_FLOAT, NULL, 0) ;
491 ```
492
493 ### Return value
494
495 Returns TRUE if normalisation is on and FALSE otherwise.
496
497 ## SFC_GET_NORM_DOUBLE
498
499 Retrieve the current float normalisation mode.
500
501 ### Parameters
502
503 sndfile
504 : A valid SNDFILE* pointer
505
506 cmd
507 : SFC_GET_NORM_DOUBLE
508
509 data
510 : NULL
511
512 datasize
513 : anything
514
515 Example:
516
517 ```c
518 normalisation = sf_command (sndfile, SFC_GET_NORM_DOUBLE, NULL, 0) ;
519 ```
520
521 ### Return value
522
523 Returns TRUE if normalisation is on and FALSE otherwise.
524
525 ## SFC_SET_SCALE_FLOAT_INT_READ
526
527 Set/clear the scale factor when integer (short/int) data is read from a file
528 containing floating point data.
529
530 ### Parameters
531
532 sndfile
533 : A valid SNDFILE* pointer
534
535 cmd:
536 SFC_SET_SCALE_FLOAT_INT_READ
537
538 data
539 : NULL
540
541 datasize
542 : TRUE or FALSE
543
544 Example:
545
546 ```c
547 sf_command (sndfile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
548 ```
549
550 ### Return value
551
552 Returns the previous `SFC_SET_SCALE_FLOAT_INT_READ` setting for this file.
553
554 ## SFC_SET_SCALE_INT_FLOAT_WRITE
555
556 Set/clear the scale factor when integer (short/int) data is written to a file as
557 floating point data.
558
559 ### Parameters
560
561 sndfile
562 : A valid SNDFILE* pointer
563
564 cmd
565 : SFC_SET_SCALE_INT_FLOAT_WRITE
566
567 data
568 : NULL
569
570 datasize
571 : TRUE or FALSE
572
573 ### Examples
574
575 ```c
576 sf_command (sndfile, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
577 ```
578
579 ### Return value
580
581 Returns the previous `SFC_SET_SCALE_INT_FLOAT_WRITE` setting for this file.
582
583 ## SFC_GET_SIMPLE_FORMAT_COUNT
584
585 Retrieve the number of simple formats supported by libsndfile.
586
587 ### Parameters
588
589 sndfile
590 : Not used.
591
592 cmd
593 : SFC_GET_SIMPLE_FORMAT_COUNT
594
595 data
596 : a pointer to an int
597
598 datasize
599 : sizeof (int)
600
601 ### Examples
602
603 ```c
604 int count ;
605 sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof (int)) ;
606 ```
607
608 ### Return value
609
610 `0`.
611
612 ## SFC_GET_SIMPLE_FORMAT
613
614 Retrieve information about a simple format.
615
616 ### Parameters
617
618 sndfile
619 : Not used.
620
621 cmd
622 : SFC_GET_SIMPLE_FORMAT
623
624 data
625 : a pointer to an SF_FORMAT_INFO struct
626
627 datasize
628 : sizeof (SF_FORMAT_INFO)
629
630 The SF_FORMAT_INFO struct is defined in *sndfile.h* as:
631
632 ```c
633 typedef struct
634 { int format ;
635 const char *name ;
636 const char *extension ;
637 } SF_FORMAT_INFO ;
638 ```
639
640 When `sf_command()` is called with `SF_GET_SIMPLE_FORMAT`, the value of the
641 format field should be the format number (ie 0 \<= format \<= count value
642 obtained using `SF_GET_SIMPLE_FORMAT_COUNT).
643
644 ### Examples
645
646 ```c
647 SF_FORMAT_INFO format_info ;
648 int k, count ;
649
650 sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &count, sizeof (int)) ;
651
652 for (k = 0 ; k < count ; k++)
653 { format_info.format = k ;
654 sf_command (sndfile, SFC_GET_SIMPLE_FORMAT, &format_info, sizeof (format_info)) ;
655 printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
656 } ;
657 ```
658
659 ### Return value
660
661 0 on success and non-zero otherwise.
662
663 The value of the format field of the `SF_FORMAT_INFO` struct will be a value
664 which can be placed in the format field of an `SF_INFO` struct when a file is to
665 be opened for write. The name field will contain a char\* pointer to the name of
666 the string, eg. "WAV (Microsoft 16 bit PCM)". The extension field will contain
667 the most commonly used file extension for that file type.
668
669 ## SFC_GET_FORMAT_INFO
670
671 Retrieve information about a major or subtype format.
672
673 ### Parameters
674
675 sndfile
676 : Not used.
677
678 cmd
679 : SFC_GET_FORMAT_INFO
680
681 data
682 : a pointer to an SF_FORMAT_INFO struct
683
684 datasize
685 : sizeof (SF_FORMAT_INFO)
686
687 The `SF_FORMAT_INFO` struct is defined in \<sndfile.h\> as:
688
689 ```c
690 typedef struct
691 { int format ;
692 const char *name ;
693 const char *extension ;
694 } SF_FORMAT_INFO ;
695 ```
696
697 When `sf_command()` is called with `SF_GET_FORMAT_INFO`, the format field is
698 examined and if (format & `SF_FORMAT_TYPEMASK`) is a valid format then the
699 struct is filled in with information about the given major type. If (format &
700 `SF_FORMAT_TYPEMASK`) is FALSE and (format & `SF_FORMAT_SUBMASK`) is a valid
701 subtype format then the struct is filled in with information about the given
702 subtype.
703
704 ### Examples
705
706 ```c
707 SF_FORMAT_INFO format_info ;
708
709 format_info.format = SF_FORMAT_WAV ;
710 sf_command (sndfile, SFC_GET_FORMAT_INFO, &format_info, sizeof (format_info)) ;
711 printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
712
713 format_info.format = SF_FORMAT_ULAW ;
714 sf_command (sndfile, SFC_GET_FORMAT_INFO, &format_info, sizeof (format_info)) ;
715 printf ("%08x %s\n", format_info.format, format_info.name) ;
716 ```
717
718 ### Return value
719
720 0 on success and non-zero otherwise.
721
722 ## SFC_GET_FORMAT_MAJOR_COUNT
723
724 Retrieve the number of major formats.
725
726 ### Parameters
727
728 sndfile
729 : Not used.
730
731 cmd
732 : SFC_GET_FORMAT_MAJOR_COUNT
733
734 data
735 : a pointer to an int
736
737 datasize
738 : sizeof (int)
739
740 ### Examples
741
742 ```c
743 int count ;
744 sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ;
745 ```
746
747 ### Return value
748
749 0.
750
751 ## SFC_GET_FORMAT_MAJOR
752
753 Retrieve information about a major format type.
754
755 ### Parameters
756
757 sndfile
758 : Not used.
759
760 cmd
761 : SFC_GET_FORMAT_MAJOR
762
763 data
764 : a pointer to an SF_FORMAT_INFO struct
765
766 datasize
767 : sizeof (SF_FORMAT_INFO)
768
769 ### Examples
770
771 ```c
772 SF_FORMAT_INFO format_info ;
773 int k, count ;
774
775 sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &count, sizeof (int)) ;
776
777 for (k = 0 ; k < count ; k++)
778 { format_info.format = k ;
779 sf_command (sndfile, SFC_GET_FORMAT_MAJOR, &format_info, sizeof (format_info)) ;
780 printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
781 } ;
782 ```
783
784 For a more comprehensive example, see the program `list_formats.c` in the
785 `examples/` directory of the libsndfile source code distribution.
786
787 ### Return value
788
789 0 on success and non-zero otherwise.
790
791 The value of the format field will be one of the major format identifiers such
792 as `SF_FORMAT_WAV` or `SF_FORMAT`_AIFF. The name field will contain a char\*
793 pointer to the name of the string, eg. "WAV (Microsoft)". The extension field
794 will contain the most commonly used file extension for that file type.
795
796 ## SFC_GET_FORMAT_SUBTYPE_COUNT
797
798 Retrieve the number of subformats.
799
800 ### Parameters
801
802 sndfile
803 : Not used.
804
805 cmd
806 : SFC_GET_FORMAT_SUBTYPE_COUNT
807
808 data
809 : a pointer to an int
810
811 datasize
812 : sizeof (int)
813
814 ### Examples
815
816 ```c
817 int count ;
818 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ;
819 ```
820
821 ### Return value
822
823 Returns zero.
824
825 ## SFC_GET_FORMAT_SUBTYPE
826
827 Enumerate the subtypes (this function does not translate a subtype into a string
828 describing that subtype). A typical use case might be retrieving a string
829 description of all subtypes so that a dialog box can be filled in.
830
831 ### Parameters
832
833 sndfile
834 : Not used.
835
836 cmd
837 : SFC_GET_FORMAT_SUBTYPE
838
839 data
840 : a pointer to an SF_FORMAT_INFO struct
841
842 datasize
843 : sizeof (SF_FORMAT_INFO)
844
845 ### Examples
846
847 Example 1: Retrieve all sybtypes supported by the WAV format.
848
849 ```c
850 SF_FORMAT_INFO format_info ;
851 int k, count ;
852
853 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ;
854
855 for (k = 0 ; k < count ; k++)
856 { format_info.format = k ;
857 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ;
858 if (! sf_format_check (format_info.format | SF_FORMAT_WAV))
859 continue ;
860 printf ("%08x %s\n", format_info.format, format_info.name) ;
861 } ;
862 ```
863
864 Example 2: Print a string describing the `SF_FORMAT_PCM_16` subtype.
865
866 ```c
867 SF_FORMAT_INFO format_info ;
868 int k, count ;
869
870 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &count, sizeof (int)) ;
871
872 for (k = 0 ; k < count ; k++)
873 { format_info.format = k ;
874 sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &format_info, sizeof (format_info)) ;
875 if (format_info.format == SF_FORMAT_PCM_16)
876 { printf ("%08x %s\n", format_info.format, format_info.name) ;
877 break ;
878 } ;
879 } ;
880 ```
881
882 For a more comprehensive example, see the program `list_formats.c` in the
883 `examples/` directory of the libsndfile source code distribution.
884
885 ### Return value
886
887 0 on success and non-zero otherwise.
888
889 The value of the format field will be one of the major format identifiers such
890 as `SF_FORMAT_WAV` or `SF_FORMAT_AIFF`. The name field will contain a char\*
891 pointer to the name of the string; for instance "WAV (Microsoft)" or "AIFF
892 (Apple/SGI)". The extension field will be a NULL pointer.
893
894 ## SFC_SET_ADD_PEAK_CHUNK
895
896 By default, WAV and AIFF files which contain floating point data (subtype
897 `SF_FORMAT_FLOAT` or `SF_FORMAT_DOUBLE`) have a PEAK chunk. By using this
898 command, the addition of a PEAK chunk can be turned on or off.
899
900 **Note**: This call must be made before any data is written to the file.
901
902 ### Parameters
903
904 sndfile
905 : A valid SNDFILE* pointer
906
907 cmd
908 : SFC_SET_ADD_PEAK_CHUNK
909
910 data
911 : Not used (should be NULL)
912
913 datasize
914 : TRUE or FALSE.
915
916 ### Examples
917
918 ```c
919 /* Turn on the PEAK chunk. */
920 sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;
921
922 /* Turn off the PEAK chunk. */
923 sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ;
924 ```
925
926 ### Return value
927
928 Returns SF_TRUE if the peak chunk will be written after this call. Returns
929 SF_FALSE if the peak chunk will not be written after this call.
930
931 ## SFC_UPDATE_HEADER_NOW
932
933 The header of an audio file is normally written by libsndfile when the file is
934 closed using [**sf_close()**](api.md#file-close-function).
935
936 There are however situations where large files are being generated and it would
937 be nice to have valid data in the header before the file is complete. Using this
938 command will update the file header to reflect the amount of data written to the
939 file so far. Other programs opening the file for read (before any more data is
940 written) will then read a valid sound file header.
941
942 ### Parameters
943
944 sndfile
945 : A valid SNDFILE* pointer
946
947 cmd
948 : SFC_UPDATE_HEADER_NOW
949
950 data
951 : Not used (should be NULL)
952
953 datasize
954 : Not used.
955
956 ### Examples
957
958 ```c
959 /* Update the header now. */
960 sf_command (sndfile, SFC_UPDATE_HEADER_NOW, NULL, 0) ;
961 ```
962
963 ### Return value
964
965 Returns zero.
966
967 ## SFC_SET_UPDATE_HEADER_AUTO
968
969 Similar to `SFC_UPDATE_HEADER_NOW` but updates the header at the end of every
970 call to the [sf_write\*](api.md#write) functions.
971
972 ### Parameters
973
974 sndfile
975 : A valid SNDFILE* pointer
976
977 cmd
978 : SFC_SET_UPDATE_HEADER_AUTO
979
980 data
981 : Not used (should be NULL)
982
983 datasize
984 : `SF_TRUE` or `SF_FALSE`
985
986 ### Examples
987
988 ```c
989 /* Turn on auto header update. */
990 sf_command (sndfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) ;
991
992 /* Turn off auto header update. */
993 sf_command (sndfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_FALSE) ;
994 ```
995
996 ### Return value
997
998 TRUE if auto update header is now on; FALSE otherwise.
999
1000 ## SFC_FILE_TRUNCATE
1001
1002 Truncate a file that was opened for write or read/write.
1003
1004 ### Parameters
1005
1006 sndfile
1007 : A valid SNDFILE* pointer
1008
1009 cmd
1010 : SFC_FILE_TRUNCATE
1011
1012 data
1013 : A pointer to an sf_count_t.
1014
1015 datasize
1016 : sizeof (sf_count_t)
1017
1018 Truncate the file to the number of frames specified by the sf_count_t pointed to
1019 by data. After this command, both the read and the write pointer will be at the
1020 new end of the file. This command will fail (returning non-zero) if the
1021 requested truncate position is beyond the end of the file.
1022
1023 ### Examples
1024
1025 ```c
1026 /* Truncate the file to a length of 20 frames. */
1027 sf_count_t frames = 20 ;
1028 sf_command (sndfile, SFC_FILE_TRUNCATE, &frames, sizeof (frames)) ;
1029 ```
1030
1031 ### Return value
1032
1033 Zero on sucess, non-zero otherwise.
1034
1035 ## SFC_SET_RAW_START_OFFSET
1036
1037 Change the data start offset for files opened up as `SF_FORMAT_RAW`.
1038
1039 ### Parameters
1040
1041 sndfile
1042 : A valid SNDFILE* pointer
1043
1044 cmd
1045 : SFC_SET_RAW_START_OFFSET
1046
1047 data
1048 : A pointer to an sf_count_t.
1049
1050 datasize
1051 : sizeof (sf_count_t)
1052
1053 For a file opened as format `SF_FORMAT_RAW`, set the data offset to the value
1054 given by `data`.
1055
1056 ### Examples
1057
1058 ```c
1059 /* Reset the data offset to 5 bytes from the start of the file. */
1060 sf_count_t offset = 5 ;
1061 sf_command (sndfile, SFC_SET_RAW_START_OFFSET, &offset, sizeof (offset)) ;
1062 ```
1063
1064 ### Return value
1065
1066 Zero on success, non-zero otherwise.
1067
1068 ## SFC_SET_CLIPPING
1069
1070 Turn on/off automatic clipping when doing floating point to integer conversion.
1071
1072 ### Parameters
1073
1074 sndfile
1075 : A valid SNDFILE* pointer
1076
1077 cmd
1078 : SFC_SET_CLIPPING
1079
1080 data
1081 : NULL
1082
1083 datasize
1084 : SF_TRUE or SF_FALSE.
1085
1086 Turn on (datasize == SF_TRUE) or off (datasize == SF_FALSE) clipping.
1087
1088 ### Examples
1089
1090 ```c
1091 sf_command (sndfile, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
1092 ```
1093
1094 ### Return value
1095
1096 Clipping mode (SF_TRUE or SF_FALSE).
1097
1098 ## SFC_GET_CLIPPING
1099
1100 Turn on/off automatic clipping when doing floating point to integer conversion.
1101
1102 ### Parameters
1103
1104 sndfile
1105 : A valid SNDFILE* pointer
1106
1107 cmd
1108 : SFC_GET_CLIPPING
1109
1110 data
1111 : NULL
1112
1113 datasize
1114 : 0
1115
1116 Retrieve the current cliiping setting.
1117
1118 ### Examples
1119
1120 ```c
1121 sf_command (sndfile, SFC_GET_CLIPPING, NULL, 0) ;
1122 ```
1123
1124 ### Return value
1125
1126 Clipping mode (SF_TRUE or SF_FALSE).
1127
1128 ## SFC_GET_EMBED_FILE_INFO
1129
1130 Get the file offset and file length of a file enbedded within another larger
1131 file.
1132
1133 ### Parameters
1134
1135 sndfile
1136 : A valid SNDFILE* pointer
1137
1138 cmd
1139 : SFC_GET_EMBED_FILE_INFO
1140
1141 data
1142 : a pointer to an SF_EMBED_FILE_INFO struct
1143
1144 datasize
1145 : sizeof (SF_EMBED_FILE_INFO)
1146
1147 The `SF_EMBED_FILE_INFO` struct is defined in *sndfile.h* as:
1148
1149 ```c
1150 typedef struct
1151 { sf_count_t offset ;
1152 sf_count_t length ;
1153 } SF_EMBED_FILE_INFO ;
1154 ```
1155
1156 ### Return value
1157
1158 0 on success and non-zero otherwise.
1159
1160 The value of the offset field of the `SF_EMBED_FILE_INFO` struct will be the
1161 offsets in bytes from the start of the outer file to the start of the audio
1162 file. The value of the offset field of the `SF_EMBED_FILE_INFO` struct will be
1163 the length in bytes of the embedded file.
1164
1165 ## SFC_WAVEX_GET_AMBISONIC
1166
1167 Test if the current file has the GUID of a WAVEX file for any of the Ambisonic
1168 formats.
1169
1170 ### Parameters
1171
1172 sndfile
1173 : A valid SNDFILE* pointer
1174
1175 cmd
1176 : SFC_WAVEX_GET_AMBISONIC
1177
1178 data
1179 : NULL
1180
1181 datasize
1182 : 0
1183
1184 The Ambisonic WAVEX formats are defined here:
1185 <http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html>.
1186
1187 ### Return value
1188
1189 `SF_AMBISONIC_NONE(0x40)` or `SF_AMBISONIC_B_FORMAT(0x41)` or zero if the file
1190 format does not support ambisonic formats.
1191
1192 ## SFC_WAVEX_SET_AMBISONIC
1193
1194 Set the GUID of a new WAVEX file to indicate an Ambisonics format.
1195
1196 ### Parameters
1197
1198 sndfile
1199 : A valid SNDFILE* pointer
1200
1201 cmd
1202 : SFC_WAVEX_SET_AMBISONIC
1203
1204 data
1205 : NULL
1206
1207 datasize
1208 : SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT
1209
1210 Turn on (`SF_AMBISONIC_B_FORMAT(0x41)`) or off (`SF_AMBISONIC_NONE(0x40)`)
1211 encoding. This command is currently only supported for files with
1212 `SF_FORMAT_WAVEX` format.
1213
1214 The Ambisonic WAVEX formats are defined here:
1215
1216 <http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html>.
1217
1218 ### Return value
1219
1220 Return the ambisonic value that has just been set or zero if the
1221 file format does not support ambisonic encoding.
1222
1223 ## SFC_SET_VBR_ENCODING_QUALITY
1224
1225 Set the Variable Bit Rate encoding quality. The encoding quality value
1226 should be between 0.0 (lowest quality) and 1.0 (highest quality).
1227 Currenly this command is only implemented for FLAC and Ogg/Vorbis files.
1228 It has no effect on un-compressed file formats.
1229
1230 ### Parameters
1231
1232 sndfile
1233 : A valid SNDFILE* pointer
1234
1235 cmd
1236 : SFC_SET_VBR_ENCODING_QUALITY
1237
1238 data
1239 : A pointer to a double value
1240
1241 datasize
1242 : sizeof (double)
1243
1244 The command must be sent before any audio data is written to the file.
1245
1246 ### Return value
1247
1248 SF_TRUE if VBR encoding quality was set. SF_FALSE otherwise.
1249
1250 ## SFC_SET_OGG_PAGE_LATENCY_MS
1251
1252 Set page latency for Ogg Opus file in milliseconds. The value should be between
1253 50.0 and 1600.0. This command is only implemented for Ogg Opus files.
1254
1255 ### Parameters
1256
1257 sndfile
1258 : A valid SNDFILE* pointer
1259
1260 cmd
1261 : SFC_SET_OGG_PAGE_LATENCY_MS
1262
1263 data
1264 : A pointer to a double value
1265
1266 datasize
1267 : sizeof (double)
1268
1269 ### Return value
1270
1271 0 on success and non-zero otherwise.
1272
1273 ## SFC_SET_COMPRESSION_LEVEL
1274
1275 Set the compression level. The compression level should be between 0.0 (minimum
1276 compression level) and 1.0 (highest compression level). Currenly this command is
1277 only implemented for FLAC and Ogg/Vorbis files. It has no effect on
1278 uncompressed file formats.
1279
1280 ### Parameters
1281
1282 sndfile
1283 : A valid SNDFILE* pointer
1284
1285 cmd
1286 : SFC_SET_COMPRESSION_LEVEL
1287
1288 data
1289 : A pointer to a double value
1290
1291 datasize
1292 : sizeof (double)
1293
1294 The command must be sent before any audio data is written to the file.
1295
1296 ### Return value
1297
1298 SF_TRUE if compression level was set. SF_FALSE otherwise.
1299
1300 ## SFC_RAW_DATA_NEEDS_ENDSWAP
1301
1302 Determine if raw data read using [sf_read_raw()](api.md#raw) needs to be end
1303 swapped on the host CPU.
1304
1305 For instance, will return SF_TRUE on when reading WAV containing
1306 `SF_FORMAT_PCM_16` data on a big endian machine and `SF_FALSE` on a
1307 little endian machine.
1308
1309 ### Parameters
1310
1311 sndfile
1312 : A valid SNDFILE* pointer
1313
1314 cmd
1315 : SFC_RAW_DATA_NEEDS_ENDSWAP
1316
1317 data
1318 : NULL
1319
1320 datasize
1321 : 0
1322
1323 ### Return value
1324
1325 `SF_TRUE` or `SF_FALSE`.
1326
1327 ## SFC_GET_BROADCAST_INFO
1328
1329 Retrieve the Broadcast Extension Chunk from WAV (and related) files.
1330
1331 ### Parameters
1332
1333 sndfile
1334 : A valid SNDFILE* pointer
1335
1336 cmd
1337 : SFC_GET_BROADCAST_INFO
1338
1339 data
1340 : a pointer to an SF_BROADCAST_INFO struct
1341
1342 datasize
1343 : sizeof (SF_BROADCAST_INFO)
1344
1345 The SF_BROADCAST_INFO struct is defined in *sndfile.h* as:
1346
1347 ```c
1348 typedef struct
1349 { char description [256] ;
1350 char originator [32] ;
1351 char originator_reference [32] ;
1352 char origination_date [10] ;
1353 char origination_time [8] ;
1354 unsigned int time_reference_low ;
1355 unsigned int time_reference_high ;
1356 short version ;
1357 char umid [64] ;
1358 char reserved [190] ;
1359 unsigned int coding_history_size ;
1360 char coding_history [256] ;
1361 } SF_BROADCAST_INFO ;
1362 ```
1363
1364 ### Return value
1365
1366 `SF_TRUE` if the file contained a Broadcast Extension chunk or `SF_FALSE`
1367 otherwise.
1368
1369 ## SFC_SET_BROADCAST_INFO
1370
1371 Set the Broadcast Extension Chunk for WAV (and related) files.
1372
1373 ### Parameters
1374
1375 sndfile
1376 : A valid SNDFILE* pointer
1377
1378 cmd
1379 : SFC_SET_BROADCAST_INFO
1380
1381 data
1382 : a pointer to an SF_BROADCAST_INFO struct
1383
1384 datasize
1385 : sizeof (SF_BROADCAST_INFO)
1386
1387 ### Return value
1388
1389 `SF_TRUE` if setting the Broadcast Extension chunk was successful and `SF_FALSE`
1390 otherwise.
1391
1392 ## SFC_GET_CHANNEL_MAP_INFO
1393
1394 Retrieve the channel map contained in an AIFF or CAF Channel Layout chunk.
1395
1396 ### Parameters
1397
1398 sndfile
1399 : A valid SNDFILE* pointer
1400
1401 cmd
1402 : SFC_GET_CHANNEL_MAP_INFO
1403
1404 data
1405 : a pointer to an array of int, the same size as the number of channels in the
1406 file
1407
1408 datasize
1409 : number of channels * sizeof (int)
1410
1411 Channel map positions are defined in an enum in *sndfile.h*:
1412
1413 | Name | Value | Description |
1414 |:-------------------------------------|:------|:------------------------------------------------------------------|
1415 | SF_CHANNEL_MAP_INVALID | 0 | |
1416 | SF_CHANNEL_MAP_MONO | 1 | |
1417 | SF_CHANNEL_MAP_LEFT | 2 | Apple calls this 'Left' |
1418 | SF_CHANNEL_MAP_RIGHT | 3 | Apple calls this 'Right' |
1419 | SF_CHANNEL_MAP_CENTER | 4 | Apple calls this 'Center' |
1420 | SF_CHANNEL_MAP_FRONT_LEFT | 5 | |
1421 | SF_CHANNEL_MAP_FRONT_RIGHT | 6 | |
1422 | SF_CHANNEL_MAP_FRONT_CENTER | 7 | |
1423 | SF_CHANNEL_MAP_REAR_CENTER | 8 | Apple calls this 'Center Surround', Msft calls this 'Back Center' |
1424 | SF_CHANNEL_MAP_REAR_LEFT | 9 | Apple calls this 'Left Surround', Msft calls this 'Back Left' |
1425 | SF_CHANNEL_MAP_REAR_RIGHT | 10 | Apple calls this 'Right Surround', Msft calls this 'Back Right' |
1426 | SF_CHANNEL_MAP_LFE | 11 | Apple calls this 'LFEScreen', Msft calls this 'Low Frequency' |
1427 | SF_CHANNEL_MAP_FRONT_LEFT_OF_CENTER | 12 | Apple calls this 'Left Center' |
1428 | SF_CHANNEL_MAP_FRONT_RIGHT_OF_CENTER | 13 | Apple calls this 'Right Center' |
1429 | SF_CHANNEL_MAP_SIDE_LEFT | 14 | Apple calls this 'Left Surround Direct' |
1430 | SF_CHANNEL_MAP_SIDE_RIGHT | 15 | Apple calls this 'Right Surround Direct' |
1431 | SF_CHANNEL_MAP_TOP_CENTER | 16 | Apple calls this 'Top Center Surround' |
1432 | SF_CHANNEL_MAP_TOP_FRONT_LEFT | 17 | Apple calls this 'Vertical Height Left' |
1433 | SF_CHANNEL_MAP_TOP_FRONT_RIGHT | 18 | Apple calls this 'Vertical Height Right' |
1434 | SF_CHANNEL_MAP_TOP_FRONT_CENTER | 19 | Apple calls this 'Vertical Height Center' |
1435 | SF_CHANNEL_MAP_TOP_REAR_LEFT | 20 | Apple and MS call this 'Top Back Left' |
1436 | SF_CHANNEL_MAP_TOP_REAR_RIGHT | 21 | Apple and MS call this 'Top Back Right' |
1437 | SF_CHANNEL_MAP_TOP_REAR_CENTER | 22 | Apple and MS call this 'Top Back Center' |
1438 | SF_CHANNEL_MAP_AMBISONIC_B_W | 23 | |
1439 | SF_CHANNEL_MAP_AMBISONIC_B_X | 24 | |
1440 | SF_CHANNEL_MAP_AMBISONIC_B_Y | 25 | |
1441 | SF_CHANNEL_MAP_AMBISONIC_B_Z | 26 | |
1442 | SF_CHANNEL_MAP_MAX | 27 | |
1443
1444 ### Return value
1445
1446 `SF_TRUE` if the file contained a Channel Layout chunk or `SF_FALSE` otherwise.
1447
1448 ## SFC_SET_CHANNEL_MAP_INFO
1449
1450 Set the channel map contained in an AIFF or CAF Channel Layout chunk.
1451
1452 ### Parameters
1453
1454 sndfile
1455 : A valid SNDFILE* pointer
1456
1457 cmd
1458 : SFC_SET_CHANNEL_MAP_INFO
1459
1460 data
1461 : a pointer to an array of int, the same size as the number of channels in the
1462 file
1463
1464 datasize
1465 : number of channels * sizeof (int)
1466
1467 ### Return value
1468
1469 `SF_TRUE` if setting the Channel Layout chunk was successful and `SF_FALSE`
1470 otherwise.
1471
1472 ## SFC_GET_CART_INFO
1473
1474 Retrieve the Cart Chunk from WAV (and related) files. Based on AES46 standard
1475 for CartChunk (see [CartChunk.org](http://www.cartchunk.org/) for more
1476 information.
1477
1478 ### Parameters
1479
1480 sndfile
1481 : A valid SNDFILE* pointer
1482
1483 cmd
1484 : SFC_GET_CART_INFO
1485
1486 data
1487 : a pointer to an SF_CART_INFO struct
1488
1489 datasize
1490 : sizeof (SF_CART_INFO)
1491
1492 The SF_CART_INFO struct is defined in *sndfile.h* as:
1493
1494 ```c
1495 #define SF_CART_INFO_VAR(p_tag_text_size) \
1496 struct
1497 { char version [4] ;
1498 char title [64] ;
1499 char artist [64] ;
1500 char cut_id [64] ;
1501 char client_id [64] ;
1502 char category [64] ;
1503 char classification [64] ;
1504 char out_cue [64] ;
1505 char start_date [10] ;
1506 char start_time [8] ;
1507 char end_date [10] ;
1508 char end_time [8] ;
1509 char producer_app_id [64] ;
1510 char producer_app_version [64] ;
1511 char user_def [64] ;
1512 long level_reference ;
1513 SF_CART_TIMER post_timers [8] ;
1514 char reserved [276] ;
1515 char url [1024] ;
1516 unsigned int tag_text_size ;
1517 char tag_text[p_tag_text_size] ;
1518 }
1519 ```
1520
1521 ### Return value
1522
1523 `SF_TRUE` if the file contained a Cart chunk or `SF_FALSE` otherwise.
1524
1525 ## SFC_SET_CART_INFO
1526
1527 Set the Cart Chunk for WAV (and related) files.
1528
1529 ### Parameters
1530
1531 sndfile
1532 : A valid SNDFILE* pointer
1533
1534 cmd
1535 : SFC_SET_CART_INFO
1536
1537 data
1538 : a pointer to an SF_CART_INFO struct
1539
1540 datasize
1541 : sizeof (SF_CART_INFO)
1542
1543 ### Return value
1544
1545 SF_TRUE if setting the Cart chunk was successful and SF_FALSE otherwise.
1546
1547 ## SFC_GET_LOOP_INFO
1548
1549 Retrieve loop information for file including time signature, length in beats and
1550 original MIDI base note
1551
1552 ### Parameters
1553
1554 sndfile
1555 : A valid SNDFILE* pointer
1556
1557 cmd
1558 : SFC_GET_LOOP_INFO
1559
1560 data
1561 : a pointer to an SF_LOOP_INFO struct
1562
1563 datasize
1564 : sizeof (SF_LOOP_INFO)
1565
1566 The SF_LOOP_INFO struct is defined in *sndfile.h* as:
1567
1568 ```c
1569 typedef struct
1570 { short time_sig_num ; /* any positive integer > 0 */
1571 short time_sig_den ; /* any positive power of 2 > 0 */
1572 int loop_mode ; /* see SF_LOOP enum */
1573
1574 int num_beats ; /* this is NOT the amount of quarter notes !!!*/
1575 /* a full bar of 4/4 is 4 beats */
1576 /* a full bar of 7/8 is 7 beats */
1577
1578 float bpm ; /* suggestion, as it can be calculated using other fields:*/
1579 /* file's lenght, file's sampleRate and our time_sig_den*/
1580 /* -> bpms are always the amount of _quarter notes_ per minute */
1581
1582 int root_key ; /* MIDI note, or -1 for None */
1583 int future [6] ;
1584 } SF_LOOP_INFO ;
1585 ```
1586
1587 ### Examples
1588
1589 ```c
1590 SF_LOOP_INFO loop;
1591 sf_command (sndfile, SFC_GET_LOOP_INFO, &loop, sizeof (loop)) ;
1592 ```
1593
1594 ### Return value
1595
1596 `SF_TRUE` if the file header contains loop information for the file, `SF_FALSE`
1597 otherwise.
1598
1599 ## SFC_GET_INSTRUMENT
1600
1601 Retrieve instrument information from file including MIDI base note, keyboard
1602 mapping and looping informations(start/stop and mode).
1603
1604 ### Parameters
1605
1606 sndfile
1607 : A valid SNDFILE* pointer
1608
1609 cmd
1610 : SFC_GET_INSTRUMENT
1611
1612 data
1613 : a pointer to an SF_INSTRUMENT struct
1614
1615 datasize
1616 : sizeof (SF_INSTRUMENT)
1617
1618 The `SF_INSTRUMENT` struct is defined in *sndfile.h* as:
1619
1620 ```c
1621 typedef struct
1622 { int gain ;
1623 char basenote, detune ;
1624 char velocity_lo, velocity_hi ;
1625 char key_lo, key_hi ;
1626 int loop_count ;
1627
1628 struct
1629 { int mode ;
1630 unsigned int start ;
1631 unsigned int end ;
1632 unsigned int count ;
1633 } loops [16] ; /* make variable in a sensible way */
1634 } SF_INSTRUMENT ;
1635 ```
1636
1637 `mode` values are defined as:
1638
1639 | Name | Value | Description |
1640 |:--------------------|:------|:------------|
1641 | SF_LOOP_NONE | 800 | |
1642 | SF_LOOP_FORWARD | 801 | |
1643 | SF_LOOP_BACKWARD | 802 | |
1644 | SF_LOOP_ALTERNATING | 803 | |
1645
1646 ### Examples
1647
1648 ```c
1649 SF_INSTRUMENT inst ;
1650 sf_command (sndfile, SFC_GET_INSTRUMENT, &inst, sizeof (inst)) ;
1651 ```
1652
1653 ### Return value
1654
1655 `SF_TRUE` if the file header contains instrument information for the file,
1656 `SF_FALSE` otherwise.
1657
1658 ## SFC_SET_INSTRUMENT
1659
1660 Set the instrument information for the file.
1661
1662 ### Parameters
1663
1664 sndfile
1665 : A valid SNDFILE* pointer
1666
1667 cmd
1668 : SFC_SET_INSTRUMENT
1669
1670 data
1671 : a pointer to an SF_INSTRUMENT struct
1672
1673 datasize
1674 : sizeof (SF_INSTRUMENT)
1675
1676 ### Examples
1677
1678 ```c
1679 SF_INSTRUMENT inst ;
1680 sf_command (sndfile, SFC_SET_INSTRUMENT, &inst, sizeof (inst)) ;
1681 ```
1682
1683 ### Return value
1684
1685 `SF_TRUE` if the file header contains instrument information for the file,
1686 `SF_FALSE` otherwise.
1687
1688 ## SFC_GET_CUE_COUNT
1689
1690 Retrieve the number of cue markers available for retrieval using the
1691 [SFC_GET_CUE](#sfc_get_cue) command.
1692
1693 ### Parameters
1694
1695 sndfile
1696 : A valid SNDFILE* pointer
1697
1698 cmd
1699 : SFC_GET_CUE_COUNT
1700
1701 data
1702 : a pointer to a uint32_t
1703
1704 datasize
1705 : sizeof (uint32_t)
1706
1707 ### Examples
1708
1709 ```c
1710 uint32_t cue_count ;
1711 sf_command (sndfile, SFC_GET_CUE_COUNT, &cue_count, sizeof (cue_count)) ;
1712 ```
1713
1714 ### Return value
1715
1716 `SF_TRUE` if the file header contains cue marker information for the file,
1717 `SF_FALSE` otherwise.
1718
1719 ## SFC_GET_CUE
1720
1721 Retrieve cue marker information from file.
1722
1723 ### Parameters
1724
1725 sndfile
1726 : A valid SNDFILE* pointer
1727
1728 cmd
1729 : SFC_GET_CUE
1730
1731 data
1732 : a pointer to an SF_CUES struct
1733
1734 datasize
1735 : sizeof (SF_CUES)
1736
1737 The SF_CUES struct is defined in *sndfile.h* as:
1738
1739 ```c
1740 typedef struct
1741 { int cue_count ;
1742
1743 struct
1744 { int32_t indx ;
1745 uint32_t position ;
1746 int32_t fcc_chunk ;
1747 int32_t chunk_start ;
1748 int32_t block_start ;
1749 uint32_t sample_offset ;
1750 char name [256] ;
1751 } cue_points [100] ;
1752 } SF_CUES ;
1753 ```
1754
1755 There is also an SF_CUES_VAR \#define that allows reading/writing more than 100
1756 cue markers.
1757
1758 ### Examples
1759
1760 ```c
1761 SF_CUES cues ;
1762 sf_command (sndfile, SFC_GET_CUE, &cues, sizeof (cues)) ;
1763 ```
1764
1765 ### Return value
1766
1767 `SF_TRUE` if the file header contains cue marker information for the file,
1768 `SF_FALSE` otherwise.
1769
1770 ## SFC_SET_CUE
1771
1772 Set the cue marker information for the file.
1773
1774 ### Parameters
1775
1776 sndfile
1777 : A valid SNDFILE* pointer
1778
1779 cmd
1780 : SFC_SET_CUE
1781
1782 data
1783 : a pointer to an SF_CUES struct
1784
1785 datasize
1786 : sizeof (SF_CUES)
1787
1788 ### Examples
1789
1790 ```c
1791 SF_CUES cues ;
1792 sf_command (sndfile, SFC_SET_CUE, &cues, sizeof (cues)) ;
1793 ```
1794
1795 ### Return value
1796
1797 `SF_TRUE` if the file header contains cue marker information for the file,
1798 `SF_FALSE` otherwise.
1799
1800 ## SFC_RF64_AUTO_DOWNGRADE
1801
1802 Enable auto downgrade from RF64 to WAV.
1803
1804 The EBU recomendation is that when writing RF64 files and the resulting file is
1805 less than 4Gig in size, it should be downgraded to a WAV file (WAV files have a
1806 maximum size of 4Gig). libsndfile doesn't follow the EBU recommendations
1807 exactly, mainly because the test suite needs to be able test reading/writing
1808 RF64 files without having to generate files larger than 4 gigabytes.
1809
1810 Note: This command should be issued before the first bit of audio data has been
1811 written to the file. Calling this command after audio data has been written will
1812 return the current value of this setting, but will not allow it to be changed.
1813
1814 ### Parameters
1815
1816 sndfile
1817 : A valid SNDFILE* pointer
1818
1819 cmd
1820 : SFC_RF64_AUTO_DOWNGRADE
1821
1822 data
1823 : NULL
1824
1825 datasize
1826 : SF_TRUE or SF_FALSE
1827
1828 ### Examples
1829
1830 ```c
1831 /* Enable auto downgrade on file close. */
1832 sf_command (sndfile, SFC_RF64_AUTO_DOWNGRADE, NULL, SF_TRUE) ;
1833 ```
1834
1835 ### Return value
1836
1837 Returns `SF_TRUE` if `SFC_RF64_AUTO_DOWNGRADE` is set and `SF_FALSE` otherwise.
1838
1839 ## SFC_GET_ORIGINAL_SAMPLERATE
1840
1841 Get original samplerate metadata.
1842
1843 The Opus audio codec stores audio data independent of samplerate, but only
1844 supports encoding or decoding at 8000Hz, 12000Hz, 16000Hz, 24000Hz or 48000Hz.
1845 Opus includes a header field to record the original source input samplerate, and
1846 a samplerate converter may be used if needed.
1847
1848 This command gets the original samplerate header field. It does not enable any
1849 (non-existent) samplerate conversion, nor change the current decoder samplerate.
1850
1851 ### Parameters
1852
1853 sndfile
1854 : A valid SNDFILE* pointer
1855
1856 cmd
1857 : SFC_GET_ORIGINAL_SAMPLERATE
1858
1859 data
1860 : pointer to an integer
1861
1862 datasize
1863 : sizeof (int)
1864
1865 ### Examples
1866
1867 ```c
1868 /* Get the original sample rate */
1869 int original_samplerate ;
1870 sf_command (sndfile, SFC_GET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (original_samplerate)) ;
1871 ```
1872
1873 ### Return value
1874
1875 Returns `SF_TRUE` on success, `SF_FALSE` otherwise.
1876
1877 The passed integer is set to the value of the original samplerate.
1878
1879 ## SFC_SET_ORIGINAL_SAMPLERATE
1880
1881 Set original samplerate metadata.
1882
1883 The Opus audio codec stores audio data independent of samplerate, but only
1884 supports encoding or decoding at 8000Hz, 12000Hz, 16000Hz, 24000Hz or 48000Hz.
1885 Opus includes a header field to record the original source input samplerate, and
1886 a samplerate converter may be used if needed.
1887
1888 When writing an Opus file this command sets the original samplerate header field
1889 to the provided value, which is then stored in the file. This has no effect on
1890 the current encoder samplerate.
1891
1892 When reading an Opus file this command overrides the original samplerate value
1893 as read from the file. libsndfile uses this value to choose what samplerate to
1894 decode at, rounding up to the nearest valid Opus samplerate. After a successful
1895 call, the file samplerate and frames count may have changed.
1896
1897 Note: This command should be issued before the first bit of audio data has been
1898 read from or written to the file.
1899
1900 ### Parameters
1901
1902 sndfile
1903 : A valid SNDFILE* pointer
1904
1905 cmd
1906 : SFC_SET_ORIGINAL_SAMPLERATE
1907
1908 data
1909 : pointer to an integer
1910
1911 datasize
1912 : sizeof (int)
1913
1914 ### Examples
1915
1916 ```c
1917 /* Store the original sample rate as 44100 */
1918 int original_samplerate 44100;
1919 sf_command (sndfile, SFC_SET_ORIGINAL_SAMPLERATE, &original_samplerate, sizeof (input_samplerate)) ;
1920 ```
1921
1922 ### Return value
1923
1924 Returns SF_TRUE on success, SF_FALSE otherwise.
1925
1926 On write, can only succeed if no data has been written. On read, if successful,
1927 [SFC_GET_CURRENT_SF_INFO](#sfc_get_current_sf_info) should be called to
1928 determine the new frames count and samplerate
0 ---
1 layout: page
2 ---
3
4 # libsndfile Development
5
6 libsndfile is being developed by a small community of users and hackers. People
7 interested in helping can raise an issue on Github.
8
9 The main repository can be found on Github:
10
11 <http://libsndfile.github.io/libsndfile/">
12
13 and includes [instuctions](https://github.com/libsndfile/libsndfile/blob/master/README.md)
14 on how to build libsndfile from the Git repo.
15
16 If you are interested in how to add a new format to a libsndfile, you may find
17 this [FAQ](new_file_type_howto.md) helpful.
0 ---
1 layout: page
2 title: libsndfile : donate.
3 ---
4
5 {% include logo.html %}
6
7 Dear libsndfile user,
8
9 This library was developed on Linux for Linux. I am not a Windows user and
10 maintaining this library for Windows costs me significant amounts of time above
11 and beyond the time taken to make it work on Linux and Unix-like systems.
12
13 I therefore ask Windows users of libsndfile to donate to ensure that
14 libsndfile's support for Windows continues. As long as donations continue to
15 flow in at a decentrate, I will continue to release precompiled Windows binaries
16 in sync with the Linux/Unix version. If donations are poor, support for windows
17 will fall behind.
18
19 You are free to donate any amount you chose. As a guideline:
20
21 * If you are simply a user of libsndfile that would like to ensure that the
22 development of libsndfile continues, a donation of $10US would be more than
23 adequate.
24 * If you are shareware author that distributes libsndfile with your app and
25 makes more than $1000 a year from your shareware, a one off donation of $50
26 would be appropriate.
27 * If your company is a commercial software house that distributes one or more
28 products that ship with libsndfile, a donation of $100 every second or third
29 year would be appropriate.
30
31 Donations can be made in Bitcoin to the Bitcoin address
32 **15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ** which can be verified by checking the
33 following GPG signature.
34
35 -----BEGIN PGP SIGNED MESSAGE-----
36 Hash: SHA256
37
38 libsndfile Bitcoin address : 15hVWemFiH6DLJ22SBYPk9b4fgWtxBEvfQ
39 -----BEGIN PGP SIGNATURE-----
40 Version: GnuPG v1.4.12 (GNU/Linux)
41
42 iQIcBAEBCAAGBQJSK7MUAAoJEEXYQ7zIiotIgXEP/R8hy65tlV7TiPw9bY9BklXS
43 /Vl8FU2RhDkBt61ZmxbfDTybyQ5Vce/3wWph15L4RvpoX1OyeintQFmwwuPjOGiq
44 eIz0nT9vDorG37Xdo5NZNBu9Tp1Od9MNtxFaAsRWFrDfvKEKljBHrcfM972cYrAp
45 DaFd0Ik+bHKom9iQXFB7TFd0w2V4uszVMQDUGqb/vRNeRURZS7ypeMNwc8tZyTKR
46 waEGMTa5sxxRjs7MqGRxSovnFT7JV3TNfdkBInUliIR/XvrudFR9J4Fiv+8Dk9P8
47 WNjm6uFxvgIqiu1G9bjrwwr+DsBju93ljGNcZoayAKw5vwbX6KTcCbc31k9dP8Hf
48 p6YdmPlZVKZmva+P3nLSJBTlxNu24Jm+ha+ZM/svDXTaPFWC8l5FP17kK0Bj8wCq
49 N7pDz6RchEn10u+HdhfT1XiUjxj0zNXrr0GGj9apjl0RlT0O49eBttV0oXIdBRLi
50 nTEaOWITpCgu7ggw1kWXHIWEncuiaSuJy/iH8PgNepWVj/6PxQRMrTqG4ux2Snk8
51 Ua4vO8YHLMZX/XvSUS7eMtgfM7AO6YjJ/ac9bQif9bh6LsYEVVklysMUin6ZRS7Z
52 Cms23FnqeQKtJOzdvqSJiV06lK6fP+tYdM4WSYn+AfL4IfYl2v48xXVU8XOOK9BH
53 bJPKMDcz1ZvfYtX5mSW1
54 =WXGB
55 -----END PGP SIGNATURE-----
56
57 Thanks and regards,
58 Erik de Castro Lopo
59 Main libsndfile author and maintainer
0 ---
1 layout: page
2 ---
3
4 # Embedded Sound Files
5
6 By using the open SNDFILE with a file descriptor function:
7
8 SNDFILE* sf_open_fd (int fd, int mode, SF_INFO *sfinfo, int close_desc) ;
9
10 it is possible to open sound files embedded within larger files. There are
11 however a couple of caveats:
12
13 * Read/Write mode (SFM_RDWR) is not supported.
14 * Writing of embedded files is only supported at the end of the file.
15 * Reading of embedded files is only supported at file offsets greater than zero.
16 * Not all file formats are supported (currently only WAV, AIFF and AU).
17
18 The test program **multi_file_test.c** in the **tests/** directory of the source
19 code tarball shows how this functionality is used to read and write embedded
20 files.
0 ---
1 layout: page
2 title: libsndfile: Supported formats
3 ---
4
5 # libsndfile : Supported formats
6
7 The following table lists the file formats and encodings that libsndfile can
8 read and write. The file formats are arranged across the top and encodings along
9 the left edge.
10
11 {:.formats-table}
12 | | Microsoft WAV | SGI / Apple AIFF / AIFC |Sun / DEC / NeXT AU / SND | Headerless RAW | Paris Audio File PAF | Commodore Amiga IFF / SVX | Sphere Nist WAV | IRCAM SF | Creative VOC | Soundforge W64 | GNU Octave 2.0 MAT4 | GNU Octave 2.1 MAT5 | Portable Voice Format PVF | Fasttracker 2 XI | HMM Tool Kit HTK | Apple CAF | Sound Designer II SD2 | Free Lossless Audio Codec FLAC |
13 |:-------------------|:-------------:|:-----------------------:|:------------------------:|:--------------:|:--------------------:|:-------------------------:|:---------------:|:--------:|:------------:|:--------------:|:-------------------:|:-------------------:|:-------------------------:|:----------------:|:----------------:|:---------:|:---------------------:|:------------------------------:|
14 | Unsigned 8 bit PCM | R/W | R/W | | R/W | | | | | R/W | R/W | | R/W | | | | | | |
15 | Signed 8 bit PCM | | R/W | R/W | R/W | R/W | R/W | R/W | | | | | | R/W | | | R/W | R/W | R/W |
16 | Signed 16 bit PCM | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | R/W | | R/W | R/W | R/W | R/W |
17 | Signed 24 bit PCM | R/W | R/W | R/W | R/W | R/W | | R/W | | | R/W | | | | | | R/W | R/W | R/W |
18 | Signed 32 bit PCM | R/W | R/W | R/W | R/W | | | R/W | R/W | | R/W | R/W | R/W | R/W | | | R/W | | |
19 | 32 bit float | R/W | R/W | R/W | R/W | | | | R/W | | R/W | R/W | R/W | | | | R/W | | |
20 | 64 bit double | R/W | R/W | R/W | R/W | | | | | | R/W | R/W | R/W | | | | R/W | | |
21 | u-law encoding | R/W | R/W | R/W | R/W | | | R/W | R/W | R/W | R/W | | | | | | R/W | | |
22 | A-law encoding | R/W | R/W | R/W | R/W | | | R/W | R/W | R/W | R/W | | | | | | R/W | | |
23 | IMA ADPCM | R/W | | | | | | | | | R/W | | | | | | | | |
24 | MS ADPCM | R/W | | | | | | | | | R/W | | | | | | | | |
25 | GSM 6.10 | R/W | R/W | | R/W | | | | | | R/W | | | | | | | | |
26 | G721 ADPCM 32kbps | R/W | | R/W | | | | | | | | | | | | | | | |
27 | G723 ADPCM 24kbps | | | R/W | | | | | | | | | | | | | | | |
28 | G723 ADPCM 40kbps | | | R/W | | | | | | | | | | | | | | | |
29 | 12 bit DWVW | | R/W | | R/W | | | | | | | | | | | | | | |
30 | 16 bit DWVW | | R/W | | R/W | | | | | | | | | | | | | | |
31 | 24 bit DWVW | | R/W | | R/W | | | | | | | | | | | | | | |
32 | Ok Dialogic ADPCM | | | | R/W | | | | | | | | | | | | | | |
33 | 8 bit DPCM | | | | | | | | | | | | | | R/W | | | | |
34 | 16 bit DPCM | | | | | | | | | | | | | | R/W | | | | |
35
36 From version 1.0.18, libsndfile also reads and writes
37 [FLAC](https://xiph.org/flac/) and [Ogg/Vorbis](https://xiph.org/vorbis/).
38
39 From version 1.0.29, libsndfile can read and write
40 [Ogg/Opus](https://opus-codec.org/).
41
42 Some of the file formats I am also interested in adding are:
43
44 - Kurzweil K2000 sampler files.
45 - Ogg Speex.
46 - MPEG Layer 3 (commonly known as MP3)
47
48 Other file formats may also be added on request.
49
50 If you are interested in how to add a new format to a libsndfile, you may find
51 this [FAQ](new_file_type_howto.md) helpful.
0 ---
1 layout: home
2 title: The libsndfile Home Page
3 ---
4
5 Libsndfile is a C library for reading and writing files containing sampled sound
6 (such as MS Windows WAV and the Apple/SGI AIFF format) through one standard
7 library interface. It is released in source code format under the
8 [Gnu Lesser General Public License](http://www.gnu.org/copyleft/lesser.html).
9
10 The library was written to compile and run on a Linux system but should compile
11 and run on just about any Unix (including MacOS X).
12 There are also pre-compiled binaries available for 32 and 64 bit windows.
13
14 It was designed to handle both little-endian (such as WAV) and big-endian (such
15 as AIFF) data, and to compile and run correctly on little-endian (such as Intel
16 and DEC/Compaq Alpha) processor systems as well as big-endian processor systems
17 such as Motorola 68k, Power PC, MIPS and Sparc. Hopefully the design of the
18 library will also make it easy to extend for reading and writing new sound file
19 formats.
20
21 It has been compiled and tested (at one time or another) on the following
22 systems:
23
24 * Every platform supported by Debian GNU/Linux including x86_64-linux-gnu,
25 i486-linux-gnu, powerpc-linux-gnu, sparc-linux-gnu, alpha-linux-gnu,
26 mips-linux-gnu and armel-linux-gnu.
27 * powerpc-apple-darwin7.0 (Mac OS X 10.3)
28 * sparc-sun-solaris2.8 (using gcc)
29 * mips-sgi-irix5.3 (using gcc)
30 * QNX 6.0
31 * i386-unknown-openbsd2.9
32 * Microsoft Windows
33
34 At the moment, each new release is being tested on i386 Linux, x86_64 Linux,
35 PowerPC Linux, Win32 and Win64.
36
37 ## Features
38
39 libsndfile has the following main features :
40
41 * Ability to read and write a large number of [file formats](formats.html).
42 * A simple, elegant and easy to use Applications Programming Interface.
43 * Usable on Unix, Win32, MacOS and others.
44 * On the fly format conversion, including endian-ness swapping, type conversion
45 and bitwidth scaling.
46 * Optional normalisation when reading floating point data from files containing
47 integer data.
48 * Ability to open files in read/write mode.
49 * The ability to write the file header without closing the file (only on files
50 open for write or read/write).
51 * Ability to query the library about all supported formats and retrieve text
52 strings describing each format.
53
54 libsndfile has a comprehensive test suite so that each release is as bug free
55 as possible.
56 When new bugs are found, new tests are added to the test suite to ensure that
57 these bugs don't creep back into the code.
58 When new features are added, tests are added to the test suite to make sure that
59 these features continue to work correctly even when they are old features.
60
61 ## History
62
63 My first attempt at reading and writing WAV files was in 1990 or so under
64 Windows 3.1. I started using Linux in early 1995 and contributed some code to
65 the [wavplay](http://www.vaxxine.com/ve3wwg/gnuwave.html) program. That
66 contributed code would eventually mutate into this library. As one of my
67 interests is Digital Signal Processing (DSP) I decided that as well as reading
68 data from an audio file in the native format (typically 16 bit short integers)
69 it would also be useful to be able to have the library do the conversion to
70 floating point numbers for DSP applications. It then dawned on me that whatever
71 file format (anything from 8 bit unsigned chars, to 32 bit floating point
72 numbers) the library should be able to convert the data to whatever format the
73 library user wishes to use it in. For example, in a sound playback program, the
74 library caller typically wants the sound data in 16 bit short integers to dump
75 into a sound card even though the data in the file may be 32 bit floating point
76 numbers (ie Microsoft's WAVE_FORMAT_IEEE_FLOAT format). Another example would be
77 someone doing speech recognition research who has recorded some speech as a 16
78 bit WAV file but wants to process it as double precision floating point numbers.
79
80 Here is the release history for libsndfile:
81
82 * Version 0.0.8 (Feb 15 1999) First official release.
83 * Version 0.0.28 (Apr 26 2002) Final release of version 0 of libsndfile.
84 * Version 1.0.0rc1 (Jun 24 2002) Release candidate 1 of version 1 of libsndfile.
85 * Version 1.0.0rc6 (Aug 14 2002) MacOS 9 fixes.
86 * Version 1.0.0 (Aug 16 2002) First 1.0.X release.
87 * Version 1.0.1 (Sep 14 2002) Added MAT4 and MAT5 file formats.
88 * Version 1.0.2 (Nov 24 2002) Added VOX ADPCM format.
89 * Version 1.0.3 (Dec 09 2002) Fixes for Linux on ia64 CPUs.
90 * Version 1.0.4 (Feb 02 2003) New file formats and functionality.
91 * Version 1.0.5 (May 03 2003) One new file format and new functionality.
92 * Version 1.0.6 (Feb 08 2004) Large file fix for Linux/Solaris, new
93 functionality and Win32 improvements.
94 * Version 1.0.7 (Feb 24 2004) Fix build problems on MacOS X and fix ia64/MIPS
95 etc clip mode detction.
96 * Version 1.0.8 (Mar 14 2004) Minor bug fixes.
97 * Version 1.0.9 (Mar 30 2004) Add AVR format. Improve handling of some WAV
98 files.
99 * Version 1.0.10 (Jun 15 2004) Minor bug fixes. Fix support for Win32 MinGW
100 compiler.
101 * Version 1.0.11 (Nov 15 2004) Add SD2 file support, reading of loop data in WAV
102 and AIFF. Minor bug fixes.
103 * Version 1.0.12 (Sep 30 2005) Add FLAC and CAF file support, virtual I/O
104 interface. Minor bug fixes and cleanups.
105 * Version 1.0.13 (Jan 21 2006) Add read/write of instrument chunks. Minor bug
106 fixes.
107 * Version 1.0.14 (Feb 19 2006) Minor bug fixes. Start shipping windows
108 binary/source ZIP.
109 * Version 1.0.15 (Mar 16 2006) Minor bug fixes.
110 * Version 1.0.16 (Apr 30 2006) Add support for RIFX. Other minor feature
111 enhancements and bug fixes.
112 * Version 1.0.17 (Aug 31 2006) Add C++ wrapper sndfile.hh. Minor bug fixes and
113 cleanups.
114 * Version 1.0.18 (Feb 07 2009) Add Ogg/Vorbis suppport, remove captive
115 libraries, many new features and bug fixes. Generate Win32 and Win64
116 pre-compiled binaries.
117 * Version 1.0.19 (Mar 02 2009) Fix for CVE-2009-0186. Huge number of minor fixes
118 as a result of static analysis.
119 * Version 1.0.20 (May 14 2009) Fix for potential heap overflow.
120 * Version 1.0.21 (December 13 2009) Bunch of minor bug fixes.
121 * Version 1.0.22 (October 04 2010) Bunch of minor bug fixes.
122 * Version 1.0.23 (October 10 2010) Minor bug fixes.
123 * Version 1.0.24 (March 23 2011) Minor bug fixes.
124 * Version 1.0.25 (July 13 2011) Fix for Secunia Advisory SA45125. Minor bug
125 fixes and improvements.
126 * Version 1.0.26 (November 22 2015) Fix for CVE-2014-9496, CVE-2014-9756 and
127 CVE-2015-7805. Add ALAC/CAF support. Minor bug fixes and improvements.
128 * Version 1.0.27 (June 19 2016) Fix a seek regression in 1.0.26. Add metadata
129 read/write for CAF and RF64. FIx PAF endian-ness issue.
130 * Version 1.0.28 (April 2 2017) Fix buffer overruns in FLAC and ID3 handling
131 code. Reduce default header memory requirements. Fix detection of Large File
132 Support for 32 bit systems.
133 * Version 1.0.29 (August 15 2020) Opus support, build system improvements and
134 bug fixes.
135 * Version 1.0.30 (September 19 2020) Bugfix release. Fix file descriptor leaks
136 in sf_open_fd () function. Fix critical CMake bug leading to broken ABI on
137 Linux platforms. Other numerous fixes to CMake build system, consider it
138 stable now. Fix some memory leaks. Fix handling of some SD2 files. Update
139 documentation. Integrate GitHub Actions for faster test builds and Oss-Fuzz
140 for fuzzing tests. Move sndfile.h.in from src/ to include/ directory. To avoid
141 problems, delete old generated sndfile.h from $(top_builddir)/src.
142 * Version 1.0.31 (January 24 2021) Bugfix release. Fix multiple memory leaks
143 reported by OSS-Fuzz. More SSE2-optimized functions for x86 and amd64.
144
145 ## Similar or Related Projects
146
147 * [SoX](http://sox.sourceforge.net/) is a program for converting between sound
148 file formats.
149 * [Wavplay](http://www.hitsquad.com/smm/programs/WavPlay/) started out as a
150 minimal WAV file player under Linux and has mutated into Gnuwave, a
151 client/server application for more general multimedia and games sound
152 playback.
153 * [Audiofile](http://www.68k.org/~michael/audiofile/) (libaudiofile) is a
154 library similar to libsndfile but with a different programming interface. The
155 author Michael Pruett has set out to clone (and fix some bugs in) the
156 libaudiofile library which ships with SGI's IRIX OS.
157 * [sndlib.tar.gz](ftp://ccrma-ftp.stanford.edu/pub/Lisp/sndlib.tar.gz) is
158 another library written by Bill Schottstaedt of CCRMA.
159
160 ## Licensing
161
162 libsndfile is released under the terms of the GNU Lesser General Public License,
163 of which there are two versions;
164 [version 2.1](http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html)
165 and
166 [version 3](http://www.gnu.org/copyleft/lesser.html).
167 To maximise the compatibility of libsndfile, the user may choose to use
168 libsndfile under either of the above two licenses.
169 You can also read a simple explanation of the ideas behind the GPL and the LGPL
170 [here](http://www.gnu.org/copyleft/lesser.html).
171
172 You can use libsndfile with
173 [Free Software](http://www.gnu.org/),
174 [Open Source](http://www.opensource.org/),
175 proprietary, shareware or other closed source applications as long as libsndfile
176 is used as a dynamically loaded library and you abide by a small number of other
177 conditions (read the LGPL for more info).
178 With applications released under the GNU GPL you can also use libsndfile
179 statically linked to your application.
180
181 I would like to see libsndfile used as widely as possible but I would prefer it
182 if you released software that uses libsndfile as
183 [Free Software](http://www.gnu.org/)
184 or
185 [Open Source](http://www.opensource.org/).
186 However, if you put in a great deal of effort building a significant application
187 which simply uses libsndfile for file I/O, then I have no problem with you
188 releasing that as closed source and charging as much money as you want for it as
189 long as you abide by [the license](http://www.gnu.org/copyleft/lesser.html).
190
191 ## Download
192
193 Check latest version on
194 [GitHub Releases page](https://github.com/libsndfile/libsndfile/releases/).
195
196 Binatries and source packages are signed by current releaser David Seifert aka
197 @SoapGentoo. You can verify signatures with his public GPG key:
198
199 ```
200 -----BEGIN PGP PUBLIC KEY BLOCK-----
201 Version: GnuPG v2
202
203 mQINBFppABgBEAC42ZiNvV7BTIgR6TQy0YnF54fx3mVRP1u8Mq00UZa7reAsNKh7
204 1H60j0W4s6+4pVVIKGfpVGxLwUdJe+KVCYw1Cd3YW6uMf5zZrC/ZWqnJiH/n6S6o
205 1l4INII2o6YbGBnzIWBPRo7PlOL+mvgKTLpBSJPnhD8XDGN5wRiV8rL2+6Dptg0F
206 nJt7oxECGF3OD3gk6HMel0o82CVkIqMtNaX1L/bhcdF7K0Rp2MXPZMmpn1izW5sI
207 asN1G9+w+Zwj7kMJzq1Aw3ac+rsX4SEYdvXjS2QhDHQUIr6LXri3D2WbcEqIZj2R
208 JVoVwblsrG11dYXFDBbgrq4NhgTBsxHYDlkr/qF2W+kbPC/nhSqTVZeCYvTBZbOQ
209 +RqyN/I0izukglnWmV1jGijFA8snyP8efx732hw/24zRYmtXOtnEITUpw8WOeZCq
210 6uiHaQ+eopnY2ojBg9BI7WZm0AFn58xxT9soMsyFOUFgXTqaWFZWlJ3fhZE8/0v8
211 JEu/kPGE5aJReT3b34B+Bojkj74XR+h2u7iJJBHMTE8RwGoUOZHer/XsL9xlcdks
212 I+7TCjiq++ShaSSt2XsJmw2BhREohrjW/2KkwmvT3b44RMpKPB4WTH+++aqJQNeM
213 IqmswOMoZvzEZezInj7WVY/r0WEei1Y6wt1tBrJ/cFf1oQBM1UmphxcrfQARAQAB
214 tB9EYXZpZCBTZWlmZXJ0IDxzb2FwQGdlbnRvby5vcmc+iQJUBBMBCgA+BQsJCAcD
215 BRUKCQgLBRYCAwEAAh4BAheAAhsBFiEEMdlcq22A0mIkShdQpHYg6AHkfpUFAl/V
216 CvoFCQkuceIACgkQpHYg6AHkfpXYxA//aiJW1NwunpmzEc62id8lRMnoLHWVjISZ
217 b+xSlm+hk4LYq+ZbthJDzKcT86/3DJOSE1zQw9wLuCao9IW2UfFJQBtR+TAfbagG
218 0Yyk/kMcLoFJxnG1ywdJWypCAauuIhia52Z7PmmjsBbFwr6LygDwSQmZAyACMAs7
219 TLQe+yERc2RNDsIEsquLSxxRF0Spk9gagWtKgrPc2XBjuNtQDwW7JgsOUoEeHyxC
220 29fRUjC3o/pG2I6iAZp17OROZI5yl4TSORrSBDGIi2sayxyxP0x+IPKtrCUcBGNx
221 wGp+56bP/V0hA6sgCPh/iwvqLoeibso6l/Kd4ltVAEQnHTd6fr8g+wLEUXfbJVTR
222 7aeFUoaFmWjSPlQrNr6HlxSLV/kRx9kVJp1Pn16vkfVBF7fG7iDLiqphwEeQg5ND
223 nmGeKAbRRNxFHyBHf0XRsaYiFZQckguO+71XSRtVx8/YP5nyNbtl9y1h/4JlT6Gy
224 t7hb5twYFQyQrKss83E/Bo1sRdHpj0ibtqb4ZbYANbh482E6yFhAkuo8YjVTJipI
225 1Ve8EBKnX3R+pDt147uyysNvtPVXML+sWpGSMVSm4NA8uT3F5nqxVwj+SeXy3Wq/
226 CHQ2VBKGBC655G+wFD5C6O7cTx2MwH+2H8tzhWm+gFlI3MFKEXa/PC+YUC/diYcb
227 BrApavriTRa5Ag0EWmkAZgEQAPXMD3mZI+ChvBysXZWksC88/uSEwFeb3XkcRm7v
228 04GN7hcz+bfrmnUTB3tuE/ZQgv+u7ZjetvH1aEKieznn/GjnWoOBoJusOYvfAQeF
229 0mQVi118QiOZRCnEZpkz+RY9TiXVgrZJg+AGqHZ3Ol4GkInEV2NWgH37Xal+HkFl
230 rwI2U7mL0kZRG+LAVCQHKzqU0R0HE1XyJ4qf0awtG5Qi/TZvgXBdZPDXgr8i9Vlf
231 UUu10c2XnXM0Av/YAlZmBFjVYrSOUCFenqSVqL+s9sTCVdWlJrGjrr3Ja4uT3kl2
232 rLva0AR4oSQoxt8adKohmFz0vzOkQtCoRzhrCwoo3JvNjKdSNoOP1nSsxlO5ji8r
233 ih5d+ajPgi580XyHLnrvG7vobR48qqscv1hizKuCgTacOTe6Db2Gqc8xF6v8HhJa
234 KwWJtmFllIfN/tIvZ6BbbgHQn0IGf4CYnWf0SksPZqpBmTRpD2jfBxcj2UEg+AR3
235 LARjuyUVpFJScyu6ExQG+6O+ByLL31iWP5MgUrza1rIpriPa3NT3rZ3DG2pvQrS3
236 ySsrPzH7VRX8L1ThSMSzjwF96aMsd14s7XzR4EzNuWwZDukfs0yavZk6l4o1M0mb
237 tbJi7hE4cz13KRHYvIkKMdZGYUnzRzZUDlsj2imakk3BR6GXnxZ1ST6062g+QxiL
238 AJFLABEBAAGJBHIEGAEKACYCGwIWIQQx2VyrbYDSYiRKF1CkdiDoAeR+lQUCX9UL
239 DQUJCS5xpwJAwXQgBBkBCgAdFiEEuNUxXaAAcsCoYIifzjbhFyAuOEIFAlppAGYA
240 CgkQzjbhFyAuOELmrQ/9H9wrWsWa21STZdxUmyU2sh9VXAWEHl1Ey0fVTznDM0Fl
241 zx5YSR/TmmnE36rpaz31Ttkx8SP914oV+mMgseecdya9Bf6uZL9Cv7V3KEsJBRL/
242 ncrOWQBHP/Xy1X+mLD6A19xq7H4RihSLj0LeK2YVjrJzJ7wMf4mKXuBayQeAHImU
243 WRCRTbmK3umh2nB5V0iPd/XZEIiYtiTPe+7E/va6+0bBvOumF3a+Z0iui7eU4hFC
244 7Jk71D0dcg09SlIaNoMOrw7cMC3j2pMdKtsj8+0I6WBv14PhhqPAsnjdf7I/4NfK
245 L7Jav8T/gDS01uA2Jxm72d+wr+eSjOBXa6x8CEbTqfkjAGxsWENThCp6zDkaXSDd
246 JsV0va47vjzG8+wTDAvPy5IxIM/KZZdl4uWM+mF5K+q+eSTOHe7aLF2OdcussoBA
247 A18zm994dAkG1COX/qpxanxx2bv/2IvCGPg+x6JtAN8ji2kncWu3dWGQdE5XbVjc
248 fDwgsUPpp04G27Mr/x+HpEbgZ5SdA0dAqJktlNvCcHALhlblCWrsh/1QNjT/2iG8
249 wsjcpEy/s4tWAuV4PTa4xvZ1JPS7Z7Eo5aBy9ZGOWG9SrHEiHnhkUsiswbHBOEjd
250 pBSkmNElDcv9fRUahVCTPfvWBATFDrQyMjJBSm+cV8c/iFQM7isVSu8W7E0eetsJ
251 EKR2IOgB5H6Vv9sP/1dxTvH0N0UoEoxIG/hnirEkbRpljdvqy4/uikYBKyQgSbo8
252 VITTjea7gIhDztil9WZYt35jbOmoaGM2Z6TP2LEDOWgljYUNq9pl9Sc2GS8cNtEO
253 WxExzGOc1Flo730dX3A85Ks3+0WPXZjLDcRRcPVkFd5WLQQDV1YVYopWkuQBC+Br
254 4q3uv+sk+bw6gDa9+zFBbDuegdsYuTXrFHoxHz2GRv9Yb7ULCMgpFeNKDgtQq91u
255 RqewoTwQp9tlp91LH/hh7R0Q4DRgeFDkLnVRXwSKjVvCrT5cBgImGwtFTGS4egoy
256 MDKd/KKjZllp1ahRCln1XfmFQyQVMVvuF/JTtt31n6KwXwK2yxIlXB01xvRH+Ees
257 AWeRYWKWXydaAY/9Ve0/PLFlgsr/XUGvt0GoEKe7odD3nZgg6015+/8JTroKw19L
258 NZkhdfFMl11Zi0j5k3UbyzjYVpFSd8K2o0VoOG1LFsPp8tlRxNoVzpId0CX1au/p
259 y1H7Wy/39mzriRG3rw+mJAQbBjN09putCltXFXpOEWk08n/N3vufCVQUoSu/2Bqw
260 2HYj8VtToQp+O5dG3XxvDHINtInP1yr2Wcw2plna0KoXLwv/lZgDm3LN+eCWpG6d
261 N/xk25DTSqTHArUQIEkhcHYK6GnyxUcvoKtG88hXtqEPYXiK08FZYAUPTnDYuQIN
262 BFppAIkBEADDjvQZUs1NoqJpxkD2QDBudU1DBCaeI1D6CancMtb5FebPUxgFlDMd
263 CBGOun48dY5i87gDhT/qS3gP/Mv9rjKJmcG9JHfhpXdW73owxrcsQ96nxxVJNEVl
264 UHJw00z8C9eGWqr0SzSoE33K/PkzSkgtsaotF6+3uCerWulweulmGa5dpVfV0mbS
265 aVw8VmrhZ5NmCeodyy/lR85rPik5pb32NT6v7xBkgkfS0VYtPB2E5gW1pXX/jEOi
266 Mfq9idOEP9lxrNXV9j49Lr0JQCwAcrYbQ2+VPe6eacJEjzJ/6HiUqhPrYdnvydmb
267 hU+xmv2NjGp2UnDZDEhzQfwm6fMx+8Nx2uPzCnXQGoyRBwiC/KcdW0F1ZPKdSXqH
268 NKoOF62pLvIMSmfI3ZVOrTohArfr1kFEYVDv9Nl7oY+qg2rZEc2srOF74a9Z46bR
269 TDPsEQzE2UMCvu3+rofhSD7aRotlKeDCvbe2s0yE4Man457Xc3LXh8Gva8CzCOLE
270 2eMhNTsHIZk68WgXp3/uvE4Xy42myrk1AV8XXDdlWgx0Kc/I6tE59O5NVPSfuGvH
271 1a15KKx0F6euEnYDKKpQ5PDR6dSn61po0tfbt96m044G/xQFjrfhHei4jji9Ogd9
272 vlXVAi2vn3+NCSHFP5l3igLByBHy9iLIdmz7yQuus/1nwRmxOHOf2QARAQABiQI8
273 BBgBCgAmAhsMFiEEMdlcq22A0mIkShdQpHYg6AHkfpUFAl/VCxkFCQkucZAACgkQ
274 pHYg6AHkfpVPSRAAmheYkYJmtDbkzPBBnj5mbCIQN1/G5PI9eixc/TXWFOXtcjU1
275 mJlJpSidHJyLRrx7r0c+N+s8vnY/JuUBsNoMJMER+Mv/CFW4iFi59V534SyAb2S0
276 7NINJnFNkXBY62CDz9KsMuv/MdSv2yLhPH2Tfrm/eDRQesj1PanE4U1cgjWyJRc/
277 IOlaRHvTasWDLgwbQi8ykt+4xUWzL/YKHzB+KyyzBK7vPBXqySX8ka4BOw7SDwG5
278 lX2gtmhk4AGBwVChLXKflqVx1WXj4DPOt0kmOKVnKFyvUijK58M0A2FMgFMXDTIS
279 DRtoZPdx/rkODXxgS+W+27NcYAnxJiM0cQqizEnQh7PQ1KzgdChPejYXMKe9lwdn
280 ssMUxrBpbuAuagEf+pebNjD2eaNR4p8kfaDdGn53q55ysDvoyxKvnVQGSk1FAR9Q
281 s4N5a4f02U7dzlyEhEfIcuUlRCfnlpn4n725YIhHheDig5zKWoEZCkNIfiRcGzDl
282 8Drj+tlZiUR+gDkIoWSBaCkKbIQlc8qCYy6Hm7oZBaol6xKlUnTMK2rjK8fR4i8r
283 bVDWBAaWj3jcDHJ0Jg3fS/qBpeya/JXMp89TR8NK5Ys7PZpWbor+puXBYyXDAVx3
284 rXQ7JBA5klHPxrgjso1S/LqwscKLENtrVjdjhryLBmPifrmofJRnrpiHIEa5Ag0E
285 WmkAswEQAL0hKwsRybQzkNGpJP+ElLSwFHd7XQhr+qIwLllpumWtnIK/DHmv8SpW
286 FqAYajmRTXipFcBHH25x2jIIliZidn0a9826l+sMzrFadMC6/W4pitP71TeqZzwn
287 pAuHs14YL7Wiy0aJQnfbCpRzPq3kYyOXmhmY7lPWO0WdUpR6W8wUbleK5XOVDDRx
288 aIC/M3hhDOxZOMzQ+pdn4BaOFQQ0ygsRkqOudbuc0R1giYRt1i6gMeT8gfzL9jlw
289 HcJ+aVnxdUQQ4uC47oKo/+lg7qh7LsiW79pQC1Bcdm8lhRmqtxe6ub60ecjax3XU
290 1ILIEfIFCv6M7LRUAwz0bqk35spgkJqrGGKkdeWEKAFHg2QWR2F0zy+HdlPLfKxO
291 uhaccpwc9EJtf744GS0SXa2AXr32j56n7CFcEjFcIQPBC6OJn6eA3hOVUYGZ7SrT
292 4fsmZiFAdGEkvLKFuNhju1Hj2EJQUY1pm4GSBco7BR8x+QqoYrt5clU3WxRMNfTR
293 0Rtuzsh4xskXNVMMgvKOahAtxENv2M2Cx6zJPVL5dmaysP7d6QRVeOQA5PwkcZ5Q
294 qK6JtDZj2jpaKQH4Za715kiIcdqMDSkwxa6avc0kARHvfFcBR4hwDm1GAlaKG7eH
295 8TOGGQIk8x2F3s4l8mTJVLWTP/uJYnkYBdqANYo5t1NIQLvwLFV3ABEBAAGJAjwE
296 GAEKACYCGyAWIQQx2VyrbYDSYiRKF1CkdiDoAeR+lQUCX9ULIwUJCS5xcAAKCRCk
297 diDoAeR+leekD/sF7aHH0W35ckWrXZlfSp0qHPWrBUaLBI9OAUHenRhgs4SbK0D4
298 wqEiu0C5iDQojpXAeALQ8g/1pUsZ1yuFqYbGYWrHkA0Pm+P3tAGB4LMZ41YfvROP
299 uaiW/+IMJbWllgRtaDt8/NtCgs30WI9I+az5M29HcGfvEwEUykrBx3dE9T+1ui3O
300 capdd+GMvdAAsX5PyVkjWgZ7GrZeH8mG7UysYfT4qthxEtQfZ/u8ceSduKA46ugh
301 C2eafIDNvluqn7BU4oKxME61u6C8BN2yHLI6LV0Tr4z5H8joVbM4BSFMwLVGlsXf
302 HhB8kLiErN6bXolxsjARlmYiD9S9H2AcYidr6RYXf2EVFSpBG59xn1WTDN+DsHQf
303 7btNPEPl/OPxa3OQjG+xn8USddiP0N0B4xsyzMNCCKDgvXXcIhX55KG9eh3Tc98S
304 fEyhxu8ybZBIGmTJysPKxijfvSgQF+RPNTsz9lvXqkoK7RTgeYMschpjJEznCLbt
305 M6eTDb5z0G5uLXh6+dYxtDOlPogI5OHd+G51LwCjvrQ+AtIUCgafuemwA9mpFT2b
306 svb/qcxSVUb44bVaNHn1JHebX2YbokGtBOm1x2PI5fT8n6YIIYz3jKYOZAYdUT7x
307 6qURyNjOfG4aPJIATwuh4GSNuxUG40+yuT+XfQF24mu1esS1J3wzRloJ7w==
308 =K3x+
309 -----END PGP PUBLIC KEY BLOCK-----
310 ```
311
312 ## See Also
313
314 * [sndfile-tools](https://github.com/libsndfile/sndfile-tools): a small
315 collection of programs which use libsndfile.
0 body {
1 background : black ;
2 color : white ;
3 font-family : arial, helvetica, sans-serif ;
4 line-height: 1.5 ;
5 margin-left: 6%;
6 margin-right: 6%;
7 }
8 td {
9 font-family : arial, helvetica, sans-serif ;
10 background : black ;
11 color : white ;
12 }
13 center {
14 font-family : arial, helvetica, sans-serif ;
15 }
16 p {
17 font-family : arial, helvetica, sans-serif ;
18 text-align : left ;
19 }
20 .indent_block {
21 font-family : arial, helvetica, sans-serif ;
22 text-align : left ;
23 }
24 br {
25 font-family : arial, helvetica, sans-serif ;
26 }
27 form {
28 font-family : arial, helvetica, sans-serif ;
29 }
30 ul {
31 font-family : arial, helvetica, sans-serif ;
32 text-align : left ;
33 }
34 ol {
35 font-family : arial, helvetica, sans-serif ;
36 text-align : left ;
37 }
38 dl {
39 font-family : arial, helvetica, sans-serif ;
40 text-align : left ;
41 }
42 h1 {
43 font-size : xx-large ;
44 background : black ;
45 color : #5050FF ;
46 text-align : left ;
47 }
48 h2 {
49 font-size : x-large ;
50 background : black ;
51 color : #5050FF ;
52 text-align : left ;
53 }
54 h3 {
55 font-size : large ;
56 background : black ;
57 color : #5050FF ;
58 text-align : left ;
59 }
60 h4 {
61 font-size : medium ;
62 background : black ;
63 color : #5050FF ;
64 text-align : left ;
65 }
66 pre {
67 font-family : courier, monospace ;
68 font-size : medium ;
69 }
70 code,
71 kbd,
72 samp,
73 var {
74 font-family: "Courier New", monospace, serif;
75 font-size: 1em;
76 }
77 a:link { color : #9090FF ; }
78 a:visited { color : #5050FF ; }
79 a:active { color : #FF00FF ; }
80 a:hover { background-color : #202080 ; }
81
82 table.formats-table {
83 text-align: center;
84 font-size: small;
85 border-collapse: collapse;
86 }
87
88 table.formats-table, table.formats-table th, table.formats-table td {
89 border: 1px solid white;
90 }
91
92 .image-logo {
93 display: block;
94 margin-left: auto;
95 margin-right: auto;
96 }
97
98 nav {
99 text-align: center;
100 }
Binary diff not shown
0 # Here are some some emails I exchanged with a guy trying to use
1 # libsndfile version 1 with code from the book "Linux Games Programming"
2 # by John Hall. The email addresses have been changed to foil the spam
3 # bots.
4
5 Date: Tue, 20 Jul 2004 22:49:21 +0100
6 From: Paul <paul@fake-domain-name.co.uk>
7 To: erikd@fake-domain-name.com
8 Subject: Can you help with a problem?
9 Date: Tue, 20 Jul 2004 22:49:21 +0100
10
11 Hi,
12
13 I'm trying to get the source examples in the "Programming Linux Games"
14 (NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile.
15
16 While I can guess some of the newer versions of function calls and
17 enumerations, there are some which I cannot guess.
18
19 Would you be able to translate them to the current version of
20 enumeration and function calls so that I can update the source?
21
22 These are the three currently failing me:
23
24 sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,SFM_READ, &sfinfo))
25 SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
26 SF_INFO.pcmbitwidth (guess: no idea!)
27
28 There are probably more. I'm happy to send you the source files for
29 sound calls, scan the pages or anything else. Failing that, is there
30 somewhere with the changes listed so I can try and fix the code for myself?
31
32 Thanks
33
34 TTFN
35
36 Paul
37
38 ================================================================================
39
40 Date: Wed, 21 Jul 2004 17:38:08 +1000
41 From: Erik de Castro Lopo <erikd@fake-domain-name.com>
42 To: Paul <paul@fake-domain-name.co.uk>
43 Subject: Re: Can you help with a problem?
44
45 On Tue, 20 Jul 2004 22:49:21 +0100
46 Paul <paul@fake-domain-name.co.uk> wrote:
47
48 > Hi,
49 >
50 > I'm trying to get the source examples in the "Programming Linux Games"
51 > (NoStarch, Loki Software + John R. Hall) which use sndfile.h/libsndfile.
52 >
53 > While I can guess some of the newer versions of function calls and
54 > enumerations, there are some which I cannot guess.
55 >
56 > Would you be able to translate them to the current version of
57 > enumeration and function calls so that I can update the source?
58 >
59 > These are the three currently failing me:
60 >
61 > sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename,
62 > SFM_READ, &sfinfo))
63
64 yes.
65
66 > SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
67
68 Actually this list:
69
70 SF_FORMAT_PCM_U8
71 SF_FORMAT_PCM_S8
72 SF_FORMAT_PCM_16
73 SF_FORMAT_PCM_24
74 SF_FORMAT_PCM_32
75
76 > SF_INFO.pcmbitwidth (guess: no idea!)
77
78 WIth the above change, pcmbitwidth becomes redundant.
79
80 > There are probably more. I'm happy to send you the source files for
81 > sound calls, scan the pages or anything else. Failing that, is there
82 > somewhere with the changes listed so I can try and fix the code for
83 > myself?
84
85 Version 1.0.0 came out some time ago, but I think this:
86
87 http://www.mega-nerd.com/libsndfile/version-1.html
88
89 lists most of the changes. You should also look at the API docs:
90
91 http://www.mega-nerd.com/libsndfile/api.html
92
93 HTH,
94 Erik
95 --
96 +-----------------------------------------------------------+
97 Erik de Castro Lopo nospam@fake-domain-name.com
98 +-----------------------------------------------------------+
99 "There is no reason why anyone would want a computer in their home"
100 Ken Olson, DEC, 1977
101
102 ================================================================================
103
104 From: PFJ <paul@fake-domain-name.co.uk>
105 To: Erik de Castro Lopo <erikd@fake-domain-name.com>
106 Subject: Re: Can you help with a problem?
107 Date: Wed, 21 Jul 2004 09:07:39 +0100
108
109
110 Hi Erik,
111
112 Thanks for getting back to me.
113
114 > > sf_open_read(filename, SF_INFO *sfinfo) (guess: sf_open(filename, SFM_READ, &sfinfo))
115 >
116 > yes.
117
118 Yay!
119
120 > > SF_FORMAT_PCM (guess: either SF_FORMAT_PCM_U8 or _RAW)
121 >
122 > Actually this list:
123 >
124 > SF_FORMAT_PCM_U8
125 > SF_FORMAT_PCM_S8
126 > SF_FORMAT_PCM_16
127 > SF_FORMAT_PCM_24
128 > SF_FORMAT_PCM_32
129
130 I know, but the source code explicitly has SF_FORMAT_PCM which given the
131 code afterwards would equate to one of the above, but given that PCM
132 files can have a varied bitwidth the author probably wanted to cover all
133 bases.
134
135 > Version 1.0.0 came out some time ago, but I think this:
136 >
137 > http://www.mega-nerd.com/libsndfile/version-1.html
138 >
139 > lists most of the changes. You should also look at the API docs:
140 >
141 > http://www.mega-nerd.com/libsndfile/api.html
142
143 I'll download them and see what I can gleen.
144
145 Thanks again for getting back to me
146
147 TTFN
148
149 Paul
150
151 ================================================================================
152
153 Date: Wed, 21 Jul 2004 18:20:29 +1000
154 From: Erik de Castro Lopo <erikd@fake-domain-name.com>
155 To: PFJ <paul@fake-domain-name.co.uk>
156 Subject: Re: Can you help with a problem?
157
158 On Wed, 21 Jul 2004 09:07:39 +0100
159 PFJ <paul@fake-domain-name.co.uk> wrote:
160
161 > I know, but the source code explicitly has SF_FORMAT_PCM which given the
162 > code afterwards would equate to one of the above, but given that PCM
163 > files can have a varied bitwidth the author probably wanted to cover all
164 > bases.
165
166 But surely the existing code does something like:
167
168 sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
169 sfinfo.pcmbitwidth = 16;
170
171 which can be directly translated to:
172
173 sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
174
175 and the same for pcmbitwitdhs of 24 and 32. For pcmbitwidth of 8
176 you need to know that WAV files use SF_FORMAT_PCM_U8 and AIFF
177 files use SF_FORMAT_PCM_S8. Thats all there is to it.
178
179 Erik
180 --
181 +-----------------------------------------------------------+
182 Erik de Castro Lopo nospam@fake-domain-name.com
183 +-----------------------------------------------------------+
184 "Python addresses true pseudocode's two major failings: that it
185 isn't standardized, and it isn't executable."
186 - Grant R. Griffin in comp.dsp
187
188 ================================================================================
189
190 Subject: Re: Can you help with a problem?
191 From: PFJ <paul@fake-domain-name.co.uk>
192 To: Erik de Castro Lopo <erikd@fake-domain-name.com>
193 Date: Wed, 21 Jul 2004 09:50:55 +0100
194
195 Hi Erik,
196
197 > > I know, but the source code explicitly has SF_FORMAT_PCM which given the
198 > > code afterwards would equate to one of the above, but given that PCM
199 > > files can have a varied bitwidth the author probably wanted to cover all
200 > > bases.
201 >
202 > But surely the existing code does something like:
203 >
204 > sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
205 > sfinfo.pcmbitwidth = 16;
206
207 If only!
208
209 The actual code is this
210
211 int LoadSoundFile(char *filename, sound_p sound)
212 {
213 SNDFILE *file;
214 SF_INFO file_info;
215 short *buffer_short = NULL;
216 u_int8_t *buffer_8 = NULL;
217 int16_t *buffer_16 = NULL;
218 unsigned int i;
219
220 /* Open the file and retrieve sample information. */
221 file = sf_open_read(filename, &file_info);
222 // I've sorted this one already - PFJ
223
224 /* Make sure the format is acceptable. */
225 if ((file_info.format & 0x0F) != SF_FORMAT_PCM) {
226 printf("'%s' is not a PCM-based audio file.\n", filename);
227 sf_close(file);
228 return -1;
229 }
230
231 if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) {
232 sound->format = AL_FORMAT_MONO8;
233 } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) {
234 sound->format = AL_FORMAT_STEREO8;
235 } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) {
236 sound->format = AL_FORMAT_MONO16;
237 } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) {
238 sound->format = AL_FORMAT_STEREO16;
239 } else {
240 printf("Unknown sample format in %s.\n", filename);
241 sf_close(file);
242 return -1;
243 }
244
245 /* Allocate buffers. */
246 buffer_short = (short *)malloc(file_info.samples * file_info.channels * sizeof (short));
247
248 buffer_8 = (u_int8_t *)malloc(file_info.samples * file_info.channels * file_info.pcmbitwidth / 8);
249
250 buffer_16 = (int16_t *)buffer_8;
251
252 if (buffer_short == NULL || buffer_8 == NULL) {
253 printf("Unable to allocate enough memory for '%s'.\n", filename);
254 goto error_cleanup;
255 }
256
257 /* Read the entire sound file. */
258 if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)-1) {
259 printf("Error while reading samples from '%s'.\n", filename);
260 goto error_cleanup;
261 }
262
263 <minor snip>
264
265 /* Fill in the sound data structure. */
266 sound->freq = file_info.samplerate;
267 sound->size = file_info.samples * file_info.channels * file_info.pcmbitwidth / 8;
268
269 /* Give our sound data to OpenAL. */
270 alGenBuffers(1, &sound->name);
271 if (alGetError() != AL_NO_ERROR) {
272 printf("Error creating an AL buffer name for %s.\n", filename);
273 goto error_cleanup;
274 }
275
276 alBufferData(sound->name, sound->format, buffer_8, sound->size,sound->freq);
277 if (alGetError() != AL_NO_ERROR) {
278 printf("Error sending buffer data to OpenAL for %s.\n", filename);
279 goto error_cleanup;
280 }
281
282 /* Close the file and return success. */
283 sf_close(file);
284 free(buffer_short);
285 free(buffer_8);
286
287 return 0;
288
289 error_cleanup:
290 if (file != NULL) fclose(file);
291 free(buffer_short);
292 free(buffer_8);
293 return -1;
294 }
295
296 As you can see, the PCM material in the listing will not currently
297 compile and for the other sndfile material, it probably won't either.
298
299 Any help would be appreciated.
300
301 TTFN
302
303 Paul
304
305 ================================================================================
306
307 From: Erik de Castro Lopo <erikd@fake-domain-name.com>
308 To: PFJ <paul@fake-domain-name.co.uk>
309 Subject: Re: Can you help with a problem?
310 Date: Wed, 21 Jul 2004 19:36:46 +1000
311
312 On Wed, 21 Jul 2004 09:50:55 +0100
313 PFJ <paul@fake-domain-name.co.uk> wrote:
314
315 > Hi Erik,
316 >
317 > > > I know, but the source code explicitly has SF_FORMAT_PCM which given the
318 > > > code afterwards would equate to one of the above, but given that PCM
319 > > > files can have a varied bitwidth the author probably wanted to cover all
320 > > > bases.
321 > >
322 > > But surely the existing code does something like:
323 > >
324 > > sfinfo.format = SF_FORMAT_WAV | SF_FORMAT_PCM;
325 > > sfinfo.pcmbitwidth = 16;
326 >
327 > If only!
328
329 No, really.
330
331 Drop this completely:
332
333 > /* Make sure the format is acceptable. */
334 > if ((file_info.format & 0x0F) != SF_FORMAT_PCM) {
335 > printf("'%s' is not a PCM-based audio file.\n", filename);
336 > sf_close(file);
337 > return -1;
338 > }
339
340 Replace this block:
341
342 > if ((file_info.pcmbitwidth == 8) && (file_info.channels == 1)) {
343 > sound->format = AL_FORMAT_MONO8;
344 > } else if ((file_info.pcmbitwidth == 8) && (file_info.channels == 2)) {
345 > sound->format = AL_FORMAT_STEREO8;
346 > } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 1)) {
347 > sound->format = AL_FORMAT_MONO16;
348 > } else if ((file_info.pcmbitwidth == 16) && (file_info.channels == 2)) {
349 > sound->format = AL_FORMAT_STEREO16;
350 > } else {
351 > printf("Unknown sample format in %s.\n", filename);
352 > sf_close(file);
353 > return -1;
354 > }
355
356 with:
357
358 int pcmbitwidth = 0;
359
360 if (file_info.format & SF_FORMAT_SUBMASK != SF_FORMAT_PCM_16)
361 { printf("'%s' is not a PCM-based audio file.\n", filename);
362 sf_close(file);
363 return -1;
364 }
365
366 if (file_info.channels < 1 || file_info.channels > 2)
367 { printf("'%s' bad channel count.\n", filename);
368 sf_close(file);
369 return -1;
370 }
371
372 switch (file_info.format & SF_FORMAT_SUBMASK + file_info.channels << 16)
373 { case (SF_FORMAT_PCM_U8 + 1 << 16):
374 sound->format = AL_FORMAT_MONO8;
375 pcmbitwidth = 8;
376 break;
377 case (SF_FORMAT_PCM_U8 + 2 << 16):
378 sound->format = AL_FORMAT_STEREO8;
379 pcmbitwidth = 8;
380 break;
381 case (SF_FORMAT_PCM_16 + 1 << 16):
382 sound->format = AL_FORMAT_MONO16;
383 pcmbitwidth = 16;
384 break;
385 case (SF_FORMAT_PCM_16 + 2 << 16):
386 sound->format = AL_FORMAT_STEREO16;
387 pcmbitwidth = 16;
388 break;
389 default:
390 printf("Unknown sample format in %s.\n", filename);
391 sf_close(file);
392 return -1;
393 }
394
395 > /* Allocate buffers. */
396 > buffer_short = (short *)malloc(file_info.samples *
397 > file_info.channels *
398 > sizeof (short));
399 >
400 > buffer_8 = (u_int8_t *)malloc(file_info.samples *
401 > file_info.channels *
402 > file_info.pcmbitwidth / 8);
403
404 Use pcmbitwidth as calculated above.
405
406 > buffer_16 = (int16_t *)buffer_8;
407 >
408 > if (buffer_short == NULL || buffer_8 == NULL) {
409 > printf("Unable to allocate enough memory for '%s'.\n", filename);
410 > goto error_cleanup;
411 > }
412 >
413 > /* Read the entire sound file. */
414 > if (sf_readf_short(file,buffer_short,file_info.samples) == (size_t)- 1) {
415
416 Replace "(size_t) - 1" with " < 0".
417
418 > As you can see, the PCM material in the listing will not currently
419 > compile and for the other sndfile material, it probably won't either.
420
421 None of the changes above should have been very difficult to figure
422 out.
423
424 Erik
425 --
426 +-----------------------------------------------------------+
427 Erik de Castro Lopo nospam@fake-domain-name.com
428 +-----------------------------------------------------------+
429 Microsoft is finally bringing all of its Windows operating system families
430 under one roof. It will combine all of the features of CE, stability and
431 support of ME and the speed of NT.
432 It will be called Windows CEMENT...
433
0 ---
1 layout: page
2 title: libsndfile Mailing Lists
3 ---
4
5 # libsndfile Mailing Lists
6
7 **Note**: These mailing lists are not maintained by the libsndfile team anymore.
8 Use [GitHub issues and pull requests instead](https://docs.github.com/en/free-pro-team@latest/github/collaborating-with-issues-and-pull-requests).
9
10 There are three mailing lists for libsndfile:
11
12 - **libsndfile-announce@mega-nerd.com**  
13 [Subscribe](mailto:libsndfile-announce-request@mega-nerd.com?subject=subscribe)
14 A list which will announce each new release of libsndfile. Noone can
15 post to this list except the author.
16 - **libsndfile-devel@mega-nerd.com**  
17 [Subscribe](mailto:libsndfile-devel-request@mega-nerd.com?subject=subscribe)
18 A list for discussing bugs, porting issues and feature requests.
19 Posting is restricted to subscribers.
20 - **libsndfile-users@mega-nerd.com**  
21 [Subscribe](mailto:libsndfile-users-request@mega-nerd.com?subject=subscribe)
22 A list for discussing the use of libsndfile in other programs.
23 Posting is restricted to subscribers.
24
25 The libsndfile-devel and libsndfile-users list will automatically receive a copy
26 of all emails to the libsndfile-announce list.
0 ---
1 layout: page
2 ---
3
4 # How to add new file format
5
6 Original : Wed May 23 19:05:07 EST 2001
7 Update 1 : Fri Jul 11 22:12:38 EST 2003
8
9 This document will attempt to explain as fully as possible how to add code to
10 libsndfile to allow the reading and writing of new file types. By new file
11 type I particularly mean a new header type rather than a new encoding method
12 for an existing file type.
13
14 This HOWTO will take the form of a step by step guide. It will assume that you
15 have all required tools including :
16
17 - gcc
18 - make (should really be the GNU version)
19 - autoconf
20 - automake
21 - libtool
22
23 These should all be available on the GNU ftp site: <ftp://ftp.gnu.org/pub/gnu/>.
24
25 To help make these steps clearer let's suppose we are adding support for the
26 Whacky file format whose files contain 'W','A','C' and 'K' as the first four
27 bytes of the file format. Lets also assume that Whacky files contain PCM encoded
28 data.
29
30 ## Step 1
31
32 Create a new .c file in the src/ directory of the libsndfile source tree. The
33 file name should be reasonable descriptive so that is is obvious that files of
34 the new type are handled by this file. In this particular case the file might
35 be named 'whacky.c'.
36
37 ## Step 2
38
39 Add your new source code file to the build process.
40
41 Edit the file src/Makefile.am and add the name of your file handler to the
42 FILESPECIFIC list of handlers. This list looks something like this:
43
44 FILESPECIFIC = aiff.c au.c au_g72x.c nist.c paf.c raw.c samplitude.c \
45 svx.c wav.c wav_float.c wav_gsm610.c wav_ima_adpcm.c \
46 wav_ms_adpcm.c
47
48 Then, run the script named 'reconf' in the libsndfile top level directory,
49 which will run autoconf and other associated tools. Finally run "./configure"
50 in the top level directory. You may want to use the "--disable-gcc-opt" option
51 to disable gcc optimisations and make debugging with gdb/ddd easier.
52
53 ## Step 3
54
55 Add a unique identifier for the new file type.
56
57 Edit src/sndfile.h.in and find the enum containing the SF_FORMAT_XXX identifiers.
58 Since you will be adding a major file type you should add your identifier to the
59 top part of the list where the values are above 0x10000 in value. The easiest
60 way to do this is to find the largest value in the list, add 0x10000 to it and
61 make that your new identifier value. The identifier should be something like
62 SF_FORMAT_WACK.
63
64 ## Step 4
65
66 Add code to the file type recogniser function.
67
68 Edit src/sndfile.c and find the function guess_file_type (). This function
69 reads the first 3 ints of the file and from that makes a guess at the file
70 type. In our case we would add:
71
72 if (buffer [0] == MAKE_MARKER ('W','A','C','K'))
73 return SF_FORMAT_WACK ;
74
75 The use of the MAKE_MARKER macro should be pretty obvious and it is defined at
76 the top of file should you need to have a look at it.
77
78 ## Step 5
79
80 Add a call to your open function from psf_open_file ().
81
82 Edit src/sndfile.c and find the switch statement in psf_open_file (). It starts
83 like this:
84
85 switch (filetype)
86 { case SF_FORMAT_WAV :
87 error = wav_open (psf) ;
88 break ;
89
90 case SF_FORMAT_AIFF :
91 error = aiff_open (psf) ;
92 break ;
93
94 Towards the bottom of this switch statement your should add one for the new file
95 type. Something like:
96
97 case SF_FORMAT_WACK :
98 sf_errno = whacky_open (psf) ;
99 break ;
100
101 ## Step 6
102
103 Add prototypes for new open read and open write functions.
104
105 Edit src/common.h, go to the bottom of the file and add something like
106
107 int whacky_open (SF_PRIVATE *psf) ;
108
109 ## Step 7
110
111 Implement your open read function. The best way to do this is by coding
112 something much like one of the other file formats. The file src/au.c might be a
113 good place to start.
114
115 In src/whacky.c you should now implement the function whacky_open() which
116 was prototyped in src/common.h. This function should return 0 on success and
117 a non-zero number on error.
118
119 Error values are defined in src/common.h in a enum which starts at SFE_NO_ERROR.
120 When adding a new error value, you also need to add an error string to the
121 SndfileErrors array in src/sndfile.c.
122
123 To parse the header of your new file type you should avoid using standard read/
124 write/seek functions (and the fread/fwrite/fseek etc) and instead use
125 psf_binheader_readf () which is implemented and documented in src/common.h.
126
127 During the parsing process, you should also print logging information to
128 libsndfile's internal log buffer using the psf_log_printf() function.
129
130 At the end of the open read process, you should have set a number of fields in
131 the SF_PRIVATE structure pointed to by psf.
132
133 **THIS FILE IS INCOMPLETE**
0 ---
1 layout: page
2 ---
3
4 # libsndfile and GNU Octave
5
6 [GNU Octave](http://www.octave.org/) is a high-level interactive language for
7 numerical computations. There are currently two development streams, a stable
8 2.0.X series and a development 2.1.X series. Octave reads and writes data in
9 binary formats that were originally developed for
10 [MATLAB](http://www.mathworks.com/). Version 2.0.X of Octave uses binary data
11 files compatible with MATLAB version 4.2 while Octave 2.1.X uses binary data
12 files compatible with MATLAB version 5.0 as well as being able to read the older
13 MATLAB 4.2 format.
14
15 From version 1.0.1 of libsndfile onwards, libsndfile has the ability of reading
16 and writing a small subset of the binary data files used by both versions of GNU
17 Octave. This gives people using GNU Octave for audio based work an easy method
18 of moving audio data between GNU Octave and other programs which use libsndfile.
19
20 For instance it is now possible to do the following:
21
22 * Load a WAV file into a sound file editor such as
23 [Sweep](http://www.metadecks.org/software/sweep/).
24 * Save it as a MAT4 file.
25 * Load the data into Octave for manipulation.
26 * Save the modified data.
27 * Reload it in Sweep.
28
29 Another example would be using the MAT4 or MAT5 file formats as a format which
30 can be easily loaded into Octave for viewing/analyzing as well as a format which
31 can be played with command line players such as the one included with
32 libsndfile.
33
34 ## Details
35
36 Octave, like most programming languages, uses variables to store data, and
37 Octave variables can contain both arrays and matrices. It is also able to store
38 one or more of these variables in a file. When reading Octave files, libsndfile
39 expects a file to contain two variables and their associated data. The first
40 variable should contain a variable holding the file sample rate while the second
41 variable contains the audio data.
42
43 For example, to generate a sine wave and store it as a binary file which is
44 compatible with libsndfile, do the following:
45
46 octave:1 > samplerate = 44100 ;
47 octave:2 > wavedata = sin ((0:1023)*2*pi/1024) ;
48 octave:3 > save sine.mat samplerate wavedata
49
50 The process of reading and writing files compatible with libsndfile can be made
51 easier by use of two Octave script files:
52
53 octave:4 > [data fs] = sndfile_load ("sine.mat") ;
54 octave:5 > sndfile_save ("sine2.mat", data, fs) ;
55
56 In addition, libsndfile contains a command line program which which is able to
57 play the correct types of Octave files. Using this command line player
58 **sndfile-play** and a third Octave script file allows Octave data to be played
59 from within Octave on any of the platforms which **sndfile-play** supports (at
60 the moment: Linux, MacOS X, Solaris and Win32).
61
62 octave:6 > sndfile_play (data, fs) ;
63
64 These three Octave scripts are installed automatically in Octave's site script
65 directory when libsndfile is installed (except on Win32) ie when libsndfile is
66 being installed into /usr/local, the Octave scripts will be installed in
67 /usr/local/share/octave/site/m/.
68
69 There are some other Octave scripts for audio to be found
70 [here](http://octave.sourceforge.net/audio/index.html).
0 body {
1 background:white;
2 color:black;
3 }
4
5 h1{
6 background:white;
7 color:black;
8 }
9
10 h2 {
11 background:white;
12 color:#666;
13 }
0 ---
1 layout: page
2 title: sndfile-info
3 ---
4
5 Here is an example of the output from the **sndfile-info** program
6 distributed with libsndfile.
7
8 This file was opened and parsed correctly but had been truncated so that
9 the values in the **FORM** and **SSND** chunks were incorrect.
10
11 ```
12 erikd@hendrix > examples/sndfile-info truncated.aiff
13 truncated.aiff
14 size : 200000
15 FORM : 307474 (should be 199992)
16 AIFF
17 COMM : 18
18 Sample Rate : 16000
19 Samples : 76857
20 Channels : 2
21 Sample Size : 16
22 SSND : 307436 (should be 199946)
23 Offset : 0
24 Block Size : 0
25
26 --------------------------------
27 Sample Rate : 16000
28 Frames : 76857
29 Channels : 2
30 Bit Width : 16
31 Format : 0x00020001
32 Sections : 1
33 Seekable : TRUE
34 Signal Max : 32766
35 ```
0 ---
1 layout: page
2 ---
3
4 # libsndfile Tutorial
5
6 **More coming soon.**
7
8 For now, the best place to look for example code is the `examples/` directory of the source code distribution and the
9 libsndfile test suite which is located in the `tests/` directory of the source code distribution.
0 ---
1 layout: page
2 ---
3
4 # Building libsndfile on Win32
5
6 **Note : For pre-compiled binaries for windows, both for win32 and win64, see
7 the main web page.**
8
9 There are currently two build systems; the official GNU autotool based one and
10 a more limited and experimental CMake based build system.
11
12 libsndfile is written to be compiled by a compiler which supports large chunks
13 of the 1999 ISO C Standard (tested with GCC, Clang and Visual Studio 2015).
14
15 It is recommended to use CMake and Visual Studio to build libsndfile on Windows
16 but you can try the [MinGW](http://www.mingw.org/) compiler suite with Autotools
17 or CMake buildsystem.
1919 ** sndfile.h -- system-wide definitions
2020 **
2121 ** API documentation is in the doc/ directory of the source code tarball
22 ** and at http://www.mega-nerd.com/libsndfile/api.html.
22 ** and at http://libsndfile.github.io/libsndfile/api.html.
2323 */
2424
2525 #ifndef SNDFILE_H
4545 ** file. There is no separate implementation file.
4646 **
4747 ** API documentation is in the doc/ directory of the source code tarball
48 ** and at http://www.mega-nerd.com/libsndfile/api.html.
48 ** and at http://libsndfile.github.io/libsndfile/api.html.
4949 */
5050
5151 #ifndef SNDFILE_HH
4949 CFLAGS="$CFLAGS $pkg_CFLAGS"
5050 LIBS="$LIBS $pkg_LIBS"
5151
52 AC_TRY_LINK([], puts ("");, pkg_link=yes, pkg_link=no)
52 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <stdio.h>]], [puts ("")])], pkg_link=yes, pkg_link=no)
5353
5454 CFLAGS=$pkg_link_saved_CFLAGS
5555 LIBS=$pkg_link_saved_LIBS
2222 The audio data differs.
2323 .El
2424 .Sh SEE ALSO
25 .Lk http://www.mega-nerd.com/libsndfile
25 .Lk http://libsndfile.github.io/libsndfile/
2626 .Sh AUTHORS
2727 .An Conrad Parker Aq Mt conrad@metadecks.org
2828 .An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com
2222 .Sh EXIT STATUS
2323 .Ex -std
2424 .Sh SEE ALSO
25 .Lk http://www.mega-nerd.com/libsndfile/
25 .Lk http://libsndfile.github.io/libsndfile/
2626 .Sh AUTHORS
2727 .An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com
154154 .Sh EXIT STATUS
155155 .Ex -std
156156 .Sh SEE ALSO
157 .Lk http://www.mega-nerd.com/libsndfile/
157 .Lk http://libsndfile.github.io/libsndfile/
158158 .Sh AUTHORS
159159 .An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com .
2828 a base note, gain, velocity, key, and loop points.
2929 .El
3030 .Sh SEE ALSO
31 .Lk http://www.mega-nerd.com/libsndfile/
31 .Lk http://libsndfile.github.io/libsndfile/
3232 .Sh AUTHORS
3333 .An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com .
5656 multi_03.wav
5757 .Ed
5858 .Sh SEE ALSO
59 .Lk http://www.mega-nerd.com/libsndfile/
59 .Lk http://libsndfile.github.io/libsndfile/
6060 .Sh AUTHORS
6161 .An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com
109109 .Sh EXIT STATUS
110110 .Ex -std
111111 .Sh SEE ALSO
112 .Lk http://www.mega-nerd.com/libsndfile/
112 .Lk http://libsndfile.github.io/libsndfile/
113113 .Lk http://tech.ebu.ch/docs/tech/tech3285.pdf
114114 .Sh AUTHORS
115115 .An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com
2828 waveOut
2929 .El
3030 .Sh SEE ALSO
31 .Lk http://www.mega-nerd.com/libsndfile/
31 .Lk http://libsndfile.github.io/libsndfile/
3232 .Sh AUTHORS
3333 .An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com
1818 .Sh EXIT STATUS
1919 .Ex -std
2020 .Sh SEE ALSO
21 .Lk http://www.mega-nerd.com/libsndfile/
21 .Lk http://libsndfile.github.io/libsndfile/
2222 .\".Lk http://en.wikipedia.org/wiki/RF64
2323 .Sh AUTHORS
2424 .An Erik de Castro Lopo Aq Mt erikd@mega-nerd.com
+0
-1
ossfuzz/.gitignore less more
0 sndfile_fuzzer
1919 BRANCH=${GITHUB_REF}
2020
2121 # Modify the oss-fuzz Dockerfile so that we're checking out the current reference on CI.
22 sed -i "s@RUN.*@RUN git config --global remote.origin.fetch '+refs/pull/*:refs/remotes/origin/pull/*' \&\& git clone https://github.com/erikd/libsndfile.git /src/libsndfile \&\& cd /src/libsndfile \&\& git checkout -b ${BRANCH}@" /tmp/ossfuzz/projects/${PROJECT_NAME}/Dockerfile
22 sed -i "s@RUN.*@RUN git config --global remote.origin.fetch '+refs/pull/*:refs/remotes/origin/pull/*' \&\& git clone https://github.com/libsndfile/libsndfile.git /src/libsndfile \&\& cd /src/libsndfile \&\& git checkout -b ${BRANCH}@" /tmp/ossfuzz/projects/${PROJECT_NAME}/Dockerfile
2323
2424 # Try and build the fuzzers
2525 pushd /tmp/ossfuzz
26 python infra/helper.py build_image --pull ${PROJECT_NAME}
27 python infra/helper.py build_fuzzers ${PROJECT_NAME}
28 python infra/helper.py check_build ${PROJECT_NAME} --engine libfuzzer --sanitizer address --architecture x86_64
26 python3 infra/helper.py build_image --pull ${PROJECT_NAME}
27 python3 infra/helper.py build_fuzzers ${PROJECT_NAME}
28 python3 infra/helper.py check_build ${PROJECT_NAME} --engine libfuzzer --sanitizer address --architecture x86_64
2929 popd
22 #include <string.h>
33 #include <sys/types.h>
44 #include <sndfile.h>
5 #include <inttypes.h>
56
67 typedef struct
78 {
1920 static sf_count_t vfseek (sf_count_t offset, int whence, void *user_data)
2021 {
2122 VIO_DATA *vf = (VIO_DATA *)user_data;
23 sf_count_t new_offset;
2224
2325 switch (whence)
2426 {
2527 case SEEK_SET:
26 vf->offset = offset;
28 new_offset = offset;
2729 break ;
2830
2931 case SEEK_CUR:
30 vf->offset = vf->offset + offset;
32 new_offset = vf->offset + offset;
3133 break ;
3234
3335 case SEEK_END:
34 vf->offset = vf->length + offset;
36 new_offset = vf->length + offset;
3537 break;
3638
3739 default:
3840 break;
3941 }
42
43 /* Ensure you can't seek outside the data */
44 if (new_offset > vf->length)
45 {
46 /* Trying to seek past the end of the data */
47 printf("vf overseek: new_offset(%" PRId64 ") > vf->length(%" PRId64 ");"
48 " whence(%d), vf->offset(%" PRId64 "), offset(%" PRId64 ")\n",
49 new_offset, vf->length, whence, vf->offset, offset);
50 new_offset = vf->length;
51 }
52 else if (new_offset < 0)
53 {
54 /* Trying to seek before the start of the data */
55 printf("vf underseek: new_offset(%" PRId64 ") < 0; whence(%d), vf->offset"
56 "(%" PRId64 "), vf->length(%" PRId64 "), offset(%" PRId64 ")\n",
57 new_offset, whence, vf->offset, vf->length, offset);
58 new_offset = 0;
59 }
60 vf->offset = new_offset;
4061
4162 return vf->offset;
4263 }
242242 if ((psf->container_data = calloc (1, sizeof (AIFF_PRIVATE))) == NULL)
243243 return SFE_MALLOC_FAILED ;
244244
245 psf->container_close = aiff_close ;
246
245247 if (psf->file.mode == SFM_READ || (psf->file.mode == SFM_RDWR && psf->filelength > 0))
246248 { if ((error = aiff_read_header (psf, &comm_fmt)))
247249 return error ;
282284 psf->set_chunk = aiff_set_chunk ;
283285 } ;
284286
285 psf->container_close = aiff_close ;
286287 psf->command = aiff_command ;
287288
288289 switch (SF_CODEC (psf->sf.format))
497498 return SFE_WAV_BAD_PEAK ;
498499 } ;
499500
501 if (psf->peak_info)
502 { psf_log_printf (psf, "*** Found existing peak info, using last one.\n") ;
503 free (psf->peak_info) ;
504 psf->peak_info = NULL ;
505 } ;
500506 if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL)
501507 return SFE_MALLOC_FAILED ;
502508
799805 break ;
800806 } ;
801807
808 if (psf->cues)
809 { free (psf->cues) ;
810 psf->cues = NULL ;
811 } ;
802812 if ((psf->cues = psf_cues_alloc (mark_count)) == NULL)
803813 return SFE_MALLOC_FAILED ;
804814
17181728
17191729 psf_log_printf (psf, " Loop Type : 0x%x (%s)\n", bc.loopType, type_str) ;
17201730
1731 if (psf->loop_info)
1732 { psf_log_printf (psf, " Found existing loop info, using last one.\n") ;
1733 free (psf->loop_info) ;
1734 psf->loop_info = NULL ;
1735 } ;
17211736 if ((psf->loop_info = calloc (1, sizeof (SF_LOOP_INFO))) == NULL)
17221737 return SFE_MALLOC_FAILED ;
17231738
339339 f2alaw_array (const float *ptr, int count, unsigned char *buffer, float normfact)
340340 { while (--count >= 0)
341341 { if (ptr [count] >= 0)
342 buffer [count] = alaw_encode [lrintf (normfact * ptr [count])] ;
342 buffer [count] = alaw_encode [psf_lrintf (normfact * ptr [count])] ;
343343 else
344 buffer [count] = 0x7F & alaw_encode [- lrintf (normfact * ptr [count])] ;
344 buffer [count] = 0x7F & alaw_encode [- psf_lrintf (normfact * ptr [count])] ;
345345 } ;
346346 } /* f2alaw_array */
347347
351351 { if (!isfinite (ptr [count]))
352352 buffer [count] = 0 ;
353353 else if (ptr [count] >= 0)
354 buffer [count] = alaw_encode [lrint (normfact * ptr [count])] ;
354 buffer [count] = alaw_encode [psf_lrint (normfact * ptr [count])] ;
355355 else
356 buffer [count] = 0x7F & alaw_encode [- lrint (normfact * ptr [count])] ;
356 buffer [count] = 0x7F & alaw_encode [- psf_lrint (normfact * ptr [count])] ;
357357 } ;
358358 } /* d2alaw_array */
359359
369369 return SFE_MALFORMED_FILE ;
370370 } ;
371371
372 psf->sf.samplerate = lrint (srate) ;
372 psf->sf.samplerate = psf_lrint (srate) ;
373373
374374 psf_binheader_readf (psf, "mE44444", &desc.fmt_id, &desc.fmt_flags, &desc.pkt_bytes, &desc.frames_per_packet,
375375 &desc.channels_per_frame, &desc.bits_per_chan) ;
7070 },
7171
7272 { SF_FORMAT_OGG | SF_FORMAT_VORBIS,
73 "Ogg Vorbis (Xiph Foundation)", "oga"
73 "Ogg Vorbis (Xiph Foundation)", "ogg"
7474 },
7575 #endif
7676
876876 psf_bump_header_allocation (psf, position) ;
877877 if (position > psf->header.len)
878878 { /* Too much header to cache so just seek instead. */
879 psf->header.indx = psf->header.end ;
879880 psf_fseek (psf, position, whence) ;
880881 return ;
881882 } ;
16051606
16061607 normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ;
16071608 while (--count >= 0)
1608 dest [count] = lrintf (src [count] * normfact) ;
1609 dest [count] = psf_lrintf (src [count] * normfact) ;
16091610
16101611 return ;
16111612 } /* psf_f2s_array */
16271628 continue ;
16281629 } ;
16291630
1630 dest [count] = lrintf (scaled_value) ;
1631 dest [count] = psf_lrintf (scaled_value) ;
16311632 } ;
16321633
16331634 return ;
16391640
16401641 normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ;
16411642 while (--count >= 0)
1642 dest [count] = lrint (src [count] * normfact) ;
1643 dest [count] = psf_lrint (src [count] * normfact) ;
16431644
16441645 return ;
16451646 } /* psf_f2s_array */
16611662 continue ;
16621663 } ;
16631664
1664 dest [count] = lrint (scaled_value) ;
1665 dest [count] = psf_lrint (scaled_value) ;
16651666 } ;
16661667
16671668 return ;
16741675
16751676 normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ;
16761677 while (--count >= 0)
1677 dest [count] = lrintf (src [count] * normfact) ;
1678 dest [count] = psf_lrintf (src [count] * normfact) ;
16781679
16791680 return ;
16801681 } /* psf_f2i_array */
16961697 continue ;
16971698 } ;
16981699
1699 dest [count] = lrintf (scaled_value) ;
1700 dest [count] = psf_lrintf (scaled_value) ;
17001701 } ;
17011702
17021703 return ;
17081709
17091710 normfact = normalize ? (1.0 * 0x7FFFFFFF) : 1.0 ;
17101711 while (--count >= 0)
1711 dest [count] = lrint (src [count] * normfact) ;
1712 dest [count] = psf_lrint (src [count] * normfact) ;
17121713
17131714 return ;
17141715 } /* psf_f2i_array */
17301731 continue ;
17311732 } ;
17321733
1733 dest [count] = lrint (scaled_value) ;
1734 dest [count] = psf_lrint (scaled_value) ;
17341735 } ;
17351736
17361737 return ;
3636 #include "sndfile.h"
3737 #endif
3838
39 #include <math.h>
40
41 #ifdef USE_SSE2
42 #include <immintrin.h>
43 #endif
44
3945 #ifdef __cplusplus
4046 #error "This code is not designed to be compiled with a C++ compiler."
4147 #endif
545551 SF_CHUNK_ITERATOR * (*next_chunk_iterator) (struct sf_private_tag*, SF_CHUNK_ITERATOR * iterator) ;
546552 int (*get_chunk_size) (struct sf_private_tag*, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ;
547553 int (*get_chunk_data) (struct sf_private_tag*, const SF_CHUNK_ITERATOR * iterator, SF_CHUNK_INFO * chunk_info) ;
554
555 int cpu_flags ;
548556 } SF_PRIVATE ;
549557
550558
9981006 } /* psf_strlcpy */
9991007
10001008 /*------------------------------------------------------------------------------------
1009 ** SIMD optimized math functions.
1010 */
1011
1012 static inline int psf_lrintf (float x)
1013 {
1014 #ifdef USE_SSE2
1015 return _mm_cvtss_si32 (_mm_load_ss (&x)) ;
1016 #else
1017 return lrintf (x) ;
1018 #endif
1019 } /* psf_lrintf */
1020
1021 static inline int psf_lrint (double x)
1022 {
1023 #ifdef USE_SSE2
1024 return _mm_cvtsd_si32 (_mm_load_sd (&x)) ;
1025 #else
1026 return lrint (x) ;
1027 #endif
1028 } /* psf_lrintf */
1029
1030 /*------------------------------------------------------------------------------------
10011031 ** Other helper functions.
10021032 */
10031033
171171 /* Define to 1 if you have the <unistd.h> header file. */
172172 #cmakedefine01 HAVE_UNISTD_H
173173
174 /* Define to 1 if you have the <immintrin.h> header file. */
175 #cmakedefine01 HAVE_IMMINTRIN_H
176
174177 /* Define to 1 if you have the `vsnprintf' function. */
175178 #cmakedefine01 HAVE_VSNPRINTF
176179
188191
189192 /* Set to 1 if compiling for Win32 */
190193 #cmakedefine01 OS_IS_WIN32
194
195 /* Set to 1 if SSE2 is enabled */
196 #cmakedefine USE_SSE2
191197
192198 /* Name of package */
193199 #define PACKAGE "@PACKAGE_NAME@"
367367 out [1] |= (exponent << 4) & 0xF0 ;
368368
369369 in *= 0x20000000 ;
370 mantissa = lrint (floor (in)) ;
370 mantissa = psf_lrint (floor (in)) ;
371371
372372 out [1] |= (mantissa >> 24) & 0xF ;
373373 out [2] = (mantissa >> 16) & 0xFF ;
376376
377377 in = fmod (in, 1.0) ;
378378 in *= 0x1000000 ;
379 mantissa = lrint (floor (in)) ;
379 mantissa = psf_lrint (floor (in)) ;
380380
381381 out [5] = (mantissa >> 16) & 0xFF ;
382382 out [6] = (mantissa >> 8) & 0xFF ;
407407 out [6] |= (exponent << 4) & 0xF0 ;
408408
409409 in *= 0x20000000 ;
410 mantissa = lrint (floor (in)) ;
410 mantissa = psf_lrint (floor (in)) ;
411411
412412 out [6] |= (mantissa >> 24) & 0xF ;
413413 out [5] = (mantissa >> 16) & 0xFF ;
416416
417417 in = fmod (in, 1.0) ;
418418 in *= 0x1000000 ;
419 mantissa = lrint (floor (in)) ;
419 mantissa = psf_lrint (floor (in)) ;
420420
421421 out [2] = (mantissa >> 16) & 0xFF ;
422422 out [1] = (mantissa >> 8) & 0xFF ;
486486 static void
487487 d2s_array (const double *src, int count, short *dest, double scale)
488488 { while (--count >= 0)
489 { dest [count] = lrint (scale * src [count]) ;
489 { dest [count] = psf_lrint (scale * src [count]) ;
490490 } ;
491491 } /* d2s_array */
492492
500500 else if (CPU_CLIPS_NEGATIVE == 0 && tmp < -32768.0)
501501 dest [count] = SHRT_MIN ;
502502 else
503 dest [count] = lrint (tmp) ;
503 dest [count] = psf_lrint (tmp) ;
504504 } ;
505505 } /* d2s_clip_array */
506506
507507 static void
508508 d2i_array (const double *src, int count, int *dest, double scale)
509509 { while (--count >= 0)
510 { dest [count] = lrint (scale * src [count]) ;
510 { dest [count] = psf_lrint (scale * src [count]) ;
511511 } ;
512512 } /* d2i_array */
513513
521521 else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
522522 dest [count] = INT_MIN ;
523523 else
524 dest [count] = lrint (tmp) ;
524 dest [count] = psf_lrint (tmp) ;
525525 } ;
526526 } /* d2i_clip_array */
527527
630630 readcount = psf_fread (ubuf.dbuf, sizeof (double), bufferlen, psf) ;
631631
632632 if (psf->data_endswap == SF_TRUE)
633 endswap_double_array (ubuf.dbuf, bufferlen) ;
633 endswap_double_array (ubuf.dbuf, readcount) ;
634634
635635 d2f_array (ubuf.dbuf, readcount, ptr + total) ;
636636 total += readcount ;
627627 while (len > 0)
628628 { writecount = (len >= bufferlen) ? bufferlen : len ;
629629 for (k = 0 ; k < writecount ; k++)
630 iptr [k] = lrintf (normfact * ptr [total + k]) ;
630 iptr [k] = psf_lrintf (normfact * ptr [total + k]) ;
631631 count = dwvw_encode_data (psf, pdwvw, iptr, writecount) ;
632632
633633 total += count ;
659659 while (len > 0)
660660 { writecount = (len >= bufferlen) ? bufferlen : len ;
661661 for (k = 0 ; k < writecount ; k++)
662 iptr [k] = lrint (normfact * ptr [total + k]) ;
662 iptr [k] = psf_lrint (normfact * ptr [total + k]) ;
663663 count = dwvw_encode_data (psf, pdwvw, iptr, writecount) ;
664664
665665 total += count ;
880880 */
881881 quality = (*((double *) data)) * 8.0 ;
882882 /* Clip range. */
883 pflac->compression = lrint (SF_MAX (0.0, SF_MIN (8.0, quality))) ;
883 pflac->compression = psf_lrint (SF_MAX (0.0, SF_MIN (8.0, quality))) ;
884884
885885 psf_log_printf (psf, "%s : Setting SFC_SET_COMPRESSION_LEVEL to %u.\n", __func__, pflac->compression) ;
886886
11851185 { dest [count] = -0x80 ;
11861186 continue ;
11871187 } ;
1188 dest [count] = lrintf (scaled_value) ;
1188 dest [count] = psf_lrintf (scaled_value) ;
11891189 } ;
11901190
11911191 return ;
12071207 { dest [count] = -0x8000 ;
12081208 continue ;
12091209 } ;
1210 dest [count] = lrintf (scaled_value) ;
1210 dest [count] = psf_lrintf (scaled_value) ;
12111211 } ;
12121212 } /* f2flac16_clip_array */
12131213
12281228 { dest [count] = -0x800000 ;
12291229 continue ;
12301230 }
1231 dest [count] = lrintf (scaled_value) ;
1231 dest [count] = psf_lrintf (scaled_value) ;
12321232 } ;
12331233
12341234 return ;
12391239 { float normfact = normalize ? (1.0 * 0x7F) : 1.0 ;
12401240
12411241 while (--count >= 0)
1242 dest [count] = lrintf (src [count] * normfact) ;
1242 dest [count] = psf_lrintf (src [count] * normfact) ;
12431243 } /* f2flac8_array */
12441244
12451245 static void
12471247 { float normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ;
12481248
12491249 while (--count >= 0)
1250 dest [count] = lrintf (src [count] * normfact) ;
1250 dest [count] = psf_lrintf (src [count] * normfact) ;
12511251 } /* f2flac16_array */
12521252
12531253 static void
12551255 { float normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ;
12561256
12571257 while (--count >= 0)
1258 dest [count] = lrintf (src [count] * normfact) ;
1258 dest [count] = psf_lrintf (src [count] * normfact) ;
12591259 } /* f2flac24_array */
12601260
12611261 static sf_count_t
13161316 { dest [count] = -0x80 ;
13171317 continue ;
13181318 } ;
1319 dest [count] = lrint (scaled_value) ;
1319 dest [count] = psf_lrint (scaled_value) ;
13201320 } ;
13211321
13221322 return ;
13381338 { dest [count] = -0x8000 ;
13391339 continue ;
13401340 } ;
1341 dest [count] = lrint (scaled_value) ;
1341 dest [count] = psf_lrint (scaled_value) ;
13421342 } ;
13431343
13441344 return ;
13601360 { dest [count] = -0x800000 ;
13611361 continue ;
13621362 } ;
1363 dest [count] = lrint (scaled_value) ;
1363 dest [count] = psf_lrint (scaled_value) ;
13641364 } ;
13651365
13661366 return ;
13711371 { double normfact = normalize ? (1.0 * 0x7F) : 1.0 ;
13721372
13731373 while (--count >= 0)
1374 dest [count] = lrint (src [count] * normfact) ;
1374 dest [count] = psf_lrint (src [count] * normfact) ;
13751375 } /* d2flac8_array */
13761376
13771377 static void
13791379 { double normfact = normalize ? (1.0 * 0x7FFF) : 1.0 ;
13801380
13811381 while (--count >= 0)
1382 dest [count] = lrint (src [count] * normfact) ;
1382 dest [count] = psf_lrint (src [count] * normfact) ;
13831383 } /* d2flac16_array */
13841384
13851385 static void
13871387 { double normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ;
13881388
13891389 while (--count >= 0)
1390 dest [count] = lrint (src [count] * normfact) ;
1390 dest [count] = psf_lrint (src [count] * normfact) ;
13911391 } /* d2flac24_array */
13921392
13931393 static sf_count_t
437437 f2s_array (const float *src, int count, short *dest, float scale)
438438 {
439439 while (--count >= 0)
440 { dest [count] = lrintf (scale * src [count]) ;
440 { dest [count] = psf_lrintf (scale * src [count]) ;
441441 } ;
442442 } /* f2s_array */
443443
451451 else if (CPU_CLIPS_NEGATIVE == 0 && tmp < -32768.0)
452452 dest [count] = SHRT_MIN ;
453453 else
454 dest [count] = lrintf (tmp) ;
454 dest [count] = psf_lrintf (tmp) ;
455455 } ;
456456 } /* f2s_clip_array */
457457
458458 static inline void
459459 f2i_array (const float *src, int count, int *dest, float scale)
460460 { while (--count >= 0)
461 { dest [count] = lrintf (scale * src [count]) ;
461 { dest [count] = psf_lrintf (scale * src [count]) ;
462462 } ;
463463 } /* f2i_array */
464464
472472 else if (CPU_CLIPS_NEGATIVE == 0 && tmp < (-1.0 * INT_MAX))
473473 dest [count] = INT_MIN ;
474474 else
475 dest [count] = lrintf (tmp) ;
475 dest [count] = psf_lrintf (tmp) ;
476476 } ;
477477 } /* f2i_clip_array */
478478
537537 while (len > 0)
538538 { writecount = (len >= bufferlen) ? bufferlen : len ;
539539 for (k = 0 ; k < writecount ; k++)
540 sptr [k] = lrintf (normfact * ptr [total + k]) ;
540 sptr [k] = psf_lrintf (normfact * ptr [total + k]) ;
541541 count = g72x_write_block (psf, pg72x, sptr, writecount) ;
542542
543543 total += count ;
569569 while (len > 0)
570570 { writecount = (len >= bufferlen) ? bufferlen : len ;
571571 for (k = 0 ; k < writecount ; k++)
572 sptr [k] = lrint (normfact * ptr [total + k]) ;
572 sptr [k] = psf_lrint (normfact * ptr [total + k]) ;
573573 count = g72x_write_block (psf, pg72x, sptr, writecount) ;
574574
575575 total += count ;
562562 while (len > 0)
563563 { writecount = (len >= bufferlen) ? bufferlen : len ;
564564 for (k = 0 ; k < writecount ; k++)
565 sptr [k] = lrintf (normfact * ptr [total + k]) ;
565 sptr [k] = psf_lrintf (normfact * ptr [total + k]) ;
566566 count = gsm610_write_block (psf, pgsm610, sptr, writecount) ;
567567
568568 total += count ;
593593 while (len > 0)
594594 { writecount = (len >= bufferlen) ? bufferlen : len ;
595595 for (k = 0 ; k < writecount ; k++)
596 sptr [k] = lrint (normfact * ptr [total + k]) ;
596 sptr [k] = psf_lrint (normfact * ptr [total + k]) ;
597597 count = gsm610_write_block (psf, pgsm610, sptr, writecount) ;
598598
599599 total += count ;
4646 return 0 ;
4747
4848 /* Calculate new file offset and position ourselves there. */
49 psf->fileoffset += offset + 10 ;
50
51 if (psf->fileoffset < psf->filelength)
52 { psf_binheader_readf (psf, "p", psf->fileoffset) ;
49 offset += 10 ;
50 if (psf->fileoffset + offset < psf->filelength)
51 { psf_binheader_readf (psf, "p", offset) ;
52 psf->fileoffset += offset ;
5353 return 1 ;
5454 } ;
5555 } ;
958958 while (len > 0)
959959 { writecount = (len >= bufferlen) ? bufferlen : (int) len ;
960960 for (k = 0 ; k < writecount ; k++)
961 sptr [k] = lrintf (normfact * ptr [total + k]) ;
961 sptr [k] = psf_lrintf (normfact * ptr [total + k]) ;
962962 count = ima_write_block (psf, pima, sptr, writecount) ;
963963 total += count ;
964964 len -= writecount ;
989989 while (len > 0)
990990 { writecount = (len >= bufferlen) ? bufferlen : (int) len ;
991991 for (k = 0 ; k < writecount ; k++)
992 sptr [k] = lrint (normfact * ptr [total + k]) ;
992 sptr [k] = psf_lrint (normfact * ptr [total + k]) ;
993993 count = ima_write_block (psf, pima, sptr, writecount) ;
994994 total += count ;
995995 len -= writecount ;
247247 if ((rows != 1) || (cols != 1))
248248 return SFE_MAT4_NO_SAMPLERATE ;
249249
250 psf->sf.samplerate = lrint (value) ;
250 psf->sf.samplerate = psf_lrint (value) ;
251251
252252 /* Now write out the audio data. */
253253
369369 snprintf (name, sizeof (name), "%f\n", samplerate) ;
370370 psf_log_printf (psf, " Val : %s\n", name) ;
371371
372 psf->sf.samplerate = lrint (samplerate) ;
372 psf->sf.samplerate = psf_lrint (samplerate) ;
373373 } ;
374374 break ;
375375
730730 while (len > 0)
731731 { writecount = (len >= bufferlen) ? bufferlen : len ;
732732 for (k = 0 ; k < writecount ; k++)
733 sptr [k] = lrintf (normfact * ptr [total + k]) ;
733 sptr [k] = psf_lrintf (normfact * ptr [total + k]) ;
734734 count = msadpcm_write_block (psf, pms, sptr, writecount) ;
735735 total += count ;
736736 len -= writecount ;
760760 while (len > 0)
761761 { writecount = (len >= bufferlen) ? bufferlen : len ;
762762 for (k = 0 ; k < writecount ; k++)
763 sptr [k] = lrint (normfact * ptr [total + k]) ;
763 sptr [k] = psf_lrint (normfact * ptr [total + k]) ;
764764 count = msadpcm_write_block (psf, pms, sptr, writecount) ;
765765 total += count ;
766766 len -= writecount ;
977977 while (len > 0)
978978 { writecount = (len >= bufferlen) ? bufferlen : len ;
979979 for (k = 0 ; k < writecount ; k++)
980 sptr [k] = lrintf (normfact * ptr [total + k]) ;
980 sptr [k] = psf_lrintf (normfact * ptr [total + k]) ;
981981 count = nms_adpcm_write_block (psf, pnms, sptr, writecount) ;
982982
983983 total += count ;
10091009 while (len > 0)
10101010 { writecount = (len >= bufferlen) ? bufferlen : len ;
10111011 for (k = 0 ; k < writecount ; k++)
1012 sptr [k] = lrint (normfact * ptr [total + k]) ;
1012 sptr [k] = psf_lrint (normfact * ptr [total + k]) ;
10131013 count = nms_adpcm_write_block (psf, pnms, sptr, writecount) ;
10141014
10151015 total += count ;
11601160 if (psf->float_int_mult)
11611161 { float inverse = 1.0 / psf->float_max ;
11621162 for ( ; i < total ; i++)
1163 { ptr [i] = lrintf (((*(iptr++)) * inverse) * 32767.0f) ;
1163 { ptr [i] = psf_lrintf (((*(iptr++)) * inverse) * 32767.0f) ;
11641164 } ;
11651165 }
11661166 else
11671167 { for ( ; i < total ; i++)
1168 { ptr [i] = lrintf ((*(iptr++)) * 32767.0f) ;
1168 { ptr [i] = psf_lrintf ((*(iptr++)) * 32767.0f) ;
11691169 } ;
11701170 } ;
11711171 oopus->loc += (readlen / psf->sf.channels) ;
11971197 if (psf->float_int_mult)
11981198 { float inverse = 1.0 / psf->float_max ;
11991199 for ( ; i < total ; i++)
1200 { ptr [i] = lrintf (((*(iptr++)) * inverse) * 2147483647.0f) ;
1200 { ptr [i] = psf_lrintf (((*(iptr++)) * inverse) * 2147483647.0f) ;
12011201 }
12021202 }
12031203 else
12041204 { for ( ; i < total ; i++)
1205 { ptr [i] = lrintf ((*(iptr++)) * 2147483647.0f) ;
1205 { ptr [i] = psf_lrintf ((*(iptr++)) * 2147483647.0f) ;
12061206 }
12071207 } ;
12081208 oopus->loc += (readlen / psf->sf.channels) ;
557557 float inverse = 1.0 / psf->float_max ;
558558 for (j = 0 ; j < samples ; j++)
559559 for (n = 0 ; n < channels ; n++)
560 ptr [i++] = lrintf ((pcm [n][j] * inverse) * 32767.0f) ;
560 ptr [i++] = psf_lrintf ((pcm [n][j] * inverse) * 32767.0f) ;
561561 }
562562 else
563563 {
564564 for (j = 0 ; j < samples ; j++)
565565 for (n = 0 ; n < channels ; n++)
566 ptr [i++] = lrintf (pcm [n][j] * 32767.0f) ;
566 ptr [i++] = psf_lrintf (pcm [n][j] * 32767.0f) ;
567567 }
568568 return i ;
569569 } /* vorbis_rshort */
579579 float inverse = 1.0 / psf->float_max ;
580580 for (j = 0 ; j < samples ; j++)
581581 for (n = 0 ; n < channels ; n++)
582 ptr [i++] = lrintf ((pcm [n][j] * inverse) * 2147483647.0f) ;
582 ptr [i++] = psf_lrintf ((pcm [n][j] * inverse) * 2147483647.0f) ;
583583 }
584584 else
585585 {
586586 for (j = 0 ; j < samples ; j++)
587587 for (n = 0 ; n < channels ; n++)
588 ptr [i++] = lrintf (pcm [n][j] * 2147483647.0f) ;
588 ptr [i++] = psf_lrintf (pcm [n][j] * 2147483647.0f) ;
589589 }
590590 return i ;
591591 } /* vorbis_rint */
773773 while (len > 0)
774774 { writecount = (len >= bufferlen) ? bufferlen : len ;
775775 for (k = 0 ; k < writecount ; k++)
776 iptr [k] = lrintf (normfact * ptr [total + k]) ;
776 iptr [k] = psf_lrintf (normfact * ptr [total + k]) ;
777777 count = paf24_write (psf, ppaf24, iptr, writecount) ;
778778 total += count ;
779779 len -= writecount ;
804804 while (len > 0)
805805 { writecount = (len >= bufferlen) ? bufferlen : len ;
806806 for (k = 0 ; k < writecount ; k++)
807 iptr [k] = lrint (normfact * ptr [total+k]) ;
807 iptr [k] = psf_lrint (normfact * ptr [total+k]) ;
808808 count = paf24_write (psf, ppaf24, iptr, writecount) ;
809809 total += count ;
810810 len -= writecount ;
17651765 normfact = normalize ? (1.0 * 0x7F) : 1.0 ;
17661766
17671767 while (--count >= 0)
1768 { dest [count] = lrintf (src [count] * normfact) ;
1768 { dest [count] = psf_lrintf (src [count] * normfact) ;
17691769 } ;
17701770 } /* f2sc_array */
17711771
17861786 continue ;
17871787 } ;
17881788
1789 dest [count] = lrintf (scaled_value) >> 24 ;
1789 dest [count] = psf_lrintf (scaled_value) >> 24 ;
17901790 } ;
17911791 } /* f2sc_clip_array */
17921792
18241824 normfact = normalize ? (1.0 * 0x7F) : 1.0 ;
18251825
18261826 while (--count >= 0)
1827 { dest [count] = lrintf (src [count] * normfact) + 128 ;
1827 { dest [count] = psf_lrintf (src [count] * normfact) + 128 ;
18281828 } ;
18291829 } /* f2uc_array */
18301830
18451845 continue ;
18461846 } ;
18471847
1848 dest [count] = (lrintf (scaled_value) >> 24) + 128 ;
1848 dest [count] = (psf_lrintf (scaled_value) >> 24) + 128 ;
18491849 } ;
18501850 } /* f2uc_clip_array */
18511851
18871887
18881888 while (--count >= 0)
18891889 { ucptr -= 2 ;
1890 value = lrintf (src [count] * normfact) ;
1890 value = psf_lrintf (src [count] * normfact) ;
18911891 ucptr [1] = value ;
18921892 ucptr [0] = value >> 8 ;
18931893 } ;
19161916 continue ;
19171917 } ;
19181918
1919 value = lrintf (scaled_value) ;
1919 value = psf_lrintf (scaled_value) ;
19201920 ucptr [1] = value >> 16 ;
19211921 ucptr [0] = value >> 24 ;
19221922 } ;
19601960
19611961 while (--count >= 0)
19621962 { ucptr -= 2 ;
1963 value = lrintf (src [count] * normfact) ;
1963 value = psf_lrintf (src [count] * normfact) ;
19641964 ucptr [0] = value ;
19651965 ucptr [1] = value >> 8 ;
19661966 } ;
19891989 continue ;
19901990 } ;
19911991
1992 value = lrintf (scaled_value) ;
1992 value = psf_lrintf (scaled_value) ;
19931993 ucptr [0] = value >> 16 ;
19941994 ucptr [1] = value >> 24 ;
19951995 } ;
20302030 normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ;
20312031
20322032 while (--count >= 0)
2033 { value = lrintf (src [count] * normfact) ;
2033 { value = psf_lrintf (src [count] * normfact) ;
20342034 dest [count].bytes [0] = value ;
20352035 dest [count].bytes [1] = value >> 8 ;
20362036 dest [count].bytes [2] = value >> 16 ;
20592059 continue ;
20602060 } ;
20612061
2062 value = lrintf (scaled_value) ;
2062 value = psf_lrintf (scaled_value) ;
20632063 dest [count].bytes [0] = value >> 8 ;
20642064 dest [count].bytes [1] = value >> 16 ;
20652065 dest [count].bytes [2] = value >> 24 ;
21012101 normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ;
21022102
21032103 while (--count >= 0)
2104 { value = lrintf (src [count] * normfact) ;
2104 { value = psf_lrintf (src [count] * normfact) ;
21052105 dest [count].bytes [0] = value >> 16 ;
21062106 dest [count].bytes [1] = value >> 8 ;
21072107 dest [count].bytes [2] = value ;
21302130 continue ;
21312131 } ;
21322132
2133 value = lrint (scaled_value) ;
2133 value = psf_lrint (scaled_value) ;
21342134 dest [count].bytes [0] = value >> 24 ;
21352135 dest [count].bytes [1] = value >> 16 ;
21362136 dest [count].bytes [2] = value >> 8 ;
21742174 ucptr = ((unsigned char*) dest) + 4 * count ;
21752175 while (--count >= 0)
21762176 { ucptr -= 4 ;
2177 value = lrintf (src [count] * normfact) ;
2177 value = psf_lrintf (src [count] * normfact) ;
21782178 ucptr [0] = value >> 24 ;
21792179 ucptr [1] = value >> 16 ;
21802180 ucptr [2] = value >> 8 ;
22092209 continue ;
22102210 } ;
22112211
2212 value = lrintf (scaled_value) ;
2212 value = psf_lrintf (scaled_value) ;
22132213 ucptr [0] = value >> 24 ;
22142214 ucptr [1] = value >> 16 ;
22152215 ucptr [2] = value >> 8 ;
22552255
22562256 while (--count >= 0)
22572257 { ucptr -= 4 ;
2258 value = lrintf (src [count] * normfact) ;
2258 value = psf_lrintf (src [count] * normfact) ;
22592259 ucptr [0] = value ;
22602260 ucptr [1] = value >> 8 ;
22612261 ucptr [2] = value >> 16 ;
22902290 continue ;
22912291 } ;
22922292
2293 value = lrintf (scaled_value) ;
2293 value = psf_lrintf (scaled_value) ;
22942294 ucptr [0] = value ;
22952295 ucptr [1] = value >> 8 ;
22962296 ucptr [2] = value >> 16 ;
23322332 normfact = normalize ? (1.0 * 0x7F) : 1.0 ;
23332333
23342334 while (--count >= 0)
2335 { dest [count] = lrint (src [count] * normfact) ;
2335 { dest [count] = psf_lrint (src [count] * normfact) ;
23362336 } ;
23372337 } /* d2sc_array */
23382338
23532353 continue ;
23542354 } ;
23552355
2356 dest [count] = lrintf (scaled_value) >> 24 ;
2356 dest [count] = psf_lrintf (scaled_value) >> 24 ;
23572357 } ;
23582358 } /* d2sc_clip_array */
23592359
23912391 normfact = normalize ? (1.0 * 0x7F) : 1.0 ;
23922392
23932393 while (--count >= 0)
2394 { dest [count] = lrint (src [count] * normfact) + 128 ;
2394 { dest [count] = psf_lrint (src [count] * normfact) + 128 ;
23952395 } ;
23962396 } /* d2uc_array */
23972397
24122412 continue ;
24132413 } ;
24142414
2415 dest [count] = (lrint (src [count] * normfact) >> 24) + 128 ;
2415 dest [count] = (psf_lrint (src [count] * normfact) >> 24) + 128 ;
24162416 } ;
24172417 } /* d2uc_clip_array */
24182418
24542454
24552455 while (--count >= 0)
24562456 { ucptr -= 2 ;
2457 value = lrint (src [count] * normfact) ;
2457 value = psf_lrint (src [count] * normfact) ;
24582458 ucptr [1] = value ;
24592459 ucptr [0] = value >> 8 ;
24602460 } ;
24832483 continue ;
24842484 } ;
24852485
2486 value = lrint (scaled_value) ;
2486 value = psf_lrint (scaled_value) ;
24872487 ucptr [1] = value >> 16 ;
24882488 ucptr [0] = value >> 24 ;
24892489 } ;
25272527
25282528 while (--count >= 0)
25292529 { ucptr -= 2 ;
2530 value = lrint (src [count] * normfact) ;
2530 value = psf_lrint (src [count] * normfact) ;
25312531 ucptr [0] = value ;
25322532 ucptr [1] = value >> 8 ;
25332533 } ;
25562556 continue ;
25572557 } ;
25582558
2559 value = lrint (scaled_value) ;
2559 value = psf_lrint (scaled_value) ;
25602560 ucptr [0] = value >> 16 ;
25612561 ucptr [1] = value >> 24 ;
25622562 } ;
25972597 normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ;
25982598
25992599 while (--count >= 0)
2600 { value = lrint (src [count] * normfact) ;
2600 { value = psf_lrint (src [count] * normfact) ;
26012601 dest [count].bytes [0] = value ;
26022602 dest [count].bytes [1] = value >> 8 ;
26032603 dest [count].bytes [2] = value >> 16 ;
26262626 continue ;
26272627 } ;
26282628
2629 value = lrint (scaled_value) ;
2629 value = psf_lrint (scaled_value) ;
26302630 dest [count].bytes [0] = value >> 8 ;
26312631 dest [count].bytes [1] = value >> 16 ;
26322632 dest [count].bytes [2] = value >> 24 ;
26682668 normfact = normalize ? (1.0 * 0x7FFFFF) : 1.0 ;
26692669
26702670 while (--count >= 0)
2671 { value = lrint (src [count] * normfact) ;
2671 { value = psf_lrint (src [count] * normfact) ;
26722672 dest [count].bytes [2] = value ;
26732673 dest [count].bytes [1] = value >> 8 ;
26742674 dest [count].bytes [0] = value >> 16 ;
26972697 continue ;
26982698 } ;
26992699
2700 value = lrint (scaled_value) ;
2700 value = psf_lrint (scaled_value) ;
27012701 dest [count].bytes [2] = value >> 8 ;
27022702 dest [count].bytes [1] = value >> 16 ;
27032703 dest [count].bytes [0] = value >> 24 ;
27422742
27432743 while (--count >= 0)
27442744 { ucptr -= 4 ;
2745 value = lrint (src [count] * normfact) ;
2745 value = psf_lrint (src [count] * normfact) ;
27462746 ucptr [0] = value >> 24 ;
27472747 ucptr [1] = value >> 16 ;
27482748 ucptr [2] = value >> 8 ;
27772777 continue ;
27782778 } ;
27792779
2780 value = lrint (scaled_value) ;
2780 value = psf_lrint (scaled_value) ;
27812781 ucptr [0] = value >> 24 ;
27822782 ucptr [1] = value >> 16 ;
27832783 ucptr [2] = value >> 8 ;
28232823
28242824 while (--count >= 0)
28252825 { ucptr -= 4 ;
2826 value = lrint (src [count] * normfact) ;
2826 value = psf_lrint (src [count] * normfact) ;
28272827 ucptr [0] = value ;
28282828 ucptr [1] = value >> 8 ;
28292829 ucptr [2] = value >> 16 ;
28582858 continue ;
28592859 } ;
28602860
2861 value = lrint (scaled_value) ;
2861 value = psf_lrint (scaled_value) ;
28622862 ucptr [0] = value ;
28632863 ucptr [1] = value >> 8 ;
28642864 ucptr [2] = value >> 16 ;
123123 #define CPU_IS_X86_64 0
124124 #endif
125125
126 #if (defined (__SSE2__) || defined (_M_AMD64) || (defined (_M_IX86_FP) && (_M_IX86_FP >= 2)) && HAVE_IMMINTRIN_H)
127 #define USE_SSE2
128 #endif
129
126130 #ifndef HAVE_SSIZE_T
127131 #define HAVE_SSIZE_T 0
128132 #endif
4141 */
4242 #ifdef __BIG_ENDIAN__
4343 #if (CPU_IS_LITTLE_ENDIAN == 1)
44 #error "Universal binary compile detected. See http://www.mega-nerd.com/libsndfile/FAQ.html#Q018"
44 #error "Universal binary compile detected. See http://libsndfile.github.io/libsndfile/FAQ.html#Q018"
4545 #endif
4646 #endif
4747
4848 #ifdef __LITTLE_ENDIAN__
4949 #if (CPU_IS_BIG_ENDIAN == 1)
50 #error "Universal binary compile detected. See http://www.mega-nerd.com/libsndfile/FAQ.html#Q018"
50 #error "Universal binary compile detected. See http://libsndfile.github.io/libsndfile/FAQ.html#Q018"
5151 #endif
5252 #endif
5353 #endif
582582 subformat = SF_CODEC (info->format) ;
583583 endian = SF_ENDIAN (info->format) ;
584584
585 /* This is the place where each file format can check if the suppiled
585 /* This is the place where each file format can check if the supplied
586586 ** SF_INFO struct is valid.
587587 ** Return 0 on failure, 1 ons success.
588588 */
27752775 if (buffer [0] == MAKE_MARKER ('R', 'F', '6', '4') && buffer [2] == MAKE_MARKER ('W', 'A', 'V', 'E'))
27762776 return SF_FORMAT_RF64 ;
27772777
2778 if (buffer [0] == MAKE_MARKER ('I', 'D', '3', 3))
2778 if (buffer [0] == MAKE_MARKER ('I', 'D', '3', 2) || buffer [0] == MAKE_MARKER ('I', 'D', '3', 3)
2779 || buffer [0] == MAKE_MARKER ('I', 'D', '3', 4))
27792780 { psf_log_printf (psf, "Found 'ID3' marker.\n") ;
27802781 if (id3_skip (psf))
27812782 return guess_file_type (psf) ;
840840 f2ulaw_array (const float *ptr, int count, unsigned char *buffer, float normfact)
841841 { while (--count >= 0)
842842 { if (ptr [count] >= 0)
843 buffer [count] = ulaw_encode [lrintf (normfact * ptr [count])] ;
843 buffer [count] = ulaw_encode [psf_lrintf (normfact * ptr [count])] ;
844844 else
845 buffer [count] = 0x7F & ulaw_encode [- lrintf (normfact * ptr [count])] ;
845 buffer [count] = 0x7F & ulaw_encode [- psf_lrintf (normfact * ptr [count])] ;
846846 } ;
847847 } /* f2ulaw_array */
848848
852852 { if (!isfinite (ptr [count]))
853853 buffer [count] = 0 ;
854854 else if (ptr [count] >= 0)
855 buffer [count] = ulaw_encode [lrint (normfact * ptr [count])] ;
855 buffer [count] = ulaw_encode [psf_lrint (normfact * ptr [count])] ;
856856 else
857 buffer [count] = 0x7F & ulaw_encode [- lrint (normfact * ptr [count])] ;
857 buffer [count] = 0x7F & ulaw_encode [- psf_lrint (normfact * ptr [count])] ;
858858 } ;
859859 } /* d2ulaw_array */
860860
355355 while (len > 0)
356356 { writecount = (len >= bufferlen) ? bufferlen : (int) len ;
357357 for (k = 0 ; k < writecount ; k++)
358 sptr [k] = lrintf (normfact * ptr [total + k]) ;
358 sptr [k] = psf_lrintf (normfact * ptr [total + k]) ;
359359 count = vox_write_block (psf, pvox, sptr, writecount) ;
360360 total += count ;
361361 len -= writecount ;
386386 while (len > 0)
387387 { writecount = (len >= bufferlen) ? bufferlen : (int) len ;
388388 for (k = 0 ; k < writecount ; k++)
389 sptr [k] = lrint (normfact * ptr [total + k]) ;
389 sptr [k] = psf_lrint (normfact * ptr [total + k]) ;
390390 count = vox_write_block (psf, pvox, sptr, writecount) ;
391391 total += count ;
392392 len -= writecount ;
479479 } ;
480480
481481 psf_log_printf (psf, " Count : %d\n", cue_count) ;
482
483 if (psf->cues)
484 { free (psf->cues) ;
485 psf->cues = NULL ;
486 } ;
482487
483488 if ((psf->cues = psf_cues_alloc (cue_count)) == NULL)
484489 return SFE_MALLOC_FAILED ;
12881293 static int
12891294 wav_read_smpl_chunk (SF_PRIVATE *psf, uint32_t chunklen)
12901295 { char buffer [512] ;
1291 uint32_t thisread, bytesread = 0, dword, sampler_data, loop_count ;
1296 uint32_t thisread, bytesread = 0, dword, sampler_data, loop_count, actually_loop_count = 0 ;
12921297 uint32_t note, pitch, start, end, type = -1, count ;
12931298 int j, k ;
12941299
13341339 */
13351340 bytesread += psf_binheader_readf (psf, "4", &sampler_data) ;
13361341
1342 if (psf->instrument)
1343 { psf_log_printf (psf, " Found more than one SMPL chunk, using last one.\n") ;
1344 free (psf->instrument) ;
1345 psf->instrument = NULL ;
1346 } ;
13371347 if ((psf->instrument = psf_instrument_alloc ()) == NULL)
13381348 return SFE_MALLOC_FAILED ;
13391349
13801390 break ;
13811391 } ;
13821392 } ;
1383
1384 loop_count -- ;
1393 actually_loop_count ++ ;
1394 } ;
1395
1396 if (actually_loop_count > ARRAY_LEN (psf->instrument->loops))
1397 {
1398 psf_log_printf (psf, "*** Warning, actual Loop Points count exceeds %u, changing Loop Count from %u to %u\n", ARRAY_LEN (psf->instrument->loops), loop_count, ARRAY_LEN (psf->instrument->loops)) ;
1399 psf->instrument->loop_count = ARRAY_LEN (psf->instrument->loops) ;
1400 }
1401 else if (loop_count != actually_loop_count)
1402 { psf_log_printf (psf, "*** Warning, actual Loop Points count != Loop Count, changing Loop Count from %u to %u\n", loop_count, actually_loop_count) ;
1403 psf->instrument->loop_count = actually_loop_count ;
13851404 } ;
13861405
13871406 if (chunklen - bytesread == 0)
14851504
14861505 psf_binheader_readf (psf, "j", chunklen - bytesread) ;
14871506
1507 if (psf->loop_info)
1508 { psf_log_printf (psf, " Found existing loop info, using last one.\n") ;
1509 free (psf->loop_info) ;
1510 psf->loop_info = NULL ;
1511 } ;
14881512 if ((psf->loop_info = calloc (1, sizeof (SF_LOOP_INFO))) == NULL)
14891513 return SFE_MALLOC_FAILED ;
14901514
837837
838838 psf_log_printf (psf, "cart : %u\n", chunksize) ;
839839
840 if (psf->cart_16k)
841 { psf_log_printf (psf, " Found more than one cart chunk, using last one.\n") ;
842 free (psf->cart_16k) ;
843 psf->cart_16k = NULL ;
844 } ;
845
840846 if ((psf->cart_16k = cart_var_alloc ()) == NULL)
841847 { psf->error = SFE_MALLOC_FAILED ;
842848 return psf->error ;
11861192 return SFE_WAV_BAD_PEAK ;
11871193 } ;
11881194
1195 if (psf->peak_info)
1196 { psf_log_printf (psf, "*** Found existing peak info, using last one.\n") ;
1197 free (psf->peak_info) ;
1198 psf->peak_info = NULL ;
1199 } ;
11891200 if ((psf->peak_info = peak_info_calloc (psf->sf.channels)) == NULL)
11901201 return SFE_MALLOC_FAILED ;
11911202
12571268 */
12581269 static int
12591270 exif_subchunk_parse (SF_PRIVATE *psf, uint32_t length)
1260 { uint32_t marker, dword, vmajor = -1, vminor = -1, bytesread = 0 ;
1271 { uint32_t marker, dword = 0, vmajor = -1, vminor = -1, bytesread = 0 ;
12611272 char buf [4096] ;
12621273 int thisread ;
12631274
10711071 last_val = pxi->last_16 >> 8 ;
10721072
10731073 for (k = 0 ; k < count ; k++)
1074 { current = lrintf (src [k] * normfact) ;
1074 { current = psf_lrintf (src [k] * normfact) ;
10751075 dest [k] = current - last_val ;
10761076 last_val = current ;
10771077 } ;
10871087 last_val = pxi->last_16 >> 8 ;
10881088
10891089 for (k = 0 ; k < count ; k++)
1090 { current = lrint (src [k] * normfact) ;
1090 { current = psf_lrint (src [k] * normfact) ;
10911091 dest [k] = current - last_val ;
10921092 last_val = current ;
10931093 } ;
12011201 last_val = pxi->last_16 ;
12021202
12031203 for (k = 0 ; k < count ; k++)
1204 { current = lrintf (src [k] * normfact) ;
1204 { current = psf_lrintf (src [k] * normfact) ;
12051205 diff = current - last_val ;
12061206 dest [k] = LE2H_16 (diff) ;
12071207 last_val = current ;
12181218 last_val = pxi->last_16 ;
12191219
12201220 for (k = 0 ; k < count ; k++)
1221 { current = lrint (src [k] * normfact) ;
1221 { current = psf_lrint (src [k] * normfact) ;
12221222 diff = current - last_val ;
12231223 dest [k] = LE2H_16 (diff) ;
12241224 last_val = current ;