示例#1
0
        private int GetAudioChannelCount(AudioSpeakerMode speakerMode)
        {
            switch (speakerMode)
            {
            case AudioSpeakerMode.Mono:
                return(1);

            case AudioSpeakerMode.Stereo:
                return(2);

            case AudioSpeakerMode.Quad:
                return(4);

            case AudioSpeakerMode.Surround:
                return(5);

            case AudioSpeakerMode.Mode5point1:
                return(6);

            case AudioSpeakerMode.Mode7point1:
                return(8);

            default:
                Debug.LogError("[DemolitionMedia] " + "AudioSpeakerMode." + speakerMode.ToString() + " is unsupported");
                return(0);
            }
        }
        public static SoundFormat GetSoundFormatFromSpeakerMode(AudioSpeakerMode mode)
        {
            switch (mode)
            {
            case AudioSpeakerMode.Mono:
                return(SoundFormat.Mono);

            case AudioSpeakerMode.Stereo:
                return(SoundFormat.Stereo);

            case AudioSpeakerMode.Quad:
                return(SoundFormat.Quad);

            case AudioSpeakerMode.Surround:
                return(SoundFormat.Surround);

            case AudioSpeakerMode.Mode5point1:
                return(SoundFormat.FiveDot1);

            case AudioSpeakerMode.Mode7point1:
                return(SoundFormat.SevenDot1);

            case AudioSpeakerMode.Prologic:
                return(SoundFormat.Raw);

            default:
                throw new ArgumentException($"Invalid speaker mode {mode}", nameof(mode));
            }
        }
 public static int GetNumChannels(AudioSpeakerMode mode)
 {
     int result = 0;
     switch (mode)
     {
         case AudioSpeakerMode.Raw:
             break;
         case AudioSpeakerMode.Mono:
             result = 1;
             break;
         case AudioSpeakerMode.Stereo:
             result = 2;
             break;
         case AudioSpeakerMode.Quad:
             result = 4;
             break;
         case AudioSpeakerMode.Surround:
             result = 5;
             break;
         case AudioSpeakerMode.Mode5point1:
             result = 6;
             break;
         case AudioSpeakerMode.Mode7point1:
             result = 8;
             break;
         case AudioSpeakerMode.Prologic:
             result = 2;
             break;
     }
     return result;
 }
示例#4
0
        private void BeginMediaEncoderRecording()
        {
            InitInputs();

            if (recorder.realTime)
            {
                Application.targetFrameRate = recorder.frameRate;
            }
            else
            {
                Time.captureFramerate = recorder.frameRate;
            }

            // Configure encoder
            AudioSpeakerMode speakerMode = AudioSettings.speakerMode;

            audioAttrs = new AudioTrackAttributes
            {
                sampleRate = new MediaRational
                {
                    numerator   = AudioSettings.outputSampleRate,
                    denominator = 1
                },
                channelCount = (ushort)speakerMode,
                language     = ""
            };

            videoInput.BeginRecording();

            videoAttrs = new VideoTrackAttributes
            {
                frameRate    = new MediaRational(recorder.frameRate),
                width        = (uint)videoInput.outputWidth,
                height       = (uint)videoInput.outputHeight,
                includeAlpha = false
            };

            encodedFilePath = Path.Combine(outputPath, GetFileName());
            Debug.Log("[VimeoRecorder] Recording to " + GetFileName());

            if (!recorder.realTime)
            {
                recorder.recordAudio = false;
            }

            if (recorder.recordAudio)
            {
#if UNITY_2018_1_OR_NEWER
                audioInput.BeginRecording();
                encoder = new UnityEditor.Media.MediaEncoder(encodedFilePath, videoAttrs, audioAttrs);
#else
                encoder = new UnityEditor.Media.MediaEncoder(encodedFilePath, videoAttrs);
#endif
            }
            else
            {
                encoder = new UnityEditor.Media.MediaEncoder(encodedFilePath, videoAttrs);
            }
        }
