annotate src/libsndfile-1.0.27/examples/list_formats.c @ 148:b4bfdf10c4b3

Update Win64 capnp builds to v0.6
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 22 May 2017 18:56:49 +0100
parents cd6cdf86811e
children
rev   line source
cannam@125 1 /*
cannam@125 2 ** Copyright (C) 2001-2014 Erik de Castro Lopo <erikd@mega-nerd.com>
cannam@125 3 **
cannam@125 4 ** All rights reserved.
cannam@125 5 **
cannam@125 6 ** Redistribution and use in source and binary forms, with or without
cannam@125 7 ** modification, are permitted provided that the following conditions are
cannam@125 8 ** met:
cannam@125 9 **
cannam@125 10 ** * Redistributions of source code must retain the above copyright
cannam@125 11 ** notice, this list of conditions and the following disclaimer.
cannam@125 12 ** * Redistributions in binary form must reproduce the above copyright
cannam@125 13 ** notice, this list of conditions and the following disclaimer in
cannam@125 14 ** the documentation and/or other materials provided with the
cannam@125 15 ** distribution.
cannam@125 16 ** * Neither the author nor the names of any contributors may be used
cannam@125 17 ** to endorse or promote products derived from this software without
cannam@125 18 ** specific prior written permission.
cannam@125 19 **
cannam@125 20 ** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
cannam@125 21 ** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
cannam@125 22 ** TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
cannam@125 23 ** PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
cannam@125 24 ** CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
cannam@125 25 ** EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
cannam@125 26 ** PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
cannam@125 27 ** OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
cannam@125 28 ** WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
cannam@125 29 ** OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
cannam@125 30 ** ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
cannam@125 31 */
cannam@125 32
cannam@125 33 #include <stdio.h>
cannam@125 34 #include <stdlib.h>
cannam@125 35 #include <string.h>
cannam@125 36 #include <math.h>
cannam@125 37
cannam@125 38 #include <sndfile.h>
cannam@125 39
cannam@125 40 int
cannam@125 41 main (void)
cannam@125 42 { SF_FORMAT_INFO info ;
cannam@125 43 SF_INFO sfinfo ;
cannam@125 44 int format, major_count, subtype_count, m, s ;
cannam@125 45
cannam@125 46 memset (&sfinfo, 0, sizeof (sfinfo)) ;
cannam@125 47 printf ("Version : %s\n\n", sf_version_string ()) ;
cannam@125 48
cannam@125 49 sf_command (NULL, SFC_GET_FORMAT_MAJOR_COUNT, &major_count, sizeof (int)) ;
cannam@125 50 sf_command (NULL, SFC_GET_FORMAT_SUBTYPE_COUNT, &subtype_count, sizeof (int)) ;
cannam@125 51
cannam@125 52 sfinfo.channels = 1 ;
cannam@125 53 for (m = 0 ; m < major_count ; m++)
cannam@125 54 { info.format = m ;
cannam@125 55 sf_command (NULL, SFC_GET_FORMAT_MAJOR, &info, sizeof (info)) ;
cannam@125 56 printf ("%s (extension \"%s\")\n", info.name, info.extension) ;
cannam@125 57
cannam@125 58 format = info.format ;
cannam@125 59
cannam@125 60 for (s = 0 ; s < subtype_count ; s++)
cannam@125 61 { info.format = s ;
cannam@125 62 sf_command (NULL, SFC_GET_FORMAT_SUBTYPE, &info, sizeof (info)) ;
cannam@125 63
cannam@125 64 format = (format & SF_FORMAT_TYPEMASK) | info.format ;
cannam@125 65
cannam@125 66 sfinfo.format = format ;
cannam@125 67 if (sf_format_check (&sfinfo))
cannam@125 68 printf (" %s\n", info.name) ;
cannam@125 69 } ;
cannam@125 70 puts ("") ;
cannam@125 71 } ;
cannam@125 72 puts ("") ;
cannam@125 73
cannam@125 74 return 0 ;
cannam@125 75 } /* main */
cannam@125 76