I'm coding a program to detect frequencies from a given sample of sound, in this case from the microphone.
I don't fully visualize how to do that. It will very helpful some answers about this topic.
Printable View
I'm coding a program to detect frequencies from a given sample of sound, in this case from the microphone.
I don't fully visualize how to do that. It will very helpful some answers about this topic.
I suggest you do some research on Fast Fourier Transform (FFT)
I've done some research on FFT. The first thing I've to do is to store in a variable the information from the microphone that is the thing I'm reading how to do. Once I've the information then I can do FFT to determine 1) Frequency 2)decibels.
Bass.dll examples do it. The whole spectrum is divided into a given number of parts (eg, 4096), in each of them can be found the force.
But my main question is what kind of data I've to analyze to get the frequencies. I know the method I've to use is FFT. But my question is what kind of variable that contains the data I've to analyze.
As far I know, I think it should be the buffer that contains the variables of microphone audio input. Using FFT I can analyze it, right?
My other question is about the mechanism involved since I produce a sound in the microphone until that sound information is stored in a variable. I don't know how to do that because I've no idea about the mechanism involved.
Right, but it is already done by bass.dll.
But using the FFT may be very interesting.. Look at http://www.planetsourcecode.com/vb/s...xtCriteria=FFT
Have you any link to the website of bass.dll? I've found some links, but as you know some can offer an old version.
I'm learning now to do the same using DirectSound.
I've found a piece of code in planetsourcecode.com that comes inside a vb program:
I think in those lines I can examine the microphone buffer and pass the data to the FFT function. Right?Code:Private Sub DirectSoundRecord_GotWaveData(Buffer() As Byte, BitsPerSample As Integer, Channels As Integer)
http://www.un4seen.com/ There are many examples on the VB...
Thanks for the link.
Apparently, I've obtained the data from the microphone buffer using the code I posted above.
Private Sub DirectSoundRecord_GotWaveData
The problem is that the Buffer is Byte type and when I do...
Dim MyVariable as string
MyVariable = Byte
Text1.text = text1.text & MyVariable
The 90% of the text is "???????????????????????"
My question is if I can pass that Byte data to the FFT function to get the frequencies.
I'm also learning about Bass.dll
I think you can add FFT in the DisplayWaveData16 and the DisplayWaveData8 procedures.
Thanks, I've found this in the code:
I think DataBuff is the variable that stores the values that are read from the microphone input. I've also found inside the code DisplayWaveData8. I tried before to put the DataBuff in a textbox but an error message appears. So I think I've to transform the variable type from Byte to String.Code:' the sound is 16 bit, but it comes in Bytes, not Integer
Private Sub DisplayWaveData16_8(DataBuff() As Byte, Pic As PictureBox, Stereo As Boolean)
Dim Buff() As Integer
ReDim Buff(UBound(DataBuff) \ 2 - 1)
CopyMemory Buff(0), DataBuff(0), UBound(DataBuff) + 1
DisplayWaveData16 Buff, Pic, Stereo
End Sub
I do:
dim MyVariable as string
MyVariable = DataBuff
Text1.text = Text1.text & MyVariable
Is this way correct or there is a specific function to change from Byte type to String type variable?
I've made the conversion using StrConv but something similar happens. The textbox shows a lot of "????????????????????".
I've read in microsoft website that when you transform the data from Byte to String the data can be damaged because they're different format (Ansi and Unicode).
Just a Question.... the information in the Byte type variable is writting data to the file using values from 0 to 255. The frequency of audible sounds can be up to 4,000 Hertz or even more in some cases. So, if I want to measure the tones using FFT... I think some kind of transformation between Byte to Hertzs is made but I've to check the source code of the FFT.
Why do you want to use a strings when this is only the numbers required?
8 bits per sample - it is unsigned values (from 0 to 255)
16 bits and more - it is signed values (from -32768 to 32767 for the 16 bits)
In the stereo wave, samples are interleaved:
Left value, than right value etc.
Values in the samples is not Hertzs, it is volts. You must find a sine/cosine functions from volts with the FFT.
I think this information is enough.
You can try this... Attachment 94303
more samples: http://s.pudn.com/search_hot_en.asp?k=FFt+VB#
I guess you have to study first what FFT is. It is certainly not a frequecy meter. It is converting from the time domain to the frequency domain. Its resolution (freq steps) depends of the sample rate (soundcard) and the samples you have. Read this (chapter 10 and on) as a start:
http://www.dspguide.com/pdfbook.htm