AudioChannelMixer

Tampilkan yang Tidak Digunakan Lagi

*Konten ini diterjemahkan menggunakan AI (Beta) dan mungkin mengandung kesalahan. Untuk melihat halaman ini dalam bahasa Inggris, klik di sini.

AudioChannelMixer mencampur beberapa aliran audio menjadi satu aliran multichannel.Ini menyediakan satu kombinasi Input pin, satu Output pin, serta pins input sekunder berikut, semua yang dapat terhubung ke/dari oleh Wires : Kiri , Kanan , Tengah , SekitarKiri , SekitarKanan , Sub , BelakangKiri , BelakangKanan , TopLeft , TopRight , TopBackLeft , dan TopBackRight .

Diagram showing position of all potential channels.

Contoh Kode

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

Rangkuman

Properti

Metode

Acara

Properti

Baca Paralel

Mengontrol tata letak saluran output untuk dicampur.Pin Input dari AudioChannelMixer selalu diteruskan "sebagai adanya" ke Output , tetapi tergantung pada nilai Layout :

  • Untuk Mono , pin Pusat mengkonsumsi aliran audio.
  • Untuk Stereo , kancing Kiri dan Kanan mengkonsumsi aliran audio.
  • Untuk Quad , Kiri , Kanan , BackLeft , dan BackRight pins mengkonsumsi aliran audio.
  • Surround_5 adalah sama dengan Quad , ditambah Pusat mengkonsumsi aliran audio.
  • Surround_5_1 adalah sama dengan Surround_5 , ditambah Sub mengkonsumsi aliran audio.
  • Surround_7_1 adalah sama dengan Surround_5_1 , ditambah SurroundLeft dan SurroundRight mengkonsumsi aliran audio.
  • Untuk Surround_7_1_4 , semua pin input sekunder mengkonsumsi aliran audio.

Metode

GetConnectedWires

Instances

Kembalikan array dari Wires yang terhubung ke pin yang ditentukan.

Parameter

pin: string
Nilai Default: ""

Memberikan nilai

Instances

GetInputPins

Kembalikan tabel string yang menunjukkan pin input mana yang tersedia untuk Wire.TargetName :

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

Memberikan nilai

GetOutputPins

Kembalikan tabel yang berisi satu string, "Output" , menunjukkan pin output yang tersedia untuk Wire.SourceName .


Memberikan nilai

Acara

WiringChanged

Peristiwa yang menembak setelah Wire terhubung atau terputus, dan bahwa Wire sekarang atau sebelumnya terhubung ke pin di AudioChannelMixer dan ke beberapa instansi lain yang dapat ditransmisikan.

Parameter

connected: boolean

Apakah instansi terhubung atau terputus.

pin: string

Pin pada AudioChannelMixer yang menjadi target Wire .

wire: Wire

The Wire antara AudioChannelMixer dan instansi lainnya.

instance: Instance

Instansi lain yang terhubung atau terhubung melalui Wire .