I have an audio file and read all data from the sound card buffer. Then, I convert byte[]
to float[]
to use them for hamming window. The waveform of the audio is:
after using hamming window:
is the waveform of audio with hamming window right? Where is my mistake?
by the way i use naudio library to process audio:
WaveChannel32 wave = new WaveChannel32(new WaveFileReader("sesDosyası.wav"));
byte []buffer = new byte[wave.length];
float []data = new float[wave.length / 4];
int read = wave.Read(buffer, 0, wave.length);
for (int i = 0; i < read / 4; i++)
{
data[i] = BitConverter.ToSingle(buffer, i * 4); //converting byte to float
chart1.Series["wave"].Points.Add(data[i]); //first waveform
}
for (int j = 0; j < read/4; j++)
{
data[j] = (float)(0.54 - 0.46 * Math.Cos((2 * Math.PI * data[j]) / (read / 4 - 1)));//hamming
chart2.Series["wave"].Points.Add(data[j]); //second waveform
}
It appears you are applying the window to the whole wave, so
read
is going to be huge, so the term inside thecos
is always going to be very near 0 for adata
between [-1,1].So you are always getting
.54 - .46*cos(0)
=.54 - .46*1.0
=.08
From wikipedia, only
j
should be inside the cosine - that gives the window, which you then multiply bydata[j]
:Why are you trying to apply a hamming window to the whole wave?