HeroEngine Forums
Welcome, Guest. Please login or Register for HeroCloud Account.

Author Topic: Flexible Playing of FMOD sound fx  (Read 4272 times)

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Flexible Playing of FMOD sound fx
« on: Mar 11, 12, 06:25:07 PM »

Premise:

Previously, I had wrestled with how to play FMOD sounds, since they require specifying the event path.  We could find no method other than via the FMOD task in the FX editor, but the resource needs to be specified in the sound task and we did not want to have to create an FX for each sound.  So this topic details the system we devised to play any sound using only a single FX.

Implementation:
  • We created an FX called "FMOD Audio" with a single task that is an FMOD sound named "sound".  For the group, we named it "Audio" and set the Control Script to our client script "VozFXCallbacks". (See attached pic)
  • In VozFXCallbacks, we defined the following function:
Code: [Select]
shared function _OnFxGroupPreLoad(theFxGroup as NodeRef of Class _FxGroup)
  //----------------------------------------------------------------------
  // Called just before resources are loaded into prop buckets
  // This call allows you to dynamically change the resources to be loaded
  //----------------------------------------------------------------------
  if theFXGroup._fxName == "Audio"
    task as NodeRef of Class _Fx3DSoundFMOD = theFXGroup.FindFxTaskByName("sound")
    if task != None
      task._fxResourceName = theFXGroup._fxDynData["soundpath"]
      task.EventPath = theFXGroup._fxDynData["eventpath"]
    .
  .
.
That looks in dynamic data for the resource path to be mapped to "soundpath" and the event path in "eventpath".
  • Finally, we use a method of a system node defined as such: (where 95 is the spec key of our FMOD fx)
Code: [Select]
method Play2DFMODSound(soundResourcePath as String, eventPath as String)
  caster as Class _Target
  target as Class _Target
  data as LookupList indexed by String of String
  data["soundpath"] = soundResourcePath
  data["eventpath"] = eventPath
  $FXSYSTEM.PlayDynFxFromSpec(95, caster, target, data)
.
    With that, we need only call that method on the system node to play any fmod sound.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Flexible Playing of FMOD sound fx
« Reply #1 on: Jun 04, 12, 06:58:58 PM »

I recently found a limitation to the approach of using FX for playing FMODs: there is code in the clean engine scripts which, when leaving an area, stop all fx that are playing.  A comment by it says otherwise there would be problems.  So, that means you cannot use this approach for a sound that needs to go across areas, such as music that plays continuously while crossing over.

So, instead I worked out a method that plays FMODs without FX.  Basically, I looked at how the FX system plays them, which is by creating a client-side node for the sound and then turning pause off.  I looked at how the $Sound system node plays 3D sounds by creating nodes as well, and made a separate modified version of that code which does basically the same thing, but is designed to handle the fields that are specific to FMODs rather than SGTs.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

Gothrek

  • General Accounts
  • *
  • Posts: 92
    • View Profile
Re: Flexible Playing of FMOD sound fx
« Reply #2 on: Jun 06, 12, 01:07:05 AM »

the first fx tutorial...greeeaaattt!!!

tks scott for share it!!
Logged

FI-ScottZ

  • General Accounts
  • *
  • Posts: 1407
    • View Profile
    • Forever Interactive, Inc.
Re: Flexible Playing of FMOD sound fx
« Reply #3 on: Jun 07, 12, 11:39:16 PM »

I have done some experimenting with playing fmods via nodes created directly in a prop bucket rather than via fx, but I still find that the nodes are lost when changing instances, stopping the sound.

I had thought client-side nodes, particularly those that are only client-side such as those made in a prop bucket, would not be specific to an instance but continue to exist wherever the client's player goes, but sadly that's not the case.  I know things like the player account/character move from instance to instance, but I guess that is due to proxying, which I don't understand enough to try it with fmod nodes, or if that would even work.

Can anyone provide any advice on getting a client node to stay loaded from one area instance to another?  GUI nodes can stay up as you move, but I don't know how to do it for others. It's a shame fmods can't be played directly strictly as a sound without a node, like the way sgt's could.
Logged
Scott Zarnke
Lead Programmer, Visions of Zosimos
CTO, Forever Interactive, Inc.

HE-Cooper

  • *****
  • Posts: 2221
    • View Profile
Re: Flexible Playing of FMOD sound fx
« Reply #4 on: Jun 08, 12, 04:53:56 AM »

It looks like its something we're going to have to fix for you. Sounds are explicitly getting killed on area transition.
Logged

keeperofstars

  • General Accounts
  • *
  • Posts: 998
    • View Profile
    • StarKeeper Online
Re: Flexible Playing of FMOD sound fx
« Reply #5 on: Jun 03, 13, 08:31:32 PM »

So Cooper any update on the status of this?
Logged
[img]http://screencast.com/t/x7btcSSyp3h0[\img]