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(); } }
public override void EndRecording(RecordingSession session) { if (audioSettings.m_PreserveAudio) { AudioRenderer.Stop(); } }
protected internal override void NewFrameReady(RecordingSession session) { if (!audioSettings.PreserveAudio) { return; } if (s_Handler == null) { s_Handler = this; } if (s_Handler == this) { var sampleFrameCount = AudioRenderer.GetSampleCountForCaptureFrame(); if (RecorderOptions.VerboseMode) { Debug.Log(string.Format("AudioInput.NewFrameReady {0} audio sample frames @ {1} ch", sampleFrameCount, m_ChannelCount)); } const ushort bufferCount = 1; if (s_BufferManager != null) { s_BufferManager.Dispose(); } s_BufferManager = new BufferManager(bufferCount, sampleFrameCount, m_ChannelCount); AudioRenderer.Render(mainBuffer); } }
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(); } }
public override void EndRecording(RecordingSession session) { if (s_BufferManager != null) { s_BufferManager.Dispose(); s_BufferManager = null; } s_Handler = null; if (audioSettings.preserveAudio) { AudioRenderer.Stop(); } }
public override void NewFrameReady(RecordingSession session) { if (!audioSettings.m_PreserveAudio) { return; } var sampleFrameCount = (uint)AudioRenderer.GetSampleCountForCaptureFrame(); if (Verbose.enabled) { Debug.Log(string.Format("AudioInput.NewFrameReady {0} audio sample frames @ {1} ch", sampleFrameCount, m_ChannelCount)); } ushort bufferCount = #if RECORD_AUDIO_MIXERS (ushort)(audioSettings.m_AudioMixerGroups.Length + 1) #else 1 #endif ; m_BufferManager = new BufferManager(bufferCount, sampleFrameCount, m_ChannelCount); var mainBuffer = m_BufferManager.GetBuffer(0); #if RECORD_AUDIO_MIXERS for (int n = 1; n < bufferCount; n++) { var group = audioSettings.m_AudioMixerGroups[n - 1]; if (group.m_MixerGroup == null) { continue; } var buffer = m_BufferManager.GetBuffer(n); AudioRenderer.AddMixerGroupRecorder(group.m_MixerGroup, buffer, group.m_Isolate); } #endif AudioRenderer.Render(mainBuffer); }
protected internal override void EndRecording(RecordingSession session) { if (s_BufferManager != null) { s_BufferManager.Dispose(); s_BufferManager = null; } if (s_Handler == null) { return; } s_Handler = null; if (audioSettings.PreserveAudio) { AudioRenderer.Stop(); } }