Exemplo n.º 1
0
 def setSound(self, sound):
     """
     sets source's sound
     """
     FMOD.stopChannel(self._channel)
     self._sound = sound
     self._channel = FMOD.createChannel(self._sound, self._mode)
Exemplo n.º 2
0
 def release(self):
     """
     stops the channel and set it to none
     """
     super().release()
     FMOD.stopChannel(self._channel)
     self._channel = None
Exemplo n.º 3
0
 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
Exemplo n.º 4
0
 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)
Exemplo n.º 5
0
    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
Exemplo n.º 6
0
 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())
Exemplo n.º 7
0
 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())
Exemplo n.º 8
0
 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
Exemplo n.º 9
0
    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)
Exemplo n.º 10
0
 def setPosition(self, position):
     """
     redefined setPosition. Sets the go position and the geometry position
     """
     super().setPosition(position)
     FMOD.setGeometryPosition(self._geometry, position)
Exemplo n.º 11
0
 def setMaxDistance(self, maxDist):
     """
     max distance of the reverb
     """
     FMOD.setReverbMaxDistance(self._reverb, maxDist)
Exemplo n.º 12
0
 def setMinDistance(self, minDist):
     """
     min dist of the reverb
     """
     FMOD.setReverbMinDistance(self._reverb, minDist)
Exemplo n.º 13
0
 def setPosition(self, position):
     """
     redefined setPositions. Sets the go position and the reverb position
     """
     super().setPosition(position)
     FMOD.setReverbPosition(self._reverb, position)
Exemplo n.º 14
0
 def setPosition(self, position):
     """
     redefined setPosotion. Sets the go position and the fmodsource's position
     """
     super().setPosition(position)
     FMOD.setChannelPosition(self._channel, self.getPosition())
Exemplo n.º 15
0
 def setMode(self, mode):
     """
     sets source's mode (changes the channel mode itself)
     """
     self._mode = mode
     FMOD.setChannelMode(self._channel, self._mode)
Exemplo n.º 16
0
 def setPosition(self, position):
     """
     redefined setPosition. Sets the go position and the fmodlistener position
     """
     super().setPosition(position)
     FMOD.setListenerPosition(self._listener, position)
Exemplo n.º 17
0
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"]),