示例#1
0
            public bool LoadGame(string gamePath)
            {
                GameInfo gameInfo = LoadGameInfo(gamePath);
                bool     ret      = Libretro.RetroLoadGame(ref gameInfo);

                Console.WriteLine("\nSystem information:");

                _av = new SystemAVInfo();
                Libretro.RetroGetSystemAVInfo(ref _av);

                var audioConfig = AudioSettings.GetConfiguration();

                audioConfig.sampleRate = (int)_av.timing.sample_rate;
                AudioSettings.Reset(audioConfig);

                Debug.Log("Geometry:");
                Debug.Log("Base width: " + _av.geometry.base_width);
                Debug.Log("Base height: " + _av.geometry.base_height);
                Debug.Log("Max width: " + _av.geometry.max_width);
                Debug.Log("Max height: " + _av.geometry.max_height);
                Debug.Log("Aspect ratio: " + _av.geometry.aspect_ratio);
                Debug.Log("Geometry:");
                Debug.Log("Target fps: " + _av.timing.fps);
                Debug.Log("Sample rate " + _av.timing.sample_rate);
                return(ret);
            }
示例#2
0
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //	* Derived Method: Start
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    void Start()
    {
        // Set DSP Buffer Size
#if !UNITY_EDITOR && !UNITY_STANDALONE_WIN && !UNITY_STANDALONE_OSX
        var audioSettings = AudioSettings.GetConfiguration();
        audioSettings.dspBufferSize /= 2;
        AudioSettings.Reset(audioSettings);
#endif
        Instance = this;

        // Grab all Audio Sources already existing on this object
        sm_aAudioSource.Clear();
        AudioSource[] acquiredAudioSources = this.gameObject.GetComponents <AudioSource>();
        if (acquiredAudioSources.Length > m_iTotalAudioSourcesCount)
        {
            m_iTotalAudioSourcesCount = acquiredAudioSources.Length;
        }

        // Add Existing To List
        for (int i = 0; i < acquiredAudioSources.Length; ++i)
        {
            sm_aAudioSource.Add(new AudioHandlerManager(acquiredAudioSources[i]));
        }

        // Create the rest of the AudioSources up until the desired amount exist. Or stop if we already have more than required.
        for (int i = sm_aAudioSource.Count; i < m_iTotalAudioSourcesCount; ++i)
        {
            sm_aAudioSource.Add(new AudioHandlerManager(CreateAudioSource()));
        }
    }
    // Use this for initialization
    void Start()
    {
        AudioConfiguration config = AudioSettings.GetConfiguration();

        config.numVirtualVoices = 6;
        config.numRealVoices    = 2;
        AudioSettings.Reset(config);

        controller = FindObjectOfType <FrameworkController>();
        source     = GetComponent <AudioSource>();

        if (controller != null)
        {
            source.Play();
        }
        else
        {
            Debug.Log("Framework controller not found. Are you starting from MainMenu Scene?");
        }

        SoundSlider.onValueChanged.AddListener(delegate {
            UpdatePriorities();
        });
        NoiseSlider.onValueChanged.AddListener(delegate {
            UpdatePriorities();
        });

        UpdatePriorities();
        PlayAll();
    }
        public void Start()
        {
            #if UNITY_STANDALONE_OSX
            _core = new Core(OS.OSX, CorePath, SystemDirectory);
            #else
            _core = new Core(OS.Windows, CorePath, SystemDirectory);
            #endif

            _core.AudioSampleBatchHandler += audioSampleBatchHandler;
            _core.LogHandler        += logHandler;
            _core.VideoFrameHandler += videoFrameHandler;

            _core.Load(ROMPath);

            Time.fixedDeltaTime = (float)1 / (float)_core.FrameRate;

            AudioConfiguration audioConfiguration = AudioSettings.GetConfiguration();
            audioConfiguration.sampleRate = (int)_core.AudioSampleRate;
            AudioSettings.Reset(audioConfiguration);

            // this is required for OnAudioFilterRead to work and needs to be done after setting the AudioSettings.outputSampleRate
            gameObject.AddComponent <AudioSource>();

            _core.StartFrameTiming();
        }
