Android Question Creating a VU meter to display the decibel value

Reinald Assheuer

Member
Licensed User
Longtime User
Hi, I want to create a very easy app which shows me only a number which represents the loudness level.
I saw here several threads which are talking about the "audiorecorder" lib which I can't find. Is it obsolete?

I think the functionality of "AudioMaxAmplitude" or something like this could help me.

Thanks in advance
Reinald
 

DonManfred

Expert
Licensed User
Longtime User
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Upvote 0

MarkusR

Well-Known Member
Licensed User
Longtime User
AudioStreamer seems a lib from Erel.
it have a RecordBuffer event.
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
On further investigation of the Vizualizer class (it's been a while since I've looked at it), there is already a getMeasurementPeakRMS method, although there is a bug in the code. if you want to try it you will need to change the sub in the Visualizer class to:
B4X:
'Retrieves the latest peak AND RMS measurement.
Sub getMeasurementPeakRms As PeakRMS
    Dim PRMS As JavaObject
    PRMS.InitializeNewInstance("android.media.audiofx.Visualizer.MeasurementPeakRms",Null)
    Viz.RunMethod("getMeasurementPeakRms",Array(PRMS))
    Dim Result As PeakRMS
    Result.mPeak = PRMS.GetField("mPeak")
    Result.mRMS = PRMS.GetField("mRms")
    Return Result
End Sub

In the original the Array() definitions is missing from the line : viz.RunMethod("getMeasurementPeakRms",Array(PRMS))

It appears I forgot to update the main project when the bug was reported, either change it manually or download the separate visualizer,bas file. I will update it properly later.

Also you will need to set the measurement mode:
B4X:
Viz.MeasurementMode = 1

in the Activity create sub,
 
Last edited:
Upvote 0
Top