public static Bank LoadBank(string bankName) { if (_banks.ContainsKey(bankName)) { return(_banks[bankName]); } Bank newBank = StudioSystem.LoadBank(_bankDirectory + bankName); _banks.Add(bankName, newBank); return(newBank); }
public override void Enter() { InitUI(); // You would rather place the following in LoadContent() - it's here more for readability. // Here you load any banks that you're using. This could be a music bank, a SFX bank, etc. // The strings bank isn't actually necessary - however if you want to do string lookups, include it. _banks.Add(StudioSystem.LoadBank("Master.bank")); _banks.Add(StudioSystem.LoadBank("Master.strings.bank")); _banks.Add(StudioSystem.LoadBank("Music.bank")); _banks.Add(StudioSystem.LoadBank("SFX.bank")); _banks.Add(StudioSystem.LoadBank("Vehicles.bank")); _banks.Add(StudioSystem.LoadBank("VO.bank")); _banks.Add(StudioSystem.LoadBank("Dialogue_EN.bank")); // Events are split in the code into descriptions and instances. // You may have multiple instances of one event, but the description for it should only be loaded once. // Here is why you want the strings bank loaded, btw. So much more intuitive than Guids. _engineDescription = StudioSystem.GetEvent("event:/Vehicles/Car Engine"); _musicDescription = StudioSystem.GetEvent("event:/Music/Level 03"); // Loading an event description by Guid. // FMOD Studio will give you a string like below when you select "Copy Guid". It has to be parsed to be used. FMOD.Studio.Util.parseID("{be6203d8-c8d8-41c5-8ce6-bce0de95807b}", out Guid sfxGuid); _bonkDescription = StudioSystem.GetEvent(sfxGuid); // There are three ways to load sample data (any non-streamed sounds): // -From a bank. This will keep ALL the bank's data in memory until unloaded. // -From an event description. This will just keep the event's necessary data in memory until unloaded. // -From an event instance. Same as above, except the data will only be in memory while an instance is. // Assess when you need memory loaded and for how long, then choose which method to use properly. _engineDescription.LoadSampleData(); // The music doesn't need its data pre-loaded, since it'll just play right away, continuously. _engineInstance = _engineDescription.CreateInstance(); _musicInstance = _musicDescription.CreateInstance(); // Sound effects could be played whenever, so you don't want them constantly loading / unloading. _bonkDescription.LoadSampleData(); // If you have any parameters set within FMOD Studio, you can change them within the code. _engineInstance.SetParameterValue("RPM", _rpm); _engineInstance.SetParameterValue("Load", -1f); }