image thumbnail
from Piano notes recognition research by Maxim Vedenyov
try to define notes from its sound

sm=number2note(n)
function sm=number2note(n)
% convers note number n to note symbol sm

no1=floor(n/12); % octave number no1=0 for 4 octave

nn=n-no1*12; % note number

no=no1+4; % octave number
%if no~=4
if true
    os=num2str(no); % octave symbol, if octave is 4 than it not displayed
else
    os='';
end

switch nn
    case 0
        sm=['A' os];
    case 1
        sm=['A' os  '#'];
    case 2
        sm=['B' os];
    case 3
        sm=['C' os];
    case 4
        sm=['C' os  '#'];
    case 5
        sm=['D' os];
    case 6
        sm=['D' os  '#'];
    case 7
        sm=['E' os];
    case 8
        sm=['F' os];
    case 9
        sm=['F' os  '#'];
    case 10
        sm=['G' os];
    case 11
        sm=['G' os  '#'];
        
end

Contact us at files@mathworks.com