00001 <html>
00002
00003 <head>
00004 <title>vorbisfile - vorbisfile_example.c</title>
00005 <link rel=stylesheet href="style.css" type="text/css">
00006 </head>
00007
00008 <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
00009 <table border=0 width=100%>
00010 <tr>
00011 <td><p class=tiny>Vorbisfile documentation</p></td>
00012 <td align=right><p class=tiny>vorbisfile version 1.68 - 20030307</p></td>
00013 </tr>
00014 </table>
00015
00016 <h1>vorbisfile_example.c</h1>
00017
00018 <p>
00019 The example program source:
00020
00021 <br><br>
00022 <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
00023 <tr bgcolor=#cccccc>
00024 <td>
00025 <pre><b>
00026 #include <stdio.h>
00027 #include <stdlib.h>
00028 #include <math.h>
00029 #include "vorbis/codec.h"
00030 #include "vorbis/vorbisfile.h"
00031
00032 #ifdef _WIN32
00033 #include <io.h>
00034 #include <fcntl.h>
00035 #endif
00036
00037 char pcmout[4096];
00038
00039 int main(int argc, char **argv){
00040 OggVorbis_File vf;
00041 int eof=0;
00042 int current_section;
00043
00044 #ifdef _WIN32
00045 _setmode( _fileno( stdin ), _O_BINARY );
00046 _setmode( _fileno( stdout ), _O_BINARY );
00047 #endif
00048
00049 if(ov_open(stdin, &vf, NULL, 0) < 0) {
00050 fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
00051 exit(1);
00052 }
00053
00054 {
00055 char **ptr=ov_comment(&vf,-1)->user_comments;
00056 vorbis_info *vi=ov_info(&vf,-1);
00057 while(*ptr){
00058 fprintf(stderr,"%s\n",*ptr);
00059 ++ptr;
00060 }
00061 fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
00062 fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
00063 }
00064
00065 while(!eof){
00066 long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,¤t_section);
00067 if (ret == 0) {
00068
00069 eof=1;
00070 } else if (ret < 0) {
00071
00072
00073 } else {
00074
00075
00076 fwrite(pcmout,1,ret,stdout);
00077 }
00078 }
00079
00080 ov_clear(&vf);
00081
00082 fprintf(stderr,"Done.\n");
00083 return(0);
00084 }
00085
00086 </b></pre>
00087 </td>
00088 </tr>
00089 </table>
00090
00091
00092 <br><br>
00093 <hr noshade>
00094 <table border=0 width=100%>
00095 <tr valign=top>
00096 <td><p class=tiny>copyright © 2003 Xiph.org</p></td>
00097 <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a><br><a href="mailto:team@vorbis.org">team@vorbis.org</a></p></td>
00098 </tr><tr>
00099 <td><p class=tiny>Vorbisfile documentation</p></td>
00100 <td align=right><p class=tiny>vorbisfile version 1.68 - 20030307</p></td>
00101 </tr>
00102 </table>
00103
00104 </body>
00105
00106 </html>