示例#5
0
    static int IntToEnum(IntPtr L)
    {
        int arg0           = (int)LuaDLL.lua_tonumber(L, 1);
        AudioSpeakerMode o = (AudioSpeakerMode)arg0;

        LuaScriptMgr.PushEnum(L, o);
        return(1);
    }
    void Start()
    {
        AudioSettings.OnAudioConfigurationChanged += OnAudioConfigurationChanged;
        currentSpeakerMode = AudioSettings.speakerMode;
//		Debug.Log (currentSpeakerMode);

        // If these values need to be changed in-game, the following lines
        // should be executed in OnAudioFilterRead()
        c = Mathf.Pow(0.5f, (128.0f - cutoff) / 16.0f);
        r = Mathf.Pow(0.5f, (resonance + 24.0f) / 16.0f);
    }
示例#7
0
 public Settings()
 {
     QualityLevel        = 0;
     ShadowsType         = LightShadows.None;
     FieldOfView         = 90f;
     FullScreenMode      = FullScreenMode.FullScreenWindow;
     AntiAliasingSamples = 0;
     VSyncCount          = 0;
     ResolutionIndex     = Helper.GetCurrentResolutionIndex();
     Volume           = 1f;
     AudioSpeakerMode = AudioSpeakerMode.Stereo;
 }
示例#8
0
    private void GetSettings()
    {
        sensitivityX   = PlayerPrefs.GetFloat("Mouse Sensitivity X", 1.5f);
        sensitivityY   = PlayerPrefs.GetFloat("Mouse Sensitivity Y", 1.5f);
        mouseSmoothing = PlayerPrefs.GetFloat("Mouse Smoothing", 0f);
        FOV            = PlayerPrefs.GetInt("FOV", 70);
        speakerMode    = PlayerPrefs.GetInt("Speaker Mode", 2);
        brightness     = PlayerPrefs.GetFloat("Brightness", 1f);
        enableHUD      = PlayerPrefs.GetInt("EnableHUD", 1);

        waterQuality            = PlayerPrefs.GetString("Water Quality", "Very High");
        textureQuality          = PlayerPrefs.GetInt("Texture Quality", 0);
        aniso                   = PlayerPrefs.GetString("Anisotropic", "Enable");
        shadowDistance          = PlayerPrefs.GetInt("Shadow Distance", 110);
        shadowQuality           = PlayerPrefs.GetInt("Shadow Quality", 5);
        terrainMeshDetail       = PlayerPrefs.GetInt("Terrain Mesh Detail", 5);
        vegetationDistance      = PlayerPrefs.GetInt("Vegetation Distance", 150);
        vegetationDensity       = PlayerPrefs.GetFloat("Vegetation Density", 1f);
        terrainTreeDrawDistance = PlayerPrefs.GetInt("Tree Draw Distance", 1000);
        terrainMaxTrees         = PlayerPrefs.GetInt("Tree Mesh Limit", 250);
        vsync                   = PlayerPrefs.GetString("VSync", "Disabled");
        bloom                   = PlayerPrefs.GetInt("Bloom", 1);
        sunShafts               = PlayerPrefs.GetInt("Sun Shafts", 1);
        motionBlur              = PlayerPrefs.GetInt("Motion Blur", 0);
        SSAO            = PlayerPrefs.GetInt("SSAO", 1);
        colorCorrection = PlayerPrefs.GetInt("Color Correction", 1);
        glareEffect     = PlayerPrefs.GetInt("Glare Effect", 1);
        antiAliasing    = PlayerPrefs.GetInt("AntiAliasing", 1);
        wDepthOfField   = PlayerPrefs.GetInt("Weapon DoF", 0);
        screenWidth     = PlayerPrefs.GetInt("ScreenWidth", Screen.currentResolution.width);
        screenHeight    = PlayerPrefs.GetInt("ScreenHeight", Screen.currentResolution.height);
        fullScreen      = PlayerPrefs.GetString("DisplayMode", "Fullscreen");
        showFPS         = PlayerPrefs.GetInt("ShowFPS", 0);
        aimToggle       = PlayerPrefs.GetString("Aim Toggle", "Hold (Press)");
        crosshairStyle  = PlayerPrefs.GetString("Crosshair Style", "Dynamic");

        soundVolume          = PlayerPrefs.GetFloat("Sound Volume", 1f);
        AudioListener.volume = soundVolume;

        for (int i = 1; i < 7; i++)
        {
            AudioSpeakerMode asm = (AudioSpeakerMode)i;
            if (speakerMode == i && AudioSettings.speakerMode != asm)
            {
                AudioSettings.speakerMode = asm;
            }
        }

        targetFrameRate             = PlayerPrefs.GetInt("TargetFPS", 60);
        Application.targetFrameRate = Mathf.Clamp(targetFrameRate, 15, 300);
        Shader.globalMaximumLOD     = 800;
    }
