AudioFilter 調整音頻流的頻率內容。提供一個 輸入</
範例程式碼
Emitter Filtering
-- 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 是 Peak、Lowpass[x]dB、2>Highpass[x]dB2>、5>Bandpass
對於 FilterType 值的 Lowpass12dB 和 Highpass12dB , 1>