AudioRecorder

Show Deprecated
Not Browsable

AudioRecorder records audio streams in-experience with a fixed time limit of 60 seconds. The results can be loaded into an AudioPlayer for playback.

At this time, AudioDeviceInput cannot be recorded. The GetUnrecordableInstancesAsync() method can be used to check specifically which instances aren't recordable.

Code Samples

Audio Recorder

local Workspace = game:GetService("Workspace")
local audioRecorder = Instance.new("AudioRecorder")
audioRecorder.Parent = Workspace
local audioPlayer = Instance.new("AudioPlayer")
audioPlayer.Asset = "rbxassetid://1839825437"
audioPlayer.Volume = 0.8
audioPlayer.Parent = Workspace
-- Wire AudioPlayer into the AudioRecorder
local wire1 = Instance.new("Wire")
wire1.SourceInstance = audioPlayer
wire1.TargetInstance = audioRecorder
wire1.Parent = audioRecorder
-- There is no exact way to determine when audio buffer enters in to trigger the recording properly
-- Recording will have pre-head empty silence compared to the original asset
audioPlayer:Play()
audioRecorder:RecordAsync() -- Start recording the AudioPlayer
print("Recording...")
task.wait(5)
audioRecorder:Stop() -- Stop recording
print("Stopped recording!")
audioPlayer:Stop()
audioPlayer.TimePosition = 0
-- Create output to listen the results
local audioOutput = Instance.new("AudioDeviceOutput")
audioOutput.Parent = Workspace
local wire2 = Instance.new("Wire")
wire2.SourceInstance = audioPlayer
wire2.TargetInstance = audioOutput
wire2.Parent = audioOutput
-- Get the recorded content and play it in the AudioPlayer
local resultUri = audioRecorder:GetTemporaryContent().Uri
audioPlayer.Asset = resultUri
if not (audioPlayer.IsReady) then
audioPlayer:GetPropertyChangedSignal("IsReady"):Wait()
end
audioPlayer:Play()

Properties

IsRecording

Roblox Security
Read Parallel

Returns whether the AudioRecorder is currently recording.

TimeLength

Read Only
Not Replicated
Read Parallel

Returns the current length of the recording in seconds.

Methods

Clear

()

Clears out the recording from the AudioRecorder.


Returns

()

GetConnectedWires

Instances

Parameters

pin: string
Default Value: ""

Returns

Instances

GetInputPins


Returns

GetOutputPins


Returns

GetTemporaryContent

Returns recorded content that can be played back with AudioPlayer. The content retrieved from this method is only valid in the current session.


Returns

Stop

()

Stops recording.


Returns

()

CanRecordAsync

Yields

Returns whether the AudioRecorder can currently record. For instance, this will return false if the current recording data has reached the recording time limit. To clear the recording, use Clear().


Returns

GetUnrecordableInstancesAsync

Instances
Yields

Traverses the audio graph, starting from this recorder's inputs, to find unrecordable instances. Currently, AudioDeviceInput is not recordable.


Returns

Instances

RecordAsync

()
Yields

If CanRecordAsync() returns true, recording begins. If recording cannot begin, this method produces an error.


Returns

()

Events

WiringChanged

Parameters

connected: boolean
pin: string
wire: Wire
instance: Instance