示例#9
0
        void ChangeSpeakerConfiguration()
        {
//			currentSpeakerMode = AudioSettings.speakerMode;
            currentSpeakerMode = AudioSettings.driverCapabilities;
            if (currentSpeakerMode == speakerModes [0] || currentSpeakerMode == speakerModes [1])
            {
                enableSurroundTools = false;
            }
            else
            {
                enableSurroundTools = true;
            }
//			Debug.Log (AudioSettings.driverCapabilities);
//			Debug.Log (currentSpeakerMode);
        }
        public void Activate()
        {
            CastRemoteDisplayiOSUnityBridge.StartScan(
                extensionManager.CastRemoteDisplayManager.CastAppId, extensionManager);

            AudioSpeakerMode audioSpeakerMode = AudioSettings.GetConfiguration().speakerMode;
            int numberChannels = 0;

            switch (audioSpeakerMode)
            {
            case AudioSpeakerMode.Mono:
                numberChannels = 1;
                break;

            case AudioSpeakerMode.Stereo:
                numberChannels = 2;
                break;

            case AudioSpeakerMode.Quad:
                numberChannels = 4;
                break;

            case AudioSpeakerMode.Surround:
                numberChannels = 5;
                break;

            case AudioSpeakerMode.Mode5point1:
                numberChannels = 6;
                break;

            case AudioSpeakerMode.Mode7point1:
                numberChannels = 7;
                break;

            default:
                Debug.LogError("Cast remote display cannot support audio configuration speakermode: " +
                               audioSpeakerMode);
                return;
            }

            // Note: Unity uses PCM float 32 interleaved audio.
            CastRemoteDisplayiOSUnityBridge.SetAudioFormat(
                CastRemoteDisplayiOSUnityBridge.AudioFormat.AVAudioPCMFormatFloat32,
                AudioSettings.GetConfiguration().sampleRate,
                numberChannels,
                /* isInterleaved */ true);
        }
示例#11
0
    public EliasHelper(string file, string basePath, ushort framesPerBuffer, byte channels, uint sampleRate, EliasWrapper.elias_data_reader_functions?readerFunctions, EliasWrapper.elias_memory_functions?memoryFunctions, int cachePageCount, int cachePageSize, bool loadProject = true)
    {
        SampleRate      = (int)sampleRate;
        FramesPerBuffer = (int)framesPerBuffer;
        //If no channel count is set for the Elias Object, Unity's channel count setting is used.
        if (channels == 0)
        {
            AudioSpeakerMode unityChannelMode = AudioSettings.speakerMode;
            switch (unityChannelMode)
            {
            case AudioSpeakerMode.Mono:
                channels = 1;
                break;

            case AudioSpeakerMode.Stereo:
                channels = 2;
                break;

            case AudioSpeakerMode.Quad:
                channels = 4;
                break;

            case AudioSpeakerMode.Surround:
                channels = 5;
                break;

            case AudioSpeakerMode.Mode5point1:
                channels = 6;
                break;

            case AudioSpeakerMode.Mode7point1:
                channels = 8;
                break;

            default:     //If Unity is set to "Raw", or some new/unknown AudioSpeakerMode is used, we default Elias to use Stereo (As 0 is not a vaid channel count).
                Debug.LogError("No channel count set for Elias, and unknown channel count is set for Unity. Defaulting Elias to use Stereo!");
                channels = 2;
                break;
            }
        }
        ChannelCount = channels;
        Initialize(readerFunctions, basePath, sampleRate, channels, framesPerBuffer, memoryFunctions, cachePageCount, cachePageSize);
        if (loadProject && Handle != IntPtr.Zero)
        {
            Deserialize(file);
        }
    }
