找回密码
 注册
查看: 1385|回复: 0

R语言 signal包 specgram()函数中文帮助文档(中英文对照)

[复制链接]
发表于 2012-9-30 02:11:33 | 显示全部楼层 |阅读模式
specgram(signal)
specgram()所属R语言包:signal

                                         Spectrogram plot
                                         谱图图

                                         译者:生物统计家园网 机器人LoveR

描述----------Description----------

Generate a spectrogram for the signal. This chops the signal into overlapping slices, windows each slice and applies a Fourier transform to determine the frequency components at that slice.
生成的信号的频谱。此印章重叠片,窗每个切片和适用的傅立叶变换,以确定的频率分量,在该切片的信号转换成。


用法----------Usage----------


specgram(x, n = min(256, length(x)), Fs = 2, window = hanning(n),
         overlap = ceiling(length(window)/2))

## S3 method for class 'specgram'
plot(x, col = gray(0:512 / 512), xlab="time", ylab="frequency", ...)

## S3 method for class 'specgram'
print(x, col = gray(0:512 / 512), xlab="time", ylab="frequency", ...)



参数----------Arguments----------

参数:x
the vector of samples.  
样本矢量。


参数:n
the size of the Fourier transform window.  
傅里叶变换窗口的大小。


参数:Fs
the sample rate, Hz.  
的采样速率,赫兹。


参数:window
shape of the fourier transform window, defaults to hanning(n). The window length for a hanning window can be specified instead.  
形状傅立叶变换的窗口,默认为hanning(n)。汉宁窗的窗口长度,可以指定。


参数:overlap
overlap with previous window, defaults to half the window length.
重叠与前一个窗口,默认为窗口长度的一半。


参数:col
color scale used for the underlying image function.
色标使用的底层的的image功能。


参数:xlab,ylab
axis labels with sensible defaults.
轴标签与合理的默认值。


参数:...
additional arguments passed to the underlying plot functions.
额外的参数传递给底层的绘图功能。


Details

详细信息----------Details----------

When results of specgram are printed, a spectrogram will be plotted. As with lattice plots, automatic printing does not work inside loops and function calls, so explicit calls to print or plot are needed there.
specgram打印,频谱将被绘制。 lattice图,自动打印不工作的内循环和函数调用,调用print或plot都需要有这样明确的。

The choice of window defines the time-frequency resolution. In speech for example, a wide window shows more harmonic detail while a narrow window averages over the harmonic detail and shows more formant structure. The shape of the window is not so critical so long as it goes gradually to zero on the ends.
的窗口定义的选择的时间 - 频率分辨率。在讲话例如,广泛窗口显示更和谐的细节,而窄窗平均对谐波的细节和更多的共振峰结构。不是那么关键的,只要它逐渐为零的端部上的窗口的形状。

Step size (which is window length minus overlap) controls the horizontal scale of the spectrogram. Decrease it to stretch, or increase it to compress. Increasing step size will reduce time resolution, but decreasing it will not improve it much beyond the limits imposed by the window size (you do gain a little bit, depending on the shape of your window, as the peak of the window slides over peaks in the signal energy). The range 1-5 msec is good for speech.
步长(这是窗口的长度减去重叠)控制的水平刻度的频谱。减少伸展,或增加压缩。增加步长将降低时间分辨率,但下降不会提高它远远超出了限制窗口的大小(你获得了一点点,这取决于你的窗口的形状,作为窗口的高峰期滑过峰信号能量)。 1-5毫秒范围是良好的语音。

FFT length controls the vertical scale. Selecting an FFT length greater than the window length does not add any information to the spectrum, but it is a good way to interpolate between frequency points which can make for prettier spectrograms.
FFT长度控制垂直比例尺。选择FFT长度大于窗口长度不添加任何信息的频谱,但它是一个很好的方式之间进行插值频点,可以使漂亮的光谱图。

After you have generated the spectral slices, there are a number of decisions for displaying them. First the phase information is discarded and the energy normalized:
在已经生成的分光片,有用于显示它们的若干决定。首先的相位信息被丢弃了的能量归一化:

S = abs(S); S = S/max(S)
S = abs(S); S = S/max(S)

Then the dynamic range of the signal is chosen. Since information in speech is well above the noise floor, it makes sense to eliminate any dynamic range at the bottom end. This is done by taking the max of the magnitude and some minimum energy such as minE=-40dB. Similarly, there is not much information in the very top of the range, so clipping to a maximum energy such as maxE=-3dB makes sense:
然后,被选择的信号的动态范围。由于在语音信息,远高于本底噪声,它是有道理的,以消除任何动态范围的底端。这是最大的幅度和一些最低限度的能源,如矿山=-40dB的。同样,有没有多的信息中非常顶级的,所以削波最大能源(如maxE)=-3dB的是有道理的:

S = max(S, 10^(minE/10)); S = min(S, 10^(maxE/10))
S = max(S, 10^(minE/10)); S = min(S, 10^(maxE/10))

The frequency range of the FFT is from 0 to the Nyquist frequency of one half the sampling rate. If the signal of interest is band limited, you do not need to display the entire frequency range. In speech for example, most of the signal is below 4 kHz, so there is no reason to display up to the Nyquist frequency of 10 kHz for a 20 kHz sampling rate. In this case you will want to keep only the first 40% of the rows of the returned S and f. More generally, to display the frequency range [minF, maxF], you could use the following row index:
的FFT的频率范围是从0到1采样率的一半的奈奎斯特频率。如果感兴趣的信号的带宽限制,你并不需要显示在整个频率范围内。在语音例如,大部分的信号是4 kHz以下的,所以没有任何理由显示多达10千赫的奈奎斯特频率为20 kHz的采样速率。在这种情况下,你会想,只保留40%的行返回的S和f。更一般地,显示的频率范围[minF, maxF],你可以使用下面的行索引:

idx = (f >= minF &amp; f <= maxF)
idx = (f >= minF &amp; f <= maxF)

Then there is the choice of colormap. A brightness varying colormap such as copper or bone gives good shape to the ridges and valleys. A hue varying colormap such as jet or hsv gives an indication of the steepness of the slopes. The final spectrogram is displayed in log energy scale and by convention has low frequencies on the bottom of the image.
再有就是选择色彩对照表。如铜或骨的亮度不同的颜色表提供了良好的形状的山脊和山谷。如喷气或单纯疱疹病毒的色调不同的颜色表给出了指示的斜坡的陡度。最终的频谱显示在log能源的规模和按照惯例,具有低频率的底部的图像。


值----------Value----------

For specgram list of class specgram with items:
对于specgram类列表specgram的项目:


参数:S
complex output of the FFT, one row per slice.  
复杂的FFT输出,每排片。


参数:f
the frequency indices corresponding to the rows of S.
对应的行的S.的频率指数


参数:t
the time indices corresponding to the columns of S.
对应于S的列的时间指数


(作者)----------Author(s)----------


Original Octave version by Paul Kienzle
<a href="mailto:pkienzle@users.sf.net">pkienzle@users.sf.net</a>. Conversion to R by Tom Short.



参考文献----------References----------



参见----------See Also----------

fft, image
fft,image


实例----------Examples----------


specgram(chirp(seq(-2, 15, by = 0.001), 400, 10, 100, 'quadratic'))
specgram(chirp(seq(0, 5, by = 1/8000), 200, 2, 500, "logarithmic"), Fs = 8000)

data(wav)  # contains wav$rate, wav$sound[包含WAV $率,WAV声音]
Fs <- wav$rate
step &lt;- trunc(5*Fs/1000)             # one spectral slice every 5 ms[一个频谱片每5毫秒]
window &lt;- trunc(40*Fs/1000)          # 40 ms data window[40 ms的数据窗口]
fftn &lt;- 2^ceiling(log2(abs(window))) # next highest power of 2[下一个最高功率为2]
spg <- specgram(wav$sound, fftn, Fs, window, window-step)
S &lt;- abs(spg$S[2fftn*4000/Fs),])   # magnitude in range 0&lt;f&lt;=4000 Hz.[幅度的范围0 <F <= 4000赫兹。]
S &lt;- S/max(S)         # normalize magnitude so that max is 0 dB.[标准化的大小,最大为0 dB。]
S[S &lt; 10^(-40/10)] &lt;- 10^(-40/10)    # clip below -40 dB.[夹低于-40分贝。]
S[S &gt; 10^(-3/10)] &lt;- 10^(-3/10)      # clip above -3 dB.[夹-3分贝以上。]
image(t(20*log10(S)), axes = FALSE)  #, col = gray(0:255 / 255))[,列=灰色(0:255 / 255))]

转载请注明:出自 生物统计家园网(http://www.biostatistic.net)。


注:
注1:为了方便大家学习,本文档为生物统计家园网机器人LoveR翻译而成,仅供个人R语言学习参考使用,生物统计家园保留版权。
注2:由于是机器人自动翻译,难免有不准确之处,使用时仔细对照中、英文内容进行反复理解,可以帮助R语言的学习。
注3:如遇到不准确之处,请在本贴的后面进行回帖,我们会逐渐进行修订。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|小黑屋|生物统计家园 网站价格

GMT+8, 2025-5-22 22:05 , Processed in 0.024750 second(s), 16 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表