Answered
0
0

Using:
FMOD Studio 1.08.00 (build 73609) 64 bit
Visual Studio Community 2015 – C++
Windows 7

The example projects are all up and running fine and I have used the code from them to start implementing my own.

I have an existing project that I am trying to integrate FMOD into. I am loading a lot of assets from different directories and I notice that if I do not leave the current working directory set to the location where my FMOD banks are being loaded from, when a looping event reaches the end of its loop region, it will simply stop playing. The play state when I query that event ( getPlaybackState()) it still states that it is running but the audio has clearly stopped.

I can’t even seem to trigger the event again until the current working directory points back to the directory that contains the banks.

Every FMOD call is wrapped in ERRCHECK() (copied from examples) and I don’t see a single error being returned at ANY point.

What is going on?

I could maybe understand if an event couldnt be triggered if the current working directory wasnt pointing to the resource but a) the resource should already be loaded into memory from system->loadBankFile(), shouldnt it? and b) since it is already playing, why would it STOP looping just because the current working directory has changed?

I’ve been googling all morning and don’t seem to have found anyone having a similar problem. Am I missing something basic?

EDIT: I made a change to the simple_event example – adding a _chdir() call to a location other than the directory which contains the banks. When the current working dir changes, the looping ambience events will no longer fire, although the explosion sound will. The main difference appears to be only that the instance for the looping sound is only created once (and changing the working directory seems to cause it to fail subsequently) and the explosion instance is created / released each time it is fired (but this works regardless if the current working directory has been changed or not)

This behaviour seems completely bizarre to me. HALP!?

EDIT 2:
(from http://stackoverflow.com/questions/7544153/what-is-the-difference-between-chdir-and-setcurrentdirectory-in-windows )

However, _chdir does one more thing: it updates the current directory
of the current drive, stored in an environment variable. This is
needed, as the remark in _tchdir states, because “other functions
(fullpath, spawn, etc) need them to be set”.

This suggests to me not only that FMOD is using the environment variable of the current working dir rather than storing the full path of the banks, but that is not actually loading the contents into memory with loadBankFile()?

I am not loading asynch, so why wouldnt it?

  • You must to post comments
Best Answer
1
0

If you are loading the bank files with a relative path then FMOD will pass that onto the underlying file system open and it will use the working directory to load file data.

As for why Studio would be loading data after the bank has loaded, please see this section:

http://www.fmod.org/documentation/#content/generated/overview/studio_banks.html

If you call bank->loadSampleData() or event->loadSampleData(), then the sample data will stay loaded. Otherwise it will load on demand depending on what event instances are alive.

However, that won’t cause sample data to load and unload in a loop, with the exception of streaming sounds. Studio will mark audio streaming automatically for you if it is very long, so this is most likely what has happened. You can double check that in the FMOD Studio audio bin, and look to see that the audio asset is streaming or not.

You can connect the FMOD Studio via live update and record a profiling capture. It will display bars for IO with categories for bank data, sample data, and streaming data. In your case I would expect to see a profile with initial IO due to the bank and then streaming IO occurring regularly as the sound is played. Generally the profiler is a good way to make sure loading is occuring when you expect.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.