示例#12
0
        public static SpeakersConfiguration FromUnity(this AudioSpeakerMode audioSpeakerMode)
        {
            switch (audioSpeakerMode)
            {
            case AudioSpeakerMode.Mono:
                return(SpeakersConfiguration.Mono);

            case AudioSpeakerMode.Stereo:
                return(SpeakersConfiguration.Headphones);

            case AudioSpeakerMode.Mode5point1:
                return(SpeakersConfiguration.Speakers_5_1);

            case AudioSpeakerMode.Mode7point1:
                return(SpeakersConfiguration.Speakers_7_1);

            default:
                throw new NotImplementedException("Unsupported speaker mode");
            }
        }
示例#13
0
        protected static int speakerModeToChannels(AudioSpeakerMode mode)
        {
            switch (mode)
            {
            case AudioSpeakerMode.Mono: return(1);

            case AudioSpeakerMode.Stereo: return(2);

            case AudioSpeakerMode.Quad: return(4);

            case AudioSpeakerMode.Surround: return(5);

            case AudioSpeakerMode.Mode5point1: return(6);

            case AudioSpeakerMode.Mode7point1: return(8);

            case AudioSpeakerMode.Prologic: return(2);

            default: return(2);
            }
        }
 /// <summary>
 /// Add items to the speaker mode settings dropdown and set the default
 /// </summary>
 protected void SetUpSpeakerModesDropdown()
 {
     if (speakerModesDropdown)
     {
         speakerModes = AudioHelper.GetAudioSpeakerModes();
         AudioSpeakerMode current = AudioHelper.GetCurrentSpeakerMode();
         int selected             = 0;
         List <TMPro.TMP_Dropdown.OptionData> speakerDropdownOptions = new List <TMPro.TMP_Dropdown.OptionData>();
         for (int i = 0; i < speakerModes.Count; i++)
         {
             speakerDropdownOptions.Add(new TMPro.TMP_Dropdown.OptionData(speakerModes[i].Key));
             if (speakerModes[i].Value == current)
             {
                 selected = i;
             }
         }
         TMPro.TMP_Dropdown dropdown = speakerModesDropdown.GetComponent <TMPro.TMP_Dropdown>();
         dropdown.options = speakerDropdownOptions;
         dropdown.SetValueWithoutNotify(selected);
     }
 }
        private static int GetChannelCount(AudioSpeakerMode mode)
        {
            int result = 0;

            switch (mode)
            {
#if !UNITY_2019_2_OR_NEWER
            case AudioSpeakerMode.Raw:
                break;
#endif
            case AudioSpeakerMode.Mono:
                result = 1;
                break;

            case AudioSpeakerMode.Stereo:
                result = 2;
                break;

            case AudioSpeakerMode.Quad:
                result = 4;
                break;

            case AudioSpeakerMode.Surround:
                result = 5;
                break;

            case AudioSpeakerMode.Mode5point1:
                result = 6;
                break;

            case AudioSpeakerMode.Mode7point1:
                result = 8;
                break;

            case AudioSpeakerMode.Prologic:
                result = 2;
                break;
            }
            return(result);
        }
        // 修改音频全局设置,一般不予以调用!!
        public void AudioGlobalSetting(int dspBufferSize,    /*数字音频处理的缓冲区大小,低16位标明缓冲区尺寸,高16位表明分片(fragment的最大序号)*/
                                                             /*int numRealVoices,*/ /*当前游戏中进行的最大的同时进行的音频的数量,不予以修改*/
                                       int numVirtualVoices, /*可以支持的最大的同时进行的音频数量,超过这个数量的会简单的停止*/
                                       int sampleRate,       /*音频输出设备的采样率*/
                                       AudioSpeakerMode speakerMode)
        {
            // 声音的全局设置
            AudioConfiguration audioConfiguration = AudioSettings.GetConfiguration();

            // TODO:中间设置内容
            audioConfiguration.dspBufferSize = dspBufferSize;
            //audioConfiguration.numRealVoices = numRealVoices;  这可不能随便更改啊!
            audioConfiguration.numVirtualVoices = numVirtualVoices;
            audioConfiguration.sampleRate       = sampleRate;
            audioConfiguration.speakerMode      = speakerMode;

            /*
             * //     Channel count is unaffected.
             * Raw = 0,
             * //     Channel count is set to 1. The speakers are monaural.
             * Mono = 1,
             * //     Channel count is set to 2. The speakers are stereo. This is the editor default.
             * Stereo = 2,
             * //     Channel count is set to 4. 4 speaker setup. This includes front left, front right,
             * //     rear left, rear right.
             * Quad = 3,
             * //     Channel count is set to 5. 5 speaker setup. This includes front left, front right,
             * //     center, rear left, rear right.
             * Surround = 4,
             * //     Channel count is set to 6. 5.1 speaker setup. This includes front left, front
             * //     right, center, rear left, rear right and a subwoofer.
             * Mode5point1 = 5,
             * //     Channel count is set to 8. 7.1 speaker setup. This includes front left, front
             * //     right, center, rear left, rear right, side left, side right and a subwoofer.
             * Mode7point1 = 6,
             * //     Channel count is set to 2. Stereo output, but data is encoded in a way that is
             * //     picked up by a Prologic/Prologic2 decoder and split into a 5.1 speaker setup.
             * Prologic = 7*/
            AudioSettings.Reset(audioConfiguration);
        }
        static public int GetNumChannels(AudioSpeakerMode mode)
        {
            int result = 0;

            switch (mode)
            {
            case AudioSpeakerMode.Raw:
                break;

            case AudioSpeakerMode.Mono:
                result = 1;
                break;

            case AudioSpeakerMode.Stereo:
                result = 2;
                break;

            case AudioSpeakerMode.Quad:
                result = 4;
                break;

            case AudioSpeakerMode.Surround:
                result = 5;
                break;

            case AudioSpeakerMode.Mode5point1:
                result = 6;
                break;

            case AudioSpeakerMode.Mode7point1:
                result = 8;
                break;

            case AudioSpeakerMode.Prologic:
                result = 2;
                break;
            }
            return(result);
        }
