Ejemplo n.º 1
0
    /**
     * <summary>ASRラックの作成</summary>
     * <param name="config">コンフィグ構造体</param>
     * <param name="platformConfig">プラットフォーム固有パラメータ構造体</param>
     * <returns>ASRラック</returns>
     * \par 説明:
     * ASRラックを作成します。<br>
     * 本関数で作成したASRラックは、必ず Dispose 関数で破棄してください。
     * */
    public CriAtomExAsrRack(Config config, PlatformConfig platformConfig)
    {
        #if CRIWARE_SUPPORT_ASR
        CriAtomPlugin.InitializeLibrary();

        this._rackId = criAtomUnityAsrRack_Create(ref config, ref platformConfig);
        if (config.context != IntPtr.Zero)
        {
            Marshal.FreeHGlobal(config.context);
        }
        if (this._rackId == -1)
        {
            throw new Exception("CriAtomExAsrRack() failed.");
        }
        #else
        this._rackId = -1;
        #endif
    }
Ejemplo n.º 2
0
    public static void InitializeLibrary()
    {
        /* 初期化カウンタの更新 */
        CriAtomPlugin.initializationCount++;
        if (CriAtomPlugin.initializationCount != 1)
        {
            return;
        }

        /* シーン実行前に初期化済みの場合は終了させる */
        if (CriAtomPlugin.IsLibraryInitialized() == true)
        {
            CriAtomPlugin.FinalizeLibrary();
            CriAtomPlugin.initializationCount = 1;
        }

        /* 初期化パラメータが設定済みかどうかを確認 */
        if (CriAtomPlugin.isConfigured == false)
        {
            Debug.Log("[CRIWARE] Atom initialization parameters are not configured. "
                      + "Initializes Atom by default parameters.");
        }

        /* 依存ライブラリの初期化 */
        CriFsPlugin.InitializeLibrary();

        /* ライブラリの初期化 */
        CriAtomPlugin.criAtomUnity_Initialize();


        /* CriAtomServerのインスタンスを生成 */
                #if UNITY_EDITOR
        /* ゲームプレビュー時のみ生成する */
        if (UnityEngine.Application.isPlaying)
        {
            CriAtomServer.CreateInstance();
        }
                #else
        CriAtomServer.CreateInstance();
                #endif

        /* CriAtomListenerが存在しない場合のためのダミーリスナーを生成 */
        CriAtomListener.CreateDummyNativeListener();
    }
Ejemplo n.º 3
0
    private void OnEnable()
    {
        #if UNITY_EDITOR
        if (CriAtomPlugin.previewCallback != null)
        {
            CriAtomPlugin.previewCallback();
        }
        #endif
        if (CriAtom.instance != null)
        {
            return;
        }

        #if (!UNITY_EDITOR || UNITY_EDITOR_OSX) && UNITY_WEBGL
        this.SetupAsync();
        #else
        this.Setup();
        #endif
    }
Ejemplo n.º 4
0
    private void OnEnable()
    {
        #if UNITY_EDITOR
        if (CriAtomPlugin.previewCallback != null)
        {
            CriAtomPlugin.previewCallback();
        }
        #endif
        if (CriAtom.instance != null)
        {
            return;
        }

        #if CRIWARE_FORCE_LOAD_ASYNC
        this.SetupAsync();
        #else
        this.Setup();
        #endif
    }
Ejemplo n.º 5
0
 private void Shutdown()
 {
     foreach (var cueSheet in this.cueSheets)
     {
         if (cueSheet.acb != null)
         {
             cueSheet.acb.Dispose();
             cueSheet.acb = null;
         }
             #if (!UNITY_EDITOR || UNITY_EDITOR_OSX) && UNITY_WEBGL
         if (cueSheet.async != null)
         {
             cueSheet.async.Dispose();
             cueSheet.async = null;
         }
             #endif
     }
     CriAtomPlugin.FinalizeLibrary();
     CriAtom.instance = null;
 }
Ejemplo n.º 6
0
    void OnDestroy()
    {
        /* 初期化カウンタの更新 */
        if (initializationCount == 0)
        {
            return;
        }

        initializationCount--;
        if (initializationCount != 0)
        {
            return;
        }

#if UNITY_EDITOR || (!UNITY_PS3)
        /* CRI Manaライブラリの終了 */
        if (initializesMana)
        {
            CriManaPlugin.FinalizeLibrary();
        }
#endif

        /* CRI Atomライブラリの終了 */
        if (initializesAtom)
        {
            /* EstimatorがStop状態になるまでFinalize */
            while (CriAtomExLatencyEstimator.GetCurrentInfo().status != CriAtomExLatencyEstimator.Status.Stop)
            {
                CriAtomExLatencyEstimator.FinalizeModule();
            }

            /* 終了処理の実行 */
            CriAtomPlugin.FinalizeLibrary();
        }

        /* CRI File Systemライブラリの終了 */
        if (initializesFileSystem)
        {
            CriFsPlugin.FinalizeLibrary();
        }
    }
Ejemplo n.º 7
0
    /* プラグイン内部用API */
    public static void SetEventCallback(CriAtomExSequencer.EventCbFunc func, string separator)
    {
#if CRIWARE_SUPPORT_SEQUENCE_CALLBACK
        /* ネイティブプラグインに関数ポインタを登録 */
        IntPtr ptr = IntPtr.Zero;
        eventUserCbFunc = func;
        if (func != null)
        {
        #if CRIWARE_CALLBACK_IMPL_UNITYSENDMESSAGE
            ptr = IntPtr.Zero;
        #elif CRIWARE_CALLBACK_IMPL_NATIVE2MANAGED
            CriAtomExSequencer.EventCbFunc localFunc;
            localFunc = new CriAtomExSequencer.EventCbFunc(CriAtom.instance.EventCallbackFromNative);
            ptr       = Marshal.GetFunctionPointerForDelegate(localFunc);
        #endif
            CriAtomPlugin.criAtomUnitySeqencer_SetEventCallback(ptr, CriAtom.instance.gameObject.name, "EventCallbackFromNative", separator);
        }
#elif CRIWARE_UNSUPPORT_SEQUENCE_CALLBACK
        Debug.LogError("This platform does not support event callback feature.");
#endif
    }
Ejemplo n.º 8
0
 public override void OnPlayableCreate(Playable playable)
 {
     base.OnPlayableCreate(playable);
     m_Guid = Guid.NewGuid();
     if (IsEditor)
     {
         if (CriAtomPlugin.IsLibraryInitialized() == false)
         {
             CriWareInitializer criInitializer = GameObject.FindObjectOfType <CriWareInitializer>();
             if (criInitializer != null)
             {
                 CriWareInitializer.InitializeAtom(criInitializer.atomConfig);
             }
             else
             {
                 CriWareInitializer.InitializeAtom(new CriAtomConfig());
                 Debug.Log("[CRIWARE] Timeline / Atom: Can't find CriWareInitializer component; Using default parameters in edit mode.");
             }
         }
     }
     m_lastDirectorTime = 0;
 }
Ejemplo n.º 9
0
    private void SetupAsync()
    {
        CriAtom.instance = this;

        CriAtomPlugin.InitializeLibrary();

        if (this.dontDestroyOnLoad)
        {
            GameObject.DontDestroyOnLoad(this.gameObject);
        }

        if (!String.IsNullOrEmpty(this.acfFile))
        {
            this.acfIsLoading = true;
            StartCoroutine(RegisterAcfAsync(this.acfFile, this.dspBusSetting));
        }

        foreach (var cueSheet in this.cueSheets)
        {
            StartCoroutine(LoadAcbFileCoroutine(cueSheet, null, cueSheet.acbFile, cueSheet.awbFile));
        }
    }
