[xiph-commits] r8256 - in experimental/dholth/oggpy: . tests

dholth at motherfish-iii.xiph.org dholth at motherfish-iii.xiph.org
Mon Nov 22 18:07:46 PST 2004


Author: dholth
Date: 2004-11-22 18:07:45 -0800 (Mon, 22 Nov 2004)
New Revision: 8256

Modified:
   experimental/dholth/oggpy/Makefile
   experimental/dholth/oggpy/oggcc.cc
   experimental/dholth/oggpy/oggpy.pyste
   experimental/dholth/oggpy/setup.py
   experimental/dholth/oggpy/tests/decode.py
   experimental/dholth/oggpy/tests/oggtext.py
   experimental/dholth/oggpy/tests/test.py
   experimental/dholth/oggpy/tests/theoratest.py
   experimental/dholth/oggpy/theoracc.h
   experimental/dholth/oggpy/theorapy.pyste
   experimental/dholth/oggpy/vorbispy.pyste
   experimental/dholth/oggpy/vorbispy_wrappers.cc
Log:
patch-23


Modified: experimental/dholth/oggpy/Makefile
===================================================================
--- experimental/dholth/oggpy/Makefile	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/Makefile	2004-11-23 02:07:45 UTC (rev 8256)
@@ -3,9 +3,9 @@
 
 all: module
 
-multiple: oggpy.pyste vorbispy.pyste theorapy.pyste
-	pyste --multiple --module=oggpy --out=oggpy -I. -I$(PYTHON_HEADER_DIR) -I$(BOOST_HEADER_DIR) -I$(HOME)/include/theora \
-	oggpy.pyste vorbispy.pyste theorapy.pyste
+#multiple: oggpy.pyste vorbispy.pyste theorapy.pyste
+#	pyste --multiple --module=oggpy --out=oggpy -I. -I$(PYTHON_HEADER_DIR) -I$(BOOST_HEADER_DIR) -I$(HOME)/include/theora \
+#	oggpy.pyste vorbispy.pyste theorapy.pyste
 
 oggpy.cpp: oggpy_wrappers.h oggcc.cc oggcc.h oggpy.pyste
 	pyste --module=oggpy --out=oggpy.cpp -I. -I$(PYTHON_HEADER_DIR) -I$(BOOST_HEADER_DIR) oggpy.pyste
@@ -17,9 +17,12 @@
 	pyste --module=theorapy --out=theorapy.cpp -I. \
 	-I$(PYTHON_HEADER_DIR) -I$(BOOST_HEADER_DIR) -I$(HOME)/include/theora  theorapy.pyste
 
-module: oggpy.cpp vorbispy.cpp theorapy.cpp oggcc.cc oggcc.h vorbispy_wrappers.cc vorbispy_wrappers.h
+module: theorapy.cpp oggpy.cpp vorbispy.cpp
 	python ./setup.py build
 
+bridge:
+	python ./setup.py build
+
 webcode: tests/*.py
 
 .py .html:

Modified: experimental/dholth/oggpy/oggcc.cc
===================================================================
--- experimental/dholth/oggpy/oggcc.cc	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/oggcc.cc	2004-11-23 02:07:45 UTC (rev 8256)
@@ -4,5 +4,46 @@
  * 19 Jan. 2004
  */
 
