Inheritance: HandleBase
Example #1
0
    static bool LoadAllBanks()
    {
        UnloadAllBanks();

        if (!CreateSystem())
        {
            return(false);
        }

        string bankPath = Application.dataPath + "/StreamingAssets";

        FMOD.Studio.UnityUtil.Log("Loading banks in path: " + bankPath);

        var info = new System.IO.DirectoryInfo(bankPath);

        FMOD.Studio.UnityUtil.Log("Directory " + (info.Exists ? "exists" : "doesn't exist!!"));

        if (info.Exists)
        {
            var fileInfo = info.GetFiles();
            FMOD.Studio.UnityUtil.Log("Number of files: " + fileInfo.Length);

            List <System.IO.FileInfo> bankFiles = new List <System.IO.FileInfo>();
            foreach (var file in fileInfo)
            {
                bankFiles.Add(file);
            }

            int count = 0;
            foreach (var file in bankFiles)
            {
                FMOD.Studio.UnityUtil.Log("file: " + file.Name);
                var s  = info.FullName + "/" + file.Name;
                var ex = file.Extension;

                if (ex.Equals(".bank", System.StringComparison.CurrentCultureIgnoreCase) ||
                    ex.Equals(".strings", System.StringComparison.CurrentCultureIgnoreCase))
                {
                    FMOD.Studio.Bank bank   = null;
                    FMOD.RESULT      result = sFMODSystem.loadBankFile(s, FMOD.Studio.LOAD_BANK_FLAGS.NORMAL, out bank);
                    if (result == FMOD.RESULT.ERR_VERSION)
                    {
                        FMOD.Studio.UnityUtil.LogError("These banks were built with an incompatible version of FMOD Studio. Make sure the unity integration matches the FMOD Studio version (current integration version = " + getVersionString(FMOD.VERSION.number) + ")");
                        return(false);
                    }
                    if (result != FMOD.RESULT.OK)
                    {
                        FMOD.Studio.UnityUtil.LogError("An error occured while loading bank " + s + ": " + result.ToString() + "\n  " + FMOD.Error.String(result));
                        return(false);
                    }
                    loadedBanks.Add(bank);
                }

                ++count;
            }
        }

        return(true);
    }
Example #2
0
 public static Bank FromFmod(FMOD.Studio.Bank bank)
 {
     if (bank == null)
     {
         throw new ArgumentNullException("bank");
     }
     return(new Bank(bank));
 }
Example #3
0
    void loadBank(string fileName)
    {
        string bankPath = getStreamingAsset(fileName);

        FMOD.Studio.Bank bank = null;
        ERRCHECK(FMOD_StudioSystem.instance.System.loadBankFile(bankPath, out bank));

        Debug.Log("bank load: " + (bank != null ? "suceeded" : "failed!!"));
    }
Example #4
0
    void loadBank(string fileName)
    {
        string bankPath = getStreamingAsset(fileName);

        FMOD.Studio.Bank bank   = null;
        FMOD.RESULT      result = FMOD_StudioSystem.instance.System.loadBankFile(bankPath, LOAD_BANK_FLAGS.NORMAL, out bank);
        if (result == FMOD.RESULT.ERR_VERSION)
        {
            FMOD.Studio.UnityUtil.LogError("These banks were built with an incompatible version of FMOD Studio.");
        }

        FMOD.Studio.UnityUtil.Log("bank load: " + (bank != null ? "suceeded" : "failed!!"));
    }
Example #5
0
    void loadBank(string fileName)
    {
        string bankPath = getStreamingAsset(fileName);

        FMOD.Studio.Bank bank   = null;
        FMOD.RESULT      result = FMOD_StudioSystem.instance.System.loadBankFile(bankPath, LOAD_BANK_FLAGS.NORMAL, out bank);
        if (result == FMOD.RESULT.ERR_VERSION)
        {
            FMOD.Studio.UnityUtil.LogError(String.Format("Bank {0} built with an incompatible version of FMOD Studio.", fileName));
        }
        else if (result != FMOD.RESULT.OK)
        {
            FMOD.Studio.UnityUtil.LogError(String.Format("Bank {0} encountered a loading error {1}", fileName, result.ToString()));
        }

        FMOD.Studio.UnityUtil.Log("bank load: " + (bank != null ? "suceeded" : "failed!!"));
    }
    static bool LoadAllBanks()
    {
        UnloadAllBanks();

        CreateSystem();         //TODO: error check

        string bankPath = Application.dataPath + "/StreamingAssets";
        //Debug.Log("Loading banks in path: " + bankPath);

        var info = new System.IO.DirectoryInfo(bankPath);

        //Debug.Log("Directory " + (info.Exists ? "exists" : "doesn't exist!!"));

        if (info.Exists)
        {
            var fileInfo = info.GetFiles();
            //Debug.Log("number of files: " + fileInfo.Length); //PAS

            foreach (var file in fileInfo)
            {
                //Debug.Log("file: " + file.Name); //PAS
                var s  = info.FullName + "/" + file.Name;
                var ex = file.Extension;

                if (ex.Equals(".bank", System.StringComparison.CurrentCultureIgnoreCase) ||
                    ex.Equals(".strings", System.StringComparison.CurrentCultureIgnoreCase))
                {
                    FMOD.Studio.Bank bank   = null;
                    FMOD.RESULT      result = sFMODSystem.loadBankFile(s, out bank);
                    if (result != FMOD.RESULT.OK)
                    {
                        Debug.LogError("An error occured while loading bank " + s + ": " + result.ToString() + "\n  " + FMOD.Error.String(result));
                        return(false);
                    }
                    loadedBanks.Add(bank);
                }
            }
        }

        return(true);
    }
Example #7
0
    /// <summary>
    /// Loads the bank.
    /// </summary>
    /// <param name="fileName">Name of the file.</param>
    public bool LoadBank(string fileName)
    {
        string bankPath = GetStreamingAsset(fileName);

        FMOD.Studio.Bank bank   = null;
        FMOD.Result      result = FMODStudioSystem.Instance.System.LoadBankFile(bankPath, LoadBankFlags.Normal, out bank);
        if (result == FMOD.Result.ErrorVersion)
        {
            Logger.LogError("These banks were built with an incompatible version of FMOD Studio.");
            return(false);
        }
        if (result != FMOD.Result.Ok)
        {
            Logger.LogError("An error occured while loading bank " + fileName + ": " + result.ToString() + "\n  " + FMOD.Error.String(result));
            return(false);
        }

        Logger.LogMessage("Bank Load \"" + fileName + "\": " + (bank != null ? "Succeeded!" : "Failed!"));

        this.loadedBanks.Add(bank);

        return(true);
    }
        public RESULT getBankByID(Guid guid, out Bank bank)
        {
            bank = null;

            IntPtr newPtr = new IntPtr();
			RESULT result = FMOD_Studio_System_GetBankByID(rawPtr, guid.ToByteArray(), out newPtr);
            if (result != RESULT.OK)
            {
                return result;
            }

            bank = new Bank(newPtr);
            return result;
        }
        public RESULT getBank(string path, out Bank bank)
        {
            bank = null;

            IntPtr newPtr = new IntPtr();
            RESULT result = FMOD_Studio_System_GetBank(rawPtr, Encoding.UTF8.GetBytes(path + Char.MinValue), out newPtr);
            if (result != RESULT.OK)
            {
                return result;
            }

            bank = new Bank(newPtr);
            return result;
        }
Example #10
0
    string FMODBankList(string param)
    {
        if (FMOD_StudioSystem.instance == null)
        {
            return("No FMOD system found");
        }
        if (FMOD_StudioSystem.instance.System == null)
        {
            return("No FMOD system found");
        }
        FMOD.Studio.Bank[] banks = new FMOD.Studio.Bank[0];
        FMOD_StudioSystem.instance.System.getBankList(out banks);
        string retval = "Bank Count: " + banks.Length.ToString() + "\r\n";

        foreach (FMOD.Studio.Bank bank in banks)
        {
            string bank_path = "";
            bank.getPath(out bank_path);
            retval += "    Bank [" + bank_path + "]\r\n";
            if (param.IndexOf("-event") >= 0 || param.IndexOf("-all") >= 0)
            {
                FMOD.Studio.EventDescription[] eventdescs = new FMOD.Studio.EventDescription[0];
                bank.getEventList(out eventdescs);
                //if (eventdescs.Length > 0)
                {
                    retval += "        Events: (" + eventdescs.Length + ")\r\n";
                    foreach (FMOD.Studio.EventDescription eventdesc in eventdescs)
                    {
                        string event_path = "";
                        eventdesc.getPath(out event_path);
                        retval += "            Event [" + event_path + "]\r\n";
                    }
                }
            }
            if (param.IndexOf("-vca") >= 0 || param.IndexOf("-all") >= 0)
            {
                FMOD.Studio.VCA[] vcas = new FMOD.Studio.VCA[0];
                bank.getVCAList(out vcas);
                //if (vcas.Length > 0)
                {
                    retval += "        VCAs: (" + vcas.Length + ")\r\n";
                    foreach (FMOD.Studio.VCA vca in vcas)
                    {
                        string vca_path = "";
                        vca.getPath(out vca_path);
                        retval += "            VCA [" + vca_path + "]\r\n";
                    }
                }
            }
            if (param.IndexOf("-bus") >= 0 || param.IndexOf("-all") >= 0)
            {
                FMOD.Studio.Bus[] buses = new FMOD.Studio.Bus[0];
                bank.getBusList(out buses);
                //if (buses.Length > 0)
                {
                    retval += "        Buses: (" + buses.Length + ")\r\n";
                    foreach (FMOD.Studio.Bus bus in buses)
                    {
                        string bus_path = "";
                        bus.getPath(out bus_path);
                        retval += "            Bus [" + bus_path + "]\r\n";
                    }
                }
            }
            if (param.IndexOf("-string") >= 0 || param.IndexOf("-all") >= 0)
            {
                int strcnt = 0;
                bank.getStringCount(out strcnt);
                if (strcnt > 0)
                {
                    retval += "        Strings: (" + strcnt + ")\r\n";
                    for (int i = 0; i < strcnt; ++i)
                    {
                        Guid   _guid;
                        string _path;
                        bank.getStringInfo(i, out _guid, out _path);
                        retval += "            GUID {" + _guid.ToString() + "}    Path [" + _path + "]\r\n";
                    }
                }
            }
        }
        Debug.Log(retval);
        return(retval);
    }
 public RESULT getBankByID(Guid guid, out Bank bank)
 {
     return(FMOD_Studio_System_GetBankByID(handle, ref guid, out bank.handle));
 }
Example #12
0
        public RESULT loadBankCustom(BANK_INFO info, LOAD_BANK_FLAGS flags, out Bank bank)
        {
            bank = null;

            info.size = Marshal.SizeOf(info);

            IntPtr newPtr = new IntPtr();
            RESULT result = FMOD_Studio_System_LoadBankCustom(rawPtr, ref info, flags, out newPtr);
            if (result != RESULT.OK)
            {
                return result;
            }

            bank = new Bank(newPtr);
            return result;
        }
Example #13
0
        public RESULT getBank(GUID guid, out Bank bank)
        {
            bank = null;

            IntPtr newPtr = new IntPtr();
            RESULT result = FMOD_Studio_System_GetBank(rawPtr, ref guid, out newPtr);
            if (result != RESULT.OK)
            {
                return result;
            }

            bank = new Bank(newPtr);
            return result;
        }
Example #14
0
 private Bank(FMOD.Studio.Bank bank)
     : this()
 {
     FmodBank = bank;
 }
Example #15
0
        public RESULT loadBankFile(string name, LOAD_BANK_FLAGS flags, out Bank bank)
        {
            bank = null;

            IntPtr newPtr = new IntPtr();
            RESULT result = FMOD_Studio_System_LoadBankFile(rawPtr, Encoding.UTF8.GetBytes(name + Char.MinValue), flags, out newPtr);
            if (result != RESULT.OK)
            {
                return result;
            }

            bank = new Bank(newPtr);
            return result;
        }
Example #16
0
        public RESULT loadBankMemory(byte[] buffer, LOAD_BANK_FLAGS flags, out Bank bank)
        {
            bank = null;

            IntPtr newPtr = new IntPtr();

            // Manually pin the byte array. It's what the marshaller should do anyway but don't leave it to chance.
            GCHandle pinnedArray = GCHandle.Alloc(buffer, GCHandleType.Pinned);
            IntPtr pointer = pinnedArray.AddrOfPinnedObject();
            RESULT result = FMOD_Studio_System_LoadBankMemory(rawPtr, pointer, buffer.Length, LOAD_MEMORY_MODE.LOAD_MEMORY, flags, out newPtr);
            pinnedArray.Free();
            if (result != RESULT.OK)
            {
                return result;
            }

            bank = new Bank(newPtr);
            return result;
        }
Example #17
0
        public RESULT loadBankMemory(byte[] buffer, LOAD_BANK_FLAGS flags, out Bank bank)
        {
            bank = null;

            IntPtr newPtr = new IntPtr();
            RESULT result = FMOD_Studio_System_LoadBankMemory(rawPtr, buffer, buffer.Length, LOAD_MEMORY_MODE.LOAD_MEMORY, flags, out newPtr);
            if (result != RESULT.OK)
            {
                return result;
            }

            bank = new Bank(newPtr);
            return result;
        }
Example #18
0
        public RESULT getBankList(out Bank[] array)
        {
            array = null;

            RESULT result;
            int capacity;
            result = FMOD_Studio_System_GetBankCount(rawPtr, out capacity);
            if (result != RESULT.OK)
            {
                return result;
            }
            if (capacity == 0)
            {
                array = new Bank[0];
                return result;
            }

            IntPtr[] rawArray = new IntPtr[capacity];
            int actualCount;
            result = FMOD_Studio_System_GetBankList(rawPtr, rawArray, capacity, out actualCount);
            if (result != RESULT.OK)
            {
                return result;
            }
            if (actualCount > capacity) // More items added since we queried just now?
            {
                actualCount = capacity;
            }
            array = new Bank[actualCount];
            for (int i=0; i<actualCount; ++i)
            {
                array[i] = new Bank(rawArray[i]);
            }
            return RESULT.OK;
        }
 public RESULT loadBankCustom(BANK_INFO info, LOAD_BANK_FLAGS flags, out Bank bank)
 {
     info.size = Marshal.SizeOf(info);
     return(FMOD_Studio_System_LoadBankCustom(handle, ref info, flags, out bank.handle));
 }