AudioEqualizer

非推奨を表示
閲覧できません

AudioEqualizer adjusts the frequency content of audio streams. It provides one Input pin and one Output pin which can be connected to/from by Wires. AudioEqualizer has 3 frequency bands whose gain values can be controlled, and the crossover points between bands can be moved.

コードサンプル

Listener Equalization

local function wireUp(source: Instance, target: Instance) : Wire
local wire = Instance.new("Wire")
wire.Parent = target
wire.SourceInstance = source
wire.TargetInstance = target
return wire
end
local function getCFrameFrom(inst: Instance) : CFrame?
local parent = inst.Parent
if not parent then
return nil
elseif parent:IsA("Model") then
return parent.WorldPivot
elseif parent:IsA("BasePart") then
return parent.CFrame
elseif parent:IsA("Attachment") then
return parent.WorldCFrame
elseif parent:IsA("Camera") then
return parent.CFrame
else
return nil
end
end
local function rescale(value: number, oldRange: NumberRange, newRange: NumberRange) : number
local clamped = math.clamp(value, oldRange.Min, oldRange.Max)
local normalized = clamped - oldRange.Min / (oldRange.Max - oldRange.Min)
return normalized * (newRange.Max - newRange.Min) + newRange.Min
end
local assetPlayer = Instance.new("AudioPlayer")
assetPlayer.AssetId = "rbxassetid://142376088"
assetPlayer.Parent = workspace
local equalizer = Instance.new("AudioEqualizer")
equalizer.MidRange = NumberRange.new(400, 3000)
equalizer.Parent = workspace
local emitterPart = Instance.new("Part")
emitterPart.Anchored = true
emitterPart.Position = Vector3.new(0, 5, 0)
emitterPart.Parent = workspace
local emitter = Instance.new("AudioEmitter")
emitter.Parent = emitterPart
local listener = Instance.new("AudioListener")
listener.Parent = workspace.CurrentCamera
local output = Instance.new("AudioDeviceOutput")
output.Parent = workspace
wireUp(assetPlayer, equalizer)
wireUp(equalizer, emitter)
wireUp(listener, output)
assetPlayer.Looping = true
assetPlayer:Play()
while true do
local emitterFrame = getCFrameFrom(emitter)
local listenerFrame = getCFrameFrom(listener)
if emitterFrame and listenerFrame then
local towardEmitter = emitterFrame.Position - listenerFrame.Position
local look = towardEmitter.Unit:Dot(listenerFrame.LookVector) -- ranges from [-1, 1]
look = rescale(look, NumberRange.new(-1, 1), NumberRange.new(-20, 0))
local distance = math.max(towardEmitter.Magnitude, 1)
local rolloff = 1 / distance -- ranges from [0, 1]
rolloff = rescale(rolloff, NumberRange.new(0, 1), NumberRange.new(-10, 10))
equalizer.HighGain = look + rolloff
equalizer.LowGain = rolloff
end
task.wait()
end

概要

プロパティ

  • 並列読み取り
  • 並列読み取り

    Gain value to be applied to the frequency content of the highest band in the equalizer.

  • 並列読み取り

    Gain value to be applied to the frequency content of the lowest band in the equalizer.

  • 並列読み取り

    Gain value to be applied to the frequency content of the middle band in the equalizer.

  • 並列読み取り

    The frequency range of the band influenced by MidGain.

プロパティ

Bypass

並列読み取り

HighGain

並列読み取り

Gain value, in decibels, to be applied to the frequency content of the highest band in the equalizer. Ranges from -80 to 10.

LowGain

並列読み取り

Gain value, in decibels, to be applied to the frequency content of the lowest band in the equalizer. Ranges from -80 to 10.

MidGain

並列読み取り

Gain value, in decibels, to be applied to the frequency content of the middle band in the equalizer. Ranges from -80 to 10.

MidRange

並列読み取り

The frequency range in hertz of the band influenced by MidGain. The lower value of the range determines the crossover frequency between the low and mid bands. The higher value of the range determines the crossover frequency between the mid and high bands. Both crossover frequencies range from 200 to 20,000.

方法

GetConnectedWires

パラメータ

pin: string

戻り値

イベント