vorbisfile_example_c.html 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. <html>
  2. <head>
  3. <title>vorbisfile - vorbisfile_example.c</title>
  4. <link rel=stylesheet href="style.css" type="text/css">
  5. </head>
  6. <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
  7. <table border=0 width=100%>
  8. <tr>
  9. <td><p class=tiny>vorbisfile documentation</p></td>
  10. <td align=right><p class=tiny>vorbisfile version 1.25 - 20000615</p></td>
  11. </tr>
  12. </table>
  13. <h1>vorbisfile_example.c</h1>
  14. <p>
  15. The example program source:
  16. <br><br>
  17. <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
  18. <tr bgcolor=#cccccc>
  19. <td>
  20. <pre><b>
  21. #include &lt;stdio.h&gt;
  22. #include &lt;stdlib.h&gt;
  23. #include &lt;math.h&gt;
  24. #include "vorbis/codec.h"
  25. #include "vorbis/vorbisfile.h"
  26. #ifdef _WIN32
  27. #include &lt;io.h&gt;
  28. #include &lt;fcntl.h&gt;
  29. #endif
  30. char pcmout[4096];
  31. int main(int argc, char **argv){
  32. OggVorbis_File vf;
  33. int eof=0;
  34. int current_section;
  35. #ifdef _WIN32
  36. _setmode( _fileno( stdin ), _O_BINARY );
  37. _setmode( _fileno( stdout ), _O_BINARY );
  38. #endif
  39. if(ov_open(stdin, &vf, NULL, 0) < 0) {
  40. fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n");
  41. exit(1);
  42. }
  43. {
  44. char **ptr=ov_comment(&vf,-1)->user_comments;
  45. vorbis_info *vi=ov_info(&vf,-1);
  46. while(*ptr){
  47. fprintf(stderr,"%s\n",*ptr);
  48. ++ptr;
  49. }
  50. fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate);
  51. fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor);
  52. }
  53. while(!eof){
  54. long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,&current_section);
  55. if (ret == 0) {
  56. /* EOF */
  57. eof=1;
  58. } else if (ret < 0) {
  59. /* error in the stream. Not a problem, just reporting it in
  60. case we (the app) cares. In this case, we don't. */
  61. } else {
  62. /* we don't bother dealing with sample rate changes, etc, but
  63. you'll have to*/
  64. fwrite(pcmout,1,ret,stdout);
  65. }
  66. }
  67. ov_clear(&vf);
  68. fprintf(stderr,"Done.\n");
  69. return(0);
  70. }
  71. </b></pre>
  72. </td>
  73. </tr>
  74. </table>
  75. <br><br>
  76. <hr noshade>
  77. <table border=0 width=100%>
  78. <tr valign=top>
  79. <td><p class=tiny>copyright &copy; 2000 vorbis team</p></td>
  80. <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>
  81. </tr><tr>
  82. <td><p class=tiny>vorbisfile documentation</p></td>
  83. <td align=right><p class=tiny>vorbisfile version 1.25 - 20000615</p></td>
  84. </tr>
  85. </table>
  86. </body>
  87. </html>