Question

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.

Was it helpful?

Solution

I guess that you forgot the sampling frequency:

wavwrite(y,samplingFreq ,'temp.wav')
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top