AudioFilter
*このコンテンツは、ベータ版のAI(人工知能)を使用して翻訳されており、エラーが含まれている可能性があります。このページを英語で表示するには、 こちら をクリックしてください。
AudioFilter オーディオストリームの頻度コンテンツを調整します。それは 1 つの 入力 ピンと 1 つの 出力 ピンを提供し、Wires に接続できます/接続できます。 は、 、 、および のプロパティを使用して、特定のカットオフ周りで何をすべきかを決定します。
コードサンプル
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
オーディオシグナルをフィルタするために使用される周波数応答曲線の種類。各種のカーブは、オーディオの周波数コンテンツを異なる方法で影響します。
Gain
フィルターで表現される曲線のボリュームレベルを決定するのに使用されるデシベルの獲得値。適用されるのは、FilterType が Peak、LowShelf 、または HighShelf のときだけです。-30から30までの範囲。
フィルターで表現される曲線の傾きまたは共鳴値を決定するために使用される品質値。適用されるのは、FilterType が Peak 、Lowpass[x]dB 、Highpass[x]dB 、Bandpass 、または Notch のときだけです。0.1から 10までの範囲。
For FilterType 値の Lowpass12dB と Highpass12dB 、 Q 値の sqrt(2) / 2 または 0.707 は、12dB/オクターブのスロープでフラットフィルタに相当します。
方法
GetConnectedWires
指定されたピピン留めに接続された Wires のアレイを返します。AudioFilter には「入力」ピンと「出力」ピピン留めが 1 つずつあります。
パラメータ
戻り値
GetGainAt
フィルタで指定された周波数で表される周波応答曲線の、ゲイン値、デシベルで返します。Returns the gain value, in decibels, of the frequency response curve represented by the filter at the given frequency, in hertz.これを使用して、キープレースや全体でフィルターの正確な形状をサンプルすることができます。
パラメータ
サンプルする頻度、ヘルツで。
戻り値
指定された周波数で、デシベルでの獲得値。
イベント
WiringChanged
Wire が接続または切断された後に発生するイベント、および Wire が現在または以前に AudioFilter および他のワイヤー可能なインスタンスのピンに接続されているか、接続されていました。