--=-K3ypPuM4F3iBWwT+xu+l Content-Type: text/plain Content-Transfer-Encoding: 7bit Hello! I've written a tiny-and-dirty Python script that reads in a ".mood" file from Amarok's moodbar and displays it on the screen using pygame. Maybe it's useful to somebody or maybe you want to include it in the moodbar source as example code for reading ".mood" files. Thomas --=-K3ypPuM4F3iBWwT+xu+l Content-Disposition: attachment; filename=moodbar.py Content-Type: text/x-python; name=moodbar.py; charset=UTF-8 Content-Transfer-Encoding: 7bit #!/usr/bin/python # # moodbar.py -- Read and visualize "moodbar" files # Copyright 2007 Thomas Perl # Initial version: 2007-09-29 # # This program reads in ".mood" files that have been # created with the "moodbar" utility from # # http://amarok.kde.org/wiki/Moodbar # # The moodbar file is a simple binary file with # three bytes per frame: red, green and blue. # import sys import os.path import pygame from pygame.locals import * HEIGHT = 100 fn = sys.argv[-1] if not os.path.exists( fn) or len(sys.argv) < 2: print 'Usage: moodbar.py my-audiofile.mood' sys.exit( -1) def moodbar_from_file( fn): fp = open( fn, 'rb') result = [] s = fp.read( 3) while s: result.append( ( ord( s[0]), ord( s[1]), ord( s[2]))) s = fp.read( 3) fp.close() return result bars = moodbar_from_file( fn) pygame.init() pygame.display.set_mode( (len(bars), HEIGHT)) pygame.display.set_caption('Moodbar: %s' % os.path.basename( fn)) screen = pygame.display.get_surface() for x in range( len(bars)): pygame.draw.line( screen, bars[x], (x,0),(x,HEIGHT)) pygame.display.flip() while True: for event in pygame.event.get(): if event.type == QUIT: sys.exit( 0) --=-K3ypPuM4F3iBWwT+xu+l Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Amarok mailing list Amarok@kde.org https://mail.kde.org/mailman/listinfo/amarok --=-K3ypPuM4F3iBWwT+xu+l--