aboutsummaryrefslogtreecommitdiff
path: root/oggread~
diff options
context:
space:
mode:
Diffstat (limited to 'oggread~')
-rw-r--r--oggread~/codec.h233
-rw-r--r--oggread~/help-oggread~.pd34
-rw-r--r--oggread~/oggread~.c413
-rw-r--r--oggread~/readme75
4 files changed, 755 insertions, 0 deletions
diff --git a/oggread~/codec.h b/oggread~/codec.h
new file mode 100644
index 0000000..9365ea3
--- /dev/null
+++ b/oggread~/codec.h
@@ -0,0 +1,233 @@
+/********************************************************************
+ * *
+ * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE. *
+ * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS *
+ * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *
+ * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING. *
+ * *
+ * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2001 *
+ * by the XIPHOPHORUS Company http://www.xiph.org/ *
+
+ ********************************************************************
+
+ function: libvorbis codec headers
+ last mod: $Id: codec.h,v 1.1 2002-11-26 10:51:49 ggeiger Exp $
+
+ ********************************************************************/
+
+#ifndef _vorbis_codec_h_
+#define _vorbis_codec_h_
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif /* __cplusplus */
+
+#include <ogg/ogg.h>
+
+typedef struct vorbis_info{
+ int version;
+ int channels;
+ long rate;
+
+ /* The below bitrate declarations are *hints*.
+ Combinations of the three values carry the following implications:
+
+ all three set to the same value:
+ implies a fixed rate bitstream
+ only nominal set:
+ implies a VBR stream that averages the nominal bitrate. No hard
+ upper/lower limit
+ upper and or lower set:
+ implies a VBR bitstream that obeys the bitrate limits. nominal
+ may also be set to give a nominal rate.
+ none set:
+ the coder does not care to speculate.
+ */
+
+ long bitrate_upper;
+ long bitrate_nominal;
+ long bitrate_lower;
+ long bitrate_window;
+
+ void *codec_setup;
+} vorbis_info;
+
+/* vorbis_dsp_state buffers the current vorbis audio
+ analysis/synthesis state. The DSP state belongs to a specific
+ logical bitstream ****************************************************/
+typedef struct vorbis_dsp_state{
+ int analysisp;
+ vorbis_info *vi;
+
+ float **pcm;
+ float **pcmret;
+ int pcm_storage;
+ int pcm_current;
+ int pcm_returned;
+
+ int preextrapolate;
+ int eofflag;
+
+ long lW;
+ long W;
+ long nW;
+ long centerW;
+
+ ogg_int64_t granulepos;
+ ogg_int64_t sequence;
+
+ ogg_int64_t glue_bits;
+ ogg_int64_t time_bits;
+ ogg_int64_t floor_bits;
+ ogg_int64_t res_bits;
+
+ void *backend_state;
+} vorbis_dsp_state;
+
+typedef struct vorbis_block{
+ /* necessary stream state for linking to the framing abstraction */
+ float **pcm; /* this is a pointer into local storage */
+ oggpack_buffer opb;
+
+ long lW;
+ long W;
+ long nW;
+ int pcmend;
+ int mode;
+
+ int eofflag;
+ ogg_int64_t granulepos;
+ ogg_int64_t sequence;
+ vorbis_dsp_state *vd; /* For read-only access of configuration */
+
+ /* local storage to avoid remallocing; it's up to the mapping to
+ structure it */
+ void *localstore;
+ long localtop;
+ long localalloc;
+ long totaluse;
+ struct alloc_chain *reap;
+
+ /* bitmetrics for the frame */
+ long glue_bits;
+ long time_bits;
+ long floor_bits;
+ long res_bits;
+
+ void *internal;
+
+} vorbis_block;
+
+/* vorbis_block is a single block of data to be processed as part of
+the analysis/synthesis stream; it belongs to a specific logical
+bitstream, but is independant from other vorbis_blocks belonging to
+that logical bitstream. *************************************************/
+
+struct alloc_chain{
+ void *ptr;
+ struct alloc_chain *next;
+};
+
+/* vorbis_info contains all the setup information specific to the
+ specific compression/decompression mode in progress (eg,
+ psychoacoustic settings, channel setup, options, codebook
+ etc). vorbis_info and substructures are in backends.h.
+*********************************************************************/
+
+/* the comments are not part of vorbis_info so that vorbis_info can be
+ static storage */
+typedef struct vorbis_comment{
+ /* unlimited user comment fields. libvorbis writes 'libvorbis'
+ whatever vendor is set to in encode */
+ char **user_comments;
+ int *comment_lengths;
+ int comments;
+ char *vendor;
+
+} vorbis_comment;
+
+
+/* libvorbis encodes in two abstraction layers; first we perform DSP
+ and produce a packet (see docs/analysis.txt). The packet is then
+ coded into a framed OggSquish bitstream by the second layer (see
+ docs/framing.txt). Decode is the reverse process; we sync/frame
+ the bitstream and extract individual packets, then decode the
+ packet back into PCM audio.
+
+ The extra framing/packetizing is used in streaming formats, such as
+ files. Over the net (such as with UDP), the framing and
+ packetization aren't necessary as they're provided by the transport
+ and the streaming layer is not used */
+
+/* Vorbis PRIMITIVES: general ***************************************/
+
+extern void vorbis_info_init(vorbis_info *vi);
+extern void vorbis_info_clear(vorbis_info *vi);
+extern int vorbis_info_blocksize(vorbis_info *vi,int zo);
+extern void vorbis_comment_init(vorbis_comment *vc);
+extern void vorbis_comment_add(vorbis_comment *vc, char *comment);
+extern void vorbis_comment_add_tag(vorbis_comment *vc,
+ char *tag, char *contents);
+extern char *vorbis_comment_query(vorbis_comment *vc, char *tag, int count);
+extern int vorbis_comment_query_count(vorbis_comment *vc, char *tag);
+extern void vorbis_comment_clear(vorbis_comment *vc);
+
+extern int vorbis_block_init(vorbis_dsp_state *v, vorbis_block *vb);
+extern int vorbis_block_clear(vorbis_block *vb);
+extern void vorbis_dsp_clear(vorbis_dsp_state *v);
+
+/* Vorbis PRIMITIVES: analysis/DSP layer ****************************/
+
+extern int vorbis_analysis_init(vorbis_dsp_state *v,vorbis_info *vi);
+extern int vorbis_commentheader_out(vorbis_comment *vc, ogg_packet *op);
+extern int vorbis_analysis_headerout(vorbis_dsp_state *v,
+ vorbis_comment *vc,
+ ogg_packet *op,
+ ogg_packet *op_comm,
+ ogg_packet *op_code);
+extern float **vorbis_analysis_buffer(vorbis_dsp_state *v,int vals);
+extern int vorbis_analysis_wrote(vorbis_dsp_state *v,int vals);
+extern int vorbis_analysis_blockout(vorbis_dsp_state *v,vorbis_block *vb);
+extern int vorbis_analysis(vorbis_block *vb,ogg_packet *op);
+
+extern int vorbis_bitrate_addblock(vorbis_block *vb);
+extern int vorbis_bitrate_flushpacket(vorbis_dsp_state *vd,
+ ogg_packet *op);
+
+/* Vorbis PRIMITIVES: synthesis layer *******************************/
+extern int vorbis_synthesis_headerin(vorbis_info *vi,vorbis_comment *vc,
+ ogg_packet *op);
+
+extern int vorbis_synthesis_init(vorbis_dsp_state *v,vorbis_info *vi);
+extern int vorbis_synthesis(vorbis_block *vb,ogg_packet *op);
+extern int vorbis_synthesis_trackonly(vorbis_block *vb,ogg_packet *op);
+extern int vorbis_synthesis_blockin(vorbis_dsp_state *v,vorbis_block *vb);
+extern int vorbis_synthesis_pcmout(vorbis_dsp_state *v,float ***pcm);
+extern int vorbis_synthesis_read(vorbis_dsp_state *v,int samples);
+extern long vorbis_packet_blocksize(vorbis_info *vi,ogg_packet *op);
+
+/* Vorbis ERRORS and return codes ***********************************/
+
+#define OV_FALSE -1
+#define OV_EOF -2
+#define OV_HOLE -3
+
+#define OV_EREAD -128
+#define OV_EFAULT -129
+#define OV_EIMPL -130
+#define OV_EINVAL -131
+#define OV_ENOTVORBIS -132
+#define OV_EBADHEADER -133
+#define OV_EVERSION -134
+#define OV_ENOTAUDIO -135
+#define OV_EBADPACKET -136
+#define OV_EBADLINK -137
+#define OV_ENOSEEK -138
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif
+
diff --git a/oggread~/help-oggread~.pd b/oggread~/help-oggread~.pd
new file mode 100644
index 0000000..a37e225
--- /dev/null
+++ b/oggread~/help-oggread~.pd
@@ -0,0 +1,34 @@
+#N canvas 415 163 496 344 10;
+#X obj 35 298 dac~;
+#X floatatom 78 268 5 0 0;
+#X obj 35 236 oggread~;
+#X msg 55 83 start;
+#X msg 94 128 stop;
+#X msg 117 180 resume;
+#X msg 35 45 open myfile.ogg;
+#X text 99 81 play file from beginning;
+#X text 132 126 stop (pause) playing;
+#X text 165 179 resume playing at current position;
+#X msg 317 275 \; pd dsp 1;
+#X msg 383 275 \; pd dsp 0;
+#X obj 317 249 loadbang;
+#X text 185 50 get latest version at;
+#X text 186 63 http://www.akustische-kunst.de/puredata/;
+#X text 121 269 position in file (seconds);
+#X text 186 38 written by Olaf Matthes <olaf.matthes@gmx.de>;
+#X text 17 16 oggread~ version 0.2 - Ogg Vorbis file player;
+#X msg 110 152 0;
+#X msg 72 105 1;
+#X msg 148 210 seek 60;
+#X text 206 210 set new playing position (in seconds);
+#X connect 2 0 0 0;
+#X connect 2 1 0 1;
+#X connect 2 2 1 0;
+#X connect 3 0 2 0;
+#X connect 4 0 2 0;
+#X connect 5 0 2 0;
+#X connect 6 0 2 0;
+#X connect 12 0 10 0;
+#X connect 18 0 2 0;
+#X connect 19 0 2 0;
+#X connect 20 0 2 0;
diff --git a/oggread~/oggread~.c b/oggread~/oggread~.c
new file mode 100644
index 0000000..af07fb0
--- /dev/null
+++ b/oggread~/oggread~.c
@@ -0,0 +1,413 @@
+/* ------------------------- oggread~ ------------------------------------------ */
+/* */
+/* Tilde object to read and play back Ogg Vorbis files. */
+/* Written by Olaf Matthes (olaf.matthes@gmx.de) */
+/* Get source at http://www.akustische-kunst.de/puredata/ */
+/* */
+/* This library is free software; you can redistribute it and/or */
+/* modify it under the terms of the GNU Lesser General Public */
+/* License as published by the Free Software Foundation; either */
+/* version 2 of the License, or (at your option) any later version. */
+/* */
+/* This library is distributed in the hope that it will be useful, */
+/* but WITHOUT ANY WARRANTY; without even the implied warranty of */
+/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU */
+/* Lesser General Public License for more details. */
+/* */
+/* You should have received a copy of the GNU Lesser General Public */
+/* License along with this library; if not, write to the */
+/* Free Software Foundation, Inc., 59 Temple Place - Suite 330, */
+/* Boston, MA 02111-1307, USA. */
+/* */
+/* Based on PureData by Miller Puckette and others. */
+/* Uses the Ogg Vorbis decoding library which can be found at */
+/* http://www.vorbis.com/ */
+/* */
+/* ---------------------------------------------------------------------------- */
+
+
+#include "m_imp.h"
+#include "g_canvas.h"
+#include "codec.h"
+#include "vorbis/vorbisfile.h"
+
+#include <sys/types.h>
+#include <string.h>
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#ifdef UNIX
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <netinet/tcp.h>
+#include <arpa/inet.h>
+#include <netdb.h>
+#include <sys/time.h>
+#include <unistd.h>
+#define SOCKET_ERROR -1
+#else
+#include <io.h>
+#include <stdlib.h>
+#endif
+
+#ifdef NT
+#pragma warning( disable : 4244 )
+#pragma warning( disable : 4305 )
+#endif
+
+#define READ 4096 /* amount of data we pass on to decoder */
+#define MIN_AUDIO_INPUT READ*8 /* this is completely guessed! we just fill half the buffer */
+#define OUTPUT_BUFFER_SIZE 65536 /* audio output buffer: 64k */
+
+static char *oggread_version = "oggread~: ogg/vorbis file reader version 0.2b, written by Olaf Matthes";
+
+/* ------------------------ oggread~ ----------------------------- */
+
+static t_class *oggread_class;
+
+typedef struct _oggread
+{
+ t_object x_obj;
+ t_clock *x_clock;
+ /* ogg/vorbis related stuff */
+ OggVorbis_File x_ov;
+ ogg_stream_state x_os; /* take physical pages, weld into a logical stream of packets */
+ ogg_sync_state x_oy; /* sync and verify incoming physical bitstream */
+ ogg_page x_og; /* one Ogg bitstream page. Vorbis packets are inside */
+ ogg_packet x_op; /* one raw packet of data for decode */
+ vorbis_info *x_vi; /* struct that stores all the static vorbis bitstream settings */
+ vorbis_comment x_vc; /* struct that stores all the user comments */
+ vorbis_dsp_state x_vd; /* central working state for the packet->PCM decoder */
+ vorbis_block x_vb; /* local working space for packet->PCM decode */
+ t_int x_eos; /* end of stream */
+ char *x_buffer;/* buffer used to pass on data to ogg/vorbis */
+
+ t_float x_position; /* current playing position */
+ t_outlet *x_out_position; /* output to send them to */
+
+
+ t_outlet *x_connection;
+ t_int x_fd; /* the file handle */
+ FILE *x_file;
+ int x_current_section;
+ t_int x_blocksize; /* size of a dsp block */
+ t_int x_decoded; /* number of samples we got from decoder on last call */
+
+ t_float *x_outbuffer; /* buffer to store audio decoded data */
+ t_int x_outwriteposition;
+ t_int x_outreadposition;
+ t_int x_outunread;
+ t_int x_outbuffersize;
+
+ t_int x_samplerate; /* pd's samplerate, might differ from stream */
+ t_int x_stream; /* indicates if a stream gets output */
+} t_oggread;
+
+ /* output playing position */
+static void oggread_tick(t_oggread *x)
+{
+ outlet_float(x->x_out_position, x->x_position);
+ clock_delay(x->x_clock, 250);
+}
+
+static int oggread_decode_input(t_oggread *x)
+{
+ long ret; /* bytes per channel returned by decoder */
+ int i;
+ float **pcm;
+
+ x->x_vi = ov_info(&x->x_ov, x->x_current_section);
+
+ while(!x->x_eos)
+ {
+ ret = ov_read_float(&x->x_ov, &pcm, READ, &x->x_current_section);
+ if (ret == 0)
+ {
+ /* EOF */
+ x->x_eos = 1;
+ x->x_stream = 0;
+ clock_unset(x->x_clock);
+ post("oggread~: end of file detected, stopping");
+ }
+ else if (ret < 0)
+ {
+ /* error in the stream. Not a problem, just reporting it in
+ case we (the app) cares. In this case, we don't. */
+ }
+ else
+ {
+ /* we don't bother dealing with sample rate changes, etc, but
+ you'll have to */
+ long j;
+ for(j = 0; j < ret; j++)
+ {
+ for(i = 0; i < x->x_vi->channels; i++)
+ {
+ x->x_outbuffer[x->x_outwriteposition] = pcm[i][j];
+ x->x_outwriteposition = (x->x_outwriteposition + 1)%x->x_outbuffersize;
+ }
+ }
+ x->x_outunread += (t_int)ret * x->x_vi->channels;
+
+ }
+ break;
+ }
+ x->x_decoded = (t_int)ret * x->x_vi->channels; /* num. of samples we got from decoder */
+
+ x->x_position = (t_float)ov_time_tell(&x->x_ov);
+
+ /* exit decoding 'loop' here, we'll get called again by perform() */
+ return 1;
+}
+
+
+static t_int *oggread_perform(t_int *w)
+{
+ t_oggread *x = (t_oggread*) (w[1]);
+ t_float *out1 = (t_float *)(w[2]);
+ t_float *out2 = (t_float *)(w[3]);
+ int n = (int)(w[4]);
+ int ret;
+ int i = 0;
+
+ x->x_blocksize = n;
+
+ while( n-- )
+ { /* check that the stream provides enough data */
+ if((x->x_stream == 1) && (x->x_outunread > (x->x_blocksize * x->x_vi->channels)))
+ {
+ if(x->x_vi->channels != 1) /* play stereo */
+ {
+ *out1++=*(x->x_outbuffer+x->x_outreadposition);
+ x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize;
+ *out2++=*(x->x_outbuffer+x->x_outreadposition);
+ x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize;
+ x->x_outunread-=2;
+ }
+ else /* play mono on both sides */
+ {
+ *out1++=*(x->x_outbuffer+x->x_outreadposition);
+ *out2++=*(x->x_outbuffer+x->x_outreadposition);
+ x->x_outreadposition = (x->x_outreadposition + 1)%x->x_outbuffersize;
+ x->x_outunread--;
+ }
+ }
+ else /* silence in case of buffer underrun */
+ {
+ *out1++=0.0;
+ *out2++=0.0;
+ }
+ }
+
+ /* decode data whenever we used up some samples from outbuffer */
+ if((x->x_fd > 0) && (x->x_stream) /* only go when file is open and ready */
+ && (x->x_outunread < (MIN_AUDIO_INPUT - x->x_decoded))) /* we used up data from last decode */
+ {
+ // post("oggread~: decoding...");
+ if(oggread_decode_input(x) != 1)
+ {
+ post("oggread~: decoder error");
+ }
+ // else post("oggread~: decoder returned %d samples", x->x_decoded);
+ }
+ return (w+5);
+}
+
+static void oggread_dsp(t_oggread *x, t_signal **sp)
+{
+ dsp_add(oggread_perform, 4, x, sp[1]->s_vec, sp[2]->s_vec, sp[1]->s_n);
+}
+
+
+ /* start playing */
+static void oggread_start(t_oggread *x)
+{
+ if(x->x_fd > 0)
+ {
+ if(ov_time_seek(&x->x_ov, 0) < 0)
+ {
+ post("oggread~: could not rewind file to beginning");
+ }
+ post("oggread~: START");
+ x->x_eos = 0;
+ x->x_outreadposition = 0;
+ x->x_outwriteposition = 0;
+ x->x_outunread = 0;
+ x->x_position = 0;
+ clock_delay(x->x_clock, 0);
+ x->x_stream = 1;
+ }
+ else post("oggread~: no file open (ignored)");
+}
+
+ /* resume file reading */
+static void oggread_resume(t_oggread *x)
+{
+ if(x->x_fd > 0)
+ {
+ x->x_stream = 1;
+ clock_delay(x->x_clock, 0);
+ post("oggread~: RESUME");
+ }
+ else post("oggread~: encoder not initialised");
+}
+
+ /* seek in file */
+static void oggread_seek(t_oggread *x, t_floatarg f)
+{
+ if(x->x_fd > 0)
+ if(ov_time_seek(&x->x_ov, f) < 0)
+ {
+ post("oggread~: could not set playing position to %g seconds", f);
+ }
+ else post("oggread~: playing position set to %g seconds", f);
+}
+
+ /* stop playing */
+static void oggread_stop(t_oggread *x)
+{
+ if(x->x_stream)post("oggread~: STOP");
+ x->x_stream = 0;
+ clock_unset(x->x_clock);
+}
+
+static void oggread_float(t_oggread *x, t_floatarg f)
+{
+ if(f == 0) oggread_stop(x);
+ else oggread_start(x);
+}
+
+ /* open ogg/vorbis file */
+static void oggread_open(t_oggread *x, t_symbol *filename)
+{
+ int i;
+
+ x->x_stream = 0;
+ /* first close previous file */
+ if(x->x_fd > 0)
+ {
+ ov_clear(&x->x_ov);
+ post("oggread~: previous file closed");
+ }
+ /* open file for reading */
+#ifdef UNIX
+ if((x->x_file = fopen(filename->s_name, "r")) < 0)
+#else
+ if((x->x_file = fopen(filename->s_name, "rb")) < 0)
+#endif
+ {
+ post("oggread~: could not open file \"%s\"", filename->s_name);
+ x->x_eos = 1;
+ x->x_fd = -1;
+ }
+ else
+ {
+ x->x_stream = 0;
+ x->x_eos = 0;
+ x->x_fd = 1;
+ x->x_outreadposition = 0;
+ x->x_outwriteposition = 0;
+ x->x_outunread = 0;
+ post("oggread~: file \"%s\" opened", filename->s_name);
+ outlet_float( x->x_out_position, 0);
+
+ /* try to open as ogg vorbis file */
+ if(ov_open(x->x_file, &x->x_ov, NULL, -1) < 0)
+ { /* an error occured (no ogg vorbis file ?) */
+ post("oggread~: error: could not open \"%s\" as an OggVorbis file", filename->s_name);
+ ov_clear(&x->x_ov);
+ post("oggread~: file closed due to error");
+ }
+
+ /* print details about each logical bitstream in the input */
+ if(ov_seekable(&x->x_ov))
+ {
+ post("oggread~: input bitstream contained %ld logical bitstream section(s)", ov_streams(&x->x_ov));
+ post("oggread~: total bitstream playing time: %ld seconds", (long)ov_time_total(&x->x_ov,-1));
+ post("oggread~: encoded by: %s\n",ov_comment(&x->x_ov,-1)->vendor);
+ }
+ else
+ {
+ post("oggread~: file \"%s\" was not seekable"
+ "oggread~: first logical bitstream information:", filename->s_name);
+ }
+
+ for(i = 0; i < ov_streams(&x->x_ov); i++)
+ {
+ x->x_vi = ov_info(&x->x_ov,i);
+ post("\tlogical bitstream section %d information:",i+1);
+ post("\t\t%ldHz %d channels bitrate %ldkbps serial number=%ld",
+ x->x_vi->rate,x->x_vi->channels,ov_bitrate(&x->x_ov,i)/1000, ov_serialnumber(&x->x_ov,i));
+ post("\t\theader length: %ld bytes",(long)
+ (x->x_ov.dataoffsets[i] - x->x_ov.offsets[i]));
+ post("\t\tcompressed length: %ld bytes",(long)(ov_raw_total(&x->x_ov,i)));
+ post("\t\tplay time: %ld seconds\n",(long)ov_time_total(&x->x_ov,i));
+ }
+
+ }
+}
+
+
+static void oggread_free(t_oggread *x)
+{
+ if (x->x_fd > 0) {
+ post( "oggread~: closing file" );
+ ov_clear(&x->x_ov);
+ x->x_fd = -1;
+ }
+ freebytes(x->x_outbuffer, OUTPUT_BUFFER_SIZE*sizeof(t_float));
+ clock_free(x->x_clock);
+}
+
+static void *oggread_new(t_floatarg fdographics)
+{
+ t_oggread *x = NULL;
+
+ x = (t_oggread *)pd_new(oggread_class);
+ outlet_new(&x->x_obj, gensym("signal"));
+ outlet_new(&x->x_obj, gensym("signal"));
+ x->x_out_position = outlet_new(&x->x_obj, gensym("float"));
+ x->x_clock = clock_new(x, (t_method)oggread_tick);
+
+ x->x_fd = -1;
+ x->x_eos = 1;
+ x->x_stream = 0;
+ x->x_position = 0;
+ x->x_samplerate = sys_getsr();
+
+ x->x_outbuffersize = OUTPUT_BUFFER_SIZE;
+ x->x_outbuffer = (t_float*) getbytes(OUTPUT_BUFFER_SIZE*sizeof(t_float));
+
+ if(!x->x_outbuffer)
+ {
+ post( "oggread~: could not allocate buffer" );
+ return NULL;
+ }
+ memset(x->x_outbuffer, 0x0, OUTPUT_BUFFER_SIZE);
+
+ x->x_outreadposition = 0;
+ x->x_outwriteposition = 0;
+ x->x_outunread = 0;
+ x->x_decoded = 0;
+
+ post(oggread_version);
+
+ return (x);
+}
+
+
+void oggread_tilde_setup(void)
+{
+ oggread_class = class_new(gensym("oggread~"),
+ (t_newmethod) oggread_new, (t_method) oggread_free,
+ sizeof(t_oggread), 0, A_DEFFLOAT, A_NULL);
+ class_addfloat(oggread_class, (t_method)oggread_float);
+ class_addmethod(oggread_class, nullfn, gensym("signal"), 0);
+ class_addmethod(oggread_class, (t_method)oggread_dsp, gensym("dsp"), 0);
+ class_addmethod(oggread_class, (t_method)oggread_open, gensym("open"), A_SYMBOL, 0);
+ class_addmethod(oggread_class, (t_method)oggread_start, gensym("start"), 0);
+ class_addmethod(oggread_class, (t_method)oggread_resume, gensym("resume"), 0);
+ class_addmethod(oggread_class, (t_method)oggread_seek, gensym("seek"), A_DEFFLOAT, 0);
+ class_addmethod(oggread_class, (t_method)oggread_stop, gensym("stop"), 0);
+ class_sethelpsymbol(oggread_class, gensym("help-oggread~.pd"));
+}
diff --git a/oggread~/readme b/oggread~/readme
new file mode 100644
index 0000000..0f61fc8
--- /dev/null
+++ b/oggread~/readme
@@ -0,0 +1,75 @@
+oggread~ version 0.2a
+copyright (c) 2002 by Olaf Matthes
+
+oggread~ is an ogg/vorbis file player external for pd (by Miller
+Puckette).
+
+
+To run oggread~ place the file oggread~.dll for win or oggread~.pd_linux
+in the directory of our patch or start pd with '-lib oggread~' flag.
+
+To compile oggread~ on Linux get the ogg/vorbice library from
+http://www.vorbis.com/.
+You have to modify the makefile to make it point to the place where the
+ogg/vorbis library is.
+
+
+This software is published under LGPL terms.
+
+This is software with ABSOLUTELY NO WARRANTY.
+Use it at your OWN RISK. It's possible to damage e.g. hardware or your hearing
+due to a bug or for other reasons.
+
+*****************************************************************************
+
+oggread~ uses the ogg/vorbice library to encode audio data.
+The latest version of ogg/vorbis can be found at http://www.vorbice.com/
+
+Below is the original copyright information taken from the ogg/vorbis library:
+
+
+Copyright (c) 2001, Xiphophorus
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+- Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+
+- Redistributions in binary form must reproduce the above copyright
+notice, this list of conditions and the following disclaimer in the
+documentation and/or other materials provided with the distribution.
+
+- Neither the name of the Xiphophorus nor the names of its contributors
+may be used to endorse or promote products derived from this software
+without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR
+CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*****************************************************************************
+
+Listening to it:
+
+To listen to ogg/vorbis encoded audio files many player need an extra plug-in.
+Have a look at http://www.vorbis.com/ to find the appropiate plug-in for your
+player.
+
+
+
+
+
+Latest version can be found at:
+http://www.akustische-kunst.de/puredata/
+
+Please report any bugs to olaf.matthes@gmx.de! \ No newline at end of file