|
-
Oct 27th, 2012, 02:48 PM
#1
Thread Starter
Hyperactive Member
VB6 - Detecting frequencies from microphone sounds
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.
-
Oct 27th, 2012, 04:17 PM
#2
Re: VB6 - Detecting frequencies from microphone sounds
I suggest you do some research on Fast Fourier Transform (FFT)
-
Dec 9th, 2012, 09:41 AM
#3
Thread Starter
Hyperactive Member
Re: VB6 - Detecting frequencies from microphone sounds
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.
-
Dec 11th, 2012, 05:31 AM
#4
Junior Member
Re: VB6 - Detecting frequencies from microphone sounds
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.
Last edited by Filyus; Dec 11th, 2012 at 05:35 AM.
-
Dec 15th, 2012, 04:49 AM
#5
Thread Starter
Hyperactive Member
Re: VB6 - Detecting frequencies from microphone sounds
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.
-
Dec 15th, 2012, 04:54 AM
#6
Junior Member
Re: VB6 - Detecting frequencies from microphone sounds
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
-
Dec 15th, 2012, 05:27 AM
#7
Thread Starter
Hyperactive Member
Re: VB6 - Detecting frequencies from microphone sounds
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:
Code:
Private Sub DirectSoundRecord_GotWaveData(Buffer() As Byte, BitsPerSample As Integer, Channels As Integer)
I think in those lines I can examine the microphone buffer and pass the data to the FFT function. Right?
-
Dec 15th, 2012, 05:33 AM
#8
Junior Member
Re: VB6 - Detecting frequencies from microphone sounds
http://www.un4seen.com/ There are many examples on the VB...
-
Dec 16th, 2012, 05:32 AM
#9
Thread Starter
Hyperactive Member
Re: VB6 - Detecting frequencies from microphone sounds
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
-
Dec 16th, 2012, 05:59 AM
#10
Junior Member
Re: VB6 - Detecting frequencies from microphone sounds
I think you can add FFT in the DisplayWaveData16 and the DisplayWaveData8 procedures.
-
Dec 16th, 2012, 06:21 AM
#11
Thread Starter
Hyperactive Member
Re: VB6 - Detecting frequencies from microphone sounds
Thanks, I've found this in the code:
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 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.
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?
-
Dec 16th, 2012, 06:45 AM
#12
Thread Starter
Hyperactive Member
Re: VB6 - Detecting frequencies from microphone sounds
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.
-
Dec 16th, 2012, 06:57 AM
#13
Junior Member
Re: VB6 - Detecting frequencies from microphone sounds
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.
Last edited by Filyus; Dec 16th, 2012 at 07:02 AM.
-
Dec 16th, 2012, 07:35 AM
#14
Junior Member
Re: VB6 - Detecting frequencies from microphone sounds
Last edited by Filyus; Dec 16th, 2012 at 07:39 AM.
-
Dec 17th, 2012, 03:37 AM
#15
Re: VB6 - Detecting frequencies from microphone sounds
 Originally Posted by Jose_VB
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.
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|