sound – Parerga und Paralipomena http://www.michelepasin.org/blog At the core of all well-founded belief lies belief that is unfounded - Wittgenstein Mon, 09 Aug 2010 17:25:17 +0000 en-US hourly 1 https://wordpress.org/?v=5.2.11 13825966 Listen to the RainForest at Kew Gardens http://www.michelepasin.org/blog/2010/08/09/listen-to-the-rainforest-at-kew-gardens/ Mon, 09 Aug 2010 17:25:17 +0000 http://www.michelepasin.org/blog/?p=814 Screen shot 2010-08-09 at 18.17.35.png

If you happen to be going to London’s Kew Gardens, make sure you don’t miss this nice sound installation by Chris Watson. The installation is on till September 5th and it’s called Whispering in the Leaves:

Whispering in the Leaves features two sound pieces – Dawn and Dusk – composed by Chris from memory using his extensive archive of on-location recordings in Central and South American rainforests.

Designed specifically for the Palm House, Whispering in the Leaves is the audio equivalent of 3D cinema. Visitors will be immersed in a dynamic, spatial soundscape of primate calls and birdsong, backed with a shimmering wall of insect sounds. Some of the species heard are currently unknown to humans. Visitors will experience the heard but never seen.

Diffused through 80 speakers, the two compositions will be transmitted at hourly intervals throughout the day – Dawn in the morning and Dusk in the afternoon. Each lasts for 15-20 minute durations – the approximate time it takes for the transitions between darkness and daylight in the dense tropical vegetation.

The website makes available some of the nature recordings too.

]]>
814
Pyglet: multimedia library for python http://www.michelepasin.org/blog/2009/12/12/pyglet-multimedia-library-for-python/ Sat, 12 Dec 2009 21:05:02 +0000 http://magicrebirth.wordpress.com/?p=462 UPDATE 30/03/1: Just realized that unfortunately pyglet doesn’t play well with the latest 64bit architecture of oSX. A real shame, as this obviously breaks Pyglet’s famed run-anywhere feature. There are reasons to think that the next version will fix this problem (check out this thread for more info).. but for the moment, I guess that the only alternative is falling back to PyOpenGl.
UPDATE 14/12/09: pyProcessing is a project building on pyglet that that creates an environment for graphics applications that closely resembles that of the Processing system. Quite neat uh?

Pyglet provides an object-oriented programming interface for developing games and other visually-rich applications for Windows, Mac OS X and Linux. I’ve been playing with it for an hour or so, and was surprised of how quickly it can let you create a python-based multimedia application.

Some of the features of pyglet are:

No external dependencies or installation requirements. For most application and game requirements, pyglet needs nothing else besides Python, simplifying distribution and installation.
Take advantage of multiple windows and multi-monitor desktops. pyglet allows you to use as many windows as you need, and is fully aware of multi-monitor setups for use with fullscreen games.
Load images, sound, music and video in almost any format. pyglet can optionally use AVbin to play back audio formats such as MP3, OGG/Vorbis and WMA, and video formats such as DivX, MPEG-2, H.264, WMV and Xvid.

Two possibly useful tips when getting started:

– Go get AVBIN without hesitations, as you’ll need it. MP3 and other compressed audio formats require AVbin to be installed (this is the default for the Windows and Mac OS X installers). Uncompressed WAV files can be played without AVbin.

– [tested on OSx leopard only] If you try running the hello-world example from the console, after hitting window = pyglet.window.Window() you’ll see a new window appearing on your screen. That looks like good news obviously, but soon you’ll find out that the Finder doesn’t like that, and apparently the Python launcher results being as ‘not responding’ on the Force Quit Application menu. Well nothing to worry there: it’s because you haven’t issued the pyglet.app.run() command yet (which is where the main event loop gets handled).

The screenshot above is taken from one of the example apps you can download. Balls keeps bouncing around in a window, playing a sound when they hit the border. Check out the code:

import os
import random
import sys

from pyglet.gl import *
import pyglet
from pyglet.window import key

BALL_IMAGE = 'ball.png'
BALL_SOUND = 'ball.wav'

if len(sys.argv) > 1:
    BALL_SOUND = sys.argv[1]

sound = pyglet.resource.media(BALL_SOUND, streaming=False)

class Ball(pyglet.sprite.Sprite):
    ball_image = pyglet.resource.image(BALL_IMAGE)
    width = ball_image.width
    height = ball_image.height

    def __init__(self):
        x = random.random() * (window.width - self.width)
        y = random.random() * (window.height - self.height)

        super(Ball, self).__init__(self.ball_image, x, y, batch=balls_batch)

        self.dx = (random.random() - 0.5) * 1000
        self.dy = (random.random() - 0.5) * 1000

    def update(self, dt):
        if self.x = window.width:
            self.dx *= -1
            sound.play()
        if self.y = window.height:
            self.dy *= -1
            sound.play()
        self.x += self.dx * dt
        self.y += self.dy * dt

        self.x = min(max(self.x, 0), window.width - self.width)
        self.y = min(max(self.y, 0), window.height - self.height)

window = pyglet.window.Window(640, 480)

@window.event
def on_key_press(symbol, modifiers):
    if symbol == key.SPACE:
        balls.append(Ball())
    elif symbol == key.BACKSPACE:
        if balls:
            del balls[-1]
    elif symbol == key.ESCAPE:
        window.has_exit = True

@window.event
def on_draw():
    window.clear()
    balls_batch.draw()
    label.draw()

def update(dt):
    for ball in balls:
        ball.update(dt)
pyglet.clock.schedule_interval(update, 1/30.)

balls_batch = pyglet.graphics.Batch()
balls = []
label = pyglet.text.Label('Press space to add a ball, backspace to remove',
                          font_size=14,
                          x=window.width // 2, y=10,
                          anchor_x='center')

if __name__ == '__main__':
    pyglet.app.run()

 

]]>
462