Engine Class
AudioRecorder
Summary
Properties
Methods
Clear():() |
GetConnectedWires(pin: string):{Wire} |
RecordAsync():() |
Stop():() |
Events
WiringChanged(connected: boolean,pin: string,wire: Wire,instance: Instance):RBXScriptSignal |
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://5829815715"
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()API Reference
Properties
Methods
Clear
AudioRecorder:Clear():()
Returns
()
GetConnectedWires
GetUnrecordableInstancesAsync
RecordAsync
AudioRecorder:RecordAsync():()
Returns
()
Stop
AudioRecorder:Stop():()
Returns
()
Events