Ejemplo n.º 10
0
    public static void FinalizeLibrary()
    {
        /* 初期化カウンタの更新 */
        CriAtomPlugin.initializationCount--;
        if (CriAtomPlugin.initializationCount < 0)
        {
            CriAtomPlugin.initializationCount = 0;
            if (CriAtomPlugin.IsLibraryInitialized() == false)
            {
                return;
            }
        }
        if (CriAtomPlugin.initializationCount != 0)
        {
            return;
        }

        /* CriAtomListenerが存在しない場合のためのダミーリスナーを破棄 */
        CriAtomListener.DestroyDummyNativeListener();

        /* CriAtomServerのインスタンスを破棄 */
        CriAtomServer.DestroyInstance();

        /* 未破棄のDisposableを破棄 */
        CriDisposableObjectManager.CallOnModuleFinalization(CriDisposableObjectManager.ModuleType.Atom);

        /* ユーザエフェクトインタフェースのリストをクリア */
        if (effectInterfaceList != null)
        {
            effectInterfaceList.Clear();
            effectInterfaceList = null;
        }

        /* ライブラリの終了 */
        CriAtomPlugin.criAtomUnity_Finalize();

        /* 依存ライブラリの終了 */
        CriFsPlugin.FinalizeLibrary();
    }
Ejemplo n.º 11
0
    public static void InitializeLibrary()
    {
        /* 初期化カウンタの更新 */
        CriAtomPlugin.initializationCount++;
        if (CriAtomPlugin.initializationCount != 1)
        {
            return;
        }

        /* CriWareInitializerが実行済みかどうかを確認 */
        bool initializerWorking = CriWareInitializer.IsInitialized();

        if (initializerWorking == false)
        {
            Debug.Log("[CRIWARE] CriWareInitializer is not working. "
                      + "Initializes Atom by default parameters.");
        }

        /* 依存ライブラリの初期化 */
        CriFsPlugin.InitializeLibrary();

        /* ライブラリの初期化 */
        CriAtomPlugin.criAtomUnity_Initialize();

        /* CriAtomServerのインスタンスを生成 */
                #if UNITY_EDITOR
        /* ゲームプレビュー時のみ生成する */
        if (UnityEngine.Application.isPlaying)
        {
            CriAtomServer.CreateInstance();
        }
                #else
        CriAtomServer.CreateInstance();
                #endif

        /* CriAtomListener の共有ネイティブリスナーを生成 */
        CriAtomListener.CreateSharedNativeListener();
    }
Ejemplo n.º 12
0
    public static void FinalizeLibrary()
    {
        /* 初期化カウンタの更新 */
        CriAtomPlugin.initializationCount--;
        if (CriAtomPlugin.initializationCount < 0)
        {
            Debug.LogError("[CRIWARE] ERROR: Atom library is already finalized.");
            return;
        }
        if (CriAtomPlugin.initializationCount != 0)
        {
            return;
        }

        /* CriAtomServerのインスタンスを破棄 */
        CriAtomServer.DestroyInstance();

        /* ライブラリの終了 */
        CriAtomPlugin.criAtomUnity_Finalize();

        /* 依存ライブラリの終了 */
        CriFsPlugin.FinalizeLibrary();
    }
Ejemplo n.º 13
0
    public static void FinalizeLibrary()
    {
        /* 初期化カウンタの更新 */
        CriManaPlugin.initializationCount--;
        if (CriManaPlugin.initializationCount < 0)
        {
            Debug.LogError("[CRIWARE] ERROR: Mana library is already finalized.");
            return;
        }
        if (CriManaPlugin.initializationCount != 0)
        {
            return;
        }

        /* ライブラリの終了 */
        CriManaPlugin.criManaUnity_Finalize();

        /* RendererResourceFactoryのインスタンスを破棄 */
        CriMana.Detail.RendererResourceFactory.DisposeAllFactories();

        /* 依存ライブラリの終了 */
        CriAtomPlugin.FinalizeLibrary();
        CriFsPlugin.FinalizeLibrary();
    }
Ejemplo n.º 14
0
 protected virtual void InternalInitialize()
 {
     CriAtomPlugin.InitializeLibrary();
     this.player = new CriAtomExPlayer();
     this.source = new CriAtomEx3dSource();
 }
Ejemplo n.º 15
0
    public static bool InitializeAtom(CriAtomConfig config)
    {
        /* CRI Atomライブラリの初期化 */
        if (CriAtomPlugin.IsLibraryInitialized() == false)
        {
            /* 初期化処理の実行 */
            CriAtomPlugin.SetConfigParameters(
                (int)Math.Max(config.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(config)),
                config.maxVoiceLimitGroups,
                config.maxCategories,
                config.maxSequenceEventsPerFrame,
                config.maxBeatSyncCallbacksPerFrame,
                config.standardVoicePoolConfig.memoryVoices,
                config.standardVoicePoolConfig.streamingVoices,
                config.hcaMxVoicePoolConfig.memoryVoices,
                config.hcaMxVoicePoolConfig.streamingVoices,
                config.outputSamplingRate,
                config.asrOutputChannels,
                config.usesInGamePreview,
                config.serverFrequency,
                config.maxParameterBlocks,
                config.categoriesPerPlayback,
                config.maxBuses,
                config.vrMode);

            CriAtomPlugin.SetConfigAdditionalParameters_PC(
                config.pcBufferingTime
                );


            CriAtomPlugin.SetConfigAdditionalParameters_IOS(
                (uint)Math.Max(config.iosBufferingTime, 16),
                config.iosOverrideIPodMusic
                );
            /* Android 固有の初期化パラメータを登録 */
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (config.androidBufferingTime == 0)
                {
                    config.androidBufferingTime = (int)(4 * 1000.0 / config.serverFrequency);
                }
                if (config.androidStartBufferingTime == 0)
                {
                    config.androidStartBufferingTime = (int)(3 * 1000.0 / config.serverFrequency);
                }
#if !UNITY_EDITOR && UNITY_ANDROID
                CriAtomEx.androidDefaultSoundRendererType = config.androidForceToUseAsrForDefaultPlayback ?
                                                            CriAtomEx.SoundRendererType.Asr : CriAtomEx.SoundRendererType.Default;
#endif
                CriAtomPlugin.SetConfigAdditionalParameters_ANDROID(
                    config.androidLowLatencyStandardVoicePoolConfig.memoryVoices,
                    config.androidLowLatencyStandardVoicePoolConfig.streamingVoices,
                    config.androidBufferingTime,
                    config.androidStartBufferingTime,
                    config.androidUsesAndroidFastMixer,
                    config.androidUsesAAudio);
            }

            CriAtomPlugin.InitializeLibrary();

            if (config.useRandomSeedWithTime == true)
            {
                /* 時刻を乱数種に設定 */
                CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks);
            }

            /* ACFファイル指定時は登録 */
            if (config.acfFileName.Length != 0)
            {
                        #if UNITY_WEBGL
                Debug.LogError("In WebGL, ACF File path should be set to CriAtom Component.");
                        #else
                string acfPath = config.acfFileName;
                if (CriWare.Common.IsStreamingAssetsPath(acfPath))
                {
                    acfPath = Path.Combine(CriWare.Common.streamingAssetsPath, acfPath);
                }

                CriAtomEx.RegisterAcf(null, acfPath);
                        #endif
            }
            CriAtomServer.KeepPlayingSoundOnPause = config.keepPlayingSoundOnPause;
            return(true);
        }
        else
        {
            return(false);
        }
    }
