Using Inspector to preview FMOD event

Hi there :slight_smile:
I’m currently working on a way to preview an FMOD event in the inspector when I press a button in a script while outside of playmode.

Essentially, my needs would be something like:

Public void PreviewSoundInInspectorOnButtonPress()
{
//Play FMOD event preview
]

If, additionally, anyone knew of a way to get the duration of the event, as well as how one would play from x seconds, that would be incredible too :blush:

While FMOD has a way to preview audio already, this use case is relevant to me, as I need to sync some elements in the inspector :slight_smile:

I’m afraid I’m not quite able to comprehend a lot of FMOD code currently, so if someone would be able to lay out the steps, that would really help me, and I’d be very thankful :slightly_smiling_face:

Thank you for your time

Hi,

If you want to play sounds outside of runtime you will have to create your own FMOD Studio system which can then play your events. We have C++ examples of creating Studio Systems included in the FMOD Engine download here: Download FMOD - FMOD Engine. Then in the download, the example can be found here: C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\studio\examples\vs2019\examples.sln I would suggest looking at the simple_event project.

In regards to getting the length of the event is isn’t that straight forward as you are actually trying to get the length of the audio source. You would have to dig down to the FMOD.Sound and call Sound::getLength.

Hope this helps!