+/** \mainpage oggpy's C++ API
+ * \section Intro
+ *
+ *  Oggpy is a new binding that lets you write Python
+ *  programs that take advantage of ogg, vorbis,
+ *  and theora.  It was put together with the excellent <a
+ *  href="http://boost.org/libs/python/doc/index.html">Boost.Python</a>
+ *  library; so, as a side effect of writing the Python wrapper, there is
+ *  also a thin C++ wrapper for these xiph.org libraries.
+ *
+ *  This is the documentation for those C++ libraries.
+ *
+ *  Oggpy's home is http://dingoskidneys.com/oggpy/
+ *
+ * \section License
+ *  Copyright (c) 2004 Daniel Holth <dholth at fastmail.fm>
+ *
+ *  Permission is hereby granted, free of charge, to any person obtaining a
+ *  copy of this software and associated documentation files (the "Software"),
+ *  to deal in the Software without restriction, including without limitation
+ *  the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ *  and/or sell copies of the Software, and to permit persons to whom the
+ *  Software is furnished to do so, subject to the following conditions:
+ *
+ *  The above copyright notice and this permission notice shall be included
+ *  in all copies or substantial portions of the Software.
+ *
+ *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ *  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ *  THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ *  OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ *  ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ *  OTHER DEALINGS IN THE SOFTWARE.
+ *
+ *  Although the license does not require it, I encourage you to share with
+ *  me any enhancements you make or bugs you find.  Thanks for trying oggpy.
+ *
+ * \author Daniel Holth <dholth at fastmail.fm>
+ */
+
 #include "oggcc.h"
 

Modified: experimental/dholth/oggpy/oggpy.pyste
===================================================================
--- experimental/dholth/oggpy/oggpy.pyste	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/oggpy.pyste	2004-11-23 02:07:45 UTC (rev 8256)
@@ -1,3 +1,6 @@
+# Pyste wrapper for ogg.
+# Daniel Holth <dholth at fastmail.fm>, Mar. 2004
+
 def document(element, blurb):
 	"""Add a docstring to a definition"""
 	element._Attribute('doc', blurb)
@@ -2,34 +5,2 @@
 
-Include("oggpy_wrappers.h")
-Include("oggcc.h")
-
-# oggpy    = AllFromHeader("oggcc.h")
-
-# exclude(oggpy.oggpack_base)
-# exclude(oggpy.oggpack_base.get_data)
-# exclude(oggpy.oggpack_base.get_buffer)
-# exclude(oggpy.oggpack.get_buffer)
-# exclude(oggpy.oggpack.get_data)
-# exclude(oggpy.oggpackB.get_buffer)
-# exclude(oggpy.oggpackB.get_data)
-# exclude(oggpy.packet.data)
-# exclude(oggpy.packet.get_data)
-# exclude(oggpy.page.data)
-# exclude(oggpy.page.get_data)
-# exclude(oggpy.stream.data)
-# exclude(oggpy.sync.buffer)
-# exclude(oggpy.sync.data)
-# exclude(oggpy.sync.wrote)
-# exclude(oggpy.userpacket.get_data)
-#
-# syncwrite = Function("ogg::sync_write", "oggpy_wrappers.h")
-# oggpy.syncwrite = syncwrite
-#
-# document(oggpy.sync, "Separate streams into ogg pages")
-# document(oggpy.sync.pageout, "Produce a page.")
-#
-# add_method(oggpy.sync, "sync_write")
-
-# New AllFromHeader-free version:
-    
 packet       = Class("ogg::packet", "oggcc.h")

Modified: experimental/dholth/oggpy/setup.py
===================================================================
--- experimental/dholth/oggpy/setup.py	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/setup.py	2004-11-23 02:07:45 UTC (rev 8256)
@@ -6,7 +6,7 @@
 import os.path
 import sys
 
-extra_include_dirs = [".", "/home/dholth/include/theora"]
+extra_include_dirs = [".", "/home/dholth/include/theora", "/usr/include/SDL"]
 
 if sys.version[0:3] == "2.3":
     boost = "/home/dholth/opt/include/boost-1_31" # boost.python include path