Ejemplo n.º 16
0
    /**
     * <summary>プラグインの初期化(手動初期化用)</summary>
     * <remarks>
     * <para header='説明'>プラグインの初期化を行います。<br/>
     * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/>
     * <br/>
     * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/></para>
     * <para header='注意'>本関数を使用する場合は、 自動初期化を無効にするため、
     * ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/>
     * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前である必要があります。
     * Script Execution Orderが高いスクリプト上で行ってください。</para>
     * </remarks>
     *
     */
    public void Initialize()
    {
        /* 初期化カウンタの更新 */
        initializationCount++;
        if (initializationCount != 1)
        {
            /* CriWareInitializer自身による多重初期化は許可しない */
            GameObject.Destroy(this);
            return;
        }

        /* 非実行時にライブラリ機能を使用していた場合は一度終了処理を行う */
        if ((CriFsPlugin.IsLibraryInitialized() == true && CriAtomPlugin.IsLibraryInitialized() == true && CriManaPlugin.IsLibraryInitialized() == true) ||
            (CriFsPlugin.IsLibraryInitialized() == true && CriAtomPlugin.IsLibraryInitialized() == true && CriManaPlugin.IsLibraryInitialized() == false) ||
            (CriFsPlugin.IsLibraryInitialized() == true && CriAtomPlugin.IsLibraryInitialized() == false && CriManaPlugin.IsLibraryInitialized() == false))
        {
#if UNITY_EDITOR || (!UNITY_PS3)
            /* CRI Manaライブラリの終了 */
            if (initializesMana)
            {
                CriManaPlugin.FinalizeLibrary();
            }
#endif

            /* CRI Atomライブラリの終了 */
            if (initializesAtom)
            {
                /* EstimatorがStop状態になるまでFinalize */
                while (CriAtomExLatencyEstimator.GetCurrentInfo().status != CriAtomExLatencyEstimator.Status.Stop)
                {
                    CriAtomExLatencyEstimator.FinalizeModule();
                }

                /* 終了処理の実行 */
                CriAtomPlugin.FinalizeLibrary();
            }

            /* CRI File Systemライブラリの終了 */
            if (initializesFileSystem)
            {
                CriFsPlugin.FinalizeLibrary();
            }
        }

        /* CRI File Systemライブラリの初期化 */
        if (initializesFileSystem)
        {
            InitializeFileSystem(fileSystemConfig);
        }


        /* CRI Atomライブラリの初期化 */
        if (initializesAtom)
        {
            switch (atomConfig.inGamePreviewMode)
            {
            case CriAtomConfig.InGamePreviewSwitchMode.Disable:
                atomConfig.usesInGamePreview = false;
                break;

            case CriAtomConfig.InGamePreviewSwitchMode.Enable:
                atomConfig.usesInGamePreview = true;
                break;

            case CriAtomConfig.InGamePreviewSwitchMode.FollowBuildSetting:
                atomConfig.usesInGamePreview = UnityEngine.Debug.isDebugBuild;
                break;

            default:
                /* 既に設定されたフラグに従う */
                break;
            }
            InitializeAtom(atomConfig);
        }


        /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */
        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(transform.gameObject);
            DontDestroyOnLoad(CriWare.Common.managerObject);
        }
    }
Ejemplo n.º 17
0
    public override void OnInspectorGUI()
    {
        CriWareInitializer initializer = target as CriWareInitializer;

        // FileSystem Config
        initializer.initializesFileSystem =
            EditorGUILayout.BeginToggleGroup("Initialize FileSystem", initializer.initializesFileSystem);
        EditorGUI.indentLevel += 1;
        {
            GenIntField("Number of Loaders", "The maximum number of CriFsLoader objects used at a time. " +
                        "NOTE: Count the number of CriFsLoadFileRequest objects and the total number of Streaming Voices in CRI Atom settings and the number of CriManaPlayer component,",
                        ref initializer.fileSystemConfig.numberOfLoaders, 0, 128);
            GenIntField("Number of Binders", "", ref initializer.fileSystemConfig.numberOfBinders, 0, 128);
            GenIntField("Number of Installers", "", ref initializer.fileSystemConfig.numberOfInstallers, 0, 128);
            GenIntFieldWithUnit("Install Buffer Size", "[KiB]", "Internal buffer size to install data. A larger buffer size result in better performance.", ref initializer.fileSystemConfig.installBufferSize, 32, int.MaxValue);
            GenIntField("Max Length of Path", "The maximum length of path (file path or url path) that can be passed.", ref initializer.fileSystemConfig.maxPath, 64, 2048);
            GenStringField("User Agent String", "", ref initializer.fileSystemConfig.userAgentString);

            showFileSystemAndroidConfig = EditorGUILayout.Foldout(showFileSystemAndroidConfig, "Android Config");
            if (showFileSystemAndroidConfig)
            {
                EditorGUI.indentLevel += 1;
                {
                    /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                    if (initializer.fileSystemConfig.androidDeviceReadBitrate == 0)
                    {
                        initializer.fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate;
                    }
                }
                GenIntFieldWithUnit("Device Read Bitrate", "[bps]", "Expected minimum device read bitrate to be used for multi-streaming management." + CriFsConfig.defaultAndroidDeviceReadBitrate + " bps",
                                    ref initializer.fileSystemConfig.androidDeviceReadBitrate, 0, int.MaxValue, 225);
                EditorGUI.indentLevel -= 1;
            }
        }
        EditorGUI.indentLevel -= 1;
        EditorGUILayout.EndToggleGroup();

        // Atom Config
        initializer.initializesAtom =
            EditorGUILayout.BeginToggleGroup("Initialize Atom", initializer.initializesAtom);
        EditorGUI.indentLevel += 1;
        {
            GenStringField("ACF File Name", "", ref initializer.atomConfig.acfFileName);
            GenIntField("Max Virtual Voices", "", ref initializer.atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(initializer.atomConfig), 1024);
            GenIntFieldWithUnit("Sampling Rate", "[Hz]",
                                "Sound output sampling rate. "
                                + "HCA-MX needs to set the sampling rate of HCA-MX data. "
                                + "A value of 0 (the default value) means that the internal value will be applied.",
                                ref initializer.atomConfig.outputSamplingRate, 0, 192000);
            GenPositiveFloatField("Server Frequency", "[Hz]", "", ref initializer.atomConfig.serverFrequency, 15.0f, 120.0f);
            GenToggleField("Uses Time For Seed", "", ref initializer.atomConfig.useRandomSeedWithTime);
            GenToggleField("Uses In Game Preview", "", ref initializer.atomConfig.usesInGamePreview);

            showAtomStandardVoicePoolConfig = EditorGUILayout.Foldout(showAtomStandardVoicePoolConfig, "Standard Voice Pool Config");
            if (showAtomStandardVoicePoolConfig)
            {
                EditorGUI.indentLevel += 1;
                GenIntField("Memoy Voices", "", ref initializer.atomConfig.standardVoicePoolConfig.memoryVoices, 0, 1024);
                GenIntField("Streaming Voices", "", ref initializer.atomConfig.standardVoicePoolConfig.streamingVoices, 0, 1024);
                EditorGUI.indentLevel -= 1;
            }

            showAtomHcaMxVoicePoolConfig = EditorGUILayout.Foldout(showAtomHcaMxVoicePoolConfig, "HCA-MX Voice Pool Config");
            if (showAtomHcaMxVoicePoolConfig)
            {
                EditorGUI.indentLevel += 1;
                GenIntField("Memoy Voices", "", ref initializer.atomConfig.hcaMxVoicePoolConfig.memoryVoices, 0, 1024);
                GenIntField("Streaming Voices", "", ref initializer.atomConfig.hcaMxVoicePoolConfig.streamingVoices, 0, 1024);
                EditorGUI.indentLevel -= 1;
            }

            showAtomIOSConfig = EditorGUILayout.Foldout(showAtomIOSConfig, "iOS Config");
            if (showAtomIOSConfig)
            {
                EditorGUI.indentLevel += 1;
                GenIntFieldWithUnit("Buffering Time", "[msec]", "Sound buffering time in msec.", ref initializer.atomConfig.iosBufferingTime, 16, 200);
                GenToggleField("Override iPod Music", "", ref initializer.atomConfig.iosOverrideIPodMusic);
                EditorGUI.indentLevel -= 1;
            }

            showAtomAndroidConfig = EditorGUILayout.Foldout(showAtomAndroidConfig, "Android Config");
            if (showAtomAndroidConfig)
            {
                EditorGUI.indentLevel += 1;
                {
                    /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                    if (initializer.atomConfig.androidBufferingTime == 0)
                    {
                        initializer.atomConfig.androidBufferingTime = (int)(4 * 1000.0 / initializer.atomConfig.serverFrequency);
                    }
                    if (initializer.atomConfig.androidStartBufferingTime == 0)
                    {
                        initializer.atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / initializer.atomConfig.serverFrequency);
                    }
                }
                GenIntFieldWithUnit("Buffering TimeWithUnit", "[msec]", "Sound buffering time in msec.", ref initializer.atomConfig.androidBufferingTime, 50, 500);
                GenIntFieldWithUnit("Start Buf TimeWithUnit", "[msec]", "Sound buffering time to start playing. This value will be applied when using the low latency voice pool.", ref initializer.atomConfig.androidStartBufferingTime, 50, 500);
                showAtomAndroidVoicePoolConfig = EditorGUILayout.Foldout(showAtomAndroidVoicePoolConfig, "Low Latency Standard Voice Pool Config");
                if (showAtomAndroidVoicePoolConfig)
                {
                    EditorGUI.indentLevel += 1;
                    GenIntField("Memory Voices", "", ref initializer.atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices, 0, 32);
                    GenIntField("Streaming Voices", "", ref initializer.atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices, 0, 32);
                    EditorGUI.indentLevel -= 1;
                }
                EditorGUI.indentLevel -= 1;
            }
        }
        EditorGUI.indentLevel -= 1;
        EditorGUILayout.EndToggleGroup();

        // Mana Config
        initializer.initializesMana =
            EditorGUILayout.BeginToggleGroup("Initialize Mana", initializer.initializesMana);
        EditorGUI.indentLevel += 1;
        {
            GenIntField("Number Of Decoders", "", ref initializer.manaConfig.numberOfDecoders, 0, 128);
            GenIntField("Number Of Max Entries", "", ref initializer.manaConfig.numberOfMaxEntries, 0, 1024);
            GenToggleField("Enable CuePoint", "", ref initializer.manaConfig.enableCuePoint);
        }

        EditorGUI.indentLevel -= 1;
        EditorGUILayout.EndToggleGroup();

        GenToggleField("Dont Destroy On Load", "", ref initializer.dontDestroyOnLoad);
    }
