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.

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)

概要

プロパティ

  • 並列読み取り

    オーディオストリームがこの効果に影響を受けずに通過するかどうか。

  • 複製されていません
    Robloxのスクリプトセキュリティ
    並列読み取り
  • フィルターで表現されるバンドのカーブタイプ。

  • 並列読み取り

    フィルターが周りに行う中央周波数。

  • 並列読み取り

    ピークとシェルフィルターの場合、コントロールボリュームの増加または減少。

  • 並列読み取り

    ピーク、低パス、高パス、バンドパス、ノッチフィルターの場合、選択性または共鳴を制御します。

方法

イベント

プロパティ

Bypass

並列読み取り

如果 true 、オーディオストリームはこの効果によって影響を受けずに通過します。

Editor

複製されていません
Robloxのスクリプトセキュリティ
並列読み取り
並列読み取り

オーディオシグナルをフィルタするために使用される周波数応答曲線の種類。各種のカーブは、オーディオの周波数コンテンツを異なる方法で影響します。

Frequency

並列読み取り

フィルターによって表現される曲線の中央周波数。一般的に、この値を上下調整することは、全体の頻度曲線の横移に相当します。20から22000までの範囲。

Gain

並列読み取り

フィルターで表現される曲線のボリュームレベルを決定するのに使用されるデシベルの獲得値。適用されるのは、FilterTypePeakLowShelf 、または HighShelf のときだけです。-30から30までの範囲。

並列読み取り

フィルターで表現される曲線の傾きまたは共鳴値を決定するために使用される品質値。適用されるのは、FilterTypePeakLowpass[x]dBHighpass[x]dBBandpass 、または Notch のときだけです。0.1から 10までの範囲。

For FilterType 値の Lowpass12dBHighpass12dBQ 値の sqrt(2) / 2 または 0.707 は、12dB/オクターブのスロープでフラットフィルタに相当します。

方法

GetConnectedWires

Instances

指定されたピピン留めに接続された Wires のアレイを返します。AudioFilter には「入力」ピンと「出力」ピピン留めが 1 つずつあります。

パラメータ

pin: string
既定値: ""

戻り値

Instances

GetGainAt

フィルタで指定された周波数で表される周波応答曲線の、ゲイン値、デシベルで返します。Returns the gain value, in decibels, of the frequency response curve represented by the filter at the given frequency, in hertz.これを使用して、キープレースや全体でフィルターの正確な形状をサンプルすることができます。

パラメータ

frequency: number

サンプルする頻度、ヘルツで。

既定値: ""

戻り値

指定された周波数で、デシベルでの獲得値。

GetInputPins


戻り値

GetOutputPins


戻り値

イベント

WiringChanged

Wire が接続または切断された後に発生するイベント、および Wire が現在または以前に AudioFilter および他のワイヤー可能なインスタンスのピンに接続されているか、接続されていました。

パラメータ

connected: boolean

インスタンスが接続されたか、切断されたか。

pin: string

ターゲットの AudioFilter にピンを打った Wire

wire: Wire

Wire と他のインスタンスの間の AudioFilter

instance: Instance

Wire を介して接続された他のインスタンス。