FMOD Studio API module for Clickteam Fusion 2.5 This module adds support for the FMOD Studio API 2.03.04 (x86) in Clickteam Fusion 2.5 (x86) via the XLua extension. Works with Windows. Pull requests are welcome.
Original LĂ–VE support this was based off was made by Alessandro FamĂ
Note: FMOD is not free, visit https://www.fmod.com/licensing for more info.
Download the fmodlove.dll/libfmodlove.dylib file and add it to the directory containing the project .mfa file. Download the FMOD Studio API (2.03.04 / x86) and also add fmodstudio.dll/libfmodstudio.dylib /and fmod.dll/libfmod.dll to your game folder.
This project uses SCons. Navigate to the folder containing the SConstruct file and run:
scons platform=windows target=release fmod_api="C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows"
Replace platform (windows only) and the fmod_api path with the path of your FMOD API installation.
fmod = require("fmodlove") // "libfmodlove" for macOS
to load the library.
fmod.init(outputType, realChannels, virtualChannels,
studioInitFlags)
will create and initialize the Studio System. outputType expects an integer, 0 should be fine in most cases. Change Real and Virtual Channels to your liking. Setting studioInitFlags to 1 will enable live update (check docs)
Returns false if failed, true if succeded.
fmod.update()
To update the Studio System (call it in love.update).
Returns false if failed, true if succeded.
fmod.setNumListeners(numOfListeners)
Returns false if failed, true if succeded.
fmod.setListener3DPosition(listenerIndex, posX, posY, posZ, dirX, dirY, dirZ, oX, oY, oZ)
If you have one listener the listenerIndex is 0. dirX dirY dirZ is the forward vector, oX oY oZ the up vector.
Returns false if failed, true if succeded.
fmod.loadBank(bankPath, flags)
bankPath is the path to the bank file. flags (int) can be:
- FMOD_STUDIO_LOAD_BANK_NORMAL (0)
- FMOD_STUDIO_LOAD_BANK_NONBLOCKING (1)
- FMOD_STUDIO_LOAD_BANK_DECOMPRESS_SAMPLES (2)
- FMOD_STUDIO_LOAD_BANK_UNENCRYPTED (4)
Will return an index value to the bank.
Returns -1 if failed.
Use the returned value to unload the bank if necessary:
fmod.unloadBank(index)
Returns false if failed, true if succeded.
fmod.createInstance(eventPath)
Returns an index value to the EventInstance.
Returns -1 if failed. Use the index value to start the instance:
fmod.startIntance(index)
Returns false if failed, true if succeded.
fmod.stopInstance(index, stopMode)
stopMode can be:
- FMOD_STUDIO_STOP_ALLOWFADEOUT (0)
- FMOD_STUDIO_STOP_IMMEDIATE (1)
Returns false if failed, true if succeded.
fmod.releaseInstance(index)
Returns false if failed, true if succeded. This will remove the instance from the index.
fmod.set3DAttributes(index, posX, posY, posZ, dirX, dirY, dirZ, oX, oY, oZ)
dirX dirY dirZ is the forward vector, oX oY oZ the up vector.
Returns false if failed, true if succeded.
fmod.playOneShot2D(eventPath)
Will automatically call EventInstance::release after starting. No need to take care of the instance.
Returns false if failed, true if succeded.
fmod.playOneShot3D(eventPath, posX, posY, posZ, dirX, dirY, dirZ, oX, oY, oZ)
It will automatically call EventInstance::release after playing. dirX dirY dirZ is the forward vector, oX oY oZ the up vector.
Returns false if failed, true if succeded.
fmod.PlayEvent(eventPath)
Returns an index value to the EventInstance.
fmod.PlayEvent3D(eventPath, posX, posY, posZ, dirX, dirY, dirZ, oX, oY, oZ)
Returns an index value to the EventInstance.
fmod.setInstanceVolume(index, volume)
Returns false if failed, true if succeded.
fmod.isPlaying(index)
Returns false if failed or not playing, true if playing.
fmod.setInstancePaused(index, pauseState)
pauseState should be true or false.
fmod.setInstancePitch(index, pitch)
Returns false if failed, true if succeded.
fmod.getTimelinePosition(index)
Returns the timeline position (int).
Returns -1 if failed.
fmod.setTimelinePosition(index, position)
Returns false if failed, true if succeded.
fmod.getInstanceRms(index)
Returns the RMS value of an instance.
Returns -1 if failed.
fmod.getGlobalParameterByName(parameterName)
Takes the parameter name and returns the parameter value.
Returns -1 if failed.
fmod.setGlobalParameterByName(parameterName, value, ignoreSeekSpeed)
ignoreSeekSpeed can be true or false.
Returns false if failed, true if succeded.
fmod.SetGlobalParameterByNameWithLabel(parameterName, value, ignoreSeekSpeed)
ignoreSeekSpeed can be true or false.
Returns false if failed, true if succeded.
fmod.getParameterByName(instanceIndex, parameterName)
Takes the instance index and the parameter name and returns its value.
Returns -1 if failed.
fmod.setParameterByName(instanceIndex, parameterName, value, ignoreSeekSpeed)
Returns false if failed, true if succeded.
fmod.SetParameterByNameWithLabel(instanceIndex, parameterName, value, ignoreSeekSpeed)
Returns false if failed, true if succeded.
fmod.getBus(busPath)
Takes the bus path and returns an index to that bus. Use it to get or set the bus volume.
Returns -1 if failed.
fmod.getBusVolume(index)
Returns the bus volume.
Returns -1 if failed.
fmod.setBusVolume(index, volume)
Returns false if failed, true if succeded.
fmod.StopAllEvents(index, stopMode)
Returns false if failed, true if succeded.
fmod.getVCA(vcaPath)
Takes the VCA path and returns an index value to that VCA. Use it to get or set the VCA volume.
Returns -1 if failed.
fmod.getVCAVolume(index)
Returns the VCA volume.
Returns -1 if failed.
fmod.setVCAVolume(index, volume)
Returns false if failed, true if succeded.
fmod = require("fmod_love")
initResult = fmod.init(0, 32, 128, 1)
bankIndex1 = fmod.loadBank("Desktop/Master.bank", 0)
bankIndex2 = fmod.loadBank("Desktop/Master.strings.bank", 0)
instance = fmod.createInstance("event:/OneShot")
fmod.set3DAttributes(instance, X, Y, 0, 0,
-1, 0, 0, 0, 1)
fmod.startInstance(instance)
fmod.releaseInstance(instance)
fmod.playOneShot2D("event:/Player/OneShot")