示例#5
0
        /// <summary>
        /// Apply the current ConfigState configuration to the game
        /// </summary>
        public void ApplyConfiguration()
        {
            //AUDIO CONFIG
            AudioListener.volume = ConfigState.Instance.SoundVolume;
            var ac = AudioSettings.GetConfiguration();

#if UNITY_WSA
            if (ConfigState.Instance.SpeakerMode == AudioSpeakerMode.Raw)
            {
                ConfigState.Instance.SpeakerMode = AudioSpeakerMode.Stereo;
            }
#endif
            ac.speakerMode = ConfigState.Instance.SpeakerMode;
            AudioSettings.Reset(ac);

            //VIDEO CONFIG
            if (ConfigState.Instance.UseCustomVideoSettings)
            {
                ApplyExtendedGraphicsConfiguration();
            }

            if (!CoreParams.IsEditor)
            {
                Screen.SetResolution(ConfigState.Instance.Resolution.x, ConfigState.Instance.Resolution.y, ConfigState.Instance.FullScreen, ConfigState.Instance.RefreshRate);
            }

            QualitySettings.vSyncCount  = ConfigState.Instance.VsyncCount;
            Application.targetFrameRate = ConfigState.Instance.MaxFrames;

            //INPUT CONFIG
            MappedInput.SetMapper(ConfigState.Instance.InputMapper); //safe?

            //let other things handle it on their own
            QdmsMessageBus.Instance.PushBroadcast(new ConfigChangedMessage());
        }
示例#6
0
    public void changeGlobalVolume(Slider slider)
    {
        AudioConfiguration config = AudioSettings.GetConfiguration();

        config.dspBufferSize = (int)slider.value;
        AudioSettings.Reset(config);
    }
示例#7
0
    void OnGUI()
    {
        //storing the audio source in source
        AudioSource source   = GetComponent <AudioSource>();
        bool        modified = false;

        AudioConfiguration config = AudioSettings.GetConfiguration();

        //reconfiguring the values and appropraitely changing the modified values
        config.speakerMode      = (AudioSpeakerMode)GUIRow("speakerMode", validSpeakerModes, (int)config.speakerMode, ref modified);
        config.dspBufferSize    = GUIRow("dspBufferSize", validDSPBufferSizes, config.dspBufferSize, ref modified);
        config.sampleRate       = GUIRow("sampleRate", validSampleRates, config.sampleRate, ref modified);
        config.numRealVoices    = GUIRow("RealVoices", validNumRealVoices, config.numRealVoices, ref modified);
        config.numVirtualVoices = GUIRow("numVirtualVoices", validNumVirtualVoices, config.numVirtualVoices, ref modified);

        //we reset if the values have changed
        if (modified)
        {
            AudioSettings.Reset(config);
        }

        //when the button pressed the audio starts playing
        if (GUILayout.Button("Start"))
        {
            source.Play();
        }

        //audio stops playing on pressing the Stop
        if (GUILayout.Button("Stop"))
        {
            source.Stop();
        }
    }
        private void SetupSurroundSound()
        {
            AudioConfiguration audioConfig = AudioSettings.GetConfiguration();

            audioConfig.speakerMode = AudioSpeakerMode.Mode5point1;
            AudioSettings.Reset(audioConfig);
        }
示例#9
0
    void setupAudioBuffer()
    {
        AudioConfiguration config = AudioSettings.GetConfiguration();

        switch (PlayerPrefs.GetInt("audioQuality"))
        {
        case 0:
            config.dspBufferSize = 256;
            break;

        case 1:
            config.dspBufferSize = 512;
            break;

        case 2:
            config.dspBufferSize = 1024;
            break;

        default:
            break;
        }

        AudioSource[] sources = FindObjectsOfType <AudioSource>();
        for (int i = 0; i < sources.Length; i++)
        {
            sources[i].enabled = false;
        }
        AudioSettings.Reset(config);
        for (int i = 0; i < sources.Length; i++)
        {
            sources[i].enabled = true;
        }
    }
    private void Start()
    {
        var config = AudioSettings.GetConfiguration();

        config.numRealVoices = maxCount;
        AudioSettings.Reset(config);
    }
示例#11
0
    private static void UpdateDSPBufferSize()
    {
        var config = AudioSettings.GetConfiguration();

        config.dspBufferSize = (int)Math.Pow(2, Settings.Instance.DSPBufferSize);
        AudioSettings.Reset(config);
    }
示例#12
0
    ////////////////////////////////////////////////////////////////
    public void Start()
    {
        var audio_configuration = AudioSettings.GetConfiguration();

        audio_configuration.dspBufferSize = 512;
        AudioSettings.Reset(audio_configuration);

        m_InstanceID = NewInstance(audio_configuration.sampleRate);
        _EnableCompletedVoicePolling(true, m_InstanceID);

        var dummy = AudioClip.Create("dummy", 1, 1, AudioSettings.outputSampleRate, false);

        dummy.SetData(new float[] { 1 }, 0);

        AudioSource TargetSrc = GetComponent <AudioSource>();

        TargetSrc.clip         = dummy;
        TargetSrc.loop         = true;
        TargetSrc.spatialBlend = 1;
        TargetSrc.Play();

        m_bRunning = true;

        if (m_sTextToParse.Length > 0)
        {
            ParseString(m_sTextToParse);
            m_sTextToParse = "";
        }
    }
