เรียนรู้
Engine Class
AudioChannelMixer

*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่


สรุป
คุณสมบัติ
เหตุการณ์
WiringChanged(connected: boolean,pin: string,wire: Wire,instance: Instance):RBXScriptSignal
สมาชิกที่ได้รับทอด
ตัวอย่างโค้ด
การแยกและผสมช่องเสียง
local Workspace = game:GetService("Workspace")
local function wireUp(source: Instance, target: Instance, sourceName: string?, targetName: string?)
local wire = Instance.new("Wire", source)
wire.SourceInstance = source
wire.TargetInstance = target
if sourceName then
wire.SourceName = sourceName
end
if targetName then
wire.TargetName = targetName
end
return wire
end
local listener = Instance.new("AudioListener")
listener.Parent = Workspace.CurrentCamera
local output = Instance.new("AudioDeviceOutput")
output.Parent = Workspace
local splitter = Instance.new("AudioChannelSplitter")
splitter.Parent = Workspace
local mixer = Instance.new("AudioChannelMixer")
mixer.Parent = Workspace
-- ส่งสิ่งที่ผู้ฟังได้ยินไปยังตัวแยกและส่งการผสมไปยังผลลัพธ์สุดท้าย
wireUp(listener, splitter)
wireUp(mixer, output)
-- ตั้งค่าทั้งตัวแยกและตัวผสมให้ใช้รูปแบบเสียงสี่ช่อง
splitter.Layout = Enum.AudioChannelLayout.Quad
mixer.Layout = Enum.AudioChannelLayout.Quad
-- ให้ช่องทั้งสี่ช่องมีการเปลี่ยนระดับเสียงของตัวเอง
local frontLeft = Instance.new("AudioPitchShifter")
frontLeft.Name = "Front Left"
frontLeft.Pitch = 1.25
frontLeft.Parent = Workspace
local backLeft = Instance.new("AudioPitchShifter")
backLeft.Name = "Back Left"
backLeft.Pitch = 0.5
backLeft.Parent = Workspace
local frontRight = Instance.new("AudioPitchShifter")
frontRight.Name = "Front Right"
frontRight.Pitch = 1.5
frontRight.Parent = Workspace
local backRight = Instance.new("AudioPitchShifter")
backRight.Name = "Back Right"
backRight.Pitch = 0.75
backRight.Parent = Workspace
wireUp(splitter, frontLeft, "Left")
wireUp(splitter, backLeft, "BackLeft")
wireUp(splitter, frontRight, "Right")
wireUp(splitter, backRight, "BackRight")
wireUp(frontLeft, mixer, nil, "Left")
wireUp(backLeft, mixer, nil, "BackLeft")
wireUp(frontRight, mixer, nil, "Right")
wireUp(backRight, mixer, nil, "BackRight")
-- ตั้งค่าชิ้นส่วนเพื่อให้เสียงออกมา
local part = Instance.new("Part")
part.Shape = Enum.PartType.Ball
part.Size = Vector3.new(4, 4, 4)
part.Material = Enum.Material.SmoothPlastic
part.CastShadow = false
part.Position = Vector3.new(0, 4, -12)
part.Anchored = true
part.Parent = Workspace
local analyzer = Instance.new("AudioAnalyzer")
analyzer.Parent = part
local emitter = Instance.new("AudioEmitter")
emitter.Parent = part
local assetPlayer = Instance.new("AudioPlayer")
assetPlayer.Looping = true
assetPlayer.Asset = "rbxassetid://97799489309320"
assetPlayer.Parent = emitter
wireUp(assetPlayer, emitter)
wireUp(assetPlayer, analyzer)
-- เริ่มเล่นเสียง
assetPlayer:Play()
-- ปรับสีของชิ้นส่วนขณะที่เสียงกำลังเล่น
while true do
local peak = math.sqrt(analyzer.PeakLevel)
part.Color = Color3.new(peak, peak, peak)
task.wait()
end

เอกสารอ้างอิงเกี่ยวกับ API
คุณสมบัติ
Layout
อ่านพร้อมๆ กัน
ความสามารถ: Audio
AudioChannelMixer.Layout:Enum.AudioChannelLayout

วิธีการ
GetConnectedWires
ความสามารถ: Audio
AudioChannelMixer:GetConnectedWires(pin:string):{Wire}
พารามิเตอร์
pin:string
ส่งค่ากลับ

GetInputPins
ความสามารถ: Audio
AudioChannelMixer:GetInputPins():{any}
ส่งค่ากลับ

GetOutputPins
ความสามารถ: Audio
AudioChannelMixer:GetOutputPins():{any}
ส่งค่ากลับ

เหตุการณ์
WiringChanged
ความสามารถ: Audio
AudioChannelMixer.WiringChanged(
connected:boolean, pin:string, wire:Wire, instance:Instance
พารามิเตอร์
connected:boolean
pin:string
wire:Wire
instance:Instance

©2026 Roblox Corporation. Roblox, โลโก้ Roblox และ Powering Imagination เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