문제

I am trying to write a sine wave generted from code to a .wav file in Octave. However, when I plot spectrum of the wav file (in Audacity), the frequency of the wave from the code and that shown in the plot spectrum do not match. Furthermore, the time duration specified in the code doesn't match with the time in the file's properties. Below is my octave script for generating and writing sine wave to .wav file

freqOfTone = 12000; %audacity is showing freq = 2100hz (approx)
samplingFreq = 44100;
duration = 1; %the file properties is showing duration of 5s
t=[0: 1/samplingFreq: duration];
y=sin(2*pi*freqOfTone*t)';
wavwrite(y,'temp.wav');

I am not sure what I am doing wrong. Please help.

도움이 되었습니까?

해결책

I guess that you forgot the sampling frequency:

wavwrite(y,samplingFreq ,'temp.wav')
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top