简体   繁体   English

在wav文件中过滤频率超过限制(低通滤波器)

[英]Filtering frequencies above limit in wav file (Low pass filter)

I need to filter frequencies above 5Khz in a wav file. 我需要在wav文件中过滤5Khz以上的频率。 I made some research and found about butterworth algorithm but couldn't apply it. 我做了一些研究,发现了关于butterworth算法,但无法应用它。

Assume that I have a mono channel wav file. 假设我有一个单声道wav文件。 I read it, then I want to use a low pass filter to filter frequencies above 5Khz. 我读了它,然后我想使用低通滤波器来过滤5Khz以上的频率。

What I've done so far is this. 到目前为止我所做的就是这个。 I read the file, read frames and convert them to numerical values. 我读取文件,读取帧并将它们转换为数值。

from pydub import AudioSegment

song = AudioSegment.from_wav("audio.wav")
frame_count = int(song.frame_count())
all_frames = [song.get_frame(i) for i in range(frame_count)]

def sample_to_int(sample):
    return int(sample.encode("hex"), 16)

int_freqs = [sample_to_int(frame) for frame in all_frames]

If I make change values >5000 to 0 is it enough? 如果我将更改值> 5000更改为0就够了吗? I don't think that's the way, I am very confused and would be glad to hear any help. 我不认为那样,我很困惑,很乐意听到任何帮助。

Pydub includes a lopass filter -- there's no need for you to implement it yourself: Pydub包含一个lopass过滤器 - 您无需自己实现它:

from pydub import AudioSegment

song = AudioSegment.from_wav("audio.wav")
new = song.low_pass_filter(5000)

It's "documented" in effects.py . 它在effects.py中 “记录”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM