AudioFilter 오디오 스트림의 주파수 콘텐츠를 조정합
코드 샘플
An AudioFilter can be used to change the frequency content of audio streams. In this example, an AudioFilter is used to make the AudioEmitter output more muffled when there's a wall between it and the AudioListener.
-- This assumes the workspace contains a Part with an AudioEmitter and an AudioPlayer, and the camera has an AudioListener
local RunService = game:GetService("RunService")
local part: BasePart = workspace.Part
local camera: Camera = workspace.CurrentCamera
local audioPlayer: AudioPlayer = part.AudioPlayer
local audioEmitter: AudioEmitter = part.AudioEmitter
local audioListener: AudioListener = camera.AudioListener
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {audioEmitter.Parent}
raycastParams.FilterType = Enum.RaycastFilterType.Exclude
-- Create a new AudioFilter
local filter: AudioFilter = Instance.new("AudioFilter")
filter.FilterType = Enum.AudioFilterType.Lowpass12dB
filter.Frequency = 22000
filter.Q = math.sqrt(2) / 2 -- This Q value produces a flat lowpass for the 12dB slope type
filter.Parent = part
-- Put the AudioFilter between the player and the emitter
local function wireTo(source: Instance, target: Instance): Wire
local wire = Instance.new("Wire")
wire.SourceInstance = source
wire.TargetInstance = target
wire.Parent = target
end
wireTo(audioPlayer, filter)
wireTo(filter, audioEmitter)
-- Update the filter based on the positions of the emitter and listener
RunService.Heartbeat:Connect(function()
local emitterPos: Vector3 = part.Position
local listenerPos: Vector3 = camera.CFrame.Position
local raycastResult = workspace:Raycast(emitterPos, (listenerPos - emitterPos), raycastParams)
filter.Frequency = if raycastResult then 500 else 22000
end)
요약
속성
오디오 스트림이 이 효과로 인해 전달되는지 여부.
필터에 의해 표시되는 밴드의 곡선 형식입니다.
필터가 작동하는 중앙 주파수.
정상화 및 진열 필터에 대해 컨트롤 볼륨 증가 또는 감소.
피크, 로우패스, 하이패스, 밴드패스 및 노치 필터에 대해 선택성 또는 공진을 조정합니다.
메서드
지정된 핀하다연결된 Wires 배열을 반환합니다.
지정된 주파수에 대한 필터의 대응 크기를 반환합니다.
속성
Editor
FilterType
오디오 신호를 필터링하는 데 사용할 횟수 응답 곡선의 유형입니다. 각 횟수 곡선은 오디오 콘텐츠의 주파수 콘텐츠를 다르게 영향을 미칩니다.
Frequency
필터가 표시하는 곡선의 중앙 주파수. 일반적으로 이 값을 위쪽이나 아래쪽으로 조정하면 전체 주파수 곡선에 대한 가로 이동이 일어납니다. 범위는 20에서 22000입니다.
Gain
필터에 표시된 곡선의 볼륨 수준을 결정하는 데 사용되는 데시벨 단위의 얻는 값입니다. 필터가 FilterType 이거나 Peak 또는 LowShelf 인 경우에만 적용됩니다. 범위는 -30에서 30입니다.
필터에 표시된 곡선의 경사나 공진을 결정하는 품질 값입니다. FilterType 이 Peak, Lowpass[x]dB, 2>Highpass[x]dB2>, 5>Bandpass
For FilterType 값의 Lowpass12dB 및 Highpass12dB , a
메서드
GetConnectedWires
지정된 핀하다연결된 Wires 배열을 반환합니다. AudioFilter 에는 하나의 "입력" 핀과 하나의 "출력" 핀하다있습니다.