示例#18
0
 void OnAudioConfigurationChanged(bool deviceWasChanged)
 {
     currentSpeakerMode = AudioSettings.speakerMode;
 }
 //TODO Current changing AudioMode in runtime make crash sound. Waiting for fixed this by Unity team.
 /// <summary>
 /// Converts the audio speaker mode to int.
 /// </summary>
 /// <returns>The audio speaker mode to int.</returns>
 /// <param name="mode">AudioSpeakerMode.</param>
 public static int ConvertAudioSpeakerModeToInt(AudioSpeakerMode mode)
 {
     return (int)mode;
 }
    public static int GetNumChannelsFromSpeakerMode(AudioSpeakerMode speakerMode)
    {
        switch (AudioSettings.speakerMode)
        {
        case AudioSpeakerMode.Mono:
            return 1;

        case AudioSpeakerMode.Stereo:
            return 2;

        case AudioSpeakerMode.Quad:
            return 4;

        case AudioSpeakerMode.Surround:
        case AudioSpeakerMode.Mode5point1:
            return 5;

        case AudioSpeakerMode.Mode7point1:
            return 7;

        case AudioSpeakerMode.Prologic:
            return 2;

        case AudioSpeakerMode.Raw:
        default:
            return 2;
        }
    }
 /// <summary>
 /// Set the audio speaker mode
 /// </summary>
 /// <param name="mode">Mode to set the speaker mode to</param>
 public static void SetAudioSpeakerMode(AudioSpeakerMode mode)
 {
     AudioSettings.speakerMode = mode;
 }
