Add Russian translation provided by Валерий Крувялис <valkru@mail.ru>
[xiph-mirror.git] / vorbis / doc / vorbisfile / vorbisfile_example_c.html
blobf3ba1d6cc7590c6db576f6479aa7d15d5d5d103f
1 <html>
3 <head>
4 <title>vorbisfile - vorbisfile_example.c</title>
5 <link rel=stylesheet href="style.css" type="text/css">
6 </head>
8 <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
9 <table border=0 width=100%>
10 <tr>
11 <td><p class=tiny>Vorbisfile documentation</p></td>
12 <td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
13 </tr>
14 </table>
16 <h1>vorbisfile_example.c</h1>
18 <p>
19 The example program source:
21 <br><br>
22 <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
23 <tr bgcolor=#cccccc>
24 <td>
25 <pre><b>
26 #include &lt;stdio.h&gt;
27 #include &lt;stdlib.h&gt;
28 #include &lt;math.h&gt;
29 #include "vorbis/codec.h"
30 #include "vorbis/vorbisfile.h"
32 #ifdef _WIN32
33 #include &lt;io.h&gt;
34 #include &lt;fcntl.h&gt;
35 #endif
37 char pcmout[4096];
39 int main(int argc, char **argv){
40 OggVorbis_File vf;
41 int eof=0;
42 int current_section;
44 #ifdef _WIN32
45 _setmode( _fileno( stdin ), _O_BINARY );
46 _setmode( _fileno( stdout ), _O_BINARY );
47 #endif
49 if(ov_open_callbacks(stdin, &amp;vf, NULL, 0, OV_CALLBACKS_NOCLOSE) &lt; 0) {
50 fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
51 exit(1);
55 char **ptr=ov_comment(&amp;vf,-1)-&gt;user_comments;
56 vorbis_info *vi=ov_info(&amp;vf,-1);
57 while(*ptr){
58 fprintf(stderr,"%s\n",*ptr);
59 ++ptr;
61 fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi-&gt;channels,vi-&gt;rate);
62 fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&amp;vf,-1)-&gt;vendor);
65 while(!eof){
66 long ret=ov_read(&amp;vf,pcmout,sizeof(pcmout),0,2,1,&amp;current_section);
67 if (ret == 0) {
68 /* EOF */
69 eof=1;
70 } else if (ret &lt; 0) {
71 /* error in the stream. Not a problem, just reporting it in
72 case we (the app) cares. In this case, we don't. */
73 } else {
74 /* we don't bother dealing with sample rate changes, etc, but
75 you'll have to */
76 fwrite(pcmout,1,ret,stdout);
80 ov_clear(&amp;vf);
82 fprintf(stderr,"Done.\n");
83 return(0);
86 </b></pre>
87 </td>
88 </tr>
89 </table>
92 <br><br>
93 <hr noshade>
94 <table border=0 width=100%>
95 <tr valign=top>
96 <td><p class=tiny>copyright &copy; 2000-2010 Xiph.Org</p></td>
97 <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/index.html">Ogg Vorbis</a></p></td>
98 </tr><tr>
99 <td><p class=tiny>Vorbisfile documentation</p></td>
100 <td align=right><p class=tiny>vorbisfile version 1.3.2 - 20101101</p></td>
101 </tr>
102 </table>
104 </body>
106 </html>