9
Spectral Analysis & Spectral Analysis & Spectrogram Spectrogram SASPL SASPL Cheolwoo Jo Cheolwoo Jo

Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

Embed Size (px)

Citation preview

Page 1: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

Spectral Analysis & Spectral Analysis & SpectrogramSpectrogram

SASPLSASPLCheolwoo JoCheolwoo Jo

Page 2: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

ContentsContents

Spectral AnalysisSpectral Analysis SpectrogramSpectrogram

Narrow BandNarrow Band

Wide BandWide Band Analysis of SpectrogramAnalysis of Spectrogram AR, MA, ARMA model of SpeechAR, MA, ARMA model of Speech

Page 3: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

Spectral AnalysisSpectral Analysis

Page 4: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

Spectrogram Spectrogram in matlabin matlab

[B,F,T] = SPECGRAM(A,NFFT,Fs,WINDOW,NOVERLAP)[B,F,T] = SPECGRAM(A,NFFT,Fs,WINDOW,NOVERLAP)

A: Speech SignalA: Speech Signal NFFT: Number of samplesNFFT: Number of samples Fs: Sampling FrequencyFs: Sampling Frequency Window: Type of WindowWindow: Type of Window NOVERLAP: Number of Overlapping signalNOVERLAP: Number of Overlapping signal

Page 5: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

Spectrogram Spectrogram in auditory in auditory toolboxtoolbox

function [array,raw] = spectrogram(wave,segsize,nlap,ntrans);

%function array = spectrogram(wave,segsize,nlap,ntrans);

% defaults spectrogram(wave,128,8,4) % nlap is number of hamming windows over

lapping a point; % ntrans is factor by which transform is big

ger than segment; % returns a spectrogram 'array' with fourth

root of power, % filter smoothed and formatted for display.

% Added option to return raw spectrogram.... Malcolm 5/26/95

% Added code so that input could be any direction ... Malcolm 5/26/95

% (c) 1998 Interval Research Corporation

if nargin < 4; ntrans=4; end if nargin < 3; nlap=8; end if nargin < 2; segsize=128; end

[r c] = size(wave); if (r < c) wave = filter([1 -0.95],[1],wav

e'); else wave = filter([1 -0.95],[1],wave); end

Page 6: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

s = length(wave);nsegs = floor(s/(segsize/nlap))-nlap+1;array = zeros(ntrans/2*segsize,nsegs);window = 0.54-0.46*cos(2*pi/(segsize+1)*(1:segsize)');for i = 1:nsegs seg = zeros(ntrans*segsize,1); % leave half full of zeroes seg(1:segsize) = ...

window.*wave(((i-1)*segsize/nlap+1):((i+nlap-1)*segsize/nlap)); seg = abs(fft(seg));

% reverse for image display array(:,i) = seg(((ntrans/2*segsize)+1):(ntrans*segsize));end

if nargout > 1raw = array;

end

Page 7: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

array = array .* array;% back into power domain for smo

othing

for i=1:nsegs % smooth the spectral slices array(:,i) = filter([.2 1 .2],[1],array(:,i));end

for i=1:ntrans/2*segsize % smooth the channels array(i,:) = filter([.2 1 .2],[1],array(i,:));end

% compress with square root of amplitude (fourth root of power)off = 0.0001*max(max(array)); % low end stabilization offset,array = (off+array).^0.25-off^0.25; % better than a threshold hack!array = 255/max(max(array))*array;

Page 8: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

Spectrogram level scalingSpectrogram level scaling

Log|x[k]|Log|x[k]|22

Log Energy(dB)

Gray Intensity

Black

White

60dB

Page 9: Spectral Analysis & Spectrogram SASPL Cheolwoo Jo

Specgram Specgram

SPECGRAM(A,F,Fs,WINDOW)SPECGRAM(A,F,Fs,WINDOW)

Matlab Matlab A: SpeechA: Speech F: Vector of FrequenciesF: Vector of Frequencies Fs: Sampling FrequencyFs: Sampling Frequency Window: Type of Window FunctionWindow: Type of Window Function