@@ -31,7 +31,7 @@
 """
 
 setup(name="oggpy",
-      version="0.3",
+      version="0.4",
       description="Boost.Python and C++ wrappers of ogg, vorbis and theora",
       long_description=description,
       author="Daniel Holth",
@@ -52,7 +52,8 @@
                    
                     Extension("theorapy", ["oggcc.cc", "theorapy.cpp"],
                               libraries=["ogg", "theora", boostlib],
-                              include_dirs=extra_include_dirs, depends=["oggcc.h", "theoracc.h"])                    
+                              include_dirs=extra_include_dirs, depends=["oggcc.h", "theoracc.h"])
+
 # If we want to statically link libboost_python we would have to put
 # everything in one file; this doesn't work right away due to name
 # collisions.
@@ -61,6 +62,11 @@
 #                              "oggpy/_vorbispy.cpp", "vorbispy_wrappers.cc", "oggpy_wrappers.cc"],
 #                              libraries=["ogg", "theora", "vorbis", "vorbisenc", boostlib],
 #                              include_dirs=extra_include_dirs, depends=["oggcc.h", "theoracc.h"])
-                  ]
+                    # this is broken too; I think the pygame <--> boost connection is not all there.
+                    # Extension("pygame_bridge", ["pygame_bridge.cc"],
+                    #     libraries=["SDL", "ogg", "theora", boostlib],
+                    #     include_dirs=extra_include_dirs)
+
+                    ]
      )
 

Modified: experimental/dholth/oggpy/tests/decode.py
===================================================================
--- experimental/dholth/oggpy/tests/decode.py	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/tests/decode.py	2004-11-23 02:07:45 UTC (rev 8256)
@@ -10,126 +10,112 @@
 import oggpy
 import vorbispy
 import numarray
+import wave
 
 BUFSIZE=8192
 
-def test(ogg, outfile=file("decode.raw", "w")):
-    numarray.Error.setMode(all="ignore")
+
+def packetsource(ogg):
+    """Generator to take ogg packets out of a file.  Only returns packets from the first stream."""
+    state = 0
     
     oy = oggpy.sync()
     og = oggpy.page()
     op = oggpy.packet()
+
+    buffer = True   # prime the pump
+    while buffer:
+        buffer = ogg.read(BUFSIZE)
+        oy.write(buffer)
+        while(oy.pageout(og)):
+            if state == 0:
+                stream = oggpy.stream(og.serialno())
+                state += 1
+            stream.pagein(og)
+            while(stream.packetout(op) == 1):
+                yield op
+
+
+
+def test(ogg, outfile = None):
+    numarray.Error.setMode(all="ignore")
     
     vi = vorbispy.info()
     vd = vorbispy.dsp()
     vb = vorbispy.block()
     vc = vorbispy.comment()
 
-    while 1:
-        buffer = ogg.read(BUFSIZE)
-        oy.write(buffer)
+    packets = packetsource(ogg)
 
-        if oy.pageout(og) != 1:
-            if len(buffer) < BUFSIZE: break
-            print >> sys.stderr, "Input does not appear to be an Ogg bitstream."
-            sys.exit(1)
+    vorbis = 0
+    for packet in packets:
+        
+        if vorbis < 3:
+            rc = vi.synthesis_headerin(vc, packet)
+            if rc < 0:
+                print "Faulty vorbis header #%d, error %d" % (vorbis, rc)                
+                return
+            
+        elif vorbis == 3: 
+            print >> sys.stderr, vc.get_comments()
 
-        os = oggpy.stream(og.serialno())
+            channels = vi.get_channels()
+            rate     = vi.get_rate()
 
-        if os.pagein(og) < 0:
-            print >> sys.stderr, "Error reading first Ogg bitstream page"
-            sys.exit(1)
+            if not outfile:
+                audio = oss.open_audio()
+                if channels >= 2:
+                    audio.stereo(1)
+                audio.format(oss.AFMT_S16_LE)
+                audio.speed(rate)
+                samplewriter = audio.write
+            else:   # outfile will be a wave_writer object
+                audio = wave.open(outfile, "wb")
+                audio.setsampwidth(2)
+                audio.setframerate(rate)
+                audio.setnchannels(channels)
+                samplewriter = audio.writeframesraw
+        
+            vd.synthesis_init(vi)
+            vd.block_init(vb)
 
-        if os.packetout(op) != 1:
-            print >> sys.stderr, "Error reading initial header packet"
-            sys.exit(1)
+        if vorbis >= 3:
+            if vb.synthesis(packet) == 0:
+                vd.synthesis_blockin(vb)
 
-        if vi.synthesis_headerin(vc, op) < 0:
-            print >> sys.stderr, "Not an ogg/vorbis bitstream."
-            sys.exit(1)
+                samples = vd.synthesis_pcmout()
+                if samples != None:
+                    samples *= 32767;
+                    wav = samples.astype('Int16')
 
-        i = 0
-        while i < 2:
-            while i < 2:
-                result = oy.pageout(og)
-                if result == 0: break
-                if result == 1:
-                    os.pagein(og)
-                    while i < 2:
-                        result = os.packetout(op)
-                        if result == 0: break
-                        if result < 0:
-                            print >> sys.stderr, "corrupt second header."
-                            sys.exit(1)
-                        vi.synthesis_headerin(vc, op)
-                        i += 1
-        
-            buffer = ogg.read(BUFSIZE)
-            if len(buffer) == 0 and i < 2:
-                print >> sys.stderr, "EOF before finding all vorbis headers!"
-                sys.exit(1)
+                    interleaved = numarray.zeros(samples.shape[1]*channels, numarray.Int16)
 
-            oy.write(buffer)
+                    for i in range(channels):
+                        interleaved[i::channels] = wav[i]
 
-        print >> sys.stderr, vorbispy.get_comments(vc)
+                    samplewriter(interleaved.tostring())
+                    
+                    # seems to clean them out the first time.
+                    # samples = vd.synthesis_pcmout()
+                    # if samples != None:
+                    #    print "synthesis_pcmout foo!"
 
-        channels = vi.get_channels()
-        rate     = vi.get_rate()
 
-        audio = oss.open_audio()
-        if channels >= 2:
-            audio.stereo(1)
-        audio.format(oss.AFMT_S16_LE)
-        audio.speed(rate)
-        
-        vd.synthesis_init(vi)
-        vd.block_init(vb)
+        vorbis += 1
 
-        eos = False
-        while not eos:
-            while not eos:
-                result = oy.pageout(og)
-                if result == 0: break           # need more data
-                if result < 0:
-                    print >> sys.stderr, "Yikes, corruption! continue..."
-                else:
-                    os.pagein(og)
-                    p = 0
-                    while 1:
-                        result = os.packetout(op)
-                        if result == 0: break   # need more data
-                        if result > 0:          # we have a packet. decode it.
-                            p += 1
-                            if vb.synthesis(op) == 0:
-                                vd.synthesis_blockin(vb)
-                                                        
-                            samples = vorbispy.oggpy_synthesis_pcmout(vd)
-                            while samples != None:
-                                samples *= 32767;
-                                wav = samples.astype('Int16')
-
-                                interleaved = numarray.zeros(samples.shape[1]*channels, numarray.Int16)
+    # set total frames in wav header when done
+    audio.writeframes('')
                                 
-                                for i in range(channels):
-                                    interleaved[i::channels] = wav[i]
-                                
-                                # interleaved.tofile(outfile)
-                                audio.write(interleaved.tostring())
-                                        
-                                samples = vorbispy.oggpy_synthesis_pcmout(vd)
-                                
-                if og.eos(): eos = True
-            if not eos:
-                buffer = ogg.read(BUFSIZE)
-                oy.write(buffer)
-                if len(buffer) == 0: eos = True
-        
 
 if __name__ == "__main__":
+    outfile = None
+    if len(sys.argv) == 3:
+        sys.argv.pop()
+        outfile = file("decode.wav", "wb")
     if len(sys.argv) == 2:
         if sys.argv[1] == "-":
-            test(sys.stdin)
+            test(sys.stdin, outfile)
         else:
-            test(file(sys.argv[1], "rb"))
+            test(file(sys.argv[1], "rb"), outfile)
     else:
-        test(file("music.ogg", "rb"))
+        test(file("music.ogg", "rb"), outfile)

Modified: experimental/dholth/oggpy/tests/oggtext.py
===================================================================
--- experimental/dholth/oggpy/tests/oggtext.py	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/tests/oggtext.py	2004-11-23 02:07:45 UTC (rev 8256)
@@ -4,6 +4,9 @@
 #
 # Puts lines of text into a new ogg-format stream.
 #
+# Each page of the text gets a new page in the ogg stream;
+# try it with the ogg rfcs.
+#
 # Daniel Holth <dholth at fastmail.fm>, 2004
 
 import oggpy
@@ -17,19 +20,20 @@
 pack = oggpy.userpacket("OGGText", granule, True, False)
 os.packetin(pack)
 
-os.pageout(page)
+os.flush(page)
 sys.stdout.write(page.header())
 sys.stdout.write(page.body())
 
 for data in sys.stdin.readlines():
-    if(os.pageout(page) != 0):
-        sys.stdout.write(page.header())
-        sys.stdout.write(page.body())
-    granule += len(data)
+    if data[0] == chr(12):
+        while(os.flush(page) != 0):
+            sys.stdout.write(page.header())
+            sys.stdout.write(page.body())
+    granule += 1
     pack = oggpy.userpacket(data, granule, False, False)
     os.packetin(pack)
 
-pack = oggpy.userpacket("END", granule, False, True)
+pack = oggpy.userpacket("", granule, False, True)
 os.packetin(pack)
 os.pageout(page)
 sys.stdout.write(page.header())

Modified: experimental/dholth/oggpy/tests/test.py
===================================================================
--- experimental/dholth/oggpy/tests/test.py	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/tests/test.py	2004-11-23 02:07:45 UTC (rev 8256)
@@ -6,11 +6,10 @@
 # 20 Jan. 2004
 
 import oggpy
+import vorbispy
 import sys
 
-oggpy.sync.write = oggpy.sync_write
-
-def test(ogg = open("test.ogg", "rb")):
+def test(ogg = open("music.ogg", "rb")):
     sync = oggpy.sync()
     page = oggpy.page()
     pkt  = oggpy.packet()
@@ -21,8 +20,8 @@
         raise "Input doesn't seem to be an ogg bitstream."
 
     strm = oggpy.stream(page.serialno())
-    info = oggpy.info()
-    cmt  = oggpy.comment()
+    info = vorbispy.info()
+    cmt  = vorbispy.comment()
 
     print "pagein",     strm.pagein(page)
     print "packetout",  strm.packetout(pkt)
@@ -44,8 +43,8 @@
                 i = i + 1
         sync.write(ogg.read(4096))
 
-    print cmt.query_count("artist")
-    print oggpy.get_comments(cmt)
+    print cmt.query_count("artist"), " 'artist' tag[s]"
+    print cmt.get_comments()
 
 
 if __name__ == "__main__":

Modified: experimental/dholth/oggpy/tests/theoratest.py
===================================================================
--- experimental/dholth/oggpy/tests/theoratest.py	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/tests/theoratest.py	2004-11-23 02:07:45 UTC (rev 8256)
@@ -35,12 +35,16 @@
                 yield op
 
 
-def test(ogg):
-    """Display some basic information about a theora stream."""
+def test(ogg, imagewriter = None):
+    """Display some basic information about a theora stream.
+    
+    arguments:
+        ogg is a file object
+        imagewriter is a pygame_bridge object"""
 
     numarray.Error.setMode(all="ignore")
 
-    oggpy.sync.write = oggpy.sync_write # hack until the wrapper can do this itself
+    # oggpy.sync.write = oggpy.sync_write # hack until the wrapper can do this itself
     
     ti = theorapy.info()
     tc = theorapy.comment()
@@ -54,45 +58,51 @@
         if theora == 0:
             head = ti.decode_header(tc, op)
             if head >= 0:
-                print "got theora", head
+                # print "got theora", head
                 theora += 1
             else:
-                print "no theora"
+                # print "no theora"
                 return
                 
-        elif theora < 3:   # should handle packets that are more than one page long.
+        elif theora < 3:
             h = ti.decode_header(tc, op)
             print "header ", h
             theora += 1
 
         elif theora == 3:
-            print "This theora encoded by: ", tc.get_vendor()
-            print "Trying to decode with: ", theorapy.version_string(), theorapy.version_number()
-            for i in dir(ti):
-                if i[0:2] != "__":
-                    try:
-                        value = ti.__getattribute__(i)
-                        if not inspect.ismethod(value):
-                            print i, value
-                    except TypeError:
-                        pass
-            print "decode init returns", td.decode_init(ti)
-
-            print "comments:"
-            for i in range(tc.size()):
-                print tc.query_index(i)
-            print ":end comments"
-
+            td.decode_init(ti)
+            yield (ti, tc, td)
+            #
+            # print "This theora encoded by: ", tc.get_vendor()
+            # print "Trying to decode with: ", theorapy.version_string(), theorapy.version_number()
+            # for i in dir(ti):
+            #     if i[0:2] != "__":
+            #         try:
+            #             value = ti.__getattribute__(i)
+            #             if not inspect.ismethod(value):
+            #                 print i, value
+            #         except TypeError:
+            #             pass
+            # print "decode init returns",
+            #
+            # print "comments:"
+            # for i in range(tc.size()):
+            #     print tc.query_index(i)
+            # print ":end comments"
+            #
             theora += 1
            
-        elif theora > 3 and theora < 10:
-            print theora
+        elif theora > 3:
+            # print theora
             theora += 1
             assert(td.decode_packetin(op) == 0)
             assert(td.decode_YUVout(yuv) == 0)
-            print "yuv info:"
-            print "y\t%d\t%d\t%d" % (yuv.y_width, yuv.y_height, yuv.y_stride)
-            print "uv\t%d\t%d\t%d" % (yuv.uv_width, yuv.uv_height, yuv.uv_stride)
+            # print "yuv info:"
+            # print "y\t%d\t%d\t%d" % (yuv.y_width, yuv.y_height, yuv.y_stride)
+            # print "uv\t%d\t%d\t%d" % (yuv.uv_width, yuv.uv_height, yuv.uv_stride)
+
+            yield yuv
+            
         else:
             break
 
@@ -102,5 +112,8 @@
         filename = sys.argv[1]
     else:
         filename = "video.ogg"
-        
-    test(file(filename, "rb"))
+       
+    gen = test(file(filename, "rb"))
+    
+    for i in range(3):
+        print gen.next()

Modified: experimental/dholth/oggpy/theoracc.h
===================================================================
--- experimental/dholth/oggpy/theoracc.h	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/theoracc.h	2004-11-23 02:07:45 UTC (rev 8256)
@@ -78,6 +78,17 @@
 namespace ogg {
     /// libtheora
     namespace theora {
+        /// libtheora error codes
+        enum theora_errors {
+            ocFault     = OC_FAULT,
+            ocEinval    = OC_EINVAL,
+            ocBadHeader = OC_BADHEADER,
+            ocNotFormat = OC_NOTFORMAT,
+            ocImpl      = OC_IMPL,
+            ocBadPacket = OC_BADPACKET,
+            ocNewPacket = OC_NEWPACKET
+        };
+        
         /// Annotate theora streams.
         class comment {
             private:
@@ -131,9 +142,13 @@
         
 
         /// YUV image data
-        class yuv_image : public yuv_buffer { };
+        class yuv_image : public yuv_buffer
+        {
+            public:
+                yuv_buffer *get_data()  { return (yuv_buffer*)this; }
+        };
 
-        
+
         /// Codec state.
         class state {
             private:

Modified: experimental/dholth/oggpy/theorapy.pyste
===================================================================
--- experimental/dholth/oggpy/theorapy.pyste	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/theorapy.pyste	2004-11-23 02:07:45 UTC (rev 8256)
@@ -1,8 +1,9 @@
-
 theorapy = AllFromHeader("theoracc.h")
 
 exclude(theorapy.info.get_data)
 exclude(theorapy.comment.get_data)
 exclude(theorapy.state.get_data)
+exclude(theorapy.yuv_image.get_data)
 
 Enum("theora_colorspace", "theora.h")
+# Enum("ogg::theora::theora_errors", "theoracc.h")

Modified: experimental/dholth/oggpy/vorbispy.pyste
===================================================================
--- experimental/dholth/oggpy/vorbispy.pyste	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/vorbispy.pyste	2004-11-23 02:07:45 UTC (rev 8256)
@@ -1,27 +1,41 @@
-vorbispy = AllFromHeader("vorbiscc.h")
+# Pyste wrapper for vorbispy.
+# Daniel Holth <dholth at fastmail.fm>, Mar. 2004
 
-Include("vorbispy_wrappers.h")
+# The document function relies on a private Pyste hack to actually work.
+def document(element, blurb):
+	"""Add a docstring to a definition"""
+	element._Attribute('doc', blurb)
 
-# exclude(vorbispy.comment.query)
-exclude(vorbispy.dsp.analysis_buffer)
-exclude(vorbispy.dsp.get_data)
-exclude(vorbispy.comment.get_data)
-exclude(vorbispy.info.get_data)
+header  = "vorbispy_wrappers.h"
+        
+comment = Class("ogg::vorbis::comment", header)
+info    = Class("ogg::vorbis::info", header)
+block   = Class("ogg::vorbis::block", header)
+dsp 	= Class("ogg::vorbis::dsp", header)
+	
+analysis_write = Function("oggpy_analysis_write", header)
+get_comments   = Function("get_comments", header)
+pcmout 	       = Function("oggpy_synthesis_pcmout", header, doc = \
+"""synthesis_pcmout(dsp) -> pcm data
 
