What would I add to the following code to detect the pitch of the audio signal?...

50.1K

Verified Solution

Question

Electrical Engineering

What would I add to the following code to detect the pitch ofthe audio signal? (use cepstral method)

clear all;
close all;
clc;

info = audiodevinfo;

info.input(1)
info.input(2)
pause(3); % delete it if necessary

clc;

fs = 44.1e3;
noBits = 16;
noChannels = 1;

recordObject = audiorecorder(fs,noBits,noChannels);

disp('Start speaking...');
record(recordObject);
pause(3);
stop(recordObject);
disp('End of Recording.');

x = getaudiodata(recordObject); %takin in as aperiodicsignal
noSamples = length(x); %length of vector x \"max(size(x))
time = [1:noSamples]/fs; %time ticks

%DFT: X[k]= (sigma x[n]*exp(-j*2*pi*k/Nf*n)
noSamples = length(x2)
noFrequencies = noSamples;
for ct =1:noSamples
X = nan(size(x2));
for k = 1:noFrequencies
X(k) = sum(x2.*exp(-j*2*pi*k/noFrequencies*n));
end

figure;
subplot(2,1,1);
kAsFrequencyIndicies = 1:noFrequencies;
plot(kAsFrequencyIndicies,abs(X));
box off;
subplot(2,1,2);
frequencyTicks = kAsFrequencyIndicies/noFrequencies*fs;
plot(frequencyTicks,abs(X));
box off;

Answer & Explanation Solved by verified expert
4.4 Ratings (944 Votes)
This code is in MATLAB It records a signal using audiorecorderfunctionI recorded a signal where i repeatedly    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students