Badly Needed: Microphone Library

NeoTechni

Well-Known Member
Licensed User
Longtime User
Some times I get an invalid state warning after an activity resume, is there a way to check or reset the state of the mic?
 

Gravy Jones

Member
Licensed User
Longtime User
Microphone data

I too am looking for the ability to monitor microphone data in real time without actually saving the data.

In my application I'd like to be able to have the frequency data provided to a callback function.

A basic usage of something like this could be for seeding a random number generator
 

stevel05

Expert
Licensed User
Longtime User
To achieve that you'd need to use the AudioRecord Library and write your own call back based on the amplitude of the monitored signal, then calculate the frequency from captured data.
 

alfcen

Well-Known Member
Licensed User
Longtime User
Without knowing the unit of AudioMaxAmplitude it is indeed awkward to produce something like a VU-Meter or a noise level meter. The Android microphone circuit may also include an AGC.

The attached skeleton app is an analog VU-Meter that requires calibration. Perhaps someone has a professional measuring instrument which could be used to calibrate the values and bring it on a logarithmic analog scale.
 

Attachments

  • vumeter.zip
    51.7 KB · Views: 1,548
  • vumeter.jpg
    vumeter.jpg
    6.1 KB · Views: 991
Last edited:

nad

Active Member
Licensed User
Longtime User
You can try to use

https://play.google.com/store/apps/details?id=kr.sira.sound

on a second phone to adjust your function instead of a real sonometer.

Anyway i have been trying for many hours with no luck

seems decibels are log10 of the raw power


dB=20*Logarithm(Amplitude,10)

I have tried many things with no luck.

Maybe using solver from excel and building a table of equivalences between the audiomaxamplitude, how much that is in the sonometer (from google play) and try to find some equivalence.

Some mobiles seem to get 100dB max, others not so much. If that is 32768 (max amplitude), maybe that can be used for the scale


Any ideas?
 
Last edited:

Highwinder

Active Member
Licensed User
Longtime User
Actually, the wonderful VU meter from Alfcen is a great example of monitoring the MIC without saving data. I recommend starting with that, I've found it to be as accurate as anything else on the market. The app mentioned earlier gets complaints about the same level of inaccuracy, so it seems this is the norm out there.
 
Last edited:

Highwinder

Active Member
Licensed User
Longtime User
What you need to do now, is to decide what level your trigger should be at, then write the logic that says stop monitoring and start recording to a file when that level is exceeded while keeping an eye on he level, once it falls Stop recording to a file and start monitoring.

The main problem I can see is that is that sound is a moving thing, so unless your monitoring for something that you know will be loud and continuous, you're likely to get lots of stops and starts even if the overall level seems quite loud to the ear.

You may want to consider recording for a set time and then check again if you need to keep recording, but you still may hit a trough and start again immediately.

You will only get the best set up once you've tried it.

I know the above quote is a little old now, but I have done exactly this, to an extent. I have written somewhat of an "automatic dictaphone" app that monitor's the mic volume using the AudioRecorder library. It does the following by way of a timer:

1. Monitor's mic volume in a "listening" mode (without recording to a file - more on that shortly).
2. At a certain mic level threshold, it goes into a fake "recording" mode (pretending it was writing to a file - my problem).
3. It stays in "recording mode" as long as audio input to the mic remains above certain level.
4. If audio input drops below the threshold level for longer than 1/2 second, it drops out of "recording mode" and shifts into "playback mode".
5. This "playback mode" is where it would have played the recording file had it been writing one.
6. After this "playback mode" completes (I'm just faking it with another timer at this point), it then goes back into "listening mode".

It works great so far, such as it is.

Ok, so here's my problem: How on earth does one get the AudioRecorder library to write to an MP3 file - as in, the way it was described when it was posted by its author? Heck, I'd even settle for a WAV file, because the seemingly only available file formats for this library are non-standard stuff that nobody can really use. Is MP3 output even possible?

If not, then here's the real question of the day: Can I monitor Mic levels (with AudioRecorder) and simultaneously record to an MP3 file with another lib that writes to MP3?
 
Last edited:

Djembefola

Active Member
Licensed User
Longtime User
How on earth does one get the AudioRecorder library to write to an MP3 file - as in, the way it was described when it was posted by its author?

In contrast to the author's promising announcement this functionality obviously does not exist in the audiorecorder library.
There are several unanswered questions in the audirecorder library thread regarding mp3.
 

Shay

Well-Known Member
Licensed User
Longtime User
question about leaving the mic. open all the time
how does it affect the battery? (is it?)
 

carchek

Member
Licensed User
Longtime User
Without knowing the unit of AudioMaxAmplitude it is indeed awkward to produce something like a VU-Meter or a noise level meter. The Android microphone circuit may also include an AGC.

The attached skeleton app is an analog VU-Meter that requires calibration. Perhaps someone has a professional measuring instrument which could be used to calibrate the values and bring it on a logarithmic analog scale.
I know it's and old thread but I get Java Null Pointer Exception on Line 47
B4X:
Ar.AudioSource = Ar.AS_MIC
What's wrong?
 

stevel05

Expert
Licensed User
Longtime User
It looks like the library has been updated since the post was made, add AR.Initialize immediately before the AR.Audiosource = AR.AS_MIC line.
 

jonas4

Member
Licensed User
Longtime User
May be that this is a little late, and maybe this information is already posted somewhere else, but MonitorVolume App inside Microlevel.zip did not work on my device for the first (Runtime error). I found out that the AudioRecorder object in Activity_Create needs to be initialized first:

Code:

B4X:
Sub Activity_Create(FirstTime As Boolean)
   
    Activity.LoadLayout("Level")
    cn.Initialize(Panel1)
       
    'Calls sub AmplitudeCheck every 500 milliseconds
    T.Initialize("AmplitudeCheck",100)
   
    'Set up recorder
    A.AudioSource=A.AS_MIC
   ...

New:

B4X:
Sub Activity_Create(FirstTime As Boolean)
   
   
    Activity.LoadLayout("Level")
    cn.Initialize(Panel1)
       
    'Calls sub AmplitudeCheck every 500 milliseconds
    T.Initialize("AmplitudeCheck",100)
   
    'Set up recorder
    A.Initialize
    A.AudioSource=A.AS_MIC
    ...
 

Isa Paine

Member
Licensed User
Longtime User
How do I convert the incoming 600 Hz (approx.) from the 3.5" mic jack to temperature?
 

stevel05

Expert
Licensed User
Longtime User
What are you using as a data capture device?
 

Isa Paine

Member
Licensed User
Longtime User
I have a temperature probe plugged into the 3.5" mic jack of my Samsung Galaxy S5 supplying 600 Hz, approximately. How do I convert that to temperature?
I'm running Gigtron's MicroLevel App and the numbers I'm getting back are around 9.??? or 10.???.
 

stevel05

Expert
Licensed User
Longtime User
You'll need to check the manufacturers spec to see what the numbers relate to, I presume that the temperature is directly related to the amplitude of the input wave but it could be a linear or logarithmic scale. You'd also need to know the bit rate and endieness (if it's greater than 8 bits) and as the results would be very different if you are not reading the correct no of bits, or in the wrong order.
 

Gary Milne

Active Member
Licensed User
Longtime User
Is there a sample that goes with the current version of the library? I tried the one at the start of the thread but it seems the library is quite different from it's first iteration.

Thx.
 
Top