Ejemplo n.º 18
0
 protected virtual void InternalInitialize()
 {
     CriAtomPlugin.InitializeLibrary();
     this.transceiverHn = new CriAtomEx3dTransceiver();
     this.isInitialized = true;
 }
Ejemplo n.º 19
0
 protected virtual void InternalInitialize()
 {
     CriAtomPlugin.InitializeLibrary();
     this.region3dHn = new CriAtomEx3dRegion();
 }
Ejemplo n.º 20
0
 // Token: 0x060159CB RID: 88523 RVA: 0x0058063C File Offset: 0x0057E83C
 public void Pause(bool pause)
 {
     CriAtomPlugin.Pause(pause);
 }
Ejemplo n.º 21
0
    /**
     * <summary>プラグインの初期化(手動初期化用)</summary>
     * \par 説明:
     * プラグインの初期化を行います。<br/>
     * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/>
     * <br/>
     * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/>
     * \par 注意:
     * 本関数を使用する場合は、 自動初期化を無効にするため、 ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/>
     * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前に呼び出す必要があります。Script Execution Orderが高いスクリプト上で行ってください。
     *
     */
    public void Initialize()
    {
        /* 初期化カウンタの更新 */
        initializationCount++;
        if (initializationCount != 1)
        {
            /* CriWareInitializer自身による多重初期化は許可しない */
            GameObject.Destroy(this);
            return;
        }

        /* CRI File Systemライブラリの初期化 */
        if (initializesFileSystem)
        {
            CriFsPlugin.SetConfigParameters(
                fileSystemConfig.numberOfLoaders,
                fileSystemConfig.numberOfBinders,
                fileSystemConfig.numberOfInstallers,
                (fileSystemConfig.installBufferSize * 1024),
                fileSystemConfig.maxPath,
                fileSystemConfig.minimizeFileDescriptorUsage
                );
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (fileSystemConfig.androidDeviceReadBitrate == 0)
                {
                    fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate;
                }
            }
            CriFsPlugin.SetConfigAdditionalParameters_ANDROID(fileSystemConfig.androidDeviceReadBitrate);
            CriFsPlugin.InitializeLibrary();
            if (fileSystemConfig.userAgentString.Length != 0)
            {
                CriFsUtility.SetUserAgentString(fileSystemConfig.userAgentString);
            }
        }

        /* CRI Atomライブラリの初期化 */
        if (initializesAtom)
        {
            /* 初期化処理の実行 */
            CriAtomPlugin.SetConfigParameters(
                (int)Math.Max(atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(atomConfig)),
                atomConfig.maxVoiceLimitGroups,
                atomConfig.maxCategories,
                atomConfig.standardVoicePoolConfig.memoryVoices,
                atomConfig.standardVoicePoolConfig.streamingVoices,
                atomConfig.hcaMxVoicePoolConfig.memoryVoices,
                atomConfig.hcaMxVoicePoolConfig.streamingVoices,
                atomConfig.outputSamplingRate,
                atomConfig.asrOutputChannels,
                atomConfig.usesInGamePreview,
                atomConfig.serverFrequency,
                atomConfig.maxParameterBlocks,
                atomConfig.categoriesPerPlayback,
                atomConfig.maxBuses,
                false);

            CriAtomPlugin.SetConfigAdditionalParameters_PC(
                atomConfig.pcBufferingTime
                );

            CriAtomPlugin.SetConfigAdditionalParameters_IOS(
                (uint)Math.Max(atomConfig.iosBufferingTime, 16),
                atomConfig.iosOverrideIPodMusic
                );
            /* Android 固有の初期化パラメータを登録 */
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (atomConfig.androidBufferingTime == 0)
                {
                    atomConfig.androidBufferingTime = (int)(4 * 1000.0 / atomConfig.serverFrequency);
                }
                if (atomConfig.androidStartBufferingTime == 0)
                {
                    atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / atomConfig.serverFrequency);
                }
                IntPtr android_context = IntPtr.Zero;
#if !UNITY_EDITOR && UNITY_ANDROID
                if (atomConfig.androidUsesAndroidFastMixer)
                {
                    AndroidJavaClass  jc       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                    AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity");
                    android_context = activity.GetRawObject();
                }
#endif
                CriAtomPlugin.SetConfigAdditionalParameters_ANDROID(
                    atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices,
                    atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices,
                    atomConfig.androidBufferingTime,
                    atomConfig.androidStartBufferingTime,
                    android_context);
            }
            CriAtomPlugin.InitializeLibrary();

            if (atomConfig.useRandomSeedWithTime == true)
            {
                /* 時刻を乱数種に設定 */
                CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks);
            }

            /* ACFファイル指定時は登録 */
            if (atomConfig.acfFileName.Length != 0)
            {
                string acfPath = atomConfig.acfFileName;
                if (CriWare.IsStreamingAssetsPath(acfPath))
                {
                    acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath);
                }

                CriAtomEx.RegisterAcf(null, acfPath);
            }
        }

        /* CRI Manaライブラリの初期化 */
        if (initializesMana)
        {
            CriManaPlugin.SetConfigParameters(manaConfig.graphicsMultiThreaded, manaConfig.numberOfDecoders, manaConfig.numberOfMaxEntries);
            CriManaPlugin.InitializeLibrary();
        }

        /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */
        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(transform.gameObject);
            DontDestroyOnLoad(CriWare.managerObject);
        }
    }
