요약
메서드
GetConnectedWires(pin: string):{Wire} |
이벤트
WiringChanged(connected: boolean,pin: string,wire: Wire,instance: Instance):RBXScriptSignal |
상속된 멤버
코드 샘플
채널 분리 및 혼합
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
-- 리스너가 듣는 것을 분리기(splitter)로 보내고 혼합(mix)을 최종 출력(output)으로 전송
wireUp(listener, splitter)
wireUp(mixer, output)
-- 분리기와 혼합기를 4채널 레이아웃으로 설정
splitter.Layout = Enum.AudioChannelLayout.Quad
mixer.Layout = Enum.AudioChannelLayout.Quad
-- 각각의 4개의 채널에 고유의 피치 시프터를 부여
local frontLeft = Instance.new("AudioPitchShifter")
frontLeft.Name = "앞쪽 왼쪽"
frontLeft.Pitch = 1.25
frontLeft.Parent = Workspace
local backLeft = Instance.new("AudioPitchShifter")
backLeft.Name = "뒤쪽 왼쪽"
backLeft.Pitch = 0.5
backLeft.Parent = Workspace
local frontRight = Instance.new("AudioPitchShifter")
frontRight.Name = "앞쪽 오른쪽"
frontRight.Pitch = 1.5
frontRight.Parent = Workspace
local backRight = Instance.new("AudioPitchShifter")
backRight.Name = "뒤쪽 오른쪽"
backRight.Pitch = 0.75
backRight.Parent = Workspace
wireUp(splitter, frontLeft, "왼쪽")
wireUp(splitter, backLeft, "뒤쪽 왼쪽")
wireUp(splitter, frontRight, "오른쪽")
wireUp(splitter, backRight, "뒤쪽 오른쪽")
wireUp(frontLeft, mixer, nil, "왼쪽")
wireUp(backLeft, mixer, nil, "뒤쪽 왼쪽")
wireUp(frontRight, mixer, nil, "오른쪽")
wireUp(backRight, mixer, nil, "뒤쪽 오른쪽")
-- 오디오를 방출(emission)할 부분(part) 구성
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)
-- 오디오 재생 시작
assetPlayer:Play()
-- 오디오가 재생됨에 따라 부분(part)의 색깔 조정
while true do
local peak = math.sqrt(analyzer.PeakLevel)
part.Color = Color3.new(peak, peak, peak)
task.wait()
endAPI 참조
속성
메서드
이벤트