AudioFilter
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
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)
สรุป
คุณสมบัติ
ว่าสตรีมเสียงจะผ่านไปยังผู้ที่ไม่ได้รับผลกระทบโดยเอฟเฟกต์นี้หรือไม่
รูปร่างของเว้นวรรคที่แสดงโดยตัวกรอง
ความถี่กลางที่กรองทำงานรอบ ๆ
สำหรับการกรองด้วยเครื่องกำเนิดและหลังคา ควบคุมปริมาณการเพิ่มขึ้นหรือลดลง
สำหรับ peaking, lowpass, highpass, bandpass และ notch ตรวจสอบความเลือกหรือความสมดุล
วิธีการ
กลับรายการ Wires ปักหมุด
กลับค่าความเคลื่อนไหวของตัวกรองที่เรียกมา
คุณสมบัติ
Editor
FilterType
รูปแบบของคำตอบความถี่ที่จะใช้ในการกรองสัญญาณเสียง แต่ละประเภทของคำตอบความถี่ส่งผลต่อเนื้อหาของเสียงในแต่ละวิธี
Frequency
ความถี่กลางในเฮิร์ทของค่าตัวกรอง โดยทั่วไป, การปรับเพิ่มหรือลดค่านี้จะเทียบเท่ากับการเปลี่ยนแปลงแนวความถี่ทั้งหมดในความถี่รวม ระยะจาก 20 ถึง 22000
ตัวกรองFilterType ใช้ได้เฉพาะเมื่อ
สำหรับ FilterType มูลค่าของ Lowpass12dB และ ulum.AudioFilterType.Highpass12dB|Highpass12d
วิธีการ
GetConnectedWires
กลับรายการ Wires ที่เชื่อมต่อกับเข็มขัดที่กำหนด AudioFilter มีหนึ่ง "การป้อนข้อมูล" หนึ่ง "การป้อนข้อมูล" หนึ่งและหนึ่ง "ปักหมุด" หนึ่ง
พารามิเตอร์
ส่งค่ากลับ
GetGainAt
กลับค่าการได้รับที่เป็นด้านล่างของค่าการตอบสนองความถี่ที่แทนที่โดยตัวกรองที่เลือกในความถี่ที่กำหนดในเฮิร์ท นี้สามารถใช้เพื่อสแมปลักษณะเฉพาะของตัวกรองในสถานที่สำคัญหรือในรวม
พารามิเตอร์
ความถี่ในเฮิร์ทซ์เพื่อตัวอย่าง
ส่งค่ากลับ
มูลค่าการได้รับ, ใน decibels, ที่ความถี่ที่ให้.