Playing a sound in pygame

It can be useful to test sounds in your current engine (esp for testing MOD support), so I’ve made a tiny sound player for pygame. The code is just this:

import sys, pygame
from pygame.locals import *

import pygame.mixer

if __name__=="__main__":
    pygame.display.set_mode((120, 120), DOUBLEBUF | HWSURFACE)

    pygame.init()

    try:
        filename = sys.argv[1]
        pygame.mixer.init()
        sound = pygame.mixer.Sound(filename)
        print 'Press ESC to quit, any other key retriggers sound'
        sound.play()

        running = True
        while running:
            for event in pygame.event.get():
                if event.type == KEYDOWN:
                    if event.key == K_ESCAPE:
                        running = False
                    else:
                        sound.play()

    except IndexError:
        print 'Usage tplay.py filename'

The file is attached here: Tiny pygame audio player.

Vista vs Blender

The good news is, my laptop can run the Blender game engine at a decent framerate.

The bad news is I found out that is the Vista taskbar that more than halves it.  I run without Aero, as Aero completely borks OpenGL (quite apart from the fact that Vista limits you to OpenGL 1.5).   It’s bothered me for a while that in Blender I could never get over about 30FPS – on the weekend I found out that I can have the window as large as I like and get much better framerates as long as the window doesn’t touch the taskbar.

This is the kind of thing I hope SP1 will fix, but I severely doubt it :(

The One to Pick up

My dad found this old advert for the Osbourne I… at only £1250 + Vat (and with a free 12 Inch amber for a limited time), this is The One To pickup… or not as they were never popular. Weighing in at “below 24lb” (10 Kilos!) this was a proper computer running CPM the anscestor from which DOS was cloned. It’s interesting as this was before the 8 bit wars had really kicked off in the U.K. with well known computers from Spectrum and Commodore, Amstrad and Acorn.

the-one-to-pick-up.jpeg

[EDIT - Add Flickr link]

Flickr

retrocomputing

Sunlight Soap

As our washing machine broke, I was in the Laundrette where I saw this on the wall -

Sunlight Soap

The writing on the bottom says

£1000 Reward!

Will be given to any person who can prove that this soap manufactured by Lever Bros.
Port Sunlight on Mersey
Contains any form of adulteration whatsoever or contains any injurious chemicale

In Victorian times adulteration of products was widespread and it’s interesting to think that some of the big brands we have today came out of this – Cadburys being the famous one, their unadulterated cocoa essence leading to the Adulteration of Foods Acts.

Phonetorch

While trying to find some good freeware to use the flash on my phone as a torch, I stumbled across a couple of nice apps

Obex Commander for sending files to your phone over bluetooth.

YBrowser a Series 60 file manager (you can do useful things like send multiple files over bluetooth in one go)

So far haven’t found a decent torch app, though so will have to keep looking on that front.

Blue proximity

This is very cool – lock and unlock your computer depending on your phone being in bluetooth range.

blueproximity.sourceforge.net

Next time I’m in linux I’ll definately have to play with it. Something I’ve been wanting to do is automatically rotate the songs on the memory card of the phone when in bluetooth range, so I’ll have to see if it’s possible to hook up the connection event to a script.

[edit] fixed link