4 <title>vorbisfile - Example Code</title>
5 <link rel=stylesheet href="style.css" type="text/css">
8 <body bgcolor=white text=black link="#5555ff" alink="#5555ff" vlink="#5555ff">
9 <table border=0 width=100%>
11 <td><p class=tiny>vorbisfile documentation</p></td>
12 <td align=right><p class=tiny>vorbisfile version 1.25 - 20000615</p></td>
19 The following is a run-through of the seeking example program supplied
20 with vorbisfile - <a href="seeking_test_c.html">seeking_test.c</a>.
21 This program tests the vorbisfile <a href="ov_time_seek.html">ov_time_seek</a> function by seeking to random points within the file.
24 First, relevant headers, including vorbis-specific "codec.h" and "vorbisfile.h" have to be included.
27 <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
31 #include <stdlib.h>
33 #include "vorbis/codec.h"
34 #include "vorbis/vorbisfile.h"
35 #include "../lib/misc.h"
41 <p>Inside main(), we declare our primary OggVorbis_File structure. We also declare a other helpful variables to track our progress within the file.
43 <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
55 <p><a href="ov_open.html">ov_open()</a> must be
56 called to initialize the <a href="OggVorbis_File.html">OggVorbis_File</a> structure with default values.
57 <a href="ov_open.html">ov_open()</a> also checks to ensure that we're reading Vorbis format and not something else.
60 <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
64 if(ov_open(stdin,&ov,NULL,-1)<0){
65 printf("Could not open input as an OggVorbis file.\n\n");
75 First we check to make sure the stream is seekable using <a href="ov_seekable.html">ov_seekable</a>.
77 <p>Then we seek to 100 random spots in the bitstream using <a href="ov_time_seek.html">ov_time_seek</a> with randomly generated values.
80 <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
85 /* print details about each logical bitstream in the input */
87 double length=ov_time_total(&ov,-1);
88 printf("testing seeking to random places in %g seconds....\n",length);
90 double val=(double)rand()/RAND_MAX*length;
91 ov_time_seek(&ov,val);
92 printf("\r\t%d [%gs]... ",i,val);
96 printf("\r \nOK.\n\n");
98 printf("Standard input was not seekable.\n");
106 When we're done seeking, we need to call <a href="ov_clear.html">ov_clear()</a> to release the bitstream.
109 <table border=0 width=100% color=black cellspacing=0 cellpadding=7>
122 The full source for seeking_test.c can be found with the vorbis
123 distribution in <a href="seeking_test_c.html">seeking_test.c</a>.
127 <table border=0 width=100%>
129 <td><p class=tiny>copyright © 2000 vorbis team</p></td>
130 <td align=right><p class=tiny><a href="http://www.xiph.org/ogg/vorbis/">Ogg Vorbis</a><br><a href="mailto:team@vorbis.org">team@vorbis.org</a></p></td>
132 <td><p class=tiny>vorbisfile documentation</p></td>
133 <td align=right><p class=tiny>vorbisfile version 1.25 - 20000615</p></td>