コード例 #1
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();
            }
        }
コード例 #2
0
        private void CreateInputReadDsp()
        {
            this.callback = this.ReadCallback;

            var dspdesc = new DSP_DESCRIPTION();

            dspdesc.numinputbuffers = 1;
            dspdesc.numoutputbuffers = 1;
            dspdesc.read = this.callback;

            this.fmodSystem.createDSP(ref dspdesc, out this.recordDsp);
        }