Ejemplo n.º 22
0
    /**
     * <summary>プラグインの初期化(手動初期化用)</summary>
     * \par 説明:
     * プラグインの初期化を行います。<br/>
     * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/>
     * <br/>
     * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/>
     * \par 注意:
     * 本関数を使用する場合は、 自動初期化を無効にするため、 ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/>
     * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前に呼び出す必要があります。Script Execution Orderが高いスクリプト上で行ってください。
     *
     */
    public void Initialize()
    {
        /* 初期化カウンタの更新 */
        initializationCount++;
        if (initializationCount != 1)
        {
            /* CriWareInitializer自身による多重初期化は許可しない */
            GameObject.Destroy(this);
            return;
        }

        /* CRI File Systemライブラリの初期化 */
        if (initializesFileSystem)
        {
            CriFsPlugin.SetConfigParameters(
                fileSystemConfig.numberOfLoaders,
                fileSystemConfig.numberOfBinders,
                fileSystemConfig.numberOfInstallers,
                (fileSystemConfig.installBufferSize * 1024),
                fileSystemConfig.maxPath,
                fileSystemConfig.minimizeFileDescriptorUsage
                );
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (fileSystemConfig.androidDeviceReadBitrate == 0)
                {
                    fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate;
                }
            }
            CriFsPlugin.SetConfigAdditionalParameters_ANDROID(fileSystemConfig.androidDeviceReadBitrate);
            CriFsPlugin.InitializeLibrary();
            if (fileSystemConfig.userAgentString.Length != 0)
            {
                CriFsUtility.SetUserAgentString(fileSystemConfig.userAgentString);
            }
        }

        /* CRI Atomライブラリの初期化 */
        if (initializesAtom)
        {
            /* 初期化処理の実行 */
            CriAtomPlugin.SetConfigParameters(
                (int)Math.Max(atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(atomConfig)),
                atomConfig.maxVoiceLimitGroups,
                atomConfig.maxCategories,
                atomConfig.standardVoicePoolConfig.memoryVoices,
                atomConfig.standardVoicePoolConfig.streamingVoices,
                atomConfig.hcaMxVoicePoolConfig.memoryVoices,
                atomConfig.hcaMxVoicePoolConfig.streamingVoices,
                atomConfig.outputSamplingRate,
                atomConfig.asrOutputChannels,
                atomConfig.usesInGamePreview,
                atomConfig.serverFrequency,
                atomConfig.maxParameterBlocks,
                atomConfig.categoriesPerPlayback,
                atomConfig.maxBuses,
                atomConfig.vrMode);

            CriAtomPlugin.SetConfigAdditionalParameters_PC(
                atomConfig.pcBufferingTime
                );

            CriAtomPlugin.SetConfigAdditionalParameters_IOS(
                (uint)Math.Max(atomConfig.iosBufferingTime, 16),
                atomConfig.iosOverrideIPodMusic
                );
            /* Android 固有の初期化パラメータを登録 */
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (atomConfig.androidBufferingTime == 0)
                {
                    atomConfig.androidBufferingTime = (int)(4 * 1000.0 / atomConfig.serverFrequency);
                }
                if (atomConfig.androidStartBufferingTime == 0)
                {
                    atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / atomConfig.serverFrequency);
                }
                IntPtr android_context = IntPtr.Zero;
#if !UNITY_EDITOR && UNITY_ANDROID
                if (atomConfig.androidUsesAndroidFastMixer)
                {
                    AndroidJavaClass  jc       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                    AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity");
                    android_context = activity.GetRawObject();
                }
#endif
                CriAtomPlugin.SetConfigAdditionalParameters_ANDROID(
                    atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices,
                    atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices,
                    atomConfig.androidBufferingTime,
                    atomConfig.androidStartBufferingTime,
                    android_context);
            }
            CriAtomPlugin.SetConfigAdditionalParameters_VITA(
                atomConfig.vitaAtrac9VoicePoolConfig.memoryVoices,
                atomConfig.vitaAtrac9VoicePoolConfig.streamingVoices,
                (initializesMana) ? manaConfig.numberOfDecoders : 0);
            {
                /* VR Mode が有効なときも useAudio3D を True にする */
                atomConfig.ps4Audio3dConfig.useAudio3D |= atomConfig.vrMode;
                CriAtomPlugin.SetConfigAdditionalParameters_PS4(
                    atomConfig.ps4Atrac9VoicePoolConfig.memoryVoices,
                    atomConfig.ps4Atrac9VoicePoolConfig.streamingVoices,
                    atomConfig.ps4Audio3dConfig.useAudio3D,
                    atomConfig.ps4Audio3dConfig.voicePoolConfig.memoryVoices,
                    atomConfig.ps4Audio3dConfig.voicePoolConfig.streamingVoices);
            }
            CriAtomPlugin.SetConfigAdditionalParameters_WEBGL(
                atomConfig.webglWebAudioVoicePoolConfig.voices);

            CriAtomPlugin.InitializeLibrary();

            if (atomConfig.useRandomSeedWithTime == true)
            {
                /* 時刻を乱数種に設定 */
                CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks);
            }

            /* ACFファイル指定時は登録 */
            if (atomConfig.acfFileName.Length != 0)
            {
                string acfPath = atomConfig.acfFileName;
                if (CriWare.IsStreamingAssetsPath(acfPath))
                {
                    acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath);
                }

                CriAtomEx.RegisterAcf(null, acfPath);
            }
        }

#if UNITY_EDITOR || (!UNITY_PS3)
        /* CRI Manaライブラリの初期化 */
        if (initializesMana)
        {
            CriManaPlugin.SetConfigParameters(manaConfig.graphicsMultiThreaded, manaConfig.numberOfDecoders, manaConfig.numberOfMaxEntries);
            CriManaPlugin.SetConfigAdditonalParameters_ANDROID(true);
#if UNITY_PSP2
            CriWareVITA.EnableManaH264Playback(manaConfig.vitaH264PlaybackConfig.useH264Playback);
            CriWareVITA.SetManaH264DecoderMaxSize(manaConfig.vitaH264PlaybackConfig.maxWidth,
                                                  manaConfig.vitaH264PlaybackConfig.maxHeight);
            CriWareVITA.EnableManaH264DecoderGetDisplayMemoryFromUnityTexture(manaConfig.vitaH264PlaybackConfig.getMemoryFromTexture);
#endif
            CriManaPlugin.InitializeLibrary();
        }
#endif

        /*JP< CRI Ware Decrypterの設定 */
        if (useDecrypter)
        {
            ulong  decryptionKey      = (decrypterConfig.key.Length == 0) ? 0 : Convert.ToUInt64(decrypterConfig.key);
            string authenticationPath = decrypterConfig.authenticationFile;
            if (CriWare.IsStreamingAssetsPath(authenticationPath))
            {
                authenticationPath = Path.Combine(CriWare.streamingAssetsPath, authenticationPath);
            }
#if !UNITY_EDITOR && UNITY_WEBGL
            CriWare.criWareUnity_SetDecryptionKey_EMSCRIPTEN(
                decryptionKey
                );
#else
            CriWare.criWareUnity_SetDecryptionKey(
                decryptionKey,
                authenticationPath,
                decrypterConfig.enableAtomDecryption,
                decrypterConfig.enableManaDecryption
                );
#endif
        }
        else
        {
#if !UNITY_EDITOR && UNITY_WEBGL
            CriWare.criWareUnity_SetDecryptionKey_EMSCRIPTEN(0);
#else
            CriWare.criWareUnity_SetDecryptionKey(0, "", false, false);
#endif
        }

        /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */
        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(transform.gameObject);
            DontDestroyOnLoad(CriWare.managerObject);
        }
    }
Ejemplo n.º 23
0
 override protected void InternalInitialize()
 {
     CriAtomPlugin.InitializeLibrary();
     player = new CriAtomExPlayer(_enableAudioSyncedTimer);
     source = new CriAtomEx3dSource();
 }
