如何将不同的频率组合成一个.wav

时间:2014-10-29 06:24:59

标签: audio matlab-figure

我想通过matlab创建一个从12khz到13khz的.wav。我知道如何创建单个频率,但是idont知道如何将它们组合成一个文件。 有没有简单的命令?

Fs =44100;    
toneFreq1 = 12000; 
nSeconds = 25;  
f1 = sin(linspace(0, nSeconds*toneFreq1*2*pi, round(nSeconds*Fs)));
toneFreq2 = 12100; 
nSeconds = 25;  
f2 = sin(linspace(0, nSeconds*toneFreq2*2*pi, round(nSeconds*Fs)));
toneFreq3 = 12200; 
nSeconds = 25;  
f3 = sin(linspace(0, nSeconds*toneFreq3*2*pi, round(nSeconds*Fs)));
toneFreq4 = 12300; 
nSeconds = 25;  
f4 = sin(linspace(0, nSeconds*toneFreq4*2*pi, round(nSeconds*Fs)));
toneFreq5 = 12400; 
nSeconds = 25;  
f5 = sin(linspace(0, nSeconds*toneFreq5*2*pi, round(nSeconds*Fs)));
toneFreq6 = 12500; 
nSeconds = 25;  
f6 = sin(linspace(0, nSeconds*toneFreq6*2*pi, round(nSeconds*Fs)));
toneFreq7 = 12600; 
nSeconds = 25;  
f7 = sin(linspace(0, nSeconds*toneFreq7*2*pi, round(nSeconds*Fs)));
toneFreq8 = 12700; 
nSeconds = 25;  
f8 = sin(linspace(0, nSeconds*toneFreq8*2*pi, round(nSeconds*Fs)));
toneFreq9 = 12800; 
nSeconds = 25;  
f9 = sin(linspace(0, nSeconds*toneFreq9*2*pi, round(nSeconds*Fs)));
toneFreq10 = 12900; 
nSeconds = 25;  
f10 = sin(linspace(0, nSeconds*toneFreq10*2*pi, round(nSeconds*Fs)));


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


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

1 个答案:

答案 0 :(得分:0)

您的wavwrite数据需要在-1.0到1.0的范围内。您可以通过除以10来解决此问题。

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

如果生成一次时间轴,您的正弦波生成将更具可读性。

t = [1:1:(Fs*nSeconds)];
f1 = sin(2*pi*t*toneFreq1/Fs);