필터 지우기
필터 지우기

I want use function tfrsp of my sound from microphone

조회 수: 8 (최근 30일)
matija corak
matija corak 2015년 2월 1일
댓글: Star Strider 2015년 2월 1일
Hello. I have problem with function tfrsp. I want to use that function for spectrogram of sound. I can get the spectrogram of regular signal. This is the only thing what I can get from help tfrsp
tfrsp Spectrogram time-frequency distribution.
[TFR,T,F]=tfrsp(X,T,N,H,TRACE) computes the Spectrogram
distribution of a discrete-time signal X.
X : signal.
T : time instant(s) (default : 1:length(X)).
N : number of frequency bins (default : length(X)).
H : analysis window, H being normalized so as to
be of unit energy. (default : Hamming(N/4)).
TRACE : if nonzero, the progression of the algorithm is shown
(default : 0).
TFR : time-frequency representation. When called without
output arguments, tfrsp runs TFRQVIEW.
F : vector of normalized frequencies.
Example :
sig=fmlin(128,0.1,0.4);
h=tftb_window(17,'Kaiser'); tfrsp(sig,1:128,64,h,1);
[tfr,t,freq]=tfrsp(sig,1:128,64,h,1); plot(fftshift(freq),fftshift(tfr(:,100)))
When I try to use some sound what I took from my microphone example:
sig=audiorecorder;
record(sig);
stop(sig);
play(sig);
h=tftb_window(17,'rect');
[tfr,t,f]=tfrsp(sig,1:128,64,h,1);
Spectrogram
Undefined function 'times' for input arguments of type 'audiorecorder'.
Error in tfrsp (line 87)
tfr(indices,icol)=x(ti+tau).*conj(h(Lh+1+tau))/norm(h(Lh+1+tau));
>>or if I change time [tfr,t,f]=tfrsp(sig,1:length(sig),64,h,1);
Spectrogram
100 % complete in 0 seconds.
Undefined function 'times' for input arguments of type 'audiorecorder'.
Error in tfrsp (line 87)
tfr(indices,icol)=x(ti+tau).*conj(h(Lh+1+tau))/norm(h(Lh+1+tau));
thanks in advance.

채택된 답변

Star Strider
Star Strider 2015년 2월 1일
편집: Star Strider 2015년 2월 1일
I am not certain what you are doing, but if you want to get your recorded sound as numeric array, you have to use the getaudiodata function.
This works:
Fs = 1E+4;
nBits = 24;
nChannels = 2;
sig = audiorecorder(Fs, nBits, nChannels);
recordblocking(sig,5);
sigsound = getaudiodata(sig);
t = linspace(0, size(sigsound,1), size(sigsound,1))/Fs;
figure(1)
plot(t, sigsound)
grid
xlabel('Time (s)')
ylabel('Amplitude (kPa)')
It plots the amplitude as a function of time, not the spectrogram, but it illustrates the idea.
I cannot find any information on ‘tfrsp’. It is not in the online documentation, and I cannot find it in the File Exchange, so I cannot help you with it. (I have the Signal Processing Toolbox, that has the spectrogram function.)
Also, be certain that your microphone is turned on! In Windows machines, go to Control Panel > Sound to be sure.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Spectral Measurements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by