示例#13
0
    // public AudioSource c;

    // Use this for initialization
    void Start()
    {
        AudioConfiguration audio_config = AudioSettings.GetConfiguration();

        AudioSettings.Reset(audio_config);
        //  this.c.Play();
    }
示例#14
0
    //TODO Current changing AudioMode in runtime make crash sound. Waiting for fixed this by Unity team.
    /// <summary>
    /// Sets the general audio mode.
    /// </summary>
    /// <param name="value">Value of audio speaker mode.</param>
    public static void SetGeneralAudioMode(int value)
    {
        AudioConfiguration config = AudioSettings.GetConfiguration();

        switch (value)
        {
        case 1:
            config.speakerMode = AudioSpeakerMode.Mono;
            break;

        case 2:
            config.speakerMode = AudioSpeakerMode.Stereo;
            break;

        case 3:
            config.speakerMode = AudioSpeakerMode.Quad;
            break;

        case 4:
            config.speakerMode = AudioSpeakerMode.Surround;
            break;

        case 5:
            config.speakerMode = AudioSpeakerMode.Mode5point1;
            break;

        case 6:
            config.speakerMode = AudioSpeakerMode.Mode7point1;
            break;
        }

        AudioSettings.Reset(config);
    }
    /// <summary>
    /// Change default audio settings
    /// </summary>
    private static void AudioSettingsSetup()
    {
        // Change default speaker mode from Stereo to Quad
        AudioConfiguration audioConfiguration = AudioSettings.GetConfiguration();

        audioConfiguration.speakerMode = AudioSpeakerMode.Quad;
        AudioSettings.Reset(audioConfiguration);
    }
        private void SetAudioDSP()
        {
            //Pull DSP setting from config
            var configuration = AudioSettings.GetConfiguration();

            configuration.dspBufferSize = NSSettings.config.audioDSP;
            AudioSettings.Reset(configuration);
        }
示例#17
0
        public static void SetRecommendedAudioSettings()
        {
            AudioConfiguration audioConfiguration = AudioSettings.GetConfiguration();

            audioConfiguration.dspBufferSize = 0;
            audioConfiguration.sampleRate    = 0;
            audioConfiguration.speakerMode   = MetaSpeakerMode;
            AudioSettings.Reset(audioConfiguration);
        }
示例#18
0
    void SetDspBufferSize(int bufferLenfth)
    {
        var config = AudioSettings.GetConfiguration();

        config.dspBufferSize = bufferLenfth;
        AudioSettings.Reset(config);
        AudioSettings.GetDSPBufferSize(out int bufferLength, out int numBuffers);
        Debug.Log(string.Format("dspBufferLength: {0}, numBuffers: {1}", bufferLength, numBuffers));
    }
示例#19
0
    void ChangeMonoStereo(bool value)
    {
        this.stereoActivated = value;
        PlayerPrefs.SetInt("stereo_mode", value ? 1 : 0);
        AudioConfiguration audioConfiguration = AudioSettings.GetConfiguration();

        audioConfiguration.speakerMode = stereoActivated ? AudioSpeakerMode.Stereo : AudioSpeakerMode.Mono;
        AudioSettings.Reset(audioConfiguration);
    }
示例#20
0
        void OnDSPBufferSizeChanged(int value)
        {
            var audioConf = AudioSettings.GetConfiguration();

            audioConf.dspBufferSize = dspBufferSizeOptions.Values.ToArray()[value];
            if (!AudioSettings.Reset(audioConf))
            {
                Debug.LogError("Failed changing Audio Settings");
            }
        }
示例#21
0
文件: Audio.cs 项目: gimoz71/Elfi-VR
    /// <summary>Attempts to adjust settings for less latency</summary>
    void SetupGlobalAudio()
    {
        AudioConfiguration config = AudioSettings.GetConfiguration();

        config.dspBufferSize    = (int)Dsp_Buffer_Size;
        config.sampleRate       = 0;    //11025, 22050, 44100, 48000, 88200, 96000,
        config.numVirtualVoices = 1;    //1, 2, 4, 8, 16, 32, 50, 64, 100, 128, 256, 512,
        config.numRealVoices    = 1;    //1, 2, 4, 8, 16, 32, 50, 64, 100, 128, 256, 512,
        config.speakerMode      = AudioSpeakerMode.Mono;
        AudioSettings.Reset(config);
    }
