I want use function tfrsp of my sound from microphone

3 visualizaciones (últimos 30 días)
matija corak
matija corak el 1 de Feb. de 2015
Comentada: Star Strider el 1 de Feb. de 2015
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.

Respuesta aceptada

Star Strider
Star Strider el 1 de Feb. de 2015
Editada: Star Strider el 1 de Feb. de 2015
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.

Más respuestas (0)

Categorías

Más información sobre Audio I/O and Waveform Generation en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by