Measuring a tone via microphone in realtime

fatman

Active Member
Licensed User
Longtime User
Hi folks,

I searched nearly everywhere ;-) but could not find the real thing.
I want to measure the frequency of a tone in hertz in realtime. The source is the buildt in microphone.
Found an example of a vu-meter etc but none of the examples is measuring the frequency...
Any hints/ideas are welcome.

Fatman
 

fatman

Active Member
Licensed User
Longtime User
Thx Peacemaker,

I stumbled upon FFT too- but this topic exceeds my skills;)

Gonna try it out anyway.

Fatman
 
Upvote 0

peacemaker

Expert
Licensed User
Longtime User
For some try:

'Service module
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim UAV As UAVisualization
Dim Timer1, Timer2 As Timer
Dim BufferSize As Int: BufferSize = 128
Dim UAVinitialized As Boolean

End Sub

Sub Service_Create

End Sub

Sub Service_Start (StartingIntent As Intent)
Timer2.Enabled = True

If UAVinitialized = False Then

Try
UAV.initialize("UAVV",0) 'Initialize the Visualizer. 0 is for the Generalsoung
UAV.setCaptureSize(BufferSize) 'Set the Max Buffer
UAV.setEnabled(True) 'Set Enable
UAVinitialized = True
Timer1.Initialize("Timer1", Interval)
Catch
UAVinitialized = False
ToastMessageShow("Error during audio capture, restart device.", True)
StopService("")
Return
End Try


If UAV.Enabled=False Then
UAV.setEnabled(True)
End If
Timer1.Enabled=True
Else
StopService("")
ToastMessageShow("Service is already started.", True)
End If

End Sub

Sub Timer1_Tick

Timer1.Enabled = False

Dim MBytes(BufferSize-1) As Byte 'Byte in 512 Array = Max BufferSize
UAV.getWaveForm(MBytes) 'Get the Byte from getWaveForm

For I = 0 To MBytes.Length -1
level = Bit.AND(MBytes(I), 0xff) 'Convert unsignat Byte
.............

You need UAV.getFft.

Good luck.
 
Last edited:
Upvote 0

fatman

Active Member
Licensed User
Longtime User
Thank you very much!

I will try this our later and will give you a feedback.
The challenge for me writing app/progs is not the algorithm itself but the communication with the system/hardware.

Regards Fatman
 
Upvote 0
Top