示例#22
0
        void OnSpeakerModeChanged(int value)
        {
            var audioConf = AudioSettings.GetConfiguration();

            audioConf.speakerMode = (AudioSpeakerMode)value;
            Debug.Log(audioConf.speakerMode);
            if (!AudioSettings.Reset(audioConf))
            {
                Debug.LogError("Failed changing Audio Settings");
            }
        }
示例#23
0
        public AudioUnit(Emulator emulator) : base(emulator)
        {
            var audioConfig = AudioSettings.GetConfiguration();

            audioConfig.sampleRate    = SampleRate;
            audioConfig.dspBufferSize = SampleSize;

            audioSamples = new double[SampleSize];

            AudioSettings.Reset(audioConfig);
            emulator.GetComponent <AudioSource>().Play();
        }
示例#24
0
 /// <summary>
 /// Minimize the audio latency.
 /// 遅延量の最小化を行います。
 /// </summary>
 public static void Minimize()
 {
     IsMinimizing = true;
     Duration     = TimeDuration.Zero;
     foreach (var candidateSize in BufferSizeCandidates)
     {
         var config = AudioSettings.GetConfiguration();
         config.dspBufferSize = candidateSize;
         _ = AudioSettings.Reset(config);
     }
     IsMinimizing = false;
 }
示例#25
0
 void OnAudioConfigurationChanged(bool deviceWasChanged)
 {
     Debug.Log(deviceWasChanged ? "Device was changed" : "Reset was called");
     if (deviceWasChanged)
     {
         AudioConfiguration config = AudioSettings.GetConfiguration();
         config.dspBufferSize = 256;
         config.speakerMode   = AudioSpeakerMode.Mono;
         config.sampleRate    = 15360;
         AudioSettings.Reset(config);
     }
     GetComponent <AudioSource>().Play();
 }
示例#26
0
        public void Init(int sampleRate)
        {
            DeInit();

            AudioConfiguration audioConfig = AudioSettings.GetConfiguration();

            audioConfig.sampleRate = sampleRate;
            _ = AudioSettings.Reset(audioConfig);

            _audioSource      = GetComponent <AudioSource>();
            _audioSource.clip = AudioClip.Create("LibretroAudioClip", AUDIO_BUFFER_SIZE, 2, sampleRate, false);
            _audioSource.Play();
        }
示例#27
0
 public void InitAudioConfig()
 {
     initialAudioConfig = AudioSettings.GetConfiguration();
     AudioSettings.Reset(new AudioConfiguration {
         speakerMode      = AudioSpeakerMode.Stereo,
         dspBufferSize    = initialAudioConfig.dspBufferSize,
         sampleRate       = 96000,            // As high as possible
         numRealVoices    = 0,
         numVirtualVoices = 0,
     });
     initialAudioConfig = AudioSettings.GetConfiguration();
     Debug.Log("Init " + initialAudioConfig.dspBufferSize + " " + initialAudioConfig.sampleRate);
 }
示例#28
0
        public void ApplyAppAudioConfig()
        {
            Debug.Log("Apply " + appConfig.audioBufferUpscale + " " + appConfig.sampleRateDownscale);
            AudioSettings.Reset(new AudioConfiguration {
                speakerMode          = AudioSpeakerMode.Stereo,
                dspBufferSize        = initialAudioConfig.dspBufferSize << appConfig.audioBufferUpscale,
                    sampleRate       = initialAudioConfig.sampleRate >> appConfig.sampleRateDownscale,
                    numRealVoices    = initialAudioConfig.numRealVoices,
                    numVirtualVoices = initialAudioConfig.numVirtualVoices,
            });
            var audioConfig = AudioSettings.GetConfiguration();

            Debug.Log("Get " + audioConfig.dspBufferSize + " " + audioConfig.sampleRate);
        }
示例#29
0
        public override void OnApplicationStart()
        {
            AudioConfiguration a = AudioSettings.GetConfiguration();

            a.speakerMode = AudioSpeakerMode.Mode7point1;
            if (AudioSettings.Reset(a))
            {
                MelonModLogger.Log("Successful change");
            }
            else
            {
                MelonModLogger.LogError("Change failed");
            }
        }
示例#30
0
 void OnAudioConfigurationChanged(bool deviceWasChanged)
 {
     Debug.Log(deviceWasChanged ? "Device was changed" : "Reset was called");
     if (deviceWasChanged)
     {
         ///returns the current configuration of the audio device and System
         AudioConfiguration config = AudioSettings.GetConfiguration();
         config.dspBufferSize = 64;
         //resetting the dspbuffersize using config and then resetting
         AudioSettings.Reset(config);
     }
     //calls up the audio file
     GetComponent <AudioSource>().Play();
 }