示例#22
0
        //
        // Get Audio Configuration.
        //
        static public AudioFormat GetAudioConfiguration()
        {
            AudioSpeakerMode projectSpeakerMode = AudioSettings.GetConfiguration().speakerMode;
            AudioSpeakerMode driverSpeakerMode  = AudioSettings.driverCapabilities;
            AudioSpeakerMode minSpeakerMode;

            // NOTE: Prologic mode is not supported. Revert to stereo.
            if ((projectSpeakerMode == AudioSpeakerMode.Prologic) && (driverSpeakerMode == AudioSpeakerMode.Prologic))
            {
                minSpeakerMode = AudioSpeakerMode.Stereo;
            }
            else
            {
                minSpeakerMode = (projectSpeakerMode < driverSpeakerMode) ? projectSpeakerMode : driverSpeakerMode;
            }

            AudioFormat audioFormat;

            audioFormat.channelLayoutType       = ChannelLayoutType.Speakers;
            audioFormat.speakerDirections       = null;
            audioFormat.ambisonicsOrder         = -1;
            audioFormat.ambisonicsOrdering      = AmbisonicsOrdering.ACN;
            audioFormat.ambisonicsNormalization = AmbisonicsNormalization.N3D;
            audioFormat.channelOrder            = ChannelOrder.Interleaved;

            switch (minSpeakerMode)
            {
            case AudioSpeakerMode.Mono:
                audioFormat.channelLayout = ChannelLayout.Mono;
                audioFormat.numSpeakers   = 1;
                break;

            case AudioSpeakerMode.Stereo:
                audioFormat.channelLayout = ChannelLayout.Stereo;
                audioFormat.numSpeakers   = 2;
                break;

            case AudioSpeakerMode.Quad:
                audioFormat.channelLayout = ChannelLayout.Quadraphonic;
                audioFormat.numSpeakers   = 4;
                break;

            case AudioSpeakerMode.Mode5point1:
                audioFormat.channelLayout = ChannelLayout.FivePointOne;
                audioFormat.numSpeakers   = 6;
                break;

            case AudioSpeakerMode.Mode7point1:
                audioFormat.channelLayout = ChannelLayout.SevenPointOne;
                audioFormat.numSpeakers   = 8;
                break;

            default:
                Debug.LogWarning("Surround and Prologic mode is not supported. Revert to stereo");
                audioFormat.channelLayout = ChannelLayout.Stereo;
                audioFormat.numSpeakers   = 2;
                break;
            }

            CustomSpeakerLayout speakerLayout = FindObjectOfType <CustomSpeakerLayout>();

            if ((speakerLayout != null) && (speakerLayout.speakerPositions.Length == audioFormat.numSpeakers))
            {
                audioFormat.channelLayout     = ChannelLayout.Custom;
                audioFormat.speakerDirections = new Vector3[audioFormat.numSpeakers];
                for (int i = 0; i < speakerLayout.speakerPositions.Length; ++i)
                {
                    audioFormat.speakerDirections[i].x = speakerLayout.speakerPositions[i].x;
                    audioFormat.speakerDirections[i].y = speakerLayout.speakerPositions[i].y;
                    audioFormat.speakerDirections[i].z = speakerLayout.speakerPositions[i].z;
                }
            }

            return(audioFormat);
        }
示例#23
0
 //TODO Current changing AudioMode in runtime make crash sound. Waiting for fixed this by Unity team.
 /// <summary>
 /// Converts the audio speaker mode to int.
 /// </summary>
 /// <returns>The audio speaker mode to int.</returns>
 /// <param name="mode">AudioSpeakerMode.</param>
 public static int ConvertAudioSpeakerModeToInt(AudioSpeakerMode mode)
 {
     return((int)mode);
 }
示例#24
0
 /// <summary>
 /// Set the channel count of the speakers.
 /// </summary>
 /// <remarks>AudioSpeakerMode.Raw (Obsolete)</remarks>
 public void SetSpeakerMode(AudioSpeakerMode audioSpeakerMode)
 {
     audioData.stereo = audioSpeakerMode;
     UnityEngine.AudioSettings.speakerMode = AudioSpeakerMode.Stereo;
 }
示例#25
0
	public void SetNewAduioSpeakerMode(AudioSpeakerMode toThis)
	{
		AudioSettings.speakerMode = toThis;
		m_CurrentSpeakerMode = AudioSettings.speakerMode;
	}
示例#26
0
 public static int SpeakerModeToChannel(AudioSpeakerMode mode)
 {
     return(pairs[mode]);
 }