I want to increase the FS to 44100 from 8000, when I do so i get an error regarding the size of the "CELL ARRAY" saying "Matrix dimensions must agree". I am using a function as i am recording simultaneously with the recording. Much appreciated.
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
codefanta
el 28 de Abr. de 2019
Comentada: codefanta
el 28 de Abr. de 2019
function recording = audioOI(x,fs)
% audioOI - Simulataneously plays and records the test signal.
% Uses Parallel Computing Toolbox.
% INPUT: x - test signal
% fs - sampling frequency
% OUTPUT: y - recorded signal
time = length(x)/fs; % play/record time
recObj = audiorecorder;
parfor ii = 1:2
if ii==1
recordblocking(recObj, time);
recording{ii} = getaudiodata(recObj);
elseif ii==2
soundsc(x, fs);
end
end
%% Audio Input-Output
% y = getaudiodata(recording)
recording = cell(2,1); % sliced cell array "recording", to store the recorded signal
% load('chirp.mat'); % Create a signal to play and record
% x = chirp;
fs = 44100; % sampling frequency
time = 5; % signal duration
N = time * fs; % number of samples
x = randn(1,N); % Gaussian white noise
% play, record and plot
recording = audioOI(x,fs);
y = cell2mat(recording);
% plot(y); grid on;
h2 = ifft(fft(y)./fft(x')); plot(h2);
5 comentarios
Respuesta aceptada
Walter Roberson
el 28 de Abr. de 2019
You have
fft(y)./fft(x')
where y is 40000 x 1 and x is 1 x 220500
The source of the difficulty is that you generate x as 5 seconds of 44100 Hz, but you generate y as 5 seconds of audiorecorder. The default for audiorecorder is 8000 Hz.
Note: when you ask audiorecorder for 5 seconds of 44100, you should not assume that it will return exactly 220500 samples. It would be safer to extract the length corresponding to the shorter of the 2.
Más respuestas (0)
Ver también
Categorías
Más información sobre Audio and Video Data en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!