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

6 ビュー (過去 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 Center および File ExchangeAudio Processing Algorithm Design についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by