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.

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
    อ่านพร้อมๆ กัน
  • อ่านพร้อมๆ กัน

    รูปร่างของเว้นวรรคที่แสดงโดยตัวกรอง

  • อ่านพร้อมๆ กัน

    ความถี่กลางที่กรองทำงานรอบ ๆ

  • อ่านพร้อมๆ กัน

    สำหรับการกรองด้วยเครื่องกำเนิดและหลังคา ควบคุมปริมาณการเพิ่มขึ้นหรือลดลง

  • อ่านพร้อมๆ กัน

    สำหรับ peaking, lowpass, highpass, bandpass และ notch ตรวจสอบความเลือกหรือความสมดุล

วิธีการ

  • GetConnectedWires(pin : string):Instances

    กลับรายการ Wires ปักหมุด

  • GetGainAt(frequency : number):number

    กลับค่าความเคลื่อนไหวของตัวกรองที่เรียกมา

คุณสมบัติ

Bypass

อ่านพร้อมๆ กัน

หาก true สตรีมอินพุตเสียงจะไม่ได้รับผลกระทบจากผลลัพธ์นี้

Editor

ไม่ซ้ำ
การรักษาความปลอดภัยของสคริปต์ Roblox
อ่านพร้อมๆ กัน
อ่านพร้อมๆ กัน

รูปแบบของคำตอบความถี่ที่จะใช้ในการกรองสัญญาณเสียง แต่ละประเภทของคำตอบความถี่ส่งผลต่อเนื้อหาของเสียงในแต่ละวิธี

Frequency

อ่านพร้อมๆ กัน

ความถี่กลางในเฮิร์ทของค่าตัวกรอง โดยทั่วไป, การปรับเพิ่มหรือลดค่านี้จะเทียบเท่ากับการเปลี่ยนแปลงแนวความถี่ทั้งหมดในความถี่รวม ระยะจาก 20 ถึง 22000

Gain

อ่านพร้อมๆ กัน

มูลค่าการได้รับในเวลาอัตราเสียง ตัวกรองFilterType ใช้ได้เฉพาะเมื่อ Peak อยู่ในช่วง

อ่านพร้อมๆ กัน

ตัวกรองFilterType ใช้ได้เฉพาะเมื่อ

สำหรับ FilterType มูลค่าของ Lowpass12dB และ ulum.AudioFilterType.Highpass12dB|Highpass12d

วิธีการ

GetConnectedWires

Instances

กลับรายการ Wires ที่เชื่อมต่อกับเข็มขัดที่กำหนด AudioFilter มีหนึ่ง "การป้อนข้อมูล" หนึ่ง "การป้อนข้อมูล" หนึ่งและหนึ่ง "ปักหมุด" หนึ่ง

พารามิเตอร์

pin: string

ส่งค่ากลับ

Instances

GetGainAt

กลับค่าการได้รับที่เป็นด้านล่างของค่าการตอบสนองความถี่ที่แทนที่โดยตัวกรองที่เลือกในความถี่ที่กำหนดในเฮิร์ท นี้สามารถใช้เพื่อสแมปลักษณะเฉพาะของตัวกรองในสถานที่สำคัญหรือในรวม

พารามิเตอร์

frequency: number

ความถี่ในเฮิร์ทซ์เพื่อตัวอย่าง


ส่งค่ากลับ

มูลค่าการได้รับ, ใน decibels, ที่ความถี่ที่ให้.

อีเวนต์