Unity Integration Issues in Teaching environment

hi folks, i’ve been using the integration for a while now in a classroom teaching situation, and my students have been experiencing a series of issues of Events not playing. i’ve been really annoyed with the inconsistency shown thus far by FMOD Studio’s Unity integration, but perhaps i’m not doing something correctly.

i have set up a project in Unity 4.3.0, something like the Sandbox app used to be, where i can trigger FMOD Studio Events inside a 3D Environment. i was able to create the Events in FMOD Studio, do the build, import the Events from the bank and strings (via the new method) and audition them successfully in Unity Pro Educational.

however nearly every student who tried to import their project and Events into Unity Free got errors when triggering the Events inside Unity. all of them could essentially audition the events in the FMODAssets folder. but when it came time to trigger the events, nothing played. instead i got the error ‘[color=#FF0040]FMOD Studio API could not be found[/color]’.

one bit of troubleshooting unearthed the fact that the presence of AudioWeather plug-ins in an Event could result in no Events from the Master Bank playing at all, but that did not seem the only explanation. i was originally starting the students out with version 1.3.03, and version 1.03 of the integration (the one with the updated import workflow). when they upgraded to 1.3.05 that seems it could have caused some errors. considering that build was out for all of three days, it seems like it could be. i have done a bunch of troubleshooting and could not definitively reproduce the error.

other errors i encountered:

Unity’s FMOD Integration forgetting where the Project folder went. i would then have to delete the FMODAssets and Streaming Assets folders and reimport the Build, which was then only occasionally successful. the best method would be to re-create all events in a new project, and import that.

One student removed her AudioWeather plugin tracks and was able to audition her project bank successfully in Unity. i then had her make a build in Unity Pro for Mac standalone which then resulted in no audio playing at all in the app. maddening!

using FMOD Studio and Unity in a classroom environment means having to take FMOD Studio and Unity projects and copy them over to different volumes. then students can then take these home and work with them, or work at the school. however, in nearly every case each student would have issues. i did include the AudioListener every time and also found out the integration would only work for Events assigned to the Master Bank.

Question: is there a definitively stable method to transport FMOD Studio and Unity projects to other media so that losing contact with the media is mitigated? should i be archiving at all times? if i update FMOD Studio, should i always use the updated integration as well?

i will try to reproduce this problem in a very small Unity project/FMOD Studio project and send it to you, but until i figure out a more stable solution, i have trouble recommending the integration. i just have trouble figuring out why i don’t have any issues but in the classroom, issues abound. maybe you don’t support sustain points? loop regions? i’m grasping at straws here. of course this is all on Macs as we are in a pro audio education setting and we’r all on either 10.8, 10.8.5 or Maverics (10.9).

anyway, any tips will be appreciated. i will update this thread as i can find solutions to these issues.

I hope the semester went well, and you didn’t lose too much hair from these issues. It’s great that there are students out there learning FMOD, using this integration.

I have added some extra checks to the copy step which aims to prevent copying both bank.strings and strings.bank files to hopefully mitigate some of the issues you encountered while importing banks.

The lock on the binaries is because once the editor accesses any FMOD feature, it opens the .DLL (or .bundle) and holds a lock on that file for the whole lifetime of that Unity session. Deleting or modifying the DLL while it is still running is like trying to delete UnityEditor.exe while it is running. When you import the FMOD integration unitypackage it will try to overwrite these DLLs, it is kind a nuisance that you can only import the package while Unity if and only if it is a fresh Unity session. That is just the way any Unity native plugin works, unfortunately there is not much that can really be done to improve that.

OK, thanks for the locking tips. i will advise my students whenever they have to start over by deleting FMODAssets and StreamingAssets that they should save, quit Unity and restart it before re-importing the Build folder afterwards.

overall the semester was only partially successful. i teach FMOD/Unity integration in three classes at two schools, and in one out of the three the issues with building apps in Unity Pro totally caused me to abandon any attempts on that front. in another i got errors between integration versions when they changed ‘instance.getEvent’ to ‘instance.GetEvent’ in the API. i lost an entire class day that day, but in the end most students were able to finally build something. the third class also ran into a lot of unstable issues that were not consistent for every student, but in the end the builds seemed to be OK. i do suspect that a limited permissions computer (common in academic settings) compounds the problem, but not sure why. i’ll give it another try in July.

in the meantime, i am putting together an integration using a simple Breakout game and replacing the SFX and music with FMOD events. i abstracted everything so the game code just calls methods in a script that play the events, but once again i’ve run into inconsistent behavior, leading to a fair amount of code modification. i’d also like some tips on how to initialize a number of Events. currently i’m manually entering these in but the code to set these up seems to involve three lines per Event:

  1. Declare the FMODAsset variable
  2. Declare the Event instance
  3. associate the path of the FMODAsset with the Event Instance

here’s a snippet of the setup:

public class Breakout_FMODCtrl : MonoBehaviour {

	public string path="";

	public FMODAsset intro_loop;
	public FMODAsset music_loop;
	public FMODAsset win_sound;
	public FMODAsset lose_sound;
	public FMODAsset block_explodes;
	public FMODAsset bumper_hit;
	public FMODAsset paddle_hit;

	FMOD.Studio.EventInstance introLoop01;
	FMOD.Studio.EventInstance musicLoop;
	FMOD.Studio.EventInstance winSound;
	FMOD.Studio.EventInstance loseSound;
	FMOD.Studio.EventInstance blockExplodes;
	FMOD.Studio.EventInstance bumperHit;
	FMOD.Studio.EventInstance paddleHit;

	void Start(){
	CacheEvents();
	}

	void CacheEvents(){
		introLoop01 = FMOD_StudioSystem.instance.GetEvent(intro_loop.path);
		musicLoop = FMOD_StudioSystem.instance.GetEvent(music_loop.path);
		winSound = FMOD_StudioSystem.instance.GetEvent(win_sound.path);
		loseSound = FMOD_StudioSystem.instance.GetEvent(lose_sound.path);
		blockExplodes = FMOD_StudioSystem.instance.GetEvent(block_explodes.path);
		bumperHit = FMOD_StudioSystem.instance.GetEvent(bumper_hit.path);
		paddleHit = FMOD_StudioSystem.instance.GetEvent(paddle_hit.path);
	}

it’s painfully explicit and probably inefficient. i’d love to know how to get the number of lines reduced!

regardless, it appears to be clear logically to me. but even this simple setup fails to trigger the first event at the beginning of the game (it’s a Method called by the game script which sends a message on Start). i had to stick in a delay to avoid NullRefs on the first event.

additionally, i have another event which switches to the main music loop on a button event in a popup. this dismisses the window and calls the method here:

	
        void PlayMusic(){
	Debug.Log ("PlayMusic called!");
	introLoop01.stop();
	introLoop01.release()
	CacheEvents();
	musicLoop.start();
	}

notice i have to re-cache the events before starting the next loop. if i don’t, the music will switch correctly from the intro loop to the music loop when the player clicks the button the first time the scene starts, but on a win condition, which pops up the same window with the same button, other method are called to Pause the main music loop, and play a win sound. those methods work fine, but clicking the button again is supposed to start the music loop again from the beginning with that pasted code. this doesn’t work unless i recache the event again. so going from one event to another without recaching is OK, but restarting the same event is not. all i can conclude is that my caching is not being efficiently done, and perhaps the release for the other event is confusing it?

last, i have a blockExplodes Event. for this one i used a simple basic Event in FMOD Studio with a single file. i’ve taken off Voice Stealing in FMOD Studio, set voices to maximum and this behaves perfectly when auditioning it, instancing copies smoothly over each other like a one shot. in Unity, however, it seems to be cutting off at the end, maybe about 1/4 of the time. the result sounds less smooth and more abrupt. would this be better implemented as a MultiEvent and just create copies of the sound there?

i wish i could get to more advanced topics. i feel sheepish bringing such basic issues to your attention, but it’s frustrating setting up what seems to be a really basic situation with no parameters and having it work inconsistently. any help would be appreciated.

lastly a couple more things - i do have to say that the recent license change allowing free use of FMOD Studio for indies is great, but my guess is that you’re going to see more and more inexperienced coders and students wrestling with the API, and the lack of documentation or example methods is going to burden you increasingly and create barriers for the education market. for example it took me a long time to figure out that double colon (::slight_smile: address notation of C++ namespaces == dot notation addresses in C#.

also the changes in the integration can at times be significant, and knowing about this via detailed Changelog on every release (instead of in class when i discover a method has changed in the latest revision) would be extremely helpful.

best,
scott

Restarting Unity should only be required if you have to upgrade the integration (e.g. form 1.3.5 to 1.3.6). If you’re just importing assets then deleting the FMODAssets shouldn’t be necessary once you’ve upgraded Studio beyond 1.03.02. We renamed the Master Bank.bank.strings to Master Bank.strings.bank and the integration ended up with both versions and got confused. If everything is a high version than that then there is no need to delete anything it should all work out of the box.

For the rest of your questions would you mind emailing support@fmod.org, so we can speak directly in more detail?

-Pete

sorry for the long wait - we were just finishing out the semester and things have finally slowed down.

you raise an interesting point about the file lock. oftentimes i take my working example integration templates, and prepare them for students by removing the FMODAssets folder and the Streaming assets folder. i do this within the Editor and i don’t restart the Editor. it sounds like you might be advising to remove these folders outside of the Editor, or least to restart the Editor after deleting these items. i have certainly had issue with not being able to play a student’s newly imported Events in the Editor, even though the Events can almost always be previewed successfully.

note that i don’t have anywhere near the same amount issues with the same sequence of procedures when i do everything myself on my laptop or desktop at home. it just when i try to demonstrate it to students that all hell breaks loose. one thing i may not have mentioned is that frequently a student’s computer on campus is set up with limited permissions. for example they are unable to run MonoDevelop to edit scripts(we don’t do any scripting for FMOD projects however. these classes are mainly step by step drag and drop implementation in Unity). so there may be issues with file lock when running Unity under these limited conditions and then deleting FMOD Assets and banks from a project and trying to re-import new banks. i’ll keep working on this, but the errors seem to be inconsistent.

OK, Bump time! i need some of these issues addressed please.

i have to say, i’ve been having a lot of issues in my attempts to integrate Studio into Unity. here are my issues, in order of priority:

  1. i cannot play FMOD Studio events in a completed Unity Pro build of a scene as a Mac standalone app. this is across the board. i just get a raft of NullRef Exceptions and no FMOD audio plays. no idea. Player.Log indicates the following:

Fallback handler could not load library /Users/scottlooney/Desktop/testBuild-Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/fmod
Fallback handler could not load library /Users/scottlooney/Desktop/testBuild-Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libfmod.dylib
Fallback handler could not load library /Users/scottlooney/Desktop/testBuild-Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libfmod.so
Fallback handler could not load library /Users/scottlooney/Desktop/testBuild-Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/libfmod.bundle
Fallback handler could not load library /Users/scottlooney/Desktop/testBuild-Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/fmod.dylib
Fallback handler could not load library /Users/scottlooney/Desktop/testBuild-Mac.app/Contents/Frameworks/MonoEmbedRuntime/osx/fmod.so

after which i get a raft of Null Ref messages since nothing can instance properly. i have a Unity Pro Edu license and i’ve tried this out on 30 Trial versions of Pro as well - no success. i even created a blank Scene and used the FMOD_Studio Event Emitter script, and it still did not play correctly. i’m including a project file here for study.

  1. The integration loses track of the path of the event data and banks when moved to a different environment or onto a different volume.

i had a working demo on my machine at home running off of an external drive. when i hooked the drive up to another machine (both were Macs), i was unable to trigger the events properly in the Editor. i had to delete the FMODAssets folder and the Streaming Assets folder and re-import my banks again. this has happened several times now.

  1. instability and inconsistency in FMOD versions

as others have stated i get the ‘bank was created in earlier version of FMOD Studio’ error message, but it’s difficult to get rid of the message. deleting the Build Folder of the project after opening,and then building the bank in a newer version of FMOD Studio is successful about half of the time. the only sure fire method is to start again from scratch in the new version.

all of these issues do not bode well for a production environment, much less an education environment.

i would very much appreciate an answer to these questions, especially #1. i am including a link to a test project to analyze:

https://dl.dropboxusercontent.com/u/146 ... tEvent.zip

maybe i’m forgetting a really obvious step here, but i’ve stripped this down to the basics - a scene with the latest integration version, a camera with the Listener, and one object with the Emitter script on it. event previews fine in FMODAssets folder, plays fine in editor. build completes successfully but no audio event or FMOD library is found. using Unity 4.3.0.

let me know if you need anything else from me.

Hi metaphysician,

Sorry for the delay in replying, I had seen your post but have been unable to reproduce any of the issues you have listed.

Here are the steps I followed trying to reproduce the issue:

  1. Download the latest FMOD Studio and the latest integration package.
  2. Build example project
  3. Create a new Unity project
  4. Import integration package
  5. Import banks in the examples/build directory
  6. Added a FMOD_Listener to the camera
  7. Added a FMOD_StudioEventEmitter and assigned the Ambience/Country event

I play in the editor, I hear the ambience sound as expected.

I build an app and run it, this also work correctly. (I tried x86, x86_64, and Universal)

I tested this project on Windows and Mac and it worked perfectly.

Some users have reported issues with using the FMOD integration on older versions of OSX, what version of OSX are you testing with?

The bank paths are relative to the project folder, I am frequently copying projects from my development PC to Mac and have never encountered any issues. There must be something I’m missing here.

There was a change in FMOD Studio to rename Master Bank.bank.strings to Master Bank.strings.bank, this can leave the old file hanging around after upgrading. I understand this is an inconvenience, this was a one off change to standardize the naming, and resolve an issue with .strings association in XCode. If you’re seeing that error, check through the build directory and the streaming assets directory and make sure the .bank.strings file is not there.

I agree that allowing the user to build banks which cannot load is not a good look, but it is not my area. I will raise this again with the UI team.

wow - that makes me think i must be going crazy. i’ve tested it on three different machines running some variant of 10.8. i’ve got 10.8.0, and i think the machines at each of the schools have 10.8.5. both of those failed to make sound in the compiled app. i’m going to try it on my 10.9 laptop right now.

OK i tried the exact same thing and had the exact same result as before (FMODAssets preview -OK, Editor playback-OK. but in the compiled app my audio does not play). this is on a 2012 MacBookPro running 10.9, and using Unity 4.3.4. so that’s four machines, including my desktop, with problems in the App build.

here’s a link to the app build i just did on the laptop that doesn’t work for me. please verify it doesn’t work for you as well:

https://dl.dropboxusercontent.com/u/146 ... ld-mbp.zip

actually, send me a link to a simple project that you know builds fine…like, after opening it myself, i can just go to Build Settings and build it immediately. this way i can at least verify it can be done.

i have no idea why i’m not having luck in this regard. sorry for my tone earlier - i know everyone’s busy but it often takes several days to get a reply.

i’m documenting this integration for a lesson plan we’re making available to schools and teachers, and i need to get things to a moderately predictable and stable place in regards to a reliable method to build and test apps. i know betas will change features but what i’ve gone through makes the current integration seem more buggy and unstable than warranted. i don’t know what magic things i’m doing, but your method of testing and mine were identical and for some reason, mine doesn’t work.

at any rate, i do appreciate your information and help. i’ll try to get to the bottom of this.

best,
scott

OK - update. it appears that merely importing the new version of the integration over the older version does not apparently delete the old version. i have since removed all of the libraries for FMOD in the test project folder and deleted the Plugins folder and re-imported the newest version of the integration, as if from scratch. this finally worked. i tried the same technique on another project and it works as well.

so this means you must remove all traces of the previous integration’s files before updating any integration. i will keep that in mind in the future, but it might be useful to indicate that you cannot currently upgrade the integration in place. also it would be good to indicate that the current integration does not support the usage of third party plugins, and that all events must be attached to the Master Bank and not a secondary bank.

thanks for your assistance in helping me track down these issues. it’s appreciated.

1 Like

I’m glad to hear that the issue is resolved. I’m surprised that was an problem, I expected Unity to overwrite all the old files. One thing to bare in mind is that if you are using the old integration in the same session before importing the new package the system will hold a lock on the binaries for that platform because it’s accessing the DLL/bundle through the editor, which prevents it updating those files. This includes using any of the audition functionality or even checking the integration version (FMOD -> About Integration). This is currently undocumented so I will add it to the documentation. Could this explain your issue or did you have the problem when opening up Unity and upgrading without using the integration?

1 Like