Ejemplo n.º 24
0
    /**
     * <summary>プラグインの初期化(手動初期化用)</summary>
     * \par 説明:
     * プラグインの初期化を行います。<br/>
     * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/>
     * <br/>
     * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/>
     * \par 注意:
     * 本関数を使用する場合は、 自動初期化を無効にするため、 ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/>
     * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前に呼び出す必要があります。Script Execution Orderが高いスクリプト上で行ってください。
     *
     */
    public void Initialize()
    {
        /* 初期化カウンタの更新 */
        initializationCount++;
        if (initializationCount != 1)
        {
            /* CriWareInitializer自身による多重初期化は許可しない */
            GameObject.Destroy(this);
            return;
        }

        /* 非実行時にライブラリ機能を使用していた場合は一度終了処理を行う */
        if ((CriFsPlugin.IsLibraryInitialized() == true && CriAtomPlugin.IsLibraryInitialized() == true && CriManaPlugin.IsLibraryInitialized() == true) ||
            (CriFsPlugin.IsLibraryInitialized() == true && CriAtomPlugin.IsLibraryInitialized() == true && CriManaPlugin.IsLibraryInitialized() == false) ||
            (CriFsPlugin.IsLibraryInitialized() == true && CriAtomPlugin.IsLibraryInitialized() == false && CriManaPlugin.IsLibraryInitialized() == false))
        {
            /* CRI Manaライブラリの終了 */
            if (initializesMana)
            {
                CriManaPlugin.FinalizeLibrary();
            }

            /* CRI Atomライブラリの終了 */
            if (initializesAtom)
            {
                /* EstimatorがStop状態になるまでFinalize */
                while (CriAtomExLatencyEstimator.GetCurrentInfo().status != CriAtomExLatencyEstimator.Status.Stop)
                {
                    CriAtomExLatencyEstimator.FinalizeModule();
                }

                /* 終了処理の実行 */
                CriAtomPlugin.FinalizeLibrary();
            }

            /* CRI File Systemライブラリの終了 */
            if (initializesFileSystem)
            {
                CriFsPlugin.FinalizeLibrary();
            }
        }

        /* CRI File Systemライブラリの初期化 */
        if (initializesFileSystem)
        {
            InitializeFileSystem(fileSystemConfig);
        }

        /* CRI Atomライブラリの初期化 */
        if (initializesAtom)
        {
            InitializeAtom(atomConfig);
        }

        /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */
        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(transform.gameObject);
            DontDestroyOnLoad(CriWare.managerObject);
        }
    }
Ejemplo n.º 25
0
 public static void Dispose()
 {
     CriAtomPlugin.FinalizeLibrary();
 }
Ejemplo n.º 26
0
 protected virtual void InternalFinalize()
 {
     region3dHn.Dispose();
     region3dHn = null;
     CriAtomPlugin.FinalizeLibrary();
 }
Ejemplo n.º 27
0
 public override void CriInternalUpdate()
 {
     CriAtomPlugin.criAtomUnitySequencer_ExecuteQueuedEventCallbacks();
     CriAtomPlugin.criAtomUnity_ExecuteQueuedBeatSyncCallbacks();
 }
