Borrar filtros
Borrar filtros

wavrecord() replacement and sound speed measurement

4 visualizaciones (últimos 30 días)
Michal Rocinski
Michal Rocinski el 27 de Abr. de 2020
Comentada: Walter Roberson el 21 de Sept. de 2023
I would like to try to measure sound speed with Matlab. I have two microphones recording sound at the same time. They are both connected to my laptop through stereo input. I have tried to use code from this topic: https://www.mathworks.com/matlabcentral/answers/129171-sound-speed-measurement-with-two-microphones
I replaced 'wavrecord()' to an audiorecorder function but it gives an error. I have no idea what I can change to make the program work properly and start recording a sound.
Here is the code and the error below:
if true
clear; figure; grid on; hold on;
Fs = 22050;
r = audiorecorder(22050,16,2);
record(r,5);
mySpeech = getaudiodata(r, 'int16');
tmax = length(mySpeech)/Fs;
t = linspace(0, tmax, 5*Fs);
plot(t*1000,mySpeech);
axis([0 tmax*1000 -2 2]);
xlabel('time (ms)');
j = 1;
for i=1:length(mySpeech)
if mySpeech(i)>0.15
pick(j) = 1000*i/Fs;
fprintf('%3d --> %8.1f ms\n',j, pick(j));
j=j+1;
end
end
end
Error using audiorecorder/getaudiodata (line 765)
Recorder is empty.
Error in program (line 7)
mySpeech = getaudiodata(r, 'int16');

Respuesta aceptada

Walter Roberson
Walter Roberson el 27 de Abr. de 2020
Change
record(r,5);
to
recordblocking(r,5);

Más respuestas (1)

Dian
Dian el 21 de Sept. de 2023
Editada: Walter Roberson el 21 de Sept. de 2023
clear all;
Fs = 8000;
y = wavrecord(5.0*Fs, Fs, 'double');
wavwrite(y,Fs,'aiueo.wav')
y1=wavread('aiueo.wav');
t=length(y1);
y2=y1(1:10000);
plot(y2)
  1 comentario
Walter Roberson
Walter Roberson el 21 de Sept. de 2023
Unfortunately, that will not solve @Michal Rocinski's problem, which was happening in R2019b. By R2019b, wavrecord() had been completely removed from MATLAB; wavwrite() had also been removed https://www.mathworks.com/matlabcentral/answers/647743-is-wavwrite-still-used#answer_544418 and probably wavread() had been removed too.

Iniciar sesión para comentar.

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by