why the number of point of sfft and istft is different、

8 次查看(过去 30 天)
I do stft to a sound,then I use the result of stft to do istft,but i find the sample point is different.
The original sound is 338160*1 double,after istft,the rebuild sound is 338112*1 double.How can I rebuild sound in the same as the point of original point?
I have try others' sound,all the number loss(original point -rebuild point) is 48.such as 338160-338112=48.

采纳的回答

David Goodmanson
David Goodmanson 2021-9-5
编辑:David Goodmanson 2021-9-30
Hi neal,
The documentation for stft says that if you want the number of sample points to be unaffected, then if
length of the signal = n,
width of the window = w
number of overlap points = 'over'
then (n-over)/(w-over) must an integer. But things are a lot easier to deal with by using the equivalent condition,
(n-w)/(w-over) = integer
For that to be true, whatever the prime factors of (n-w) are, then (w-over) must be composed of a product of some ot those prime factors.
n = 338160;
w = 256;
factor(n-w)
ans = 2 2 2 2 7 7 431
If (w-over), the unoverlapped portion of the window, is denoted by z, then fortunately for a window of length 256, there are a lof of available factors for z. In your case, though, z = 64 does not divide (n-w) so things don't work, as you found out. Here are possibilities for z, with z = 64 also included:
format short g
z = [49 8*7 64 2*49 16*7];
over = w-z
Ratio = (n-w)./(w-over) % should be an integer
fracn = over/w % overlap fraction
over = 207 200 192 158 144
Ratio = 6896 6034 5279.8 3448 3017
fracn = 0.80859 0.78125 0.75 0.61719 0.5625
so there are some choices available. If you really like 75% overlap exactly and don't care about 256 for window length, then
n = 338160;
w = 240;
over = 180; % z = 60
factor(n-w)
Ratio = (n-w)./(w-over)
ans = 2 2 2 2 2 2 2 2 2 2 2 3 5 11
Ratio = 5632
works

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Time-Frequency Analysis 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by