AudioChannelSplitter

Hiển Thị Bản Đã Lỗi Thời

*Nội dung này được dịch bằng AI (Beta) và có thể có lỗi. Để xem trang này bằng tiếng Anh, hãy nhấp vào đây.

AudioChannelSplitter chia một dòng âm thanh thành các kênh thành phần để mỗi dòng có thể được xử lý độc lập.Nó cung cấp một đầu nhập , một đầu ra kết hợp , cũng như các đầu ra thứ cấp sau đây, tất cả đều có thể được kết nối với/từ bởi : Bên trái , Phía bên phải , Trung tâm , Xung quanhLeft , Xung quanhRight , Sub , Phía bên trái trên cùng , Phía bên phải trên cùng , TopLeft , TopRight , TopBackLeft , và TopBackRight .

Diagram showing position of all potential channels.

Mẫu mã

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

Tóm Tắt

Phương Pháp

Sự Kiện

Thuộc Tính

Đọc Song Song

Kiểm soát bố trí kênh nhập để phân tách.Khi thay đổi, tất cả các dòng âm thanh trước khi chia nhánh kênh này có thể cần được trộn lẫn (mở rộng đến ít nhất số kênh như yêu cầu nhập).

Chip ra Output sản xuất một bản sao của dòng chảy được kết nối với Input nhưng, tùy thuộc vào giá trị của AudioChannelSplitter.Layout

  • Đối với Mono , chốt Trung tâm sản xuất một luồng âm thanh.
  • Đối với Stereo , các điểm TráiPhải sản xuất dòng âm thanh.
  • Đối với Quad , Bên trái , Phải , BackLeftBackRight khóa sản xuất dòng âm thanh.
  • Surround_5 giống như Quad , cộng với Trung tâm sản xuất một luồng âm thanh.
  • Surround_5_1 giống như Surround_5 , cộng với Sub sản xuất một luồng âm thanh.
  • Surround_7_1 là giống như Surround_5_1 , cộng với SurroundLeftSurroundRight sản xuất dòng âm thanh.
  • Đối với Surround_7_1_4, tất cả các đầu ra thứ cấp sản xuất dòng âm thanh.

Phương Pháp

GetConnectedWires

Instances

Trả về một array của Wires được kết nối với chân được chỉ định.

Tham Số

pin: string
Giá Trị Mặc Định: ""

Lợi Nhuận

Instances

GetInputPins

Trả về một bảng chứa một chuỗi, "Input" , cho thấy đầu nối nhập có sẵn cho Wire.TargetName .


Lợi Nhuận

GetOutputPins

Trả về một bảng các chuỗi chỉ ra các đầu nối xuất có sẵn cho Wire.SourceName :

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

Lợi Nhuận

Sự Kiện

WiringChanged

Sự kiện xảy ra sau khi một Wire được kết nối hoặc mất kết nối, và sự kiện Wire bây giờ hoặc đã từng kết nối với một chốt trên AudioChannelSplitter và một số ví dụ khác có thể kết nối được.

Tham Số

connected: boolean

Whether ví dụ đã kết nối hay mất kết nối.

pin: string

Chốt trên AudioChannelSplitter mà mục tiêu Wire nhắm.

wire: Wire

Các Wire giữa AudioChannelSplitter và instance khác.

instance: Instance

Các ví dụ khác được kết nối thông qua Wire .