Source

pygamekit / sound.pxi

Full commit

from sound cimport *

cdef class Sound:
    
    cdef gkSound *sound
    cdef gkSource *player
    cdef gkSoundProperties *props
    
    def __init__(self, name):
        self.sound = gkSoundManager().getByName(gkString(name))
        
        if self.sound:
            self.player = self.sound.createSource()
            if self.player:
                self.props = &self.player.getProperties()
        else:
            print "Sound file not found:", name
        
    def play(self):
        if self.player!=NULL:
            self.player.play()
    
    def stop(self):
        if self.player!=NULL:
            self.player.stop()
    
    def pause(self):
        if self.player!=NULL:
            self.player.pause()
    
    property loop:
        def __get__(self):
            return self.props.m_loop
        def __set__(self, v):
            self.player.loop(v)
            
    property volume:
        def __get__(self):
            return self.props.m_volume
        def __set__(self, v):
            self.props.m_volume = v
            
    property pitch:
        def __get__(self):
            return self.props.m_pitch
        def __set__(self, v):
            self.props.m_pitch = v
            
    #property :
        #def __get__(self):
            #return self.props.
        #def __set__(self, v):
            #self.