Permalink
Browse files

Merge branch 'master' of github.com:mhroth/ZenGarden

  • Loading branch information...
2 parents b1e9b86 + 88c0945 commit da92238debacd4a78e6a9d205bf4353caee0bd3a Martin Roth committed Dec 16, 2009
View
23 README
@@ -4,10 +4,14 @@ By Martin Roth <mhroth@rjdj.me>
ZenGarden is a standalone library for running Pure Data patches.
-It is beta quality software - expect bugs and don't expect everything to be implemented.
+It is beta quality software - expect bugs and don't expect everything to be
+implemented.
https://github.com/mhroth/ZenGarden/
+Mailing list:
+http://groups.google.com/group/zengarden?pli=1
+
Requirements
------------
@@ -16,19 +20,25 @@ libsndfile
- Debian GNU/Linux: apt-get install libsndfile1-dev
java - for the java example - you need at least java5
- - OSX: It's already installed
- Debian: apt-get install sun-java6-jdk
+python - for the python example
+ - ctypes (in Python 2.5 or greater)
+ - pygame - http://pygame.org/
+
Run
---
-This runs the Java hosted example:
- ./runme.sh
+The following commands both optionally take the full path to a Pd patch as
+their first argument:
+
+ * `./runme-java.sh`
+ * `./runme-python.sh`
Build
-----
-Here is how to build the java demo from scratch.
+Here is how to build the library, JNI, etc. from scratch.
cd src
make
@@ -45,11 +55,12 @@ Advantages
Why use ZenGarden?
-* Clean code
+* Clean code and API
* Portable and embeddable
* Embedded devices, synthesizers
* Mobile phones
* Inside other languages
+ * LADSPA, VST, etc.
* Compiling Pd as a library is non-trivial and requires modifications to Pd vanilla
* Less bloat
* No GUI
Binary file not shown.
Binary file not shown.
View
@@ -9,7 +9,7 @@
from pyZenGarden import pyZenGarden
-BLOCKSIZE = 256
+BLOCKSIZE = 512
CHANNELS = 2
# initialise the pygame mixer
@@ -31,26 +31,33 @@ def myPrintHook(instring):
zg.setPrintHook(myPrintHook)
-#s = pygame.mixer.Sound("dubstep.ogg")
-s = pygame.sndarray.make_sound(zeros((BLOCKSIZE, CHANNELS)))
-a = pygame.sndarray.samples(s)
-#a[0][0] = pow(2, 16) / 2
+s1 = pygame.sndarray.make_sound(zeros((BLOCKSIZE, CHANNELS)))
+s2 = pygame.sndarray.make_sound(zeros((BLOCKSIZE, CHANNELS)))
+o1 = pygame.sndarray.samples(s1)
+o2 = pygame.sndarray.samples(s2)
+
+sounds = [s1, s2]
+arrays = [o1, o2]
+current_buffer = 0
c = pygame.mixer.find_channel()
c.set_endevent(locals.USEREVENT)
s_ranger = xrange(BLOCKSIZE)
c_ranger = xrange(CHANNELS)
-c.play(s)
+c.queue(sounds[current_buffer])
+c.queue(sounds[current_buffer + 1])
try:
while 1:
if pygame.event.get(locals.USEREVENT):
+ # start playing the next buffer
zg.process()
for x in c_ranger:
for y in s_ranger:
- a[y][x] = zg.outBlock[y + x * BLOCKSIZE] * (pow(2, 16) / 2 - 1)
- c.play(s)
+ arrays[current_buffer][y][x] = zg.outBlock[y + x * BLOCKSIZE] * (pow(2, 16) / 2 - 1)
+ c.queue(sounds[current_buffer])
+ current_buffer = (current_buffer + 1) % 2
except KeyboardInterrupt:
print "done"
View
@@ -21,7 +21,7 @@ def __init__(self, pdFile, libraryPath, blockSize, inChannels, outChannels, samp
"""
if platform == "darwin":
self.zg = cdll.LoadLibrary("libzengarden.dylib")
- elif platform == "Linux2":
+ elif platform == "linux2":
self.zg = cdll.LoadLibrary("libzengarden.so")
else:
raise pyZenGardenException("Sorry, your platform '%s' doesn't seem to be supported yet" % platform)

0 comments on commit da92238

Please sign in to comment.