comparison win32-mingw/include/sndfile.h @ 58:eab3b14ddc95

Further win32 build updates
author Chris Cannam
date Mon, 09 Jan 2017 13:51:38 +0000
parents 35e00f62c407
children
comparison
equal deleted inserted replaced
57:e56993504470 58:eab3b14ddc95
1 /* 1 /*
2 ** Copyright (C) 1999-2011Erik de Castro Lopo <erikd@mega-nerd.com> 2 ** Copyright (C) 1999-2016 Erik de Castro Lopo <erikd@mega-nerd.com>
3 ** 3 **
4 ** This program is free software; you can redistribute it and/or modify 4 ** This program is free software; you can redistribute it and/or modify
5 ** it under the terms of the GNU Lesser General Public License as published by 5 ** it under the terms of the GNU Lesser General Public License as published by
6 ** the Free Software Foundation; either version 2.1 of the License, or 6 ** the Free Software Foundation; either version 2.1 of the License, or
7 ** (at your option) any later version. 7 ** (at your option) any later version.
28 28
29 /* This is the version 1.0.X header file. */ 29 /* This is the version 1.0.X header file. */
30 #define SNDFILE_1 30 #define SNDFILE_1
31 31
32 #include <stdio.h> 32 #include <stdio.h>
33 #include <stdint.h>
33 #include <sys/types.h> 34 #include <sys/types.h>
34 35
35 #ifdef __cplusplus 36 #ifdef __cplusplus
36 extern "C" { 37 extern "C" {
37 #endif /* __cplusplus */ 38 #endif /* __cplusplus */
103 SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */ 104 SF_FORMAT_DPCM_8 = 0x0050, /* 8 bit differential PCM (XI only) */
104 SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */ 105 SF_FORMAT_DPCM_16 = 0x0051, /* 16 bit differential PCM (XI only) */
105 106
106 SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */ 107 SF_FORMAT_VORBIS = 0x0060, /* Xiph Vorbis encoding. */
107 108
109 SF_FORMAT_ALAC_16 = 0x0070, /* Apple Lossless Audio Codec (16 bit). */
110 SF_FORMAT_ALAC_20 = 0x0071, /* Apple Lossless Audio Codec (20 bit). */
111 SF_FORMAT_ALAC_24 = 0x0072, /* Apple Lossless Audio Codec (24 bit). */
112 SF_FORMAT_ALAC_32 = 0x0073, /* Apple Lossless Audio Codec (32 bit). */
113
108 /* Endian-ness options. */ 114 /* Endian-ness options. */
109 115
110 SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */ 116 SF_ENDIAN_FILE = 0x00000000, /* Default file endian-ness. */
111 SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */ 117 SF_ENDIAN_LITTLE = 0x10000000, /* Force little endian-ness. */
112 SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */ 118 SF_ENDIAN_BIG = 0x20000000, /* Force big endian-ness. */
172 SFC_GET_EMBED_FILE_INFO = 0x10B0, 178 SFC_GET_EMBED_FILE_INFO = 0x10B0,
173 179
174 SFC_SET_CLIPPING = 0x10C0, 180 SFC_SET_CLIPPING = 0x10C0,
175 SFC_GET_CLIPPING = 0x10C1, 181 SFC_GET_CLIPPING = 0x10C1,
176 182
183 SFC_GET_CUE_COUNT = 0x10CD,
184 SFC_GET_CUE = 0x10CE,
185 SFC_SET_CUE = 0x10CF,
186
177 SFC_GET_INSTRUMENT = 0x10D0, 187 SFC_GET_INSTRUMENT = 0x10D0,
178 SFC_SET_INSTRUMENT = 0x10D1, 188 SFC_SET_INSTRUMENT = 0x10D1,
179 189
180 SFC_GET_LOOP_INFO = 0x10E0, 190 SFC_GET_LOOP_INFO = 0x10E0,
181 191
189 199
190 /* Support for Wavex Ambisonics Format */ 200 /* Support for Wavex Ambisonics Format */
191 SFC_WAVEX_SET_AMBISONIC = 0x1200, 201 SFC_WAVEX_SET_AMBISONIC = 0x1200,
192 SFC_WAVEX_GET_AMBISONIC = 0x1201, 202 SFC_WAVEX_GET_AMBISONIC = 0x1201,
193 203
204 /*
205 ** RF64 files can be set so that on-close, writable files that have less
206 ** than 4GB of data in them are converted to RIFF/WAV, as per EBU
207 ** recommendations.
208 */
209 SFC_RF64_AUTO_DOWNGRADE = 0x1210,
210
194 SFC_SET_VBR_ENCODING_QUALITY = 0x1300, 211 SFC_SET_VBR_ENCODING_QUALITY = 0x1300,
212 SFC_SET_COMPRESSION_LEVEL = 0x1301,
213
214 /* Cart Chunk support */
215 SFC_SET_CART_INFO = 0x1400,
216 SFC_GET_CART_INFO = 0x1401,
195 217
196 /* Following commands for testing only. */ 218 /* Following commands for testing only. */
197 SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001, 219 SFC_TEST_IEEE_FLOAT_REPLACE = 0x6001,
198 220
199 /* 221 /*
200 ** SFC_SET_ADD_* values are deprecated and will disappear at some 222 ** SFC_SET_ADD_* values are deprecated and will disappear at some
201 ** time in the future. They are guaranteed to be here up to and 223 ** time in the future. They are guaranteed to be here up to and
202 ** including version 1.0.8 to avoid breakage of existng software. 224 ** including version 1.0.8 to avoid breakage of existing software.
203 ** They currently do nothing and will continue to do nothing. 225 ** They currently do nothing and will continue to do nothing.
204 */ 226 */
205 SFC_SET_ADD_DITHER_ON_WRITE = 0x1070, 227 SFC_SET_ADD_DITHER_ON_WRITE = 0x1070,
206 SFC_SET_ADD_DITHER_ON_READ = 0x1071 228 SFC_SET_ADD_DITHER_ON_READ = 0x1071
207 } ; 229 } ;
313 335
314 #if (defined (_MSCVER) || defined (_MSC_VER)) 336 #if (defined (_MSCVER) || defined (_MSC_VER))
315 typedef __int64 sf_count_t ; 337 typedef __int64 sf_count_t ;
316 #define SF_COUNT_MAX 0x7fffffffffffffffi64 338 #define SF_COUNT_MAX 0x7fffffffffffffffi64
317 #else 339 #else
318 typedef off_t sf_count_t ; 340 typedef __int64 sf_count_t ;
319 #define SF_COUNT_MAX 0x7FFFFFFF 341 #define SF_COUNT_MAX 0x7FFFFFFFFFFFFFFFLL
320 #endif 342 #endif
321 343
322 344
323 /* A pointer to a SF_INFO structure is passed to sf_open () and filled in. 345 /* A pointer to a SF_INFO structure is passed to sf_open () and filled in.
324 ** On write, the SF_INFO structure is filled in by the user and passed into 346 ** On write, the SF_INFO structure is filled in by the user and passed into
380 402
381 typedef struct 403 typedef struct
382 { sf_count_t offset ; 404 { sf_count_t offset ;
383 sf_count_t length ; 405 sf_count_t length ;
384 } SF_EMBED_FILE_INFO ; 406 } SF_EMBED_FILE_INFO ;
407
408 /*
409 ** Struct used to retrieve cue marker information from a file
410 */
411
412 typedef struct
413 { int32_t indx ;
414 uint32_t position ;
415 int32_t fcc_chunk ;
416 int32_t chunk_start ;
417 int32_t block_start ;
418 uint32_t sample_offset ;
419 char name [256] ;
420 } SF_CUE_POINT ;
421
422 #define SF_CUES_VAR(count) \
423 struct \
424 { uint32_t cue_count ; \
425 SF_CUE_POINT cue_points [count] ; \
426 }
427
428 typedef SF_CUES_VAR (100) SF_CUES ;
385 429
386 /* 430 /*
387 ** Structs used to retrieve music sample information from a file. 431 ** Structs used to retrieve music sample information from a file.
388 */ 432 */
389 433
404 char key_lo, key_hi ; 448 char key_lo, key_hi ;
405 int loop_count ; 449 int loop_count ;
406 450
407 struct 451 struct
408 { int mode ; 452 { int mode ;
409 unsigned int start ; 453 uint32_t start ;
410 unsigned int end ; 454 uint32_t end ;
411 unsigned int count ; 455 uint32_t count ;
412 } loops [16] ; /* make variable in a sensible way */ 456 } loops [16] ; /* make variable in a sensible way */
413 } SF_INSTRUMENT ; 457 } SF_INSTRUMENT ;
414 458
415 459
416 460
424 int num_beats ; /* this is NOT the amount of quarter notes !!!*/ 468 int num_beats ; /* this is NOT the amount of quarter notes !!!*/
425 /* a full bar of 4/4 is 4 beats */ 469 /* a full bar of 4/4 is 4 beats */
426 /* a full bar of 7/8 is 7 beats */ 470 /* a full bar of 7/8 is 7 beats */
427 471
428 float bpm ; /* suggestion, as it can be calculated using other fields:*/ 472 float bpm ; /* suggestion, as it can be calculated using other fields:*/
429 /* file's lenght, file's sampleRate and our time_sig_den*/ 473 /* file's length, file's sampleRate and our time_sig_den*/
430 /* -> bpms are always the amount of _quarter notes_ per minute */ 474 /* -> bpms are always the amount of _quarter notes_ per minute */
431 475
432 int root_key ; /* MIDI note, or -1 for None */ 476 int root_key ; /* MIDI note, or -1 for None */
433 int future [6] ; 477 int future [6] ;
434 } SF_LOOP_INFO ; 478 } SF_LOOP_INFO ;
437 /* Struct used to retrieve broadcast (EBU) information from a file. 481 /* Struct used to retrieve broadcast (EBU) information from a file.
438 ** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE. 482 ** Strongly (!) based on EBU "bext" chunk format used in Broadcast WAVE.
439 */ 483 */
440 #define SF_BROADCAST_INFO_VAR(coding_hist_size) \ 484 #define SF_BROADCAST_INFO_VAR(coding_hist_size) \
441 struct \ 485 struct \
442 { char description [256] ; \ 486 { char description [256] ; \
443 char originator [32] ; \ 487 char originator [32] ; \
444 char originator_reference [32] ; \ 488 char originator_reference [32] ; \
445 char origination_date [10] ; \ 489 char origination_date [10] ; \
446 char origination_time [8] ; \ 490 char origination_time [8] ; \
447 unsigned int time_reference_low ; \ 491 uint32_t time_reference_low ; \
448 unsigned int time_reference_high ; \ 492 uint32_t time_reference_high ; \
449 short version ; \ 493 short version ; \
450 char umid [64] ; \ 494 char umid [64] ; \
451 char reserved [190] ; \ 495 char reserved [190] ; \
452 unsigned int coding_history_size ; \ 496 uint32_t coding_history_size ; \
453 char coding_history [coding_hist_size] ; \ 497 char coding_history [coding_hist_size] ; \
454 } 498 }
455 499
456 /* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */ 500 /* SF_BROADCAST_INFO is the above struct with coding_history field of 256 bytes. */
457 typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ; 501 typedef SF_BROADCAST_INFO_VAR (256) SF_BROADCAST_INFO ;
458 502
503 struct SF_CART_TIMER
504 { char usage [4] ;
505 int32_t value ;
506 } ;
507
508 typedef struct SF_CART_TIMER SF_CART_TIMER ;
509
510 #define SF_CART_INFO_VAR(p_tag_text_size) \
511 struct \
512 { char version [4] ; \
513 char title [64] ; \
514 char artist [64] ; \
515 char cut_id [64] ; \
516 char client_id [64] ; \
517 char category [64] ; \
518 char classification [64] ; \
519 char out_cue [64] ; \
520 char start_date [10] ; \
521 char start_time [8] ; \
522 char end_date [10] ; \
523 char end_time [8] ; \
524 char producer_app_id [64] ; \
525 char producer_app_version [64] ; \
526 char user_def [64] ; \
527 int32_t level_reference ; \
528 SF_CART_TIMER post_timers [8] ; \
529 char reserved [276] ; \
530 char url [1024] ; \
531 uint32_t tag_text_size ; \
532 char tag_text [p_tag_text_size] ; \
533 }
534
535 typedef SF_CART_INFO_VAR (256) SF_CART_INFO ;
459 536
460 /* Virtual I/O functionality. */ 537 /* Virtual I/O functionality. */
461 538
462 typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ; 539 typedef sf_count_t (*sf_vio_get_filelen) (void *user_data) ;
463 typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ; 540 typedef sf_count_t (*sf_vio_seek) (sf_count_t offset, int whence, void *user_data) ;
485 SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ; 562 SNDFILE* sf_open (const char *path, int mode, SF_INFO *sfinfo) ;
486 563
487 564
488 /* Use the existing file descriptor to create a SNDFILE object. If close_desc 565 /* Use the existing file descriptor to create a SNDFILE object. If close_desc
489 ** is TRUE, the file descriptor will be closed when sf_close() is called. If 566 ** is TRUE, the file descriptor will be closed when sf_close() is called. If
490 ** it is FALSE, the descritor will not be closed. 567 ** it is FALSE, the descriptor will not be closed.
491 ** When passed a descriptor like this, the library will assume that the start 568 ** When passed a descriptor like this, the library will assume that the start
492 ** of file header is at the current file offset. This allows sound files within 569 ** of file header is at the current file offset. This allows sound files within
493 ** larger container files to be read and/or written. 570 ** larger container files to be read and/or written.
494 ** On error, this will return a NULL pointer. To find the error number, pass a 571 ** On error, this will return a NULL pointer. To find the error number, pass a
495 ** NULL SNDFILE to sf_strerror (). 572 ** NULL SNDFILE to sf_strerror ().
523 600
524 const char* sf_error_number (int errnum) ; 601 const char* sf_error_number (int errnum) ;
525 602
526 603
527 /* The following two error functions are deprecated but they will remain in the 604 /* The following two error functions are deprecated but they will remain in the
528 ** library for the forseeable future. The function sf_strerror() should be used 605 ** library for the foreseeable future. The function sf_strerror() should be used
529 ** in their place. 606 ** in their place.
530 */ 607 */
531 608
532 int sf_perror (SNDFILE *sndfile) ; 609 int sf_perror (SNDFILE *sndfile) ;
533 int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ; 610 int sf_error_str (SNDFILE *sndfile, char* str, size_t len) ;
553 ** Please see the libsndfile documentation for moving the read pointer 630 ** Please see the libsndfile documentation for moving the read pointer
554 ** separately from the write pointer on files open in mode SFM_RDWR. 631 ** separately from the write pointer on files open in mode SFM_RDWR.
555 ** On error all of these functions return -1. 632 ** On error all of these functions return -1.
556 */ 633 */
557 634
635 enum
636 { SF_SEEK_SET = SEEK_SET,
637 SF_SEEK_CUR = SEEK_CUR,
638 SF_SEEK_END = SEEK_END
639 } ;
640
558 sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ; 641 sf_count_t sf_seek (SNDFILE *sndfile, sf_count_t frames, int whence) ;
559 642
560 643
561 /* Functions for retrieving and setting string data within sound files. 644 /* Functions for retrieving and setting string data within sound files.
562 ** Not all file types support this features; AIFF and WAV do. For both 645 ** Not all file types support this features; AIFF and WAV do. For both
573 656
574 /* Return the library version string. */ 657 /* Return the library version string. */
575 658
576 const char * sf_version_string (void) ; 659 const char * sf_version_string (void) ;
577 660
661 /* Return the current byterate at this point in the file. The byte rate in this
662 ** case is the number of bytes per second of audio data. For instance, for a
663 ** stereo, 18 bit PCM encoded file with an 16kHz sample rate, the byte rate
664 ** would be 2 (stereo) * 2 (two bytes per sample) * 16000 => 64000 bytes/sec.
665 ** For some file formats the returned value will be accurate and exact, for some
666 ** it will be a close approximation, for some it will be the average bitrate for
667 ** the whole file and for some it will be a time varying value that was accurate
668 ** when the file was most recently read or written.
669 ** To get the bitrate, multiple this value by 8.
670 ** Returns -1 for unknown.
671 */
672 int sf_current_byterate (SNDFILE *sndfile) ;
578 673
579 /* Functions for reading/writing the waveform data of a sound file. 674 /* Functions for reading/writing the waveform data of a sound file.
580 */ 675 */
581 676
582 sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ; 677 sf_count_t sf_read_raw (SNDFILE *sndfile, void *ptr, sf_count_t bytes) ;
656 SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ; 751 SNDFILE* sf_wchar_open (LPCWSTR wpath, int mode, SF_INFO *sfinfo) ;
657 #endif 752 #endif
658 753
659 754
660 755
756
757 /* Getting and setting of chunks from within a sound file.
758 **
759 ** These functions allow the getting and setting of chunks within a sound file
760 ** (for those formats which allow it).
761 **
762 ** These functions fail safely. Specifically, they will not allow you to overwrite
763 ** existing chunks or add extra versions of format specific reserved chunks but
764 ** should allow you to retrieve any and all chunks (may not be implemented for
765 ** all chunks or all file formats).
766 */
767
768 struct SF_CHUNK_INFO
769 { char id [64] ; /* The chunk identifier. */
770 unsigned id_size ; /* The size of the chunk identifier. */
771 unsigned datalen ; /* The size of that data. */
772 void *data ; /* Pointer to the data. */
773 } ;
774
775 typedef struct SF_CHUNK_INFO SF_CHUNK_INFO ;
776
777 /* Set the specified chunk info (must be done before any audio data is written
778 ** to the file). This will fail for format specific reserved chunks.
779 ** The chunk_info->data pointer must be valid until the file is closed.
780 ** Returns SF_ERR_NO_ERROR on success or non-zero on failure.
781 */
782 int sf_set_chunk (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ;
783
784 /*
785 ** An opaque structure to an iterator over the all chunks of a given id
786 */
787 typedef struct SF_CHUNK_ITERATOR SF_CHUNK_ITERATOR ;
788
789 /* Get an iterator for all chunks matching chunk_info.
790 ** The iterator will point to the first chunk matching chunk_info.
791 ** Chunks are matching, if (chunk_info->id) matches the first
792 ** (chunk_info->id_size) bytes of a chunk found in the SNDFILE* handle.
793 ** If chunk_info is NULL, an iterator to all chunks in the SNDFILE* handle
794 ** is returned.
795 ** The values of chunk_info->datalen and chunk_info->data are ignored.
796 ** If no matching chunks are found in the sndfile, NULL is returned.
797 ** The returned iterator will stay valid until one of the following occurs:
798 ** a) The sndfile is closed.
799 ** b) A new chunk is added using sf_set_chunk().
800 ** c) Another chunk iterator function is called on the same SNDFILE* handle
801 ** that causes the iterator to be modified.
802 ** The memory for the iterator belongs to the SNDFILE* handle and is freed when
803 ** sf_close() is called.
804 */
805 SF_CHUNK_ITERATOR *
806 sf_get_chunk_iterator (SNDFILE * sndfile, const SF_CHUNK_INFO * chunk_info) ;
807
808 /* Iterate through chunks by incrementing the iterator.
809 ** Increments the iterator and returns a handle to the new one.
810 ** After this call, iterator will no longer be valid, and you must use the
811 ** newly returned handle from now on.
812 ** The returned handle can be used to access the next chunk matching
813 ** the criteria as defined in sf_get_chunk_iterator().
814 ** If iterator points to the last chunk, this will free all resources
815 ** associated with iterator and return NULL.
816 ** The returned iterator will stay valid until sf_get_chunk_iterator_next
817 ** is called again, the sndfile is closed or a new chunk us added.
818 */
819 SF_CHUNK_ITERATOR *
820 sf_next_chunk_iterator (SF_CHUNK_ITERATOR * iterator) ;
821
822
823 /* Get the size of the specified chunk.
824 ** If the specified chunk exists, the size will be returned in the
825 ** datalen field of the SF_CHUNK_INFO struct.
826 ** Additionally, the id of the chunk will be copied to the id
827 ** field of the SF_CHUNK_INFO struct and it's id_size field will
828 ** be updated accordingly.
829 ** If the chunk doesn't exist chunk_info->datalen will be zero, and the
830 ** id and id_size fields will be undefined.
831 ** The function will return SF_ERR_NO_ERROR on success or non-zero on
832 ** failure.
833 */
834 int
835 sf_get_chunk_size (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ;
836
837 /* Get the specified chunk data.
838 ** If the specified chunk exists, up to chunk_info->datalen bytes of
839 ** the chunk data will be copied into the chunk_info->data buffer
840 ** (allocated by the caller) and the chunk_info->datalen field
841 ** updated to reflect the size of the data. The id and id_size
842 ** field will be updated according to the retrieved chunk
843 ** If the chunk doesn't exist chunk_info->datalen will be zero, and the
844 ** id and id_size fields will be undefined.
845 ** The function will return SF_ERR_NO_ERROR on success or non-zero on
846 ** failure.
847 */
848 int
849 sf_get_chunk_data (const SF_CHUNK_ITERATOR * it, SF_CHUNK_INFO * chunk_info) ;
850
851
661 #ifdef __cplusplus 852 #ifdef __cplusplus
662 } /* extern "C" */ 853 } /* extern "C" */
663 #endif /* __cplusplus */ 854 #endif /* __cplusplus */
664 855
665 #endif /* SNDFILE_H */ 856 #endif /* SNDFILE_H */