使用 R 对 wav 文件进行 lfs(线性频移)函数
我正在尝试对使用 R 录制的 wav 文件使用 lfs(线性频移)函数。 这是我运行的代码以及我的 wav 文件的功能。
library(tuneR)
library(MASS)
library(seewave)
setwd("C:/Users/Minkyung/Desktop/Call made")
bull <- readWave("croak_origin_bpf.wav")
#STDFT matrix
f <- [email protected] ; wl <- 8192; ovlp <- 50; wn <- "rectagle"
data <- spectro(bull, wl=wl, ovlp=ovlp, wn=wn,
plot=FALSE, norm=FALSE, dB=NULL, complex=TRUE)
LF.croak <- lfs(bull, shift=-25, output="Wave")
HF.croak <- lfs(bull, shift=+75, output="Wave")
writeWave(object=normalize(MF.croak, unit="16"),
filename="LF.croak_origin_bpf.wav")
writeWave(object=normalize(HF.croak, unit="16"),
filename="HF.croak_origin_bpf.wav")
#> bull
#> Wave Object
#> Number of Samples: 44272
#> Duration (seconds): 1
#> Samplingrate (Hertz): 44100
#> Channels (Mono/Stereo): Mono
#> PCM (integer format): TRUE
#> Bit (8/16/24/32/64): 16
当我运行此代码时,下移功能出现错误。
LF.croak <- lfs(bull, shift=-25, output="Wave")
> Error in lfs(bull, shift = -25, output = "Wave") :
> 'shift' value cannot be less than the frequency resolution (f/wl)
我意识到频率分辨率不能低于 0,但在这种情况下,是否不可能使用 lfs 函数来降低频率? 但在一些例子中,我确实发现降低频率是可能的。 有什么想法吗?
I'm trying to use lfs(linear frequency shift) function on a wav file I recorded using R.
Here is the code I ran, and features of my wav file.
library(tuneR)
library(MASS)
library(seewave)
setwd("C:/Users/Minkyung/Desktop/Call made")
bull <- readWave("croak_origin_bpf.wav")
#STDFT matrix
f <- [email protected] ; wl <- 8192; ovlp <- 50; wn <- "rectagle"
data <- spectro(bull, wl=wl, ovlp=ovlp, wn=wn,
plot=FALSE, norm=FALSE, dB=NULL, complex=TRUE)
LF.croak <- lfs(bull, shift=-25, output="Wave")
HF.croak <- lfs(bull, shift=+75, output="Wave")
writeWave(object=normalize(MF.croak, unit="16"),
filename="LF.croak_origin_bpf.wav")
writeWave(object=normalize(HF.croak, unit="16"),
filename="HF.croak_origin_bpf.wav")
#> bull
#> Wave Object
#> Number of Samples: 44272
#> Duration (seconds): 1
#> Samplingrate (Hertz): 44100
#> Channels (Mono/Stereo): Mono
#> PCM (integer format): TRUE
#> Bit (8/16/24/32/64): 16
When I run this code, there's an error for lower shifting function.
LF.croak <- lfs(bull, shift=-25, output="Wave")
> Error in lfs(bull, shift = -25, output = "Wave") :
> 'shift' value cannot be less than the frequency resolution (f/wl)
I realize the frequency resolution cannot be under 0, but in that case is it impossible to use lfs function as a way to lower the frequencies?
But in some examples I do find lowering frequencies are possible.
Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
错误消息表明频移不能小于短期傅立叶变换的频率分辨率。在本例中,
f
为 44100,wl
为 1024(默认值),因此频率分辨率为 43.07 Hz。如果您使用较大的wl
(例如 2048)调用 lfs,这会将频率分辨率降低到 21.53,因此使用 25 的调用应该可以工作。我没有你的数据,所以无法测试。
The error message shows that the frequency shift cannot be less than the frequency resolution of the short term Fourier transform. In this case,
f
is 44100 andwl
is 1024 - the default - so the frequency resolution is 43.07 Hz. If you calllfs
with a largerwl
, such as 2048, this will reduce the frequency resolution to 21.53 so the call using 25 should work.I don't have your data so I can't test it.