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

조회 수: 8 (최근 30일)
neal paze
neal paze 2021년 9월 5일
편집: David Goodmanson 2021년 9월 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
  댓글 수: 2
neal paze
neal paze 2021년 9월 6일
David Goodmanson,Thank you very much!
David Goodmanson
David Goodmanson 2021년 9월 7일
You're quite welcome and I found out something about stft too.

댓글을 달려면 로그인하십시오.

추가 답변 (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