Exemplo n.º 1
0
        public override void BeginRecording(RecordingSession session)
        {
            m_ChannelCount = new Func <ushort>(() => {
                switch (AudioSettings.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(7);

                case AudioSpeakerMode.Prologic:    return(2);

                default: return(1);
                }
            })();

            if (Verbose.enabled)
            {
                Debug.Log(string.Format(
                              "AudioInput.BeginRecording for capture frame rate {0}", Time.captureFramerate));
            }

            if (audioSettings.m_PreserveAudio)
            {
                AudioRenderer.Start();
            }
        }
Exemplo n.º 2
0
        protected internal override void BeginRecording(RecordingSession session)
        {
            var dspName = "RecordSessionVideo(Audio)".ToCharArray();

            Array.Resize(ref dspName, 32);
            dspCallback = DspReadCallback;
            var dspDescription = new DSP_DESCRIPTION
            {
                version          = 0x00010000,
                name             = dspName,
                numinputbuffers  = 1,
                numoutputbuffers = 1,
                read             = dspCallback,
                numparameters    = 0
            };

            FMOD.System system = RuntimeManager.CoreSystem;
            CheckError(system.getMasterChannelGroup(out ChannelGroup masterGroup));
            CheckError(masterGroup.getDSP(CHANNELCONTROL_DSP_INDEX.TAIL, out DSP masterDspTail));
            CheckError(masterDspTail.getChannelFormat(out CHANNELMASK channelMask, out int numChannels,
                                                      out SPEAKERMODE sourceSpeakerMode));

            if (RecorderOptions.VerboseMode)
            {
                Debug.Log(
                    $"(UnityRecorder) Listening to FMOD Audio. Setting DSP to [{channelMask}] [{numChannels}] [{sourceSpeakerMode}]");
            }

            // Create a new DSP with the format of the existing master group.
            CheckError(system.createDSP(ref dspDescription, out dsp));
            CheckError(dsp.setChannelFormat(channelMask, numChannels, sourceSpeakerMode));
            CheckError(masterGroup.addDSP(CHANNELCONTROL_DSP_INDEX.TAIL, dsp));

            // Fill in some basic information for the Unity audio encoder.
            mChannelCount = (ushort)numChannels;
            CheckError(system.getDriver(out int driverId));
            CheckError(system.getDriverInfo(driverId, out Guid _, out int systemRate, out SPEAKERMODE _, out int _));
            mSampleRate = systemRate;

            if (RecorderOptions.VerboseMode)
            {
                Debug.Log($"FmodAudioInput.BeginRecording for capture frame rate {Time.captureFramerate}");
            }

            if (audioSettings.PreserveAudio)
            {
                AudioRenderer.Start();
            }
        }