AudioChannelMixer

顯示已棄用項目

*此內容是使用 AI(Beta 測試版)翻譯,可能含有錯誤。若要以英文檢視此頁面,請按一下這裡

AudioChannelMixer 將多個音頻流混合為單個、多通道音頻流。它提供一個結合的 輸入 頂針、一個 輸出 頂針以及以下的次要輸入頂針,所有這些都可以由 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

概要

方法

活動

屬性

平行讀取

控制輸出通道布局要混合的。 輸入 頂針的AudioChannelMixer總是「原樣」傳送到 輸出 ,但取決於Layout的值:

  • 對於 Mono , 中心 彈簧消耗音頻流。
  • 對於 Stereo , 彈簧消耗音頻流。
  • 對於 Quad , , , 返回左侧返回右侧 彈簧消耗音頻流。
  • Surround_5Quad 相同, plus 中心 消耗音頻流。
  • Surround_5_1Surround_5 相同, plus 消耗音訊流。
  • Surround_7_1Surround_5_1 相同,加上 SurroundLeftSurroundRight 消耗音頻流。
  • 對於 Surround_7_1_4 ,所有次要輸入彈簧都會消耗音頻流。

方法

GetConnectedWires

Instances

返回連接到指定頂針的一個 Wires 陣列。

參數

pin: string
預設值:""

返回

Instances

GetInputPins

返回一個表示哪些輸入彈簧可用於 Wire.TargetName 的字串表:

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

返回

GetOutputPins

返回包含一個字串的表, "Output" , 指示可用於 Wire.SourceName 的輸出頂置。


返回

活動

WiringChanged

Wire 連接或解除連接後發生的事件,該 Wire 現在或之前已連接到 AudioChannelMixer 上的某個彈片或其他可連接的實例。

參數

connected: boolean

是否連接或解除連接實例。

pin: string

AudioChannelMixer 上的彈簧,用於 Wire 目標。

wire: Wire

之間的 WireAudioChannelMixer 和其他實例之間。

instance: Instance

通過 Wire 連接的另一個實例,或是已連接的實例。