3
votes

enter image description here

Fs =44100;    
toneFreq1 = 8000; 
nSeconds = 25;  
f1 = sin(linspace(0, nSeconds*toneFreq1*2*pi, round(nSeconds*Fs)));
toneFreq2 = 8100; 
nSeconds = 25;  
f2 = sin(linspace(0, nSeconds*toneFreq2*2*pi, round(nSeconds*Fs)));
....

toneFreq80 = 15900; 
nSeconds = 25;  
f80 = sin(linspace(0, nSeconds*toneFreq80*2*pi, round(nSeconds*Fs)));
toneFreq81 = 16000; 
nSeconds = 25;  
f81 = sin(linspace(0, nSeconds*toneFreq81*2*pi, round(nSeconds*Fs)));


f_12345678910...= [f1+f2+f3+f4+f5+f6+f7+f8+f9+f10...f81]/81;


f_z=[f_12345678910...];
sound(f_z,Fs) 
wavwrite(f_z, Fs, 24, '8_16zKHz.wav');

I create a wave file (contain frequency from 8khz to 16khz by using Matlab). Then I play the wave and use the M50 microphone(6cm above the speaker) and a recorder to record the sound(from the speaker). Finally, I use a matlab program to convert the sound into a figure. In this figure, you can see a 8-16khz platform (what I want), but also can see some high frequency component(arrow). I don't know why the high frequency(>16khz) is generated. Is the high frequency signal being generated in the speaker, or is it noise generated by the microphone? Thank you.

1
Hi there - rather than posting your email, you can put the image on another website and link it here - someone will probably edit it into your question.nkjt
A good question to ask here is: is the 20KHz signal being generated in the speaker, or is it noise generated by the microphone? Test: generate a couple of more tests with different frequencies and make sure that the 20KHz signal is dependant on your code, not dependant on your microphone.Ander Biguri
TO: nkjt, Ander Biguri. Thank you for your suggestion, I have edited my question and upload the figure. Also I will try to take more tests.yang bin
To: Ander Biguri, I generated two sounds(one contains 1-9khz, the other contains 12-20khz),and i use the same measurement to record a .wav. Then I use the same program to convert the .wav into a figure. None of the two figures has the similar high frequency. So is it means the code(8-16khz I use) is something wrong? Can you give some ideas? Thank you.yang bin

1 Answers

1
votes

I think that your problem is with the use of linspace. On the surface, it seems like it should work, but there is something uncomfortable about how you're invoking it. I think that your method does not end up with quite the exactly-correct sample rate.

Also, I have little experience with Matlab's ability to export 24-bit WAVs in a format that is universally recognizable. I think that you should try 16-bits first, as that has been extremely reliable for me.

So, as something to try, I'd re-write your code in this way:

%define my parameters
toneFreqs = [8000:100:16000];
fs = 44100;
nSeconds = 25;

%create my data
t_sec = ([1:(nSeconds*fs)]-1)/fs; %here is the time for each sample
t_sec = t_sec(:);                 %make a column instead of a row
myWav = zeros(size(t_sec));       %pre-allocate the output
for Ifreq = 1:length(toneFreqs)   %loop over each frequency
    myWav = myWav + sin(2*pi*toneFreqs(Ifreq)*t_sec);
end

%save to WAV file
myWav = myWav./max(abs(myWav));    %normalize amplitude to 1.0
wavwrite(myWav,fs,16,'myWav.wav'); %save as 16 bit