Spectral Subtraction in Java - using JMathLib

2019-07-20 15:34发布

问题:

i'm new to Android and DSP. i'm implementing the Spectral Subtraction algorithm thanks

my goal is to use this algorithm over a phone call stream buffer

i'm trying to figure how to implement this code from the Matlab implementation of Spectral Subtraction i am using.

Matalb code:

function Seg=segment(signal,W,SP,Window)

% SEGMENT chops a signal to overlapping windowed segments
% A= SEGMENT(X,W,SP,WIN) returns a matrix which its columns are segmented
% and windowed frames of the input one dimentional signal, X. W is the
% number of samples per window, default value W=256. SP is the shift
% percentage, default value SP=0.4. WIN is the window that is multiplied by
% each segment and its length should be W. the default window is hamming
% window.
% 06-Sep-04
% Esfandiar Zavarehei

if nargin<3
    SP=.4;
end
if nargin<2
    W=256;
end
if nargin<4
    Window=hamming(W);
end
Window=Window(:); %make it a column vector

L=length(signal);
SP=fix(W.*SP);
N=fix((L-W)/SP +1); %number of segments

Index=(repmat(1:W,N,1)+repmat((0:(N-1))'*SP,1,W))';
hw=repmat(Window,1,N);
Seg=signal(Index).*hw;

my question is should i use JMathLib in order to implement functions like "repmat" which is a matrix replication function or should i implement it in another way. remember i'm running on Android based smartphones. thanks Gilad