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 ビュー (過去 30 日間)
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 件のコメント
codefanta
codefanta 2019 年 4 月 28 日
Hello
I have attached the file below, I hope its what you needed
KInd regards
Oliver
codefanta
codefanta 2019 年 4 月 28 日
I sent the wrong file in the first comment, apoligies and the correct one is in this comment

サインインしてコメントする。

採用された回答

Walter Roberson
Walter Roberson 2019 年 4 月 28 日
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.

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by