def setSound(self, sound): """ sets source's sound """ FMOD.stopChannel(self._channel) self._sound = sound self._channel = FMOD.createChannel(self._sound, self._mode)
def release(self): """ stops the channel and set it to none """ super().release() FMOD.stopChannel(self._channel) self._channel = None
def release(self): """ deactivates the reverb and calls fmod reverb release """ self._reverb.active = False FMOD.update() # if you dont call system.update before releasing an object, all the changes made to it are not applied self._reverb.release() self._reverb = None
def __init__(self): """ Creates the listeners and set its position to default (0, 0) """ super() self._listener = FMOD.createListener() self.setPosition(self.getPosition()) FMOD.setRollOffScale(0.01)
def handleInput(self, event): """ Handles dragging event and right click reverb (changes the reverb, prints selected reverb) """ handled = super().handleInput(event) if self.isActive(): # only if this is active if event.type == pygame.MOUSEBUTTONDOWN: if event.button == 3: # 3: RIGHT_CLICK mousePosition = pygame.mouse.get_pos() if self._hasClickedInside(mousePosition): nReverb = getReverbByIndex(self._reverbIndex) print("Current reverb: " + str(nReverb[1])) FMOD.setReverbProperties(self._reverb, nReverb[0]) self._reverbIndex += 1 handled = True return handled
def __init__(self): """ Set source's sound, mode, creates a channel and plays it """ super() self._reverb = FMOD.createReverb() self.setMinDistance(1) self.setMaxDistance(1000) self.setPosition(self.getPosition())
def __init__(self, sound, mode=MODE.DEFAULT): """ Set source's sound, mode, creates a channel and plays it """ super() self._sound = sound self._mode = mode self._channel = FMOD.createChannel(self._sound, self._mode) self.setPosition(self.getPosition())
def __init__(self): """ Creates a fmod geometry and sets its position to default (0, 0, 0) """ super() self._geometry = FMOD.createGeometry() self.setPosition(self.getPosition()) pygame.mouse.set_cursor( *pygame.cursors.broken_x ) # changes cursor to mark geometry is being created
def addGeometry(self): """ Creates a fmod geometry with the amount of vertex in numVertex Sets its position to default (0, 0, 0) """ if self._numVertex > 1: numPolygon = self._numVertex - 1 self._geometry = FMOD.createGeometry(numPolygon + 1, (numPolygon + 2) * 4) self.setPosition((0, 0)) for v in range( numPolygon ): # Loop through the number of polygons, creating them vert = (VECTOR(self._vertexes[v][0], self._vertexes[v][1], 1), VECTOR(self._vertexes[v + 1][0], self._vertexes[v + 1][1], 1), VECTOR(self._vertexes[v + 1][0], self._vertexes[v + 1][1], -1), VECTOR(self._vertexes[v][0], self._vertexes[v][1], -1)) FMOD.addPolygonsToGeometry(self._geometry, vert)
def setPosition(self, position): """ redefined setPosition. Sets the go position and the geometry position """ super().setPosition(position) FMOD.setGeometryPosition(self._geometry, position)
def setMaxDistance(self, maxDist): """ max distance of the reverb """ FMOD.setReverbMaxDistance(self._reverb, maxDist)
def setMinDistance(self, minDist): """ min dist of the reverb """ FMOD.setReverbMinDistance(self._reverb, minDist)
def setPosition(self, position): """ redefined setPositions. Sets the go position and the reverb position """ super().setPosition(position) FMOD.setReverbPosition(self._reverb, position)
def setPosition(self, position): """ redefined setPosotion. Sets the go position and the fmodsource's position """ super().setPosition(position) FMOD.setChannelPosition(self._channel, self.getPosition())
def setMode(self, mode): """ sets source's mode (changes the channel mode itself) """ self._mode = mode FMOD.setChannelMode(self._channel, self._mode)
def setPosition(self, position): """ redefined setPosition. Sets the go position and the fmodlistener position """ super().setPosition(position) FMOD.setListenerPosition(self._listener, position)
def addFMODGeometry(gameObjects, _object): fmodGeometry = FMODGeometry() fmodGeometry.setPosition((_object.getX(), _object.getY())) # inserts the element at tht beggining of the list gameObjects.insert(0, fmodGeometry) # -------------------PYGAME------------------------- screen = pygame.display.set_mode((800, 800)) clock = pygame.time.Clock() pygame.display.set_caption("Proyecto Sonido") pygame.font.init() x = 0 # -------------------FMOD-------------------------- FMOD.init() FMOD.setRollOffScale(0.1) # -------------------RESOURCES---------------------- resourcesManager = ResourcesManager.getInstance() resourcesManager.loadImagesFromDirectory( getStringCurrentWorkingDirectory() + "\\resources\\sprites") resourcesManager.loadSoundsFromDirectory( getStringCurrentWorkingDirectory() + "\\resources\\sounds") # -------------------GAME OBJECTS------------------------- gameObjects = [] popUp = PopUpMenu(["Add Listener", "Add Source", "Add Reverb", "Add Geometry", "Remove last element"], [(addFMODListener, [gameObjects, "Listener.png"]), (addFMODSource, [gameObjects, "Source.png", "steps0.wav"]), (addFMODReverb, [gameObjects, "Reverb.png"]),