使用一个示例,我从tuneR,signal和oce包的混合物中在线找到了我从wav文件创建的频谱图。
测试频谱图:[https://drive.google.com/drive/folders/1G0aLcx3-_STLIABWwz0e7y-fzB9pfMFh?usp=sharing]
但是,当我尝试将x轴刻度从0,200,400,600,800更改为任意集合或随机数(例如0,200,400,600. 800,1000)时,频谱图会失真(因为我认为是都与频谱图中的时间相关联)。我已经使用了一些情节的基础知识来尝试和更改它,例如xlim = c(0,1000,200)。我想知道是否有人可以提供帮助,以根据程序包定义的x值更改任何x值。
代码:
library(tuneR, warn.conflicts = F, quietly = T)
library(signal, warn.conflicts = F, quietly = T)
library(oce, warn.conflicts = F, quietly = T)
fin <- "F:/noise/old/origional_combined.wav"
data = readWave(fin)
snd = data@left
dur = length(snd)/data@samp.rate
fs = data@samp.rate/1000
snd = snd - mean(snd)
nfft=1124
window=256
overlap=128
spec = specgram(x = snd,
n = nfft,
Fs = fs,
window = window,
overlap = overlap
)
P = abs(spec$S)
P = P/max(P)
P = 10*log10(P)
t = spec$t
imagep(x = t,
y = spec$f,
z = t(P),
col = oce.colorsViridis,
ylab = 'Frequency [kHz]',
xlab = 'Time [s]',
drawPalette = T,
decimate = F
)