เรียนรู้
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 = "ด้านหน้า ซ้าย"
frontLeft.Pitch = 1.25
frontLeft.Parent = Workspace
local backLeft = Instance.new("AudioPitchShifter")
backLeft.Name = "ด้านหลัง ซ้าย"
backLeft.Pitch = 0.5
backLeft.Parent = Workspace
local frontRight = Instance.new("AudioPitchShifter")
frontRight.Name = "ด้านหน้า ขวา"
frontRight.Pitch = 1.5
frontRight.Parent = Workspace
local backRight = Instance.new("AudioPitchShifter")
backRight.Name = "ด้านหลัง ขวา"
backRight.Pitch = 0.75
backRight.Parent = Workspace
wireUp(splitter, frontLeft, "ซ้าย")
wireUp(splitter, backLeft, "ด้านหลังซ้าย")
wireUp(splitter, frontRight, "ขวา")
wireUp(splitter, backRight, "ด้านหลังขวา")
wireUp(frontLeft, mixer, nil, "ซ้าย")
wireUp(backLeft, mixer, nil, "ด้านหลังซ้าย")
wireUp(frontRight, mixer, nil, "ขวา")
wireUp(backRight, mixer, nil, "ด้านหลังขวา")
-- กำหนดค่าชิ้นส่วนเพื่อปล่อยเสียง
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 เป็นส่วนหนึ่งของเครื่องหมายการค้าที่จดทะเบียน และไม่ได้จดทะเบียนของเราในสหรัฐฯ และประเทศอื่นๆ