Ejemplo n.º 28
0
    public override void OnInspectorGUI()
    {
        CriWareInitializer initializer = target as CriWareInitializer;

        Undo.RecordObject(target, null);

        GUI.changed = false;
        {
            // FileSystem Config
            initializer.initializesFileSystem =
                EditorGUILayout.BeginToggleGroup("Initialize FileSystem", initializer.initializesFileSystem);
            EditorGUI.indentLevel += 1;
            {
                GenIntField("Number of Loaders", "The maximum number of CriFsLoader objects used at a time. " +
                            "NOTE: Count the number of CriFsLoadFileRequest objects and the total number of Streaming Voices in CRI Atom settings and the number of CriMana.Player component,",
                            ref initializer.fileSystemConfig.numberOfLoaders, 0, 128);
                GenIntField("Number of Binders", "", ref initializer.fileSystemConfig.numberOfBinders, 0, 128);
                GenIntField("Number of Installers", "", ref initializer.fileSystemConfig.numberOfInstallers, 0, 128);
                GenIntFieldWithUnit("Install Buffer Size", "[KiB]", "Internal buffer size to install data. A larger buffer size result in better performance.", ref initializer.fileSystemConfig.installBufferSize, 32, int.MaxValue);
                GenIntField("Max Length of Path", "The maximum length of path (file path or url path) that can be passed.", ref initializer.fileSystemConfig.maxPath, 64, 2048);
                GenStringField("User Agent String", "", ref initializer.fileSystemConfig.userAgentString);
                GenToggleField("Minimize FD Usage", "With this option, the plugin minimizes file descriptor usage so that applicaiton can save file descriptor resource. However, this may increase file I/O instead.", ref initializer.fileSystemConfig.minimizeFileDescriptorUsage);
                GenToggleField("Enable CRC Check", "This option enables a CRC check on loading or binding when the cpk file contains CRC.", ref initializer.fileSystemConfig.enableCrcCheck);

                showFileSystemAndroidConfig = EditorGUILayout.Foldout(showFileSystemAndroidConfig, "Android Config");
                if (showFileSystemAndroidConfig)
                {
                    EditorGUI.indentLevel += 1;
                    {
                        /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                        if (initializer.fileSystemConfig.androidDeviceReadBitrate == 0)
                        {
                            initializer.fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate;
                        }
                    }
                    GenIntFieldWithUnit("Device Read Bitrate", "[bps]", "Expected minimum device read bitrate to be used for multi-streaming management." + CriFsConfig.defaultAndroidDeviceReadBitrate + " bps",
                                        ref initializer.fileSystemConfig.androidDeviceReadBitrate, 0, int.MaxValue);
                    EditorGUI.indentLevel -= 1;
                }
            }
            EditorGUI.indentLevel -= 1;
            EditorGUILayout.EndToggleGroup();

            // Atom Config
            initializer.initializesAtom =
                EditorGUILayout.BeginToggleGroup("Initialize Atom", initializer.initializesAtom);
            EditorGUI.indentLevel += 1;
            {
                GenStringField("ACF File Name", "", ref initializer.atomConfig.acfFileName);
                GenIntField("Max Virtual Voices", "", ref initializer.atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(initializer.atomConfig), 1024);
                GenIntField("Max Voice Limit Groups", "", ref initializer.atomConfig.maxVoiceLimitGroups, 0, 1024);
                GenIntField("Max Parameter Blocks", "", ref initializer.atomConfig.maxParameterBlocks, 1024, 4096);
                GenIntField("Max Buses", "Maximum number of buses.", ref initializer.atomConfig.maxBuses, 1, 64);
                GenIntField("Max Categories", "Maximum number of categories.", ref initializer.atomConfig.maxCategories, 0, 1024);
                GenIntField("Max Sequence Events Per Frame", "Maximum number of sequence events that will be triggered in one application frame.", ref initializer.atomConfig.maxSequenceEventsPerFrame, 0, 64);
                GenIntField("Max Beat Sync Callbacks Per Frame", "Maximum number of beat synchronized callback that will be triggered in one application frame.", ref initializer.atomConfig.maxBeatSyncCallbacksPerFrame, 0, 64);
                GenIntField("Categories per Playback", "Number of category references per playback.", ref initializer.atomConfig.categoriesPerPlayback, 0, 16);
                GenIntFieldWithUnit("Sampling Rate", "[Hz]",
                                    "Sound output sampling rate. "
                                    + "HCA-MX needs to set the sampling rate of HCA-MX data. "
                                    + "A value of 0 (the default value) means that the internal value will be applied.",
                                    ref initializer.atomConfig.outputSamplingRate, 0, 192000);
                GenPositiveFloatField("Server Frequency", "[Hz]", "", ref initializer.atomConfig.serverFrequency, 15.0f, 120.0f);

                int selected_output_mode = 0;
                foreach (int num_channnels in asrNumOutputChannels)
                {
                    if (num_channnels == initializer.atomConfig.asrOutputChannels)
                    {
                        break;
                    }
                    selected_output_mode++;
                }
                selected_output_mode = EditorGUILayout.Popup("ASR Output Mode", selected_output_mode, asrOutputModes);
                initializer.atomConfig.asrOutputChannels = asrNumOutputChannels[selected_output_mode];

                GenToggleField("Use Time For Seed", "", ref initializer.atomConfig.useRandomSeedWithTime);

                if (initializer.atomConfig.inGamePreviewMode == CriAtomConfig.InGamePreviewSwitchMode.Default)
                {
                    initializer.atomConfig.inGamePreviewMode = initializer.atomConfig.usesInGamePreview ?
                                                               CriAtomConfig.InGamePreviewSwitchMode.Enable :
                                                               CriAtomConfig.InGamePreviewSwitchMode.Disable;
                    initializer.atomConfig.usesInGamePreview = false;
                }
                int selected_ingamepreview_switch_mode = 0;
                foreach (CriAtomConfig.InGamePreviewSwitchMode mode in inGamePreviewSwitchModeValues)
                {
                    if (mode == initializer.atomConfig.inGamePreviewMode)
                    {
                        break;
                    }
                    selected_ingamepreview_switch_mode++;
                }
                selected_ingamepreview_switch_mode       = EditorGUILayout.Popup("In Game Preview", selected_ingamepreview_switch_mode, inGamePreviewSwitchModes);
                initializer.atomConfig.inGamePreviewMode = inGamePreviewSwitchModeValues[selected_ingamepreview_switch_mode];

                if (initializer.atomConfig.inGamePreviewMode != CriAtomConfig.InGamePreviewSwitchMode.Disable)
                {
                    EditorGUI.indentLevel += 1;
                    GenIntField("Max Preview Objects", "", ref initializer.atomConfig.inGamePreviewConfig.maxPreviewObjects, 0, 1024);
                    GenIntFieldWithUnit("Communication Buffer Size", "[KiB]", "Size of buffer for communication between library and tool.", ref initializer.atomConfig.inGamePreviewConfig.communicationBufferSize, 2048, int.MaxValue);
                    GenIntFieldWithUnit("Update Interval", "[counts of server process]", "Interval to update playback position.", ref initializer.atomConfig.inGamePreviewConfig.playbackPositionUpdateInterval, 1, 8);
                    EditorGUI.indentLevel -= 1;
                }


                GenToggleField("VR Mode", "", ref initializer.atomConfig.vrMode);
                GenToggleField("Keep Playing Sound On Pause", "", ref initializer.atomConfig.keepPlayingSoundOnPause);

                showAtomStandardVoicePoolConfig = EditorGUILayout.Foldout(showAtomStandardVoicePoolConfig, "Standard Voice Pool Config");
                if (showAtomStandardVoicePoolConfig)
                {
                    EditorGUI.indentLevel += 1;
                    GenIntField("Memory Voices", "", ref initializer.atomConfig.standardVoicePoolConfig.memoryVoices, 0, 1024);
                    GenIntField("Streaming Voices", "", ref initializer.atomConfig.standardVoicePoolConfig.streamingVoices, 0, 1024);
                    EditorGUI.indentLevel -= 1;
                }

                showAtomHcaMxVoicePoolConfig = EditorGUILayout.Foldout(showAtomHcaMxVoicePoolConfig, "HCA-MX Voice Pool Config");
                if (showAtomHcaMxVoicePoolConfig)
                {
                    EditorGUI.indentLevel += 1;
                    GenIntField("Memory Voices", "", ref initializer.atomConfig.hcaMxVoicePoolConfig.memoryVoices, 0, 1024);
                    GenIntField("Streaming Voices", "", ref initializer.atomConfig.hcaMxVoicePoolConfig.streamingVoices, 0, 1024);
                    EditorGUI.indentLevel -= 1;
                }

                showAtomPCConfig = EditorGUILayout.Foldout(showAtomPCConfig, "PC Config");
                if (showAtomPCConfig)
                {
                    EditorGUI.indentLevel += 1;
                    GenIntFieldWithUnit("Buffering Time", "[msec]", "Sound buffering time in msec.", ref initializer.atomConfig.pcBufferingTime, 0, 2000);
                    EditorGUI.indentLevel -= 1;
                }
                showAtomIOSConfig = EditorGUILayout.Foldout(showAtomIOSConfig, "iOS Config");
                if (showAtomIOSConfig)
                {
                    EditorGUI.indentLevel += 1;
                    GenIntFieldWithUnit("Buffering Time", "[msec]", "Sound buffering time in msec.", ref initializer.atomConfig.iosBufferingTime, 16, 200);
                    GenToggleField("Override iPod Music", "", ref initializer.atomConfig.iosOverrideIPodMusic);
                    EditorGUI.indentLevel -= 1;
                }

                showAtomAndroidConfig = EditorGUILayout.Foldout(showAtomAndroidConfig, "Android Config");
                if (showAtomAndroidConfig)
                {
                    EditorGUI.indentLevel += 1;
                    {
                        /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                        if (initializer.atomConfig.androidBufferingTime == 0)
                        {
                            initializer.atomConfig.androidBufferingTime = (int)(4 * 1000.0 / initializer.atomConfig.serverFrequency);
                        }
                        if (initializer.atomConfig.androidStartBufferingTime == 0)
                        {
                            initializer.atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / initializer.atomConfig.serverFrequency);
                        }
                    }
                    GenIntFieldWithUnit("Buffering Time", "[msec]", "Sound buffering time in msec.", ref initializer.atomConfig.androidBufferingTime, 50, 500);
                    GenIntFieldWithUnit("Start Buffering", "[msec]", "Sound buffering time to start playing. This value will be applied when using the low latency voice pool.", ref initializer.atomConfig.androidStartBufferingTime, 50, 500);
                    showAtomAndroidVoicePoolConfig = EditorGUILayout.Foldout(showAtomAndroidVoicePoolConfig, "Low Latency Standard Voice Pool Config");
                    if (showAtomAndroidVoicePoolConfig)
                    {
                        EditorGUI.indentLevel += 1;
                        GenIntField("Memory Voices", "", ref initializer.atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices, 0, 32);
                        GenIntField("Streaming Voices", "", ref initializer.atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices, 0, 32);
                        EditorGUI.indentLevel -= 1;
                    }
                    GenToggleField("Use Android Fast Mixer", "", ref initializer.atomConfig.androidUsesAndroidFastMixer);
                    GenToggleField("Use Asr For Default Playback", "", ref initializer.atomConfig.androidForceToUseAsrForDefaultPlayback);
                    GenToggleField("[Beta] Use AAudio", "", ref initializer.atomConfig.androidUsesAAudio);
                    EditorGUI.indentLevel -= 1;
                }
            }
            EditorGUI.indentLevel -= 1;
            EditorGUILayout.EndToggleGroup();


            GenToggleField("Dont Initialize On Awake", "", ref initializer.dontInitializeOnAwake);
            GenToggleField("Dont Destroy On Load", "", ref initializer.dontDestroyOnLoad);
        }
        if (GUI.changed)
        {
            EditorUtility.SetDirty(initializer);
        }
    }
