command.html 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  2. <HTML>
  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. <BODY>
  15. <H1><B>sf_command</B></H1>
  16. <PRE>
  17. int sf_command (SNDFILE *sndfile, int cmd, void *data, int datasize) ;
  18. </PRE>
  19. <P>
  20. This function allows the caller to retrieve information from or change aspects of the
  21. library behaviour.
  22. Examples include retrieving a string containing the library version or changing the
  23. scaling applied to floating point sample data during read and write.
  24. Most of these operations are performed on a per-file basis.
  25. </P>
  26. <P>
  27. The cmd parameter is an integer identifier which is defined in &lt;sndfile.h&gt;.
  28. All of the valid command identifiers have names beginning with "SFC_".
  29. Data is passed to and returned from the library by use of a void pointer.
  30. The library will not read or write more than datasize bytes from the void pointer.
  31. For some calls no data is required in which case data should be NULL and datasize
  32. may be used for some other purpose.
  33. </P>
  34. <P>
  35. The available commands are as follows:
  36. </P>
  37. <CENTER>
  38. <TABLE BORDER="0" WIDTH="90%" CELLPADDING="4">
  39. <TR>
  40. <TD><A HREF="#SFC_GET_LIB_VERSION">SFC_GET_LIB_VERSION</A></TD>
  41. <TD>Retrieve the version of the library.</TD>
  42. </TR>
  43. <TR>
  44. <TD><A HREF="#SFC_GET_LOG_INFO">SFC_GET_LOG_INFO</A></TD>
  45. <TD>Retrieve the internal per-file operation log.</TD>
  46. </TR>
  47. <TR>
  48. <TD><A HREF="#SFC_CALC_SIGNAL_MAX">SFC_CALC_SIGNAL_MAX</A></TD>
  49. <TD>Calculate the measured maximum signal value.</TD>
  50. </TR>
  51. <TR>
  52. <TD><A HREF="#SFC_CALC_NORM_SIGNAL_MAX">SFC_CALC_NORM_SIGNAL_MAX</A></TD>
  53. <TD>Calculate the measured normalised maximum signal value.</TD>
  54. </TR>
  55. <TR>
  56. <TD><A HREF="#SFC_CALC_MAX_ALL_CHANNELS">SFC_CALC_MAX_ALL_CHANNELS</A></TD>
  57. <TD>Calculate the peak value for each channel.</TD>
  58. </TR>
  59. <TR>
  60. <TD><A HREF="#SFC_CALC_NORM_MAX_ALL_CHANNELS">SFC_CALC_NORM_MAX_ALL_CHANNELS</A></TD>
  61. <TD>Calculate the normalised peak for each channel.</TD>
  62. </TR>
  63. <TR>
  64. <TD><A HREF="#SFC_GET_SIGNAL_MAX">SFC_GET_SIGNAL_MAX</A></TD>
  65. <TD>Retrieve the peak value for the file (as stored in the file header).</TD>
  66. </TR>
  67. <TR>
  68. <TD><A HREF="#SFC_GET_MAX_ALL_CHANNELS">SFC_GET_MAX_ALL_CHANNELS</A></TD>
  69. <TD>Retrieve the peak value for each channel (as stored in the file header).</TD>
  70. </TR>
  71. <TR>
  72. <TD><A HREF="#SFC_SET_NORM_FLOAT">SFC_SET_NORM_FLOAT</A></TD>
  73. <TD>Modify the normalisation behaviour of the floating point reading and writing functions.</TD>
  74. </TR>
  75. <TR>
  76. <TD><A HREF="#SFC_SET_NORM_DOUBLE">SFC_SET_NORM_DOUBLE</A></TD>
  77. <TD>Modify the normalisation behaviour of the double precision floating point reading and writing functions.</TD>
  78. </TR>
  79. <TR>
  80. <TD><A HREF="#SFC_GET_NORM_FLOAT">SFC_GET_NORM_FLOAT</A></TD>
  81. <TD>Retrieve the current normalisation behaviour of the floating point reading and writing functions.</TD>
  82. </TR>
  83. <TR>
  84. <TD><A HREF="#SFC_GET_NORM_DOUBLE">SFC_GET_NORM_DOUBLE</A></TD>
  85. <TD>Retrieve the current normalisation behaviour of the double precision floating point reading and writing functions.</TD>
  86. </TR>
  87. <TR>
  88. <TD><A HREF="#SFC_SET_SCALE_FLOAT_INT_READ">SFC_SET_SCALE_FLOAT_INT_READ</A></TD>
  89. <TD>Set/clear the scale factor when integer (short/int) data is read from a file
  90. containing floating point data.</TD>
  91. </TR>
  92. <TR>
  93. <TD><A HREF="#SFC_SET_SCALE_INT_FLOAT_WRITE">SFC_SET_SCALE_INT_FLOAT_WRITE</A></TD>
  94. <TD>Set/clear the scale factor when integer (short/int) data is written to a file
  95. as floating point data.</TD>
  96. </TR>
  97. <TR>
  98. <TD><A HREF="#SFC_GET_SIMPLE_FORMAT_COUNT">SFC_GET_SIMPLE_FORMAT_COUNT</A></TD>
  99. <TD>Retrieve the number of simple formats supported by libsndfile.</TD>
  100. </TR>
  101. <TR>
  102. <TD><A HREF="#SFC_GET_SIMPLE_FORMAT">SFC_GET_SIMPLE_FORMAT</A></TD>
  103. <TD>Retrieve information about a simple format.</TD>
  104. </TR>
  105. <TR>
  106. <TD><A HREF="#SFC_GET_FORMAT_INFO">SFC_GET_FORMAT_INFO</A></TD>
  107. <TD>Retrieve information about a major or subtype format.</TD>
  108. </TR>
  109. <TR>
  110. <TD><A HREF="#SFC_GET_FORMAT_MAJOR_COUNT">SFC_GET_FORMAT_MAJOR_COUNT</A></TD>
  111. <TD>Retrieve the number of major formats.</TD>
  112. </TR>
  113. <TR>
  114. <TD><A HREF="#SFC_GET_FORMAT_MAJOR">SFC_GET_FORMAT_MAJOR</A></TD>
  115. <TD>Retrieve information about a major format type.</TD>
  116. </TR>
  117. <TR>
  118. <TD><A HREF="#SFC_GET_FORMAT_SUBTYPE_COUNT">SFC_GET_FORMAT_SUBTYPE_COUNT</A></TD>
  119. <TD>Retrieve the number of subformats.</TD>
  120. </TR>
  121. <TR>
  122. <TD><A HREF="#SFC_GET_FORMAT_SUBTYPE">SFC_GET_FORMAT_SUBTYPE</A></TD>
  123. <TD>Retrieve information about a subformat.</TD>
  124. </TR>
  125. <TR>
  126. <TD><A HREF="#SFC_SET_ADD_PEAK_CHUNK">SFC_SET_ADD_PEAK_CHUNK</A></TD>
  127. <TD>Switch the code for adding the PEAK chunk to WAV and AIFF files on or off.</TD>
  128. </TR>
  129. <TR>
  130. <TD><A HREF="#SFC_UPDATE_HEADER_NOW">SFC_UPDATE_HEADER_NOW</A></TD>
  131. <TD>Used when a file is open for write, this command will update the file
  132. header to reflect the data written so far.</TD>
  133. </TR>
  134. <TR>
  135. <TD><A HREF="#SFC_SET_UPDATE_HEADER_AUTO">SFC_SET_UPDATE_HEADER_AUTO</A></TD>
  136. <TD>Used when a file is open for write, this command will cause the file header
  137. to be updated after each write to the file.</TD>
  138. </TR>
  139. <TR>
  140. <TD><A HREF="#SFC_FILE_TRUNCATE">SFC_FILE_TRUNCATE</A></TD>
  141. <TD>Truncate a file open for write or for read/write.</TD>
  142. </TR>
  143. <TR>
  144. <TD><A HREF="#SFC_SET_RAW_START_OFFSET">SFC_SET_RAW_START_OFFSET</A></TD>
  145. <TD>Change the data start offset for files opened up as SF_FORMAT_RAW.</TD>
  146. </TR>
  147. <TR>
  148. <TD><A HREF="#SFC_SET_CLIPPING">SFC_SET_CLIPPING</A></TD>
  149. <TD>Turn on/off automatic clipping when doing floating point to integer
  150. conversion.</TD>
  151. </TR>
  152. <TR>
  153. <TD><A HREF="#SFC_GET_CLIPPING">SFC_GET_CLIPPING</A></TD>
  154. <TD>Retrieve current clipping setting.</TD>
  155. </TR>
  156. <TR>
  157. <TD><A HREF="#SFC_GET_EMBED_FILE_INFO">SFC_GET_EMBED_FILE_INFO</A></TD>
  158. <TD>Retrieve information about audio files embedded inside other files.</TD>
  159. </TR>
  160. <TR>
  161. <TD><A HREF="#SFC_WAVEX_GET_AMBISONIC">SFC_GET_AMBISONIC</A></TD>
  162. <TD>Test a WAVEX file for Ambisonic format</TD>
  163. </TR>
  164. <TR>
  165. <TD><A HREF="#SFC_WAVEX_SET_AMBISONIC">SFC_SET_AMBISONIC</A></TD>
  166. <TD>Modify a WAVEX header for Ambisonic format</TD>
  167. </TR>
  168. <TR>
  169. <TD><A HREF="#SFC_SET_VBR_ENCODING_QUALITY">SFC_SET_VBR_ENCODING_QUALITY</A></TD>
  170. <TD>Set the Variable Bit Rate encoding quality</TD>
  171. </TR>
  172. <TR>
  173. <TD><A HREF="#SFC_SET_COMPRESSION_LEVEL">SFC_SET_COMPRESSION_LEVEL</A></TD>
  174. <TD>Set the compression level.</TD>
  175. </TR>
  176. <TR>
  177. <TD><A HREF="#SFC_RAW_NEEDS_ENDSWAP">SFC_RAW_NEEDS_ENDSWAP</a></td>
  178. <TD>Determine if raw data needs endswapping</TD>
  179. </TR>
  180. <TR>
  181. <TD><A HREF="#SFC_GET_BROADCAST_INFO">SFC_GET_BROADCAST_INFO</A></TD>
  182. <TD>Retrieve the Broadcast Chunk info</TD>
  183. </TR>
  184. <TR>
  185. <TD><A HREF="#SFC_SET_BROADCAST_INFO">SFC_SET_BROADCAST_INFO</A></TD>
  186. <TD>Set the Broadcast Chunk info</TD>
  187. </TR>
  188. <TR>
  189. <TD><A HREF="#SFC_SET_CART_INFO">SFC_SET_CART_INFO</A></TD>
  190. <TD>Set the Cart Chunk info</TD>
  191. </TR>
  192. <TR>
  193. <TD><A HREF="#SFC_GET_CART_INFO">SFC_GET_CART_INFO</A></TD>
  194. <TD>Retrieve the Cart Chunk info</TD>
  195. </TR>
  196. <TR>
  197. <TD><A HREF="#SFC_GET_LOOP_INFO">SFC_GET_LOOP_INFO</A></TD>
  198. <TD>Get loop info</TD>
  199. </TR>
  200. <TR>
  201. <TD><A HREF="#SFC_GET_INSTRUMENT">SFC_GET_INSTRUMENT</A></TD>
  202. <TD>Get instrument info</TD>
  203. </TR>
  204. <TR>
  205. <TD><A HREF="#SFC_SET_INSTRUMENT">SFC_SET_INSTRUMENT</A></TD>
  206. <TD>Set instrument info</TD>
  207. </TR>
  208. <!--
  209. <TR>
  210. <TD><A HREF="#add-dither">add dither</A></TD>
  211. <TD>Add dither to output on write.</TD>
  212. </TR>
  213. -->
  214. </TABLE>
  215. </CENTER>
  216. <BR><BR>
  217. <HR>
  218. <!-- ========================================================================= -->
  219. <A NAME="SFC_GET_LIB_VERSION"></A>
  220. <H2><BR><B>SFC_GET_LIB_VERSION</B></H2>
  221. <P>
  222. Retrieve the version of the library as a string.
  223. </P>
  224. <P>
  225. Parameters:
  226. <PRE>
  227. sndfile : Not used
  228. cmd : SFC_GET_LIB_VERSION
  229. data : A pointer to a char buffer
  230. datasize : The size of the the buffer
  231. </PRE>
  232. <P>
  233. Example:
  234. </P>
  235. <PRE>
  236. char buffer [128] ;
  237. sf_command (NULL, SFC_GET_LIB_VERSION, buffer, sizeof (buffer)) ;
  238. </PRE>
  239. <DL>
  240. <DT>Return value:</DT>
  241. <DD><DD>This call will return the length of the retrieved version string.
  242. </DL>
  243. <DL>
  244. <DT>Notes:</DT>
  245. <DD>
  246. The string returned in the buffer passed to this function will not overflow
  247. the buffer and will always be null terminated .
  248. </DL>
  249. <!-- ========================================================================= -->
  250. <A NAME="SFC_GET_LOG_INFO"></A>
  251. <H2><BR><B>SFC_GET_LOG_INFO</B></H2>
  252. <P>
  253. Retrieve the log buffer generated when opening a file as a string. This log
  254. buffer can often contain a good reason for why libsndfile failed to open a
  255. particular file.
  256. </P>
  257. <P>
  258. Parameters:
  259. <PRE>
  260. sndfile : A valid SNDFILE* pointer
  261. cmd : SFC_GET_LOG_INFO
  262. data : A pointer to a char buffer
  263. datasize : The size of the the buffer
  264. </PRE>
  265. <P>
  266. Example:
  267. </P>
  268. <PRE>
  269. char buffer [2048] ;
  270. sf_command (sndfile, SFC_GET_LOG_INFO, buffer, sizeof (buffer)) ;
  271. </PRE>
  272. <DL>
  273. <DT>Return value:</DT>
  274. <DD><DD>This call will return the length of the retrieved version string.
  275. </DL>
  276. <DL>
  277. <DT>Notes:</DT>
  278. <DD>
  279. The string returned in the buffer passed to this function will not overflow
  280. the buffer and will always be null terminated .
  281. </DL>
  282. <!-- ========================================================================= -->
  283. <A NAME="SFC_CALC_SIGNAL_MAX"></A>
  284. <H2><BR><B>SFC_CALC_SIGNAL_MAX</B></H2>
  285. <P>
  286. Retrieve the measured maximum signal value. This involves reading through
  287. the whole file which can be slow on large files.
  288. </P>
  289. <P>
  290. Parameters:
  291. <PRE>
  292. sndfile : A valid SNDFILE* pointer
  293. cmd : SFC_CALC_SIGNAL_MAX
  294. data : A pointer to a double
  295. datasize : sizeof (double)
  296. </PRE>
  297. <P>
  298. Example:
  299. </P>
  300. <PRE>
  301. double max_val ;
  302. sf_command (sndfile, SFC_CALC_SIGNAL_MAX, &amp;max_val, sizeof (max_val)) ;
  303. </PRE>
  304. <DL>
  305. <DT>Return value:</DT>
  306. <DD><DD>Zero on success, non-zero otherwise.
  307. </DL>
  308. <!-- ========================================================================= -->
  309. <A NAME="SFC_CALC_NORM_SIGNAL_MAX"></A>
  310. <H2><BR><B>SFC_CALC_NORM_SIGNAL_MAX</B></H2>
  311. <P>
  312. Retrieve the measured normalised maximum signal value. This involves reading
  313. through the whole file which can be slow on large files.
  314. </P>
  315. <P>
  316. Parameters:
  317. <PRE>
  318. sndfile : A valid SNDFILE* pointer
  319. cmd : SFC_CALC_NORM_SIGNAL_MAX
  320. data : A pointer to a double
  321. datasize : sizeof (double)
  322. </PRE>
  323. <P>
  324. Example:
  325. </P>
  326. <PRE>
  327. double max_val ;
  328. sf_command (sndfile, SFC_CALC_NORM_SIGNAL_MAX, &amp;max_val, sizeof (max_val)) ;
  329. </PRE>
  330. <DL>
  331. <DT>Return value:</DT>
  332. <DD><DD>Zero on success, non-zero otherwise.
  333. </DL>
  334. <!-- ========================================================================= -->
  335. <A NAME="SFC_CALC_MAX_ALL_CHANNELS"></A>
  336. <H2><BR><B>SFC_CALC_MAX_ALL_CHANNELS</B></H2>
  337. <P>
  338. Calculate the peak value (ie a single number) for each channel.
  339. This involves reading through the whole file which can be slow on large files.
  340. </P>
  341. <P>
  342. Parameters:
  343. <PRE>
  344. sndfile : A valid SNDFILE* pointer
  345. cmd : SFC_CALC_MAX_ALL_CHANNELS
  346. data : A pointer to a double
  347. datasize : sizeof (double) * number_of_channels
  348. </PRE>
  349. <P>
  350. Example:
  351. </P>
  352. <PRE>
  353. double peaks [number_of_channels] ;
  354. sf_command (sndfile, SFC_CALC_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
  355. </PRE>
  356. <DL>
  357. <DT>Return value:</DT>
  358. <DD>Zero if peaks have been calculated successfully and non-zero otherwise.
  359. </DL>
  360. <!-- ========================================================================= -->
  361. <A NAME="SFC_CALC_NORM_MAX_ALL_CHANNELS"></A>
  362. <H2><BR><B>SFC_CALC_NORM_MAX_ALL_CHANNELS</B></H2>
  363. <P>
  364. Calculate the normalised peak for each channel.
  365. This involves reading through the whole file which can be slow on large files.
  366. </P>
  367. <P>
  368. Parameters:
  369. <PRE>
  370. sndfile : A valid SNDFILE* pointer
  371. cmd : SFC_CALC_NORM_MAX_ALL_CHANNELS
  372. data : A pointer to a double
  373. datasize : sizeof (double) * number_of_channels
  374. </PRE>
  375. <P>
  376. Example:
  377. </P>
  378. <PRE>
  379. double peaks [number_of_channels] ;
  380. sf_command (sndfile, SFC_CALC_NORM_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
  381. </PRE>
  382. <DL>
  383. <DT>Return value:</DT>
  384. <DD>Zero if peaks have been calculated successfully and non-zero otherwise.
  385. </DL>
  386. <!-- ========================================================================= -->
  387. <A NAME="SFC_GET_SIGNAL_MAX"></A>
  388. <H2><BR><B>SFC_GET_SIGNAL_MAX</B></H2>
  389. <P>
  390. Retrieve the peak value for the file as stored in the file header.
  391. </P>
  392. <P>
  393. Parameters:
  394. <PRE>
  395. sndfile : A valid SNDFILE* pointer
  396. cmd : SFC_GET_SIGNAL_MAX
  397. data : A pointer to a double
  398. datasize : sizeof (double)
  399. </PRE>
  400. <P>
  401. Example:
  402. </P>
  403. <PRE>
  404. double max_peak ;
  405. sf_command (sndfile, SFC_GET_SIGNAL_MAX, &amp;max_peak, sizeof (max_peak)) ;
  406. </PRE>
  407. <DL>
  408. <DT>Return value:</DT>
  409. <DD>SF_TRUE if the file header contained the peak value. SF_FALSE otherwise.
  410. </DL>
  411. <!-- ========================================================================= -->
  412. <A NAME="SFC_GET_MAX_ALL_CHANNELS"></A>
  413. <H2><BR><B>SFC_GET_MAX_ALL_CHANNELS</B></H2>
  414. <P>
  415. Retrieve the peak value for the file as stored in the file header.
  416. </P>
  417. <P>
  418. Parameters:
  419. <PRE>
  420. sndfile : A valid SNDFILE* pointer
  421. cmd : SFC_GET_SIGNAL_MAX
  422. data : A pointer to an array of doubles
  423. datasize : sizeof (double) * number_of_channels
  424. </PRE>
  425. <P>
  426. Example:
  427. </P>
  428. <PRE>
  429. double peaks [number_of_channels] ;
  430. sf_command (sndfile, SFC_GET_MAX_ALL_CHANNELS, peaks, sizeof (peaks)) ;
  431. </PRE>
  432. <DL>
  433. <DT>Return value:</DT>
  434. <DD>SF_TRUE if the file header contains per channel peak values for the file.
  435. SF_FALSE otherwise.
  436. </DL>
  437. <!-- ========================================================================= -->
  438. <A NAME="SFC_SET_NORM_FLOAT"></A>
  439. <H2><BR><B>SFC_SET_NORM_FLOAT</B></H2>
  440. <P>
  441. This command only affects data read from or written to using the floating point functions:
  442. </P>
  443. <PRE>
  444. size_t <A HREF="api.html#read">sf_read_float</A> (SNDFILE *sndfile, float *ptr, size_t items) ;
  445. size_t <A HREF="api.html#readf">sf_readf_float</A> (SNDFILE *sndfile, float *ptr, size_t frames) ;
  446. size_t <A HREF="api.html#write">sf_write_float</A> (SNDFILE *sndfile, float *ptr, size_t items) ;
  447. size_t <A HREF="api.html#writef">sf_writef_float</A> (SNDFILE *sndfile, float *ptr, size_t frames) ;
  448. </PRE>
  449. <P>
  450. Parameters:
  451. </P>
  452. <PRE>
  453. sndfile : A valid SNDFILE* pointer
  454. cmd : SFC_SET_NORM_FLOAT
  455. data : NULL
  456. datasize : SF_TRUE or SF_FALSE
  457. </PRE>
  458. <P>
  459. For read operations setting normalisation to SF_TRUE means that the data from all
  460. subsequent reads will be be normalised to the range [-1.0, 1.0].
  461. </P>
  462. <P>
  463. For write operations, setting normalisation to SF_TRUE means than all data supplied
  464. to the float write functions should be in the range [-1.0, 1.0] and will be scaled
  465. for the file format as necessary.
  466. </P>
  467. <P>
  468. For both cases, setting normalisation to SF_FALSE means that no scaling will take place.
  469. </P>
  470. <P>
  471. Example:
  472. </P>
  473. <PRE>
  474. sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_TRUE) ;
  475. sf_command (sndfile, SFC_SET_NORM_FLOAT, NULL, SF_FALSE) ;
  476. </PRE>
  477. <DL>
  478. <DT>Return value: </DT>
  479. <DD>Returns the previous float normalisation mode.
  480. </DL>
  481. <!-- ========================================================================= -->
  482. <A NAME="SFC_SET_NORM_DOUBLE"></A>
  483. <H2><BR><B>SFC_SET_NORM_DOUBLE</B></H2>
  484. <P>
  485. This command only affects data read from or written to using the double precision
  486. floating point functions:
  487. </P>
  488. <PRE>
  489. size_t <A HREF="api.html#read">sf_read_double</A> (SNDFILE *sndfile, double *ptr, size_t items) ;
  490. size_t <A HREF="api.html#readf">sf_readf_double</A> (SNDFILE *sndfile, double *ptr, size_t frames) ;
  491. size_t <A HREF="api.html#write">sf_write_double</A> (SNDFILE *sndfile, double *ptr, size_t items) ;
  492. size_t <A HREF="api.html#writef">sf_writef_double</A> (SNDFILE *sndfile, double *ptr, size_t frames) ;
  493. </PRE>
  494. <P>
  495. Parameters:
  496. </P>
  497. <PRE>
  498. sndfile : A valid SNDFILE* pointer
  499. cmd : SFC_SET_NORM_DOUBLE
  500. data : NULL
  501. datasize : SF_TRUE or SF_FALSE
  502. </PRE>
  503. <P>
  504. For read operations setting normalisation to SF_TRUE means that the data
  505. from all subsequent reads will be be normalised to the range [-1.0, 1.0].
  506. </P>
  507. <P>
  508. For write operations, setting normalisation to SF_TRUE means than all data supplied
  509. to the double write functions should be in the range [-1.0, 1.0] and will be scaled
  510. for the file format as necessary.
  511. </P>
  512. <P>
  513. For both cases, setting normalisation to SF_FALSE means that no scaling will take place.
  514. </P>
  515. <P>
  516. Example:
  517. </P>
  518. <PRE>
  519. sf_command (sndfile, SFC_SET_NORM_DOUBLE, NULL, SF_TRUE) ;
  520. sf_command (sndfile, SFC_SET_NORM_DOUBLE, NULL, SF_FALSE) ;
  521. </PRE>
  522. <DL>
  523. <DT>Return value: </DT>
  524. <DD>Returns the previous double normalisation mode.
  525. </DL>
  526. <!-- ========================================================================= -->
  527. <A NAME="SFC_GET_NORM_FLOAT"></A>
  528. <H2><BR><B>SFC_GET_NORM_FLOAT</B></H2>
  529. <P>
  530. Retrieve the current float normalisation mode.
  531. </P>
  532. <P>
  533. Parameters:
  534. </P>
  535. <PRE>
  536. sndfile : A valid SNDFILE* pointer
  537. cmd : SFC_GET_NORM_FLOAT
  538. data : NULL
  539. datasize : anything
  540. </PRE>
  541. <P>
  542. Example:
  543. </P>
  544. <PRE>
  545. normalisation = sf_command (sndfile, SFC_GET_NORM_FLOAT, NULL, 0) ;
  546. </PRE>
  547. <DL>
  548. <DT>Return value: </DT>
  549. <DD>Returns TRUE if normalisation is on and FALSE otherwise.
  550. </DL>
  551. <!-- ========================================================================= -->
  552. <A NAME="SFC_GET_NORM_DOUBLE"></A>
  553. <H2><BR><B>SFC_GET_NORM_DOUBLE</B></H2>
  554. <P>
  555. Retrieve the current float normalisation mode.
  556. </P>
  557. <P>
  558. Parameters:
  559. </P>
  560. <PRE>
  561. sndfile : A valid SNDFILE* pointer
  562. cmd : SFC_GET_NORM_DOUBLE
  563. data : NULL
  564. datasize : anything
  565. </PRE>
  566. <P>
  567. Example:
  568. </P>
  569. <PRE>
  570. normalisation = sf_command (sndfile, SFC_GET_NORM_DOUBLE, NULL, 0) ;
  571. </PRE>
  572. <DL>
  573. <DT>Return value: </DT>
  574. <DD>Returns TRUE if normalisation is on and FALSE otherwise.
  575. </DL>
  576. <!-- ========================================================================= -->
  577. <A NAME="SFC_SET_SCALE_FLOAT_INT_READ"></A>
  578. <H2><BR><B>SFC_SET_SCALE_FLOAT_INT_READ</B></H2>
  579. <P>
  580. Set/clear the scale factor when integer (short/int) data is read from a file
  581. containing floating point data.
  582. </P>
  583. <P>
  584. Parameters:
  585. </P>
  586. <PRE>
  587. sndfile : A valid SNDFILE* pointer
  588. cmd : SFC_SET_SCALE_FLOAT_INT_READ
  589. data : NULL
  590. datasize : TRUE or FALSE
  591. </PRE>
  592. <P>
  593. Example:
  594. </P>
  595. <PRE>
  596. sf_command (sndfile, SFC_SET_SCALE_FLOAT_INT_READ, NULL, SF_TRUE) ;
  597. </PRE>
  598. <DL>
  599. <DT>Return value: </DT>
  600. <DD>Returns the previous SFC_SET_SCALE_FLOAT_INT_READ setting for this file.
  601. </DL>
  602. <!-- ========================================================================= -->
  603. <A NAME="SFC_SET_SCALE_INT_FLOAT_WRITE"></A>
  604. <H2><BR><B>SFC_SET_SCALE_INT_FLOAT_WRITE</B></H2>
  605. <P>
  606. Set/clear the scale factor when integer (short/int) data is written to a file
  607. as floating point data.
  608. </P>
  609. <P>
  610. Parameters:
  611. </P>
  612. <PRE>
  613. sndfile : A valid SNDFILE* pointer
  614. cmd : SFC_SET_SCALE_FLOAT_INT_READ
  615. data : NULL
  616. datasize : TRUE or FALSE
  617. </PRE>
  618. <P>
  619. Example:
  620. </P>
  621. <PRE>
  622. sf_command (sndfile, SFC_SET_SCALE_INT_FLOAT_WRITE, NULL, SF_TRUE) ;
  623. </PRE>
  624. <DL>
  625. <DT>Return value: </DT>
  626. <DD>Returns the previous SFC_SET_SCALE_INT_FLOAT_WRITE setting for this file.
  627. </DL>
  628. <!-- ========================================================================= -->
  629. <A NAME="SFC_GET_SIMPLE_FORMAT_COUNT"></A>
  630. <H2><BR><B>SFC_GET_SIMPLE_FORMAT_COUNT</B></H2>
  631. <P>
  632. Retrieve the number of simple formats supported by libsndfile.
  633. </P>
  634. <P>
  635. Parameters:
  636. </P>
  637. <PRE>
  638. sndfile : Not used.
  639. cmd : SFC_GET_SIMPLE_FORMAT_COUNT
  640. data : a pointer to an int
  641. datasize : sizeof (int)
  642. </PRE>
  643. <P>
  644. Example:
  645. </P>
  646. <PRE>
  647. int count ;
  648. sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &amp;count, sizeof (int)) ;
  649. </PRE>
  650. <DL>
  651. <DT>Return value: </DT>
  652. <DD>0
  653. </DL>
  654. <!-- ========================================================================= -->
  655. <A NAME="SFC_GET_SIMPLE_FORMAT"></A>
  656. <H2><BR><B>SFC_GET_SIMPLE_FORMAT</B></H2>
  657. <P>
  658. Retrieve information about a simple format.
  659. </P>
  660. <P>
  661. Parameters:
  662. </P>
  663. <PRE>
  664. sndfile : Not used.
  665. cmd : SFC_GET_SIMPLE_FORMAT
  666. data : a pointer to an SF_FORMAT_INFO struct
  667. datasize : sizeof (SF_FORMAT_INFO)
  668. </PRE>
  669. <P>
  670. The SF_FORMAT_INFO struct is defined in &lt;sndfile.h&gt; as:
  671. </P>
  672. <PRE>
  673. typedef struct
  674. { int format ;
  675. const char *name ;
  676. const char *extension ;
  677. } SF_FORMAT_INFO ;
  678. </PRE>
  679. <P>
  680. When sf_command() is called with SF_GET_SIMPLE_FORMAT, the value of the format
  681. field should be the format number (ie 0 &lt;= format &lt;= count value obtained using
  682. SF_GET_SIMPLE_FORMAT_COUNT).
  683. </P>
  684. <P>
  685. Example:
  686. </P>
  687. <PRE>
  688. SF_FORMAT_INFO format_info ;
  689. int k, count ;
  690. sf_command (sndfile, SFC_GET_SIMPLE_FORMAT_COUNT, &amp;count, sizeof (int)) ;
  691. for (k = 0 ; k &lt; count ; k++)
  692. { format_info.format = k ;
  693. sf_command (sndfile, SFC_GET_SIMPLE_FORMAT, &amp;format_info, sizeof (format_info)) ;
  694. printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
  695. } ;
  696. </PRE>
  697. <DL>
  698. <DT>Return value: </DT>
  699. <DD>0 on success and non-zero otherwise.
  700. <DD>The value of the format field of the SF_FORMAT_INFO struct will be a value which
  701. can be placed in the format field of an SF_INFO struct when a file is to be opened
  702. for write.
  703. <DD>The name field will contain a char* pointer to the name of the string, eg. "WAV (Microsoft 16 bit PCM)".
  704. <DD>The extension field will contain the most commonly used file extension for that file type.
  705. </DL>
  706. <!-- ========================================================================= -->
  707. <A NAME="SFC_GET_FORMAT_INFO"></A>
  708. <H2><BR><B>SFC_GET_FORMAT_INFO</B></H2>
  709. <P>
  710. Retrieve information about a major or subtype format.
  711. </P>
  712. <P>
  713. Parameters:
  714. </P>
  715. <PRE>
  716. sndfile : Not used.
  717. cmd : SFC_GET_FORMAT_INFO
  718. data : a pointer to an SF_FORMAT_INFO struct
  719. datasize : sizeof (SF_FORMAT_INFO)
  720. </PRE>
  721. <P>
  722. The SF_FORMAT_INFO struct is defined in &lt;sndfile.h&gt; as:
  723. </P>
  724. <PRE>
  725. typedef struct
  726. { int format ;
  727. const char *name ;
  728. const char *extension ;
  729. } SF_FORMAT_INFO ;
  730. </PRE>
  731. <P>
  732. When sf_command() is called with SF_GET_FORMAT_INFO, the format field is
  733. examined and if (format &amp; SF_FORMAT_TYPEMASK) is a valid format then the struct
  734. is filled in with information about the given major type.
  735. If (format &amp; SF_FORMAT_TYPEMASK) is FALSE and (format &amp; SF_FORMAT_SUBMASK) is a
  736. valid subtype format then the struct is filled in with information about the given
  737. subtype.
  738. </P>
  739. <P>
  740. Example:
  741. </P>
  742. <PRE>
  743. SF_FORMAT_INFO format_info ;
  744. format_info.format = SF_FORMAT_WAV ;
  745. sf_command (sndfile, SFC_GET_FORMAT_INFO, &amp;format_info, sizeof (format_info)) ;
  746. printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
  747. format_info.format = SF_FORMAT_ULAW ;
  748. sf_command (sndfile, SFC_GET_FORMAT_INFO, &amp;format_info, sizeof (format_info)) ;
  749. printf ("%08x %s\n", format_info.format, format_info.name) ;
  750. </PRE>
  751. <DL>
  752. <DT>Return value: </DT>
  753. <DD>0 on success and non-zero otherwise.
  754. </DL>
  755. <!-- ========================================================================= -->
  756. <A NAME="SFC_GET_FORMAT_MAJOR_COUNT"></A>
  757. <H2><BR><B>SFC_GET_FORMAT_MAJOR_COUNT</B></H2>
  758. <P>
  759. Retrieve the number of major formats.
  760. </P>
  761. <P>
  762. Parameters:
  763. </P>
  764. <PRE>
  765. sndfile : Not used.
  766. cmd : SFC_GET_FORMAT_MAJOR_COUNT
  767. data : a pointer to an int
  768. datasize : sizeof (int)
  769. </PRE>
  770. <P>
  771. Example:
  772. </P>
  773. <PRE>
  774. int count ;
  775. sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &amp;count, sizeof (int)) ;
  776. </PRE>
  777. <DL>
  778. <DT>Return value: </DT>
  779. <DD>0
  780. </DL>
  781. <!-- ========================================================================= -->
  782. <A NAME="SFC_GET_FORMAT_MAJOR"></A>
  783. <H2><BR><B>SFC_GET_FORMAT_MAJOR</B></H2>
  784. <P>
  785. Retrieve information about a major format type.
  786. </P>
  787. <P>
  788. Parameters:
  789. </P>
  790. <PRE>
  791. sndfile : Not used.
  792. cmd : SFC_GET_FORMAT_MAJOR
  793. data : a pointer to an SF_FORMAT_INFO struct
  794. datasize : sizeof (SF_FORMAT_INFO)
  795. </PRE>
  796. <P>
  797. Example:
  798. </P>
  799. <PRE>
  800. SF_FORMAT_INFO format_info ;
  801. int k, count ;
  802. sf_command (sndfile, SFC_GET_FORMAT_MAJOR_COUNT, &amp;count, sizeof (int)) ;
  803. for (k = 0 ; k &lt; count ; k++)
  804. { format_info.format = k ;
  805. sf_command (sndfile, SFC_GET_FORMAT_MAJOR, &amp;format_info, sizeof (format_info)) ;
  806. printf ("%08x %s %s\n", format_info.format, format_info.name, format_info.extension) ;
  807. } ;
  808. </PRE>
  809. <P>
  810. For a more comprehensive example, see the program list_formats.c in the examples/
  811. directory of the libsndfile source code distribution.
  812. </P>
  813. <DL>
  814. <DT>Return value: </DT>
  815. <DD>0 on success and non-zero otherwise.
  816. <DD>The value of the format field will be one of the major format identifiers such as
  817. SF_FORMAT_WAV or SF_FORMAT_AIFF.
  818. <DD>The name field will contain a char* pointer to the name of the string, eg. "WAV (Microsoft)".
  819. <DD>The extension field will contain the most commonly used file extension for that file type.
  820. </DL>
  821. <!-- ========================================================================= -->
  822. <A NAME="SFC_GET_FORMAT_SUBTYPE_COUNT"></A>
  823. <H2><BR><B>SFC_GET_FORMAT_SUBTYPE_COUNT</B></H2>
  824. <P>
  825. Retrieve the number of subformats.
  826. </P>
  827. <P>
  828. Parameters:
  829. </P>
  830. <PRE>
  831. sndfile : Not used.
  832. cmd : SFC_GET_FORMAT_SUBTYPE_COUNT
  833. data : a pointer to an int
  834. datasize : sizeof (int)
  835. </PRE>
  836. <P>
  837. Example:
  838. </P>
  839. <PRE>
  840. int count ;
  841. sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &amp;count, sizeof (int)) ;
  842. </PRE>
  843. <DL>
  844. <DT>Return value: </DT>
  845. <DD>0
  846. </DL>
  847. <!-- ========================================================================= -->
  848. <A NAME="SFC_GET_FORMAT_SUBTYPE"></A>
  849. <H2><BR><B>SFC_GET_FORMAT_SUBTYPE</B></H2>
  850. <P>
  851. Enumerate the subtypes (this function does not translate a subtype into
  852. a string describing that subtype).
  853. A typical use case might be retrieving a string description of all subtypes
  854. so that a dialog box can be filled in.
  855. </P>
  856. <P>
  857. </P>
  858. <P>
  859. Parameters:
  860. </P>
  861. <PRE>
  862. sndfile : Not used.
  863. cmd : SFC_GET_FORMAT_SUBTYPE
  864. data : a pointer to an SF_FORMAT_INFO struct
  865. datasize : sizeof (SF_FORMAT_INFO)
  866. </PRE>
  867. <P>
  868. Example 1: Retrieve all sybtypes supported by the WAV format.
  869. </P>
  870. <PRE>
  871. SF_FORMAT_INFO format_info ;
  872. int k, count ;
  873. sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &amp;count, sizeof (int)) ;
  874. for (k = 0 ; k &lt; count ; k++)
  875. { format_info.format = k ;
  876. sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &amp;format_info, sizeof (format_info)) ;
  877. if (! sf_format_check (format_info.format | SF_FORMAT_WAV))
  878. continue ;
  879. printf ("%08x %s\n", format_info.format, format_info.name) ;
  880. } ;
  881. </PRE>
  882. <P>
  883. Example 2: Print a string describing the SF_FORMAT_PCM_16 subtype.
  884. </P>
  885. <PRE>
  886. SF_FORMAT_INFO format_info ;
  887. int k, count ;
  888. sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE_COUNT, &amp;count, sizeof (int)) ;
  889. for (k = 0 ; k &lt; count ; k++)
  890. { format_info.format = k ;
  891. sf_command (sndfile, SFC_GET_FORMAT_SUBTYPE, &amp;format_info, sizeof (format_info)) ;
  892. if (format_info.format == SF_FORMAT_PCM_16)
  893. { printf ("%08x %s\n", format_info.format, format_info.name) ;
  894. break ;
  895. } ;
  896. } ;
  897. </PRE>
  898. <P>
  899. For a more comprehensive example, see the program list_formats.c in the examples/
  900. directory of the libsndfile source code distribution.
  901. </P>
  902. <DL>
  903. <DT>Return value: </DT>
  904. <DD>0 on success and non-zero otherwise.
  905. <DD>The value of the format field will be one of the major format identifiers such as
  906. SF_FORMAT_WAV or SF_FORMAT_AIFF.
  907. <DD>The name field will contain a char* pointer to the name of the string; for instance
  908. "WAV (Microsoft)" or "AIFF (Apple/SGI)".
  909. <DD>The extension field will be a NULL pointer.
  910. </DL>
  911. <!-- ========================================================================= -->
  912. <A NAME="SFC_SET_ADD_PEAK_CHUNK"></A>
  913. <H2><BR><B>SFC_SET_ADD_PEAK_CHUNK</B></H2>
  914. <P>
  915. By default, WAV and AIFF files which contain floating point data (subtype SF_FORMAT_FLOAT
  916. or SF_FORMAT_DOUBLE) have a PEAK chunk.
  917. By using this command, the addition of a PEAK chunk can be turned on or off.
  918. </P>
  919. <P>
  920. Note : This call must be made before any data is written to the file.
  921. </P>
  922. <P>
  923. Parameters:
  924. <PRE>
  925. sndfile : A valid SNDFILE* pointer
  926. cmd : SFC_SET_ADD_PEAK_CHUNK
  927. data : Not used (should be NULL)
  928. datasize : TRUE or FALSE.
  929. </PRE>
  930. <P>
  931. Example:
  932. </P>
  933. <PRE>
  934. /* Turn on the PEAK chunk. */
  935. sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_TRUE) ;
  936. /* Turn off the PEAK chunk. */
  937. sf_command (sndfile, SFC_SET_ADD_PEAK_CHUNK, NULL, SF_FALSE) ;
  938. </PRE>
  939. <DL>
  940. <DT>Return value:</DT>
  941. <DD>Returns SF_TRUE if the peak chunk will be written after this call.
  942. <DD>Returns SF_FALSE if the peak chunk will not be written after this call.
  943. </DL>
  944. <!-- ========================================================================= -->
  945. <A NAME="SFC_UPDATE_HEADER_NOW"></A>
  946. <H2><BR><B>SFC_UPDATE_HEADER_NOW</B></H2>
  947. <P>
  948. The header of an audio file is normally written by libsndfile when the file is
  949. closed using <B>sf_close()</B>.
  950. </P>
  951. <P>
  952. There are however situations where large files are being generated and it would
  953. be nice to have valid data in the header before the file is complete.
  954. Using this command will update the file header to reflect the amount of data written
  955. to the file so far.
  956. Other programs opening the file for read (before any more data is written) will
  957. then read a valid sound file header.
  958. </P>
  959. <P>
  960. Parameters:
  961. <PRE>
  962. sndfile : A valid SNDFILE* pointer
  963. cmd : SFC_UPDATE_HEADER_NOW
  964. data : Not used (should be NULL)
  965. datasize : Not used.
  966. </PRE>
  967. <P>
  968. Example:
  969. </P>
  970. <PRE>
  971. /* Update the header now. */
  972. sf_command (sndfile, SFC_UPDATE_HEADER_NOW, NULL, 0) ;
  973. </PRE>
  974. <DL>
  975. <DT>Return value:</DT>
  976. <DD>0
  977. </DL>
  978. <!-- ========================================================================= -->
  979. <A NAME="SFC_SET_UPDATE_HEADER_AUTO"></A>
  980. <H2><BR><B>SFC_SET_UPDATE_HEADER_AUTO</B></H2>
  981. <P>
  982. Similar to SFC_UPDATE_HEADER_NOW but updates the header at the end of every call
  983. to the <B>sf_write*</B> functions.
  984. </P>
  985. <P>
  986. Parameters:
  987. <PRE>
  988. sndfile : A valid SNDFILE* pointer
  989. cmd : SFC_UPDATE_HEADER_NOW
  990. data : Not used (should be NULL)
  991. datasize : SF_TRUE or SF_FALSE
  992. </PRE>
  993. <P>
  994. Example:
  995. </P>
  996. <PRE>
  997. /* Turn on auto header update. */
  998. sf_command (sndfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_TRUE) ;
  999. /* Turn off auto header update. */
  1000. sf_command (sndfile, SFC_SET_UPDATE_HEADER_AUTO, NULL, SF_FALSE) ;
  1001. </PRE>
  1002. <DL>
  1003. <DT>Return value:</DT>
  1004. <DD>TRUE if auto update header is now on; FALSE otherwise.
  1005. </DL>
  1006. <!-- ========================================================================= -->
  1007. <A NAME="SFC_FILE_TRUNCATE"></A>
  1008. <H2><BR><B>SFC_FILE_TRUNCATE</B></H2>
  1009. <P>
  1010. Truncate a file that was opened for write or read/write.
  1011. </P>
  1012. <P>
  1013. Parameters:
  1014. <PRE>
  1015. sndfile : A valid SNDFILE* pointer
  1016. cmd : SFC_FILE_TRUNCATE
  1017. data : A pointer to an sf_count_t.
  1018. datasize : sizeof (sf_count_t)
  1019. </PRE>
  1020. <P>
  1021. Truncate the file to the number of frames specified by the sf_count_t pointed
  1022. to by data.
  1023. After this command, both the read and the write pointer will be
  1024. at the new end of the file.
  1025. This command will fail (returning non-zero) if the requested truncate position
  1026. is beyond the end of the file.
  1027. </P>
  1028. <P>
  1029. Example:
  1030. </P>
  1031. <PRE>
  1032. /* Truncate the file to a length of 20 frames. */
  1033. sf_count_t frames = 20 ;
  1034. sf_command (sndfile, SFC_FILE_TRUNCATE, &amp;frames, sizeof (frames)) ;
  1035. </PRE>
  1036. <DL>
  1037. <DT>Return value:</DT>
  1038. <DD>Zero on sucess, non-zero otherwise.
  1039. </DL>
  1040. <!-- ========================================================================= -->
  1041. <A NAME="SFC_SET_RAW_START_OFFSET"></A>
  1042. <H2><BR><B>SFC_SET_RAW_START_OFFSET</B></H2>
  1043. <P>
  1044. Change the data start offset for files opened up as SF_FORMAT_RAW.
  1045. </P>
  1046. <P>
  1047. Parameters:
  1048. <PRE>
  1049. sndfile : A valid SNDFILE* pointer
  1050. cmd : SFC_SET_RAW_START_OFFSET
  1051. data : A pointer to an sf_count_t.
  1052. datasize : sizeof (sf_count_t)
  1053. </PRE>
  1054. <P>
  1055. For a file opened as format SF_FORMAT_RAW, set the data offset to the value
  1056. given by data.
  1057. </P>
  1058. <P>
  1059. Example:
  1060. </P>
  1061. <PRE>
  1062. /* Reset the data offset to 5 bytes from the start of the file. */
  1063. sf_count_t offset = 5 ;
  1064. sf_command (sndfile, SFC_SET_RAW_START_OFFSET, &amp;offset, sizeof (offset)) ;
  1065. </PRE>
  1066. <DL>
  1067. <DT>Return value:</DT>
  1068. <DD>Zero on success, non-zero otherwise.
  1069. </DL>
  1070. <!-- ========================================================================= -->
  1071. <A NAME="SFC_SET_CLIPPING"></A>
  1072. <H2><BR><B>SFC_SET_CLIPPING</B></H2>
  1073. <P>
  1074. Turn on/off automatic clipping when doing floating point to integer conversion.
  1075. </P>
  1076. <P>
  1077. Parameters:
  1078. <PRE>
  1079. sndfile : A valid SNDFILE* pointer
  1080. cmd : SFC_SET_CLIPPING
  1081. data : NULL
  1082. datasize : SF_TRUE or SF_FALSE.
  1083. </PRE>
  1084. <P>
  1085. Turn on (datasize == SF_TRUE) or off (datasize == SF_FALSE) clipping.
  1086. </P>
  1087. <P>
  1088. Example:
  1089. </P>
  1090. <PRE>
  1091. sf_command (sndfile, SFC_SET_CLIPPING, NULL, SF_TRUE) ;
  1092. </PRE>
  1093. <DL>
  1094. <DT>Return value:</DT>
  1095. <DD>Clipping mode (SF_TRUE or SF_FALSE).
  1096. </DL>
  1097. <!-- ========================================================================= -->
  1098. <A NAME="SFC_GET_CLIPPING"></A>
  1099. <H2><BR><B>SFC_GET_CLIPPING</B></H2>
  1100. <P>
  1101. Turn on/off automatic clipping when doing floating point to integer conversion.
  1102. </P>
  1103. <P>
  1104. Parameters:
  1105. <PRE>
  1106. sndfile : A valid SNDFILE* pointer
  1107. cmd : SFC_GET_CLIPPING
  1108. data : NULL
  1109. datasize : 0
  1110. </PRE>
  1111. <P>
  1112. Retrieve the current cliiping setting.
  1113. </P>
  1114. <P>
  1115. Example:
  1116. </P>
  1117. <PRE>
  1118. sf_command (sndfile, SFC_GET_CLIPPING, NULL, 0) ;
  1119. </PRE>
  1120. <DL>
  1121. <DT>Return value:</DT>
  1122. <DD>Clipping mode (SF_TRUE or SF_FALSE).
  1123. </DL>
  1124. <!-- ========================================================================= -->
  1125. <A NAME="SFC_GET_EMBED_FILE_INFO"></A>
  1126. <H2><BR><B>SFC_GET_EMBED_FILE_INFO</B></H2>
  1127. <P>
  1128. Get the file offset and file length of a file enbedded within another
  1129. larger file.
  1130. </P>
  1131. <P>
  1132. Parameters:
  1133. <PRE>
  1134. sndfile : A valid SNDFILE* pointer
  1135. cmd : SFC_GET_CLIPPING
  1136. data : a pointer to an SF_EMBED_FILE_INFO struct
  1137. datasize : sizeof (SF_EMBED_FILE_INFO)
  1138. </PRE>
  1139. <P>
  1140. The SF_EMBED_FILE_INFO struct is defined in &lt;sndfile.h&gt; as:
  1141. </P>
  1142. <PRE>
  1143. typedef struct
  1144. { sf_count_t offset ;
  1145. sf_count_t length ;
  1146. } SF_EMBED_FILE_INFO ;
  1147. </PRE>
  1148. <DL>
  1149. <DT>Return value: </DT>
  1150. <DD>0 on success and non-zero otherwise.
  1151. <DD>The value of the offset field of the SF_EMBED_FILE_INFO struct will be
  1152. the offsets in bytes from the start of the outer file to the start of
  1153. the audio file.
  1154. <DD>The value of the offset field of the SF_EMBED_FILE_INFO struct will be
  1155. the length in bytes of the embedded file.
  1156. </DL>
  1157. <!-- ========================================================================= -->
  1158. <A NAME="SFC_WAVEX_GET_AMBISONIC"></A>
  1159. <H2><BR><B>SFC_WAVEX_GET_AMBISONIC</B></H2>
  1160. <P>
  1161. Test if the current file has the GUID of a WAVEX file for any of the Ambisonic
  1162. formats.
  1163. </P>
  1164. <P>
  1165. Parameters:
  1166. <PRE>
  1167. sndfile : A valid SNDFILE* pointer
  1168. cmd : SFC_WAVEX_GET_AMBISONIC
  1169. data : NULL
  1170. datasize : 0
  1171. </PRE>
  1172. <P>
  1173. The Ambisonic WAVEX formats are defined here :
  1174. <A HREF="http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html">
  1175. http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html</A>.
  1176. </P>
  1177. <DL>
  1178. <DT>Return value: </DT>
  1179. <DD>SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT or zero if the file format
  1180. does not support ambisonic formats.
  1181. </DL>
  1182. <!-- ========================================================================= -->
  1183. <A NAME="SFC_WAVEX_SET_AMBISONIC"></A>
  1184. <H2><BR><B>SFC_WAVEX_SET_AMBISONIC</B></H2>
  1185. <P>
  1186. Set the GUID of a new WAVEX file to indicate an Ambisonics format.
  1187. </P>
  1188. <P>
  1189. Parameters:
  1190. <PRE>
  1191. sndfile : A valid SNDFILE* pointer
  1192. cmd : SFC_WAVEX_SET_AMBISONIC
  1193. data : NULL
  1194. datasize : SF_AMBISONIC_NONE or SF_AMBISONIC_B_FORMAT
  1195. </PRE>
  1196. <P>
  1197. Turn on (SF_AMBISONIC_B_FORMAT) or off (SF_AMBISONIC_NONE) encoding.
  1198. This command is currently only supported for files with SF_FORMAT_WAVEX format.
  1199. </P>
  1200. <P>
  1201. The Ambisonic WAVEX formats are defined here :
  1202. <A HREF="http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html">
  1203. http://dream.cs.bath.ac.uk/researchdev/wave-ex/bformat.html</A>.
  1204. </P>
  1205. <DL>
  1206. <DT>Return value: </DT>
  1207. <DD>Return the ambisonic value that has just been set or zero if the file
  1208. format does not support ambisonic encoding.
  1209. </DL>
  1210. <!-- ========================================================================= -->
  1211. <A NAME="SFC_SET_VBR_ENCODING_QUALITY"></A>
  1212. <H2><BR><B>SFC_SET_VBR_ENCODING_QUALITY</B></H2>
  1213. <P>
  1214. Set the Variable Bit Rate encoding quality.
  1215. The encoding quality value should be between 0.0 (lowest quality) and 1.0
  1216. (highest quality).
  1217. Currenly this command is only implemented for FLAC and Ogg/Vorbis files.
  1218. </P>
  1219. <P>
  1220. Parameters:
  1221. <PRE>
  1222. sndfile : A valid SNDFILE* pointer
  1223. cmd : SFC_SET_VBR_ENCODING_QUALITY
  1224. data : A pointer to a double value
  1225. datasize : sizeof (double)
  1226. </PRE>
  1227. <P>
  1228. The command must be sent before any audio data is written to the file.
  1229. </P>
  1230. <P>
  1231. </P>
  1232. <DL>
  1233. <DT>Return value:</DT>
  1234. <dd>SF_TRUE if VBR encoding quality was set.
  1235. SF_FALSE otherwise.
  1236. </DL>
  1237. <!-- ========================================================================= -->
  1238. <A NAME="SFC_SET_COMPRESSION_LEVEL"></A>
  1239. <H2><BR><B>SFC_SET_COMPRESSION_LEVEL</B></H2>
  1240. <P>
  1241. Set the compression level.
  1242. The compression level should be between 0.0 (minimum compression level) and 1.0
  1243. (highest compression level).
  1244. Currenly this command is only implemented for FLAC and Ogg/Vorbis files.
  1245. </P>
  1246. <P>
  1247. Parameters:
  1248. <PRE>
  1249. sndfile : A valid SNDFILE* pointer
  1250. cmd : SFC_SET_COMPRESSION_LEVEL
  1251. data : A pointer to a double value
  1252. datasize : sizeof (double)
  1253. </PRE>
  1254. <P>
  1255. The command must be sent before any audio data is written to the file.
  1256. </P>
  1257. <P>
  1258. </P>
  1259. <DL>
  1260. <DT>Return value:</DT>
  1261. <dd>SF_TRUE if compression level was set.
  1262. SF_FALSE otherwise.
  1263. </DL>
  1264. <!-- ========================================================================= -->
  1265. <A NAME="SFC_RAW_NEEDS_ENDSWAP"></A>
  1266. <H2><BR><B>SFC_RAW_NEEDS_ENDSWAP</B></H2>
  1267. <P>
  1268. Determine if raw data read using
  1269. <a href="api.html#raw">
  1270. sf_read_raw</a>
  1271. needs to be end swapped on the host CPU.
  1272. </P>
  1273. <P>
  1274. For instance, will return SF_TRUE on when reading WAV containing
  1275. SF_FORMAT_PCM_16 data on a big endian machine and SF_FALSE on a little endian
  1276. machine.
  1277. </P>
  1278. <P>
  1279. Parameters:
  1280. <PRE>
  1281. sndfile : A valid SNDFILE* pointer
  1282. cmd : SFC_RAW_NEEDS_ENDSWAP
  1283. data : NULL
  1284. datasize : 0
  1285. </PRE>
  1286. <DL>
  1287. <DT>Return value: </DT>
  1288. <DD>SF_TRUE or SF_FALSE
  1289. </DL>
  1290. <!-- ========================================================================= -->
  1291. <A NAME="SFC_GET_BROADCAST_INFO"></A>
  1292. <H2><BR><B>SFC_GET_BROADCAST_INFO</B></H2>
  1293. <P>
  1294. Retrieve the Broadcast Extension Chunk from WAV (and related) files.
  1295. </P>
  1296. <p>
  1297. Parameters:
  1298. </p>
  1299. <PRE>
  1300. sndfile : A valid SNDFILE* pointer
  1301. cmd : SFC_GET_BROADCAST_INFO
  1302. data : a pointer to an SF_BROADCAST_INFO struct
  1303. datasize : sizeof (SF_BROADCAST_INFO)
  1304. </PRE>
  1305. <P>
  1306. The SF_BROADCAST_INFO struct is defined in &lt;sndfile.h&gt; as:
  1307. </P>
  1308. <PRE>
  1309. typedef struct
  1310. { char description [256] ;
  1311. char originator [32] ;
  1312. char originator_reference [32] ;
  1313. char origination_date [10] ;
  1314. char origination_time [8] ;
  1315. unsigned int time_reference_low ;
  1316. unsigned int time_reference_high ;
  1317. short version ;
  1318. char umid [64] ;
  1319. char reserved [190] ;
  1320. unsigned int coding_history_size ;
  1321. char coding_history [256] ;
  1322. } SF_BROADCAST_INFO ;
  1323. </PRE>
  1324. <DL>
  1325. <DT>Return value: </DT>
  1326. <DD>SF_TRUE if the file contained a Broadcast Extension chunk or SF_FALSE
  1327. otherwise.
  1328. </DL>
  1329. <!-- ========================================================================= -->
  1330. <A NAME="SFC_SET_BROADCAST_INFO"></A>
  1331. <H2><BR><B>SFC_SET_BROADCAST_INFO</B></H2>
  1332. <P>
  1333. Set the Broadcast Extension Chunk for WAV (and related) files.
  1334. </P>
  1335. <p>
  1336. Parameters:
  1337. </p>
  1338. <PRE>
  1339. sndfile : A valid SNDFILE* pointer
  1340. cmd : SFC_SET_BROADCAST_INFO
  1341. data : a pointer to an SF_BROADCAST_INFO struct
  1342. datasize : sizeof (SF_BROADCAST_INFO)
  1343. </PRE>
  1344. <DL>
  1345. <DT>Return value: </DT>
  1346. <DD>SF_TRUE if setting the Broadcast Extension chunk was successful and SF_FALSE
  1347. otherwise.
  1348. </DL>
  1349. <!-- ========================================================================= -->
  1350. <A NAME="SFC_GET_CART_INFO"></A>
  1351. <H2><BR><B>SFC_GET_CART_INFO</B></H2>
  1352. <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.
  1353. </P>
  1354. <p>
  1355. Parameters:
  1356. </p>
  1357. <PRE>
  1358. sndfile : A valid SNDFILE* pointer
  1359. cmd : SFC_GET_CART_INFO
  1360. data : a pointer to an SF_CART_INFO struct
  1361. datasize : sizeof (SF_CART_INFO)
  1362. </PRE>
  1363. <P>
  1364. The SF_CART_INFO struct is defined in &lt;sndfile.h&gt; as:
  1365. </P>
  1366. <PRE>
  1367. #define SF_CART_INFO_VAR(p_tag_text_size) \
  1368. struct
  1369. { char version [4] ;
  1370. char title [64] ;
  1371. char artist [64] ;
  1372. char cut_id [64] ;
  1373. char client_id [64] ;
  1374. char category [64] ;
  1375. char classification [64] ;
  1376. char out_cue [64] ;
  1377. char start_date [10] ;
  1378. char start_time [8] ;
  1379. char end_date [10] ;
  1380. char end_time [8] ;
  1381. char producer_app_id [64] ;
  1382. char producer_app_version [64] ;
  1383. char user_def [64] ;
  1384. long level_reference ;
  1385. SF_CART_TIMER post_timers [8] ;
  1386. char reserved [276] ;
  1387. char url [1024] ;
  1388. unsigned int tag_text_size ;
  1389. char tag_text[p_tag_text_size] ;
  1390. }
  1391. </PRE>
  1392. <DL>
  1393. <DT>Return value: </DT>
  1394. <DD>SF_TRUE if the file contained a Cart chunk or SF_FALSE
  1395. otherwise.
  1396. </DL>
  1397. <!-- ========================================================================= -->
  1398. <A NAME="SFC_SET_CART_INFO"></A>
  1399. <H2><BR><B>SFC_SET_CART_INFO</B></H2>
  1400. <P>
  1401. Set the Cart Chunk for WAV (and related) files.
  1402. </P>
  1403. <p>
  1404. Parameters:
  1405. </p>
  1406. <PRE>
  1407. sndfile : A valid SNDFILE* pointer
  1408. cmd : SFC_SET_CART_INFO
  1409. data : a pointer to an SF_CART_INFO struct
  1410. datasize : sizeof (SF_CART_INFO)
  1411. </PRE>
  1412. <DL>
  1413. <DT>Return value: </DT>
  1414. <DD>SF_TRUE if setting the Cart chunk was successful and SF_FALSE
  1415. otherwise.
  1416. </DL>
  1417. <!-- ========================================================================= -->
  1418. <A NAME="SFC_GET_LOOP_INFO"></A>
  1419. <H2><BR><B>SFC_GET_LOOP_INFO</B></H2>
  1420. <P>
  1421. Retrieve loop information for file including time signature, length in
  1422. beats and original MIDI base note
  1423. </P>
  1424. <p>
  1425. Parameters:
  1426. </p>
  1427. <PRE>
  1428. sndfile : A valid SNDFILE* pointer
  1429. cmd : SFC_GET_LOOP_INFO
  1430. data : a pointer to an SF_LOOP_INFO struct
  1431. datasize : sizeof (SF_LOOP_INFO)
  1432. </PRE>
  1433. <P>
  1434. The SF_BROADCAST_INFO struct is defined in &lt;sndfile.h&gt; as:
  1435. </P>
  1436. <PRE>
  1437. typedef struct
  1438. { short time_sig_num ; /* any positive integer > 0 */
  1439. short time_sig_den ; /* any positive power of 2 > 0 */
  1440. int loop_mode ; /* see SF_LOOP enum */
  1441. int num_beats ; /* this is NOT the amount of quarter notes !!!*/
  1442. /* a full bar of 4/4 is 4 beats */
  1443. /* a full bar of 7/8 is 7 beats */
  1444. float bpm ; /* suggestion, as it can be calculated using other fields:*/
  1445. /* file's lenght, file's sampleRate and our time_sig_den*/
  1446. /* -> bpms are always the amount of _quarter notes_ per minute */
  1447. int root_key ; /* MIDI note, or -1 for None */
  1448. int future [6] ;
  1449. } SF_LOOP_INFO ;
  1450. </PRE>
  1451. <P>
  1452. Example:
  1453. </P>
  1454. <PRE>
  1455. SF_LOOP_INFO loop;
  1456. sf_command (sndfile, SFC_GET_LOOP_INFO, &amp;loop, sizeof (loop)) ;
  1457. </PRE>
  1458. <DL>
  1459. <DT>Return value:</DT>
  1460. <DD>SF_TRUE if the file header contains loop information for the file.
  1461. SF_FALSE otherwise.
  1462. </DL>
  1463. <!-- ========================================================================= -->
  1464. <A NAME="SFC_GET_INSTRUMENT"></A>
  1465. <H2><BR><B>SFC_GET_INSTRUMENT</B></H2>
  1466. <P>
  1467. Retrieve instrument information from file including MIDI base note,
  1468. keyboard mapping and looping informations(start/stop and mode).
  1469. </P>
  1470. <p>
  1471. Parameters:
  1472. </p>
  1473. <PRE>
  1474. sndfile : A valid SNDFILE* pointer
  1475. cmd : SFC_GET_INSTRUMENT
  1476. data : a pointer to an SF_INSTRUMENT struct
  1477. datasize : sizeof (SF_INSTRUMENT)
  1478. </PRE>
  1479. <P>
  1480. The SF_INSTRUMENT struct is defined in &lt;sndfile.h&gt; as:
  1481. </P>
  1482. <PRE>
  1483. enum
  1484. { /*
  1485. ** The loop mode field in SF_INSTRUMENT will be one of the following.
  1486. */
  1487. SF_LOOP_NONE = 800,
  1488. SF_LOOP_FORWARD,
  1489. SF_LOOP_BACKWARD,
  1490. SF_LOOP_ALTERNATING
  1491. } ;
  1492. typedef struct
  1493. { int gain ;
  1494. char basenote, detune ;
  1495. char velocity_lo, velocity_hi ;
  1496. char key_lo, key_hi ;
  1497. int loop_count ;
  1498. struct
  1499. { int mode ;
  1500. unsigned int start ;
  1501. unsigned int end ;
  1502. unsigned int count ;
  1503. } loops [16] ; /* make variable in a sensible way */
  1504. } SF_INSTRUMENT ;
  1505. </PRE>
  1506. <P>
  1507. Example:
  1508. </P>
  1509. <PRE>
  1510. SF_INSTRUMENT inst ;
  1511. sf_command (sndfile, SFC_GET_INSTRUMENT, &amp;inst, sizeof (inst)) ;
  1512. </PRE>
  1513. <DL>
  1514. <DT>Return value:</DT>
  1515. <dd>SF_TRUE if the file header contains instrument information for the
  1516. file. SF_FALSE otherwise.
  1517. </DL>
  1518. <!-- ========================================================================= -->
  1519. <A NAME="SFC_SET_INSTRUMENT"></A>
  1520. <H2><BR><B>SFC_SET_INSTRUMENT</B></H2>
  1521. <P>
  1522. Set the instrument information for the file.
  1523. </P>
  1524. <p>
  1525. Parameters:
  1526. </p>
  1527. <PRE>
  1528. sndfile : A valid SNDFILE* pointer
  1529. cmd : SFC_GET_INSTRUMENT
  1530. data : a pointer to an SF_INSTRUMENT struct
  1531. datasize : sizeof (SF_INSTRUMENT)
  1532. </PRE>
  1533. <P>
  1534. Example:
  1535. </P>
  1536. <PRE>
  1537. SF_INSTRUMENT inst ;
  1538. sf_command (sndfile, SFC_SET_INSTRUMENT, &amp;inst, sizeof (inst)) ;
  1539. </PRE>
  1540. <DL>
  1541. <DT>Return value:</DT>
  1542. <dd>SF_TRUE if the file header contains instrument information for the
  1543. file. SF_FALSE otherwise.
  1544. </DL>
  1545. <!-- ========================================================================= -->
  1546. <HR>
  1547. <P>
  1548. The libsndfile home page is here :
  1549. <A HREF="http://www.mega-nerd.com/libsndfile/">
  1550. http://www.mega-nerd.com/libsndfile/</A>.
  1551. <BR>
  1552. Version : 1.0.25
  1553. </P>
  1554. </BODY>
  1555. </HTML>