Beispiel #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)
Beispiel #2
0
 def release(self):
     """
     stops the channel and set it to none
     """
     super().release()
     FMOD.stopChannel(self._channel)
     self._channel = None
Beispiel #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
Beispiel #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)
Beispiel #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
Beispiel #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())
Beispiel #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())
Beispiel #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
Beispiel #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)
Beispiel #10
0
 def setPosition(self, position):
     """
     redefined setPosition. Sets the go position and the geometry position
     """
     super().setPosition(position)
     FMOD.setGeometryPosition(self._geometry, position)
Beispiel #11
0
 def setMaxDistance(self, maxDist):
     """
     max distance of the reverb
     """
     FMOD.setReverbMaxDistance(self._reverb, maxDist)
Beispiel #12
0
 def setMinDistance(self, minDist):
     """
     min dist of the reverb
     """
     FMOD.setReverbMinDistance(self._reverb, minDist)
Beispiel #13
0
 def setPosition(self, position):
     """
     redefined setPositions. Sets the go position and the reverb position
     """
     super().setPosition(position)
     FMOD.setReverbPosition(self._reverb, position)
Beispiel #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())
Beispiel #15
0
 def setMode(self, mode):
     """
     sets source's mode (changes the channel mode itself)
     """
     self._mode = mode
     FMOD.setChannelMode(self._channel, self._mode)
Beispiel #16
0
 def setPosition(self, position):
     """
     redefined setPosition. Sets the go position and the fmodlistener position
     """
     super().setPosition(position)
     FMOD.setListenerPosition(self._listener, position)
Beispiel #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"]),