Ejemplo n.º 29
0
    /**
     * <summary>プラグインの初期化(手動初期化用)</summary>
     * \par 説明:
     * プラグインの初期化を行います。<br/>
     * デフォルトでは本関数はAwake関数内で自動的に呼び出されるので、アプリケーションが直接呼び出す必要はありません。<br/>
     * <br/>
     * 初期化パラメタをスクリプトから動的に変更して初期化を行いたい場合、本関数を使用してください。<br/>
     * \par 注意:
     * 本関数を使用する場合は、 自動初期化を無効にするため、 ::CriWareInitializer::dontInitializeOnAwake プロパティをインスペクタ上でチェックしてください。<br/>
     * また、本関数を呼び出すタイミングは全てのプラグインAPIよりも前に呼び出す必要があります。Script Execution Orderが高いスクリプト上で行ってください。
     *
     */
    public void Initialize()
    {
        /* 初期化カウンタの更新 */
        initializationCount++;
        if (initializationCount != 1)
        {
            /* CriWareInitializer自身による多重初期化は許可しない */
            GameObject.Destroy(this);
            return;
        }

        /* CRI File Systemライブラリの初期化 */
        if (initializesFileSystem)
        {
            CriFsPlugin.SetConfigParameters(
                fileSystemConfig.numberOfLoaders,
                fileSystemConfig.numberOfBinders,
                fileSystemConfig.numberOfInstallers,
                (fileSystemConfig.installBufferSize * 1024),
                fileSystemConfig.maxPath,
                fileSystemConfig.minimizeFileDescriptorUsage
                );
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (fileSystemConfig.androidDeviceReadBitrate == 0)
                {
                    fileSystemConfig.androidDeviceReadBitrate = CriFsConfig.defaultAndroidDeviceReadBitrate;
                }
            }
            CriFsPlugin.SetConfigAdditionalParameters_ANDROID(fileSystemConfig.androidDeviceReadBitrate);
            CriFsPlugin.InitializeLibrary();
            if (fileSystemConfig.userAgentString.Length != 0)
            {
                CriFsUtility.SetUserAgentString(fileSystemConfig.userAgentString);
            }
        }

        /* CRI Atomライブラリの初期化 */
        if (initializesAtom)
        {
            /* 初期化処理の実行 */
            CriAtomPlugin.SetConfigParameters(
                (int)Math.Max(atomConfig.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(atomConfig)),
                atomConfig.standardVoicePoolConfig.memoryVoices,
                atomConfig.standardVoicePoolConfig.streamingVoices,
                atomConfig.hcaMxVoicePoolConfig.memoryVoices,
                atomConfig.hcaMxVoicePoolConfig.streamingVoices,
                atomConfig.outputSamplingRate,
                atomConfig.usesInGamePreview,
                atomConfig.serverFrequency);

            CriAtomPlugin.SetConfigAdditionalParameters_IOS(
                (uint)Math.Max(atomConfig.iosBufferingTime, 16),
                atomConfig.iosOverrideIPodMusic
                );

            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (atomConfig.androidBufferingTime == 0)
                {
                    atomConfig.androidBufferingTime = (int)(4 * 1000.0 / atomConfig.serverFrequency);
                }
                if (atomConfig.androidStartBufferingTime == 0)
                {
                    atomConfig.androidStartBufferingTime = (int)(3 * 1000.0 / atomConfig.serverFrequency);
                }
            }
            CriAtomPlugin.SetConfigAdditionalParameters_ANDROID(
                atomConfig.androidLowLatencyStandardVoicePoolConfig.memoryVoices,
                atomConfig.androidLowLatencyStandardVoicePoolConfig.streamingVoices,
                atomConfig.androidBufferingTime,
                atomConfig.androidStartBufferingTime);

            CriAtomPlugin.InitializeLibrary();

            if (atomConfig.useRandomSeedWithTime == true)
            {
                /* 時刻を乱数種に設定 */
                CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks);
            }

            /* ACFファイル指定時は登録 */
            if (atomConfig.acfFileName.Length != 0)
            {
                string acfPath = atomConfig.acfFileName;
                if (CriWare.IsStreamingAssetsPath(acfPath))
                {
                    acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath);
                }

                CriAtomEx.RegisterAcf(null, acfPath);
            }
        }

        /* CRI Manaライブラリの初期化 */
        if (initializesMana)
        {
            CriManaPlugin.SetConfigParameters(manaConfig.graphicsMultiThreaded, manaConfig.numberOfDecoders, manaConfig.numberOfMaxEntries);
            CriManaPlugin.InitializeLibrary();
        }

        /* シーンチェンジ後もオブジェクトを維持するかどうかの設定 */
        if (dontDestroyOnLoad)
        {
            DontDestroyOnLoad(transform.gameObject);
            DontDestroyOnLoad(CriWare.managerObject);
        }
    }
Ejemplo n.º 30
0
    public static bool InitializeAtom(CriAtomConfig config)
    {
        /* CRI Atomライブラリの初期化 */
        if (CriAtomPlugin.IsLibraryInitialized() == false)
        {
            /* 初期化処理の実行 */
            CriAtomPlugin.SetConfigParameters(
                (int)Math.Max(config.maxVirtualVoices, CriAtomPlugin.GetRequiredMaxVirtualVoices(config)),
                config.maxVoiceLimitGroups,
                config.maxCategories,
                config.maxSequenceEventsPerFrame,
                config.maxBeatSyncCallbacksPerFrame,
                config.standardVoicePoolConfig.memoryVoices,
                config.standardVoicePoolConfig.streamingVoices,
                config.hcaMxVoicePoolConfig.memoryVoices,
                config.hcaMxVoicePoolConfig.streamingVoices,
                config.outputSamplingRate,
                config.asrOutputChannels,
                config.usesInGamePreview,
                config.serverFrequency,
                config.maxParameterBlocks,
                config.categoriesPerPlayback,
                config.maxBuses,
                config.vrMode);

            CriAtomPlugin.SetConfigAdditionalParameters_PC(
                config.pcBufferingTime
                );

            CriAtomPlugin.SetConfigAdditionalParameters_IOS(
                (uint)Math.Max(config.iosBufferingTime, 16),
                config.iosOverrideIPodMusic
                );
            /* Android 固有の初期化パラメータを登録 */
            {
                /* Ver.2.03.03 以前は 0 がデフォルト値だったことの互換性維持のための処理 */
                if (config.androidBufferingTime == 0)
                {
                    config.androidBufferingTime = (int)(4 * 1000.0 / config.serverFrequency);
                }
                if (config.androidStartBufferingTime == 0)
                {
                    config.androidStartBufferingTime = (int)(3 * 1000.0 / config.serverFrequency);
                }
                IntPtr android_context = IntPtr.Zero;
#if !UNITY_EDITOR && UNITY_ANDROID
                if (config.androidUsesAndroidFastMixer)
                {
                    AndroidJavaClass  jc       = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                    AndroidJavaObject activity = jc.GetStatic <AndroidJavaObject>("currentActivity");
                    android_context = activity.GetRawObject();
                }
                CriAtomEx.androidDefaultSoundRendererType = config.androidForceToUseAsrForDefaultPlayback ?
                                                            CriAtomEx.SoundRendererType.Asr : CriAtomEx.SoundRendererType.Default;
#endif
                CriAtomPlugin.SetConfigAdditionalParameters_ANDROID(
                    config.androidLowLatencyStandardVoicePoolConfig.memoryVoices,
                    config.androidLowLatencyStandardVoicePoolConfig.streamingVoices,
                    config.androidBufferingTime,
                    config.androidStartBufferingTime,
                    android_context);
            }

            CriAtomPlugin.InitializeLibrary();

            if (config.useRandomSeedWithTime == true)
            {
                /* 時刻を乱数種に設定 */
                CriAtomEx.SetRandomSeed((uint)System.DateTime.Now.Ticks);
            }

            /* ACFファイル指定時は登録 */
            if (config.acfFileName.Length != 0)
            {
                string acfPath = config.acfFileName;
                if (CriWare.IsStreamingAssetsPath(acfPath))
                {
                    acfPath = Path.Combine(CriWare.streamingAssetsPath, acfPath);
                }

                CriAtomEx.RegisterAcf(null, acfPath);
            }
            return(true);
        }
        else
        {
            return(false);
        }
    }