Here is part 2 of my sound experimentation.
What I’m trying to do here is to analyse Fast Fourier Transform data from a sine wave, to determine what the initial pitch of the sound is.
First of all I’m generating a sine wave (see part 1). The pitch of this wave is relative to the mouse X position. This frequency is represented on the graph as a white line.
Then the sound data is put through the Fast Fourier Transform (FFT) using
SoundMixer.computeSpectrum(bytes, true, 2);
This data is plotted on the graph and the 5 highest peaks are marked with the red cross.
I want to determine the initial frequency of the sound that was put through FFT. This version calculates this by finding the middle point of the 3rd and 4th highest peaks, and then averaging this value with the weighted average height of the three highest peaks. The calculated frequency is represented on the graph by the red line.
In the bottom right-hand corner you can see the two pitches, and the difference between them.
Obviously this still has quite a way to go as the estimated frequency moves around quite a bit.
Hapa ni sehemu ya pili ya majaribio yangu ya sauti. Kile ninachojaribu kufanya hapa ni kuchambua data ya Fast Fourier Transform kutoka kwa wimbi la sine, ili kuamua ni nini kiwango cha awali cha sauti. Kwanza kabisa mimi <unk>m kuzalisha sine wimbi (tazama sehemu ya 1). pitch ya wimbi hili ni jamaa na nafasi ya panya X. Mzunguko huu unawakilishwa kwenye grafu kama mstari mweupe. Kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano, kwa mfano. Kwa hivyo, ni muhimu kujua ni nini frequency ya sauti ya awali ambayo inapaswa kutumiwa na FFT. Hii ni kwa njia ya kupata katikati ya kilele cha tatu na nne, na kisha wastani wa thamani hii na wastani wa urefu wa kilele cha tatu. Mzunguko uliokadiriwa unawakilishwa kwenye grafu na mstari mwekundu. Katika kona ya chini ya kulia unaweza kuona pitches mbili, na tofauti kati yao. Ni wazi hii bado ina njia kabisa ya kwenda kama mzunguko inakadiriwa hoja karibu kidogo.