AudioChannelSplitter

显示已弃用

*此内容使用人工智能(Beta)翻译,可能包含错误。若要查看英文页面,请点按 此处

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

Diagram showing position of all potential channels.

代码示例

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

概要

方法

活动

属性

读取并联

控制要分离的输入通道布局。更改时,此通道分割器的输入之前的所有音频流可能需要升级(至少与输入要求相同的频道数量)。

输出 pin 生成了连接到 输入 的流的副本,但取决于AudioChannelSplitter.Layout的值:

  • 对于 Mono , 中心 **** 钉产生了一个音频流。
  • 对于 Stereo , 钉子产生音频流。
  • 对于 Quad , 左侧 , 右侧 , 返回左侧 , 和 返回右侧 钉产生音频流。
  • Surround_5Quad 相同, plus 中心 产生音频流。
  • Surround_5_1Surround_5 相同, plus 子串 产生音频流。
  • Surround_7_1Surround_5_1 相同, plus SurroundLeftSurroundRight 产生音频流。
  • 对于 Surround_7_1_4 , 所有次要输出端口都会生成音频流。

方法

GetConnectedWires

Instances

返回与指定的引脚连接的 Wires 阵列。

参数

pin: string
默认值:""

返回

Instances

GetInputPins

返回包含一个字符串的表,"Input",表示可用于 Wire.TargetName 的输入端钮。


返回

GetOutputPins

返回一个表示哪些输出钮可用于 Wire.SourceName 的字符串表:

  • "Output"
  • "Left"
  • "Right"
  • "Center"
  • "SurroundLeft"
  • "SurroundRight"
  • "BackLeft"
  • "BackRight"
  • "Sub"
  • "TopLeft"
  • "TopRight"
  • "TopBackLeft"
  • "TopBackRight"

返回

活动

WiringChanged

Wire 连接或断开后发生的事件,该 Wire 现在或之前已连接到 AudioChannelSplitter 上的某个引脚或其他可连接的实例。

参数

connected: boolean

实例是否连接或断开。

pin: string

AudioChannelSplitter 上的按钮,用于 Wire 目标。

wire: Wire

之间的 Wire 和其他实例之间的 AudioChannelSplitter

instance: Instance

连接到 Wire 通过的另一个实例。