Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

HELP PLEASE - Guitar Tuner in MATLAB

Status
Not open for further replies.

jags802

Newbie level 1
Joined
May 15, 2009
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,294
guitar tuner matlab

Hi all im currently trying to design a guitar tuner in MATLAB and am new to this. Currently I record my string using the following code then bandpass filter it and then FFT it. I get the right result but I now need how to detect my peak so that I can look if it is on tune or not as my code just loops and records agian if the detection is high enough. I need some kind of break or if statement to go on and look at the peak. Any one any ideas please. Im only concentrating on the A string to start.

Many thanks in advance

Gareth

My code is as follows

s=1;
max_s=0;
while s==1
while max_s < .3 % if maximum sound recorded is higher than 0.3 then process
E= wavrecord(2000,10000); %record sound for 2 seconds
y=filter(AFILTER,E);
max_s = max(E); % works out maximum value in the recording
endmax_s=0; %reset max sound
nt=1024; %look
T=.1024; % nt times 1/sampling rate
dt=T/nt;
df=1/T;
fmax=(nt/2)*df;
f=0:df:(nt/2-1)*df;
ef=fft(y(300:300+nt-1));
yp=zeros(1,(nt/2));
yp(1:nt/2)=(2/nt)*ef(1:nt/2);
subplot(2,1,1);
plot(y); grid on
subplot(2,1,2);
plot(f,abs(yp))
axis([0 fmax 0 max(abs(yp))])
xlabel('freq Hz')
grid
pause(0.5)
end
 

matlab guitar tuner

You can use the "findpeaks" command or "max" command in Matlab. Look both of those up in the help window for more information and examples.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top