AudioChannelSplitter 将音频流拆分为组件通道,以便每个独立处理。它提供一个 输入 接口、一个组合的 输出 接口以及以下的次要输出接口,所有这些都可以通过 Wires : 左侧 , 右侧 , 中心 , 环绕左侧 , 环绕右侧 , 子接口 , 左背部 , 右背部 , 顶部左侧 , 顶部右侧 , 顶部左侧 , 以及 顶部右侧 .

代码示例
Splitting & Mixing Channels
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
-- Send what the listener hears to a splitter and send a mix to the final output
wireUp(listener, splitter)
wireUp(mixer, output)
-- Set up both the splitter and mixer to use a quadrophonic layout
splitter.Layout = Enum.AudioChannelLayout.Quad
mixer.Layout = Enum.AudioChannelLayout.Quad
-- Give each of the four channels its own pitch shifter
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")
-- Configure a part to emit audio
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)
-- Start playing the audio
assetPlayer:Play()
-- Adjust the part's color as the audio plays
while true do
local peak = math.sqrt(analyzer.PeakLevel)
part.Color = Color3.new(peak, peak, peak)
task.wait()
end
概要
方法
返回与指定的引脚连接的 Wires 阵列。
返回可用于 Wire.TargetName 的输入端子。
返回可由 Wire.SourceName 选择的输出端子。
活动
当另一个实例通过 AudioChannelSplitter 连接到或与 Wire 断开时发生火焰。
属性
Layout
控制要分离的输入通道布局。更改时,此通道分割器的输入之前的所有音频流可能需要升级(至少与输入要求相同的频道数量)。
输出 pin 生成了连接到 输入 的流的副本,但取决于AudioChannelSplitter.Layout的值:
- 对于 Mono , 中心 **** 钉产生了一个音频流。
- 对于 Surround_7_1_4 , 所有次要输出端口都会生成音频流。
方法
GetOutputPins
返回一个表示哪些输出钮可用于 Wire.SourceName 的字符串表:
- "Output"
- "Left"
- "Right"
- "Center"
- "SurroundLeft"
- "SurroundRight"
- "BackLeft"
- "BackRight"
- "Sub"
- "TopLeft"
- "TopRight"
- "TopBackLeft"
- "TopBackRight"
返回
活动
WiringChanged
在 Wire 连接或断开后发生的事件,该 Wire 现在或之前已连接到 AudioChannelSplitter 上的某个引脚或其他可连接的实例。