annotate src/libsndfile-1.0.25/examples/list_formats.c @ 23:619f715526df sv_v2.1

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