AudioChannelMixer

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.

AudioChannelMixer hỗn hợp nhiều luồng âm thanh thành một luồng đơn, nhiều kênh.Nó cung cấp một đầu vào kết hợp Input pin, một đầu ra Output pin, cũng như các đầu nhập thứ cấp sau, tất cả đều có thể 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 , Bên trái trên cùng , Bên phải trên cùng , Phía trên cùng bên trái , và Phía trên cùng bên phải .

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

Thuộc Tính

Phương Pháp

Sự Kiện

Thuộc Tính

Đọc Song Song

Kiểm soát bố trí kênh xuất được trộn vào.Chân Nhập của AudioChannelMixer luôn được chuyển "như là" đến Xuất nhưng tùy thuộc vào giá trị của Layout:

  • Đối với Mono, chân cắm Trung tâm tiêu thụ dòng âm thanh.
  • Đối với Stereo , các điểm TráiPhải tiêu thụ dòng âm thanh.
  • Đối với Quad , Bên trái , Phải , BackLeftBackRight khóa không tiêu thụ dòng âm thanh.
  • Surround_5 giống như Quad , cộng với Trung tâm tiêu thụ một luồng âm thanh.
  • Surround_5_1 giống như Surround_5 , cộng với Sub tiêu thụ một luồng âm thanh.
  • Surround_7_1 là giống như Surround_5_1 , cộng với SurroundLeftSurroundRight tiêu thụ dòng audio.
  • Đối với Surround_7_1_4, tất cả các đầu nối nhập thứ cấp tiêu thụ 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 các chuỗi chỉ ra các đầu nối nhập có sẵn cho Wire.TargetName :

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

Lợi Nhuận

GetOutputPins

Trả về một bảng chứa một chuỗi, "Output" , cho thấy chốt xuất có sẵn cho Wire.SourceName .


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 AudioChannelMixer 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 AudioChannelMixer mà mục tiêu Wire nhắm.

wire: Wire

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

instance: Instance

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