-# vorbispy.block.synthesis.infos.doc = "Synthesize things."
-# #Function("oggpy_synthesis_pcmout", "oggpy_wrappers.h")
+Fetch some pcm data from vorbis decode.
+Return a [channels][samples] array of 32 bit floats."""
 
-doc = """\
-oggpy_synthesis_pcmout(oggpy.dsp) -> pcm data
 
-Fetches some pcm data from vorbis decode, in a channels by samples numarray object.
-It's so cool, you could keep meat in it."""
+exclude(dsp.analysis_buffer)
+exclude(dsp.get_data)
+exclude(comment.get_data)
+exclude(info.get_data)
 
-pcmout = Function("oggpy_synthesis_pcmout", "vorbispy_wrappers.h", doc = doc)
-Function("oggpy_analysis_write", "vorbispy_wrappers.h")
-Function("get_comments", "vorbispy_wrappers.h")
+add_method(dsp, "oggpy_analysis_write")
+rename(dsp.oggpy_analysis_write, "analysis_write")
+exclude(analysis_write)
 
-# #add_method(oggpy.sync, "ogg::sync_write")
-# #rename(oggpy.sync.sync_write, "write")
+add_method(comment, "get_comments")
+exclude(get_comments)
 
-module_code("oggpy_wrappers_init();\n")
+add_method(dsp, "oggpy_synthesis_pcmout")
+rename(dsp.oggpy_synthesis_pcmout, "synthesis_pcmout")
+exclude(pcmout)
+
+module_code("    oggpy_wrappers_init();\n")

Modified: experimental/dholth/oggpy/vorbispy_wrappers.cc
===================================================================
--- experimental/dholth/oggpy/vorbispy_wrappers.cc	2004-11-23 02:06:41 UTC (rev 8255)
+++ experimental/dholth/oggpy/vorbispy_wrappers.cc	2004-11-23 02:07:45 UTC (rev 8256)
@@ -1,4 +1,4 @@
-/* Wrappers for oggpy.
+/* Wrappers for vorbispy.
  *
  * Daniel Holth <dholth at fastmail.fm>
  * 21 Jan. 2004
@@ -8,7 +8,6 @@
 #include <string.h>
 #include <vorbis/codec.h>
 #include <numarray/libnumarray.h>
-#include <boost/version.hpp>
 
 using namespace ogg;
 using namespace boost::python;
@@ -19,8 +18,9 @@
 }
 
 
-// It lives!!!
-// ideas: see if vorbis will let us read zero until samples is a minimum size > 0, to give less units to python
+// Notes:
+// synthesis_pcmout() does not accumulate sound samples if it is not
+// called each time after synthesis_blockin()
 PyObject *oggpy_synthesis_pcmout(ogg::vorbis::dsp *dsp)
 {
   PyArrayObject *pcmarray = NULL;



More information about the commits mailing list