LoadBank() public static method

public static LoadBank ( IntPtr in_pInMemoryBankPtr, uint in_uInMemoryBankSize, AkCallbackManager in_pfnBankCallback, object in_pCookie, int in_uPoolForBankMedia, uint &out_bankID ) : AKRESULT
in_pInMemoryBankPtr IntPtr
in_uInMemoryBankSize uint
in_pfnBankCallback AkCallbackManager
in_pCookie object
in_uPoolForBankMedia int
out_bankID uint
return AKRESULT
Ejemplo n.º 1
0
 //Loading the soundBank
 public void Awake()
 {
     foreach (string i in bankNames)
     {
         AkSoundEngine.LoadBank(i, AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
     }
 }
Ejemplo n.º 2
0
        private static void LoadSoundBank(byte[] data, string soundBankPath = null)
        {
            // allocate memory and copy file contents to aligned address
            IntPtr allocated = Marshal.AllocHGlobal(data.Length + MEMORY_ALIGNMENT - 1);
            IntPtr aligned   = new IntPtr((allocated.ToInt64() + MEMORY_ALIGNMENT - 1) / MEMORY_ALIGNMENT * MEMORY_ALIGNMENT);

            Marshal.Copy(data, 0, aligned, data.Length);

            uint bankID;
            var  result = AkSoundEngine.LoadBank(aligned, (uint)data.Length, out bankID);

            if (result != AKRESULT.AK_Success)
            {
                if (string.IsNullOrEmpty(soundBankPath))
                {
                    Logger.Log("Failed to load sound bank.");
                }
                else
                {
                    Logger.Log("Failed to load sound bank from: '{0}'", soundBankPath);
                }
                Logger.Log("Result was {0}.", result);
                Marshal.FreeHGlobal(allocated);
            }
        }
Ejemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        uint bankID;         // Not used

        AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
        AkSoundEngine.PostEvent(eventName, gameObject);
    }
Ejemplo n.º 4
0
    // Use this for initialization
    void Start()
    {
        uint bankID;

        AkSoundEngine.LoadBank("Car.bnk", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
        AkSoundEngine.PostEvent(AK.EVENTS.PLAY_ENGINE, gameObject);
    }
Ejemplo n.º 5
0
 /// <summary>
 /// Preload should try to load your music bank with <see cref="SoundBankName"/>
 /// </summary>
 public override void Preload()
 {
     if (!string.IsNullOrWhiteSpace(SoundBankName))
     {
         AkSoundEngine.LoadBank(SoundBankName, out _);
     }
 }
Ejemplo n.º 6
0
    //----------------------------------------------------------------------------------------
    // start
    void Start()
    {
        Instance = this;

        uint bankID;

        AkSoundEngine.LoadBank("Ambiance", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
        AkSoundEngine.LoadBank("Car_Motor", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
        AkSoundEngine.LoadBank("Music", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
        AkSoundEngine.LoadBank("UI", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);



        // set the volume of Busses
        if (modifyBussesVolume)
        {
            AkSoundEngine.SetRTPCValue("RTPC_BUS_MASTER_GLOBAL_VOL", volumeGlobal);
            AkSoundEngine.SetRTPCValue("RTPC_BUS_MASTER_MUSIC_VOL", volumeMusic);
            AkSoundEngine.SetRTPCValue("RTPC_BUS_MASTER_VOICES_VOL", volumeVoice);
            AkSoundEngine.SetRTPCValue("RTPC_BUS_MASTER_SFX_VOL", volumeSFX);
        }
        else
        {
            // volumeGlobal = 100f;
            volumeMusic = 100f;
            volumeVoice = 100f;
            volumeSFX   = 100f;
        }
    }
Ejemplo n.º 7
0
        /// Loads a bank. This version blocks until the bank is loaded. See AK::SoundEngine::LoadBank for more information.
        public override AKRESULT DoLoadBank()
        {
            if (decodeBank)
            {
                return(AkSoundEngine.LoadAndDecodeBank(bankName, saveDecodedBank, out m_BankID));
            }

            AKRESULT res = AKRESULT.AK_Success;

            if (!string.IsNullOrEmpty(decodedBankPath))
            {
                res = AkSoundEngine.SetBasePath(decodedBankPath);
            }

            if (res == AKRESULT.AK_Success)
            {
                res = AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);

                if (!string.IsNullOrEmpty(decodedBankPath))
                {
                    AkSoundEngine.SetBasePath(AkBasePathGetter.GetSoundbankBasePath());
                }
            }

            return(res);
        }
Ejemplo n.º 8
0
        public static void LoadSoundBank(string bankName)
        {
#if !DISABLE_AKSOUNDENGINE
            uint bankId;
            AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out bankId);
#endif
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Loads a soundbank from a byte array
        /// </summary>
        /// <param name="bankBytes"></param>
        /// <param name="onIndexRecieved"></param>
        public static void LoadSoundbank(Byte[] bankBytes, Action <UInt32> onIndexRecieved)
        {
            if (!loaded)
            {
                throw new CoreNotLoadedException(nameof(SoundsCore));
            }

            if (banksLoaded)
            {
                throw new Exception("Too late to add bank");
            }

            IntPtr ptr = PointerArrayHolder.Create(bankBytes);

            RoR2Application_onLoad += () =>
            {
                AKRESULT res = AkSoundEngine.LoadBank(ptr, (UInt32)bankBytes.Length, out UInt32 outId);
                if (!res.Flag(AKRESULT.AK_Success))
                {
                    Log.Error("Bank load failure");
                }
                else
                {
                    onIndexRecieved(outId);
                    activeIndicies.Add(outId, ptr);
                }
                PointerArrayHolder.Remove(ptr);
            };
        }
Ejemplo n.º 10
0
    private static AKRESULT DoLoadBank(string in_bankPath)
    {
        ms_www = new WWW(in_bankPath);
        while (!ms_www.isDone)
        {
#if !UNITY_METRO
            System.Threading.Thread.Sleep(WaitMs);
#endif // #if ! UNITY_METRO
        }

        uint in_uInMemoryBankSize = 0;
        try
        {
            ms_pinnedArray       = GCHandle.Alloc(ms_www.bytes, GCHandleType.Pinned);
            ms_pInMemoryBankPtr  = ms_pinnedArray.AddrOfPinnedObject();
            in_uInMemoryBankSize = (uint)ms_www.bytes.Length;
        }
        catch
        {
            return(AKRESULT.AK_Fail);
        }

        AKRESULT result = AkSoundEngine.LoadBank(ms_pInMemoryBankPtr, in_uInMemoryBankSize, out ms_bankID);

        return(result);
    }
Ejemplo n.º 11
0
        public void ReloadBanks()
        {
            uint num;
            int  num2  = 0;
            int  count = this.soundBankScaleStack.Count;

            while (num2 < count)
            {
                SoundBankScale scale  = this.soundBankScaleStack[num2];
                int            index  = 0;
                int            length = scale.soundBankNames.Length;
                while (index < length)
                {
                    AkSoundEngine.UnloadBank(scale.soundBankNames[index], IntPtr.Zero, null, null);
                    AkSoundEngine.LoadBank(scale.soundBankNames[index], -1, out num);
                    index++;
                }
                num2++;
            }
            int num6 = 0;
            int num7 = this.manualPrepareBanks.Count;

            while (num6 < num7)
            {
                AkSoundEngine.UnloadBank(this.manualPrepareBanks[num6], IntPtr.Zero, null, null);
                AkSoundEngine.LoadBank(this.manualPrepareBanks[num6], -1, out num);
                num6++;
            }
        }
Ejemplo n.º 12
0
 void Awake()
 {
     if (NameOfBank != "")
     {
         uint BankID = 0;
         AkSoundEngine.LoadBank(NameOfBank, AkSoundEngine.AK_DEFAULT_POOL_ID, out BankID);
     }
 }
Ejemplo n.º 13
0
 private void InitializeAudio()
 {
     AkSoundEngine.LoadBank("MX", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
     AkSoundEngine.LoadBank("SFX", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
     StartMusic();
     StartAmbiance();
     AkSoundEngine.RenderAudio();
 }
 public Text displayLowPass;       // Referance to a Text UI on screen to display the LowPass Filter
 // Use this for initialization
 void Start()
 {
     AkSoundEngine.LoadBank("ExampleBank", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);          //Load the sound bank, need to happened only once in a scene no reason to add this on every single script
     //Side note - my recommendation is to create your own handler Class and that will handle all Play and Stop SFX functions.
     //For more information watch https://www.youtube.com/watch?v=j5Aq5hg1dcA
     AkSoundEngine.PostEvent("Play_Tetris_Remix", soundSourceObj);         //Play an event from the Wwise engine from the soundSourceObj Game Object
     //On Tetris_Remix sound in Wwise the Max distance is set to 30. Which is the size of the platform in the scene
 }
Ejemplo n.º 15
0
    public static AKRESULT LoadBank(string in_bankPath)
    {
        uint BankID;

        AKRESULT result = AkSoundEngine.LoadBank(in_bankPath, AkSoundEngine.AK_DEFAULT_POOL_ID, out BankID);

        return(result);
    }
Ejemplo n.º 16
0
 void Start()
 {
     m_BankIDs = new uint[bankNames.Count];
     for (int i = 0; i < bankNames.Count; ++i)
     {
         AkSoundEngine.LoadBank(bankNames[i], AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankIDs[i]);
     }
 }
Ejemplo n.º 17
0
    /// Loads a bank. This version blocks until the bank is loaded. See AK::SoundEngine::LoadBank for more information.
    public void LoadBank()
    {
        if (m_RefCount == 0)
        {
            AKRESULT res = AKRESULT.AK_Fail;

            // There might be a case where we were asked to unload the SoundBank, but then asked immediately after to load that bank.
            // If that happens, there will be a short amount of time where the ref count will be 0, but the bank will still be in memory.
            // In that case, we do not want to unload the bank, so we have to remove it from the list of pending bank unloads.
            if (AkBankManager.BanksToUnload.Contains(this))
            {
                AkBankManager.BanksToUnload.Remove(this);
                IncRef();
                return;
            }

            if (decodeBank == false)
            {
                string basePathToSet = null;

                if (!string.IsNullOrEmpty(relativeBasePath))
                {
                    basePathToSet = AkBasePathGetter.GetValidBasePath();
                    if (string.IsNullOrEmpty(basePathToSet))
                    {
                        Debug.LogWarning("WwiseUnity: Bank " + bankName + " failed to load (could not obtain base path to set).");
                        return;
                    }

                    res = AkSoundEngine.SetBasePath(System.IO.Path.Combine(basePathToSet, relativeBasePath));
                }
                else
                {
                    res = AKRESULT.AK_Success;
                }

                if (res == AKRESULT.AK_Success)
                {
                    res = AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);

                    if (!string.IsNullOrEmpty(basePathToSet))
                    {
                        AkSoundEngine.SetBasePath(basePathToSet);
                    }
                }
            }
            else
            {
                res = AkSoundEngine.LoadAndDecodeBank(bankName, saveDecodedBank, out m_BankID);
            }

            if (res != AKRESULT.AK_Success)
            {
                Debug.LogWarning("WwiseUnity: Bank " + bankName + " failed to load (" + res.ToString() + ")");
            }
        }
        IncRef();
    }
    PlayerMovement playerScript;     // A reference to the movement script
    // Use this for initialization
    void Start()
    {
        playerScript              = gameObject.GetComponent <PlayerMovement> ();             //getting the script reference
        playerScript.PlayerMoved += PlaySFX;                                                 //Assigning the PlayerMoved event to PlaySFX() Funciton. So every time PlayerMoved event is fired PlaySFX() Function is fired too

        AkSoundEngine.LoadBank("ExampleBank", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID); //Load the sound bank, need to happened only once in a scene no reason to add this on every single script
        //Side note - my recommendation is to create your own handler Class and that will handle all Play, and Stop SFX function
        //For more information watch https://www.youtube.com/watch?v=j5Aq5hg1dcA
    }
Ejemplo n.º 19
0
    public void LoadBank(string soundbankName)
    {
        AKRESULT result;

        if ((result = AkSoundEngine.LoadBank(soundbankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID)) != AKRESULT.AK_Success)
        {
            Debug.LogError("Unable to load " + soundbankName + " with result: " + result);
        }
    }
Ejemplo n.º 20
0
 /// Loads a bank.  This version returns right away and loads in background. See AK::SoundEngine::LoadBank for more information
 public void LoadBankAsync(AkCallbackManager.BankCallback callback = null)
 {
     if (m_RefCount == 0)
     {
         bankCallback = callback;
         AkSoundEngine.LoadBank(bankName, AkBankManager.GlobalBankCallback, this, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);
     }
     IncRef();
 }
Ejemplo n.º 21
0
 public void LoadBankAsync(AkCallbackManager.BankCallback callback = null)
 {
     if (this.m_RefCount == 0)
     {
         this.bankCallback = callback;
         AkSoundEngine.LoadBank(this.bankName, new AkCallbackManager.BankCallback(AkBankManager.GlobalBankCallback), this, -1, out this.m_BankID);
     }
     this.IncRef();
 }
Ejemplo n.º 22
0
 public override void Init()
 {
     string[] allBanks = null;
     foreach (string bank in allBanks)
     {
         AkSoundEngine.LoadBank(bank, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);
         AkBankManager.LoadBank(bank, false, false);
     }
 }
 public Text displayParameter; // displays the parameter's value on screen
 // Use this for initialization
 void Start()
 {
     AkSoundEngine.LoadBank("ExampleBank", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);          //Load the sound bank, need to happened only once in a scene no reason to add this on every single script
     //Side note - my recommendation is to create your own handler Class and that will handle all Play and Stop SFX functions.
     //For more information watch https://www.youtube.com/watch?v=j5Aq5hg1dcA
     AkSoundEngine.PostEvent("Play_MusicDynamicIntensity", gameObject); //Play an event from the Wwise engine. The game object doesn't really matter because Music is useally a 2D sound.
     displayParameter.text = ("Parameter Value: Fades are in Engine "); // initially show 0 in the parameter text on screen
     AkSoundEngine.SetState("DynamicMusicIntensity", "Int1");           //Sets initial value to the State container.
     // t sometimes you may forget to set the initial Value fo the State, so consider this as a reminder
 }
Ejemplo n.º 24
0
    public static HUDSounds Instance()
    {
        if (m_Instance == null)
        {
            m_Instance = new HUDSounds();
            uint _bankID;
            AkSoundEngine.LoadBank("HUD", AkSoundEngine.AK_DEFAULT_POOL_ID, out _bankID);
        }

        return(m_Instance);
    }
Ejemplo n.º 25
0
    private System.Collections.IEnumerator LoadFile()
    {
        ms_www = new UnityEngine.WWW(m_bankPath);

        yield return(ms_www);

        uint in_uInMemoryBankSize = 0;

        // Allocate an aligned buffer
        try
        {
            ms_pinnedArray =
                System.Runtime.InteropServices.GCHandle.Alloc(ms_www.bytes, System.Runtime.InteropServices.GCHandleType.Pinned);
            ms_pInMemoryBankPtr  = ms_pinnedArray.AddrOfPinnedObject();
            in_uInMemoryBankSize = (uint)ms_www.bytes.Length;

            // Array inside the WWW object is not aligned. Allocate a new array for which we can guarantee the alignment.
            if ((ms_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0)
            {
                var alignedBytes    = new byte[ms_www.bytes.Length + AK_BANK_PLATFORM_DATA_ALIGNMENT];
                var new_pinnedArray =
                    System.Runtime.InteropServices.GCHandle.Alloc(alignedBytes, System.Runtime.InteropServices.GCHandleType.Pinned);
                var new_pInMemoryBankPtr = new_pinnedArray.AddrOfPinnedObject();
                var alignedOffset        = 0;

                // New array is not aligned, so we will need to use an offset inside it to align our data.
                if ((new_pInMemoryBankPtr.ToInt64() & AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) != 0)
                {
                    var alignedPtr = (new_pInMemoryBankPtr.ToInt64() + AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK) &
                                     ~AK_BANK_PLATFORM_DATA_ALIGNMENT_MASK;
                    alignedOffset        = (int)(alignedPtr - new_pInMemoryBankPtr.ToInt64());
                    new_pInMemoryBankPtr = new System.IntPtr(alignedPtr);
                }

                // Copy the bank's bytes in our new array, at the correct aligned offset.
                System.Array.Copy(ms_www.bytes, 0, alignedBytes, alignedOffset, ms_www.bytes.Length);

                ms_pInMemoryBankPtr = new_pInMemoryBankPtr;
                ms_pinnedArray.Free();
                ms_pinnedArray = new_pinnedArray;
            }
        }
        catch
        {
            yield break;
        }

        var result = AkSoundEngine.LoadBank(ms_pInMemoryBankPtr, in_uInMemoryBankSize, out ms_bankID);

        if (result != AKRESULT.AK_Success)
        {
            UnityEngine.Debug.LogError("WwiseUnity: AkMemBankLoader: bank loading failed with result " + result);
        }
    }
Ejemplo n.º 26
0
    // Use this for initialization
    static WwiseAudioManager()
    {
        //instance = this;
        AkSoundEngine.LoadBank("Main", AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);

        //Fonction de vibration
        AkSoundEngine.AddPlayerMotionDevice(0, 1, AkSoundEngine.AKMOTIONDEVICEID_RUMBLE);
        //AkSoundEngine.SetPlayerListener (0, 0);
        AkSoundEngine.SetListenerPipeline(0, true, true);
        //AkSoundEngine.SetActiveListeners(GameObject.FindWithTag("Player"),1);
    }
Ejemplo n.º 27
0
 public void LoadBank()
 {
     if (this.m_RefCount == 0)
     {
         AKRESULT akresult = AkSoundEngine.LoadBank(this.bankName, -1, out this.m_BankID);
         if (akresult != AKRESULT.AK_Success)
         {
             Debug.LogWarning("Wwise: Bank " + this.bankName + " failed to load (" + akresult.ToString() + ")");
         }
     }
     this.IncRef();
 }
Ejemplo n.º 28
0
 public override void Awake()
 {
     base.Awake();
     if (!this.main.EditorEnabled && !string.IsNullOrEmpty(this.Name))
     {
         AKRESULT result = AkSoundEngine.LoadBank(this.Name, AkSoundEngine.AK_DEFAULT_POOL_ID, out this.bank_id);
         if (result != AKRESULT.AK_Success)
         {
             Log.d(string.Format("Failed to load soundbank {0}: {1}", this.Name, result));
         }
     }
 }
Ejemplo n.º 29
0
    void Start()
    {
        if (!AkSoundEngine.IsInitialized())
        {
            m_logger.Error("Error_EngineNotInit");
            return;
        }

        AkSoundEngine.SetCurrentLanguage("English(US)");
        uint bankID;

        AkSoundEngine.LoadBank(m_BankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out bankID);
    }
Ejemplo n.º 30
0
    /// Loads a bank.  This version blocks until the bank is loaded.  See AK::SoundEngine::LoadBank for more information
    public void LoadBank()
    {
        if (m_RefCount == 0)
        {
            AKRESULT res = AkSoundEngine.LoadBank(bankName, AkSoundEngine.AK_DEFAULT_POOL_ID, out m_BankID);
            if (res != AKRESULT.AK_Success)
            {
                Debug.LogWarning("Wwise: Bank " + bankName + " failed to load (" + res.ToString() + ")");
            }
        }

        IncRef();
    }