cannam@86: cannam@86: cannam@86:
cannam@86:Vorbisfile documentation |
cannam@86: vorbisfile version 1.3.2 - 20101101 |
cannam@86:
cannam@86: The example program source:
cannam@86:
cannam@86:
cannam@86:
cannam@86: cannam@86: #include <stdio.h> cannam@86: #include <stdlib.h> cannam@86: #include <math.h> cannam@86: #include "vorbis/codec.h" cannam@86: #include "vorbis/vorbisfile.h" cannam@86: cannam@86: #ifdef _WIN32 cannam@86: #include <io.h> cannam@86: #include <fcntl.h> cannam@86: #endif cannam@86: cannam@86: char pcmout[4096]; cannam@86: cannam@86: int main(int argc, char **argv){ cannam@86: OggVorbis_File vf; cannam@86: int eof=0; cannam@86: int current_section; cannam@86: cannam@86: #ifdef _WIN32 cannam@86: _setmode( _fileno( stdin ), _O_BINARY ); cannam@86: _setmode( _fileno( stdout ), _O_BINARY ); cannam@86: #endif cannam@86: cannam@86: if(ov_open_callbacks(stdin, &vf, NULL, 0, OV_CALLBACKS_NOCLOSE) < 0) { cannam@86: fprintf(stderr,"Input does not appear to be an Ogg bitstream.\n"); cannam@86: exit(1); cannam@86: } cannam@86: cannam@86: { cannam@86: char **ptr=ov_comment(&vf,-1)->user_comments; cannam@86: vorbis_info *vi=ov_info(&vf,-1); cannam@86: while(*ptr){ cannam@86: fprintf(stderr,"%s\n",*ptr); cannam@86: ++ptr; cannam@86: } cannam@86: fprintf(stderr,"\nBitstream is %d channel, %ldHz\n",vi->channels,vi->rate); cannam@86: fprintf(stderr,"Encoded by: %s\n\n",ov_comment(&vf,-1)->vendor); cannam@86: } cannam@86: cannam@86: while(!eof){ cannam@86: long ret=ov_read(&vf,pcmout,sizeof(pcmout),0,2,1,¤t_section); cannam@86: if (ret == 0) { cannam@86: /* EOF */ cannam@86: eof=1; cannam@86: } else if (ret < 0) { cannam@86: /* error in the stream. Not a problem, just reporting it in cannam@86: case we (the app) cares. In this case, we don't. */ cannam@86: } else { cannam@86: /* we don't bother dealing with sample rate changes, etc, but cannam@86: you'll have to */ cannam@86: fwrite(pcmout,1,ret,stdout); cannam@86: } cannam@86: } cannam@86: cannam@86: ov_clear(&vf); cannam@86: cannam@86: fprintf(stderr,"Done.\n"); cannam@86: return(0); cannam@86: } cannam@86: cannam@86:cannam@86: |
cannam@86:
copyright © 2000-2010 Xiph.Org |
cannam@86: cannam@86: |
Vorbisfile documentation |
cannam@86: vorbisfile version 1.3.2 - 20101101 |
cannam@86: