
import os, stat, os.path, math
from pygame import mixer

scale = []
baserate = 22050
sounds = {}

def init_sound():
	mixer.init()
	for i in range( -5, 20 ):
		scale.append( int( math.pow( 2.0, i / 12.0 ) * baserate ))

def play( sound, pitch ):
	try: snd = sounds[sound]
	except KeyError: snd = sounds[sound] = mixer.Sound(sound)
	snd.play() # TODO: apply pitch

def find_samples( dirs ):
	return [ os.path.join( d, filename )
			for d in dirs for filename in os.listdir( d )
			if stat.S_ISREG( os.stat( os.path.join( d, filename )).st_mode ) ]

