Android Question AudioRecorder - lib - is it works or not ?

renemo

Member
Licensed User
Longtime User
Hi
I use AudioRecorder in the past but from last Android updates i have some fail with this

This sequence:
Ar.Initialize
Ar.AudioSource = Ar.AS_MIC
Ar.OutputFormat = Ar.OF_THREE_GPP
Ar.AudioEncoder = Ar.AE_AMR_NB
Ar.setOutputFile("","/dev/null")
Ar.prepare
Ar.start

ends with error:
java.lang.RuntimeException: start failed.

Any permission are done
So, Is it some additional changes in use of this lib ?
 

stevel05

Expert
Licensed User
Longtime User
Looking at the problem on the internet, it appears that AMR_NB (and WB) is not as widely supported on devices as it used to be. Probably time to update to something better supported. As Erel suggested, Audio streamer may be a better bet.
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
If you really need an AMR_WB format, you could record first record in a WAV format, then use FFmpeg to convert to AMR_WB format.
 
Upvote 0

renemo

Member
Licensed User
Longtime User
I need solution similar to SoundMeter - read mic audio volume in real time - AudioRecorder works fine - AudioStreamer is not in real time
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
Have you tried different audio encoder settings?
 
Upvote 0

JohnC

Expert
Licensed User
Longtime User
Are you saying that the data being processed by the below routine of streamer does not contain real-time volume data?

B4X:
Sub streamer_RecordBuffer (Buffer() As Byte)
    RecOutput.WriteBytes(Buffer, 0, Buffer.Length)
End Sub
 
Upvote 0

kimstudio

Active Member
Licensed User
I need solution similar to SoundMeter - read mic audio volume in real time - AudioRecorder works fine - AudioStreamer is not in real time

For this it is better to user AudioRecord made by steve, record raw PCM audio in a buffer and check raw audio data in the buffer instead of in a file. I believe AudioStreamer is the same and convinient as it has a callback event mentioned by JohnC to avoid using the threading lib. If it is not in real-time you need to reduce the buffersize parameter to for example 100ms or smaller.
 
Upvote 0

boller2012

New Member
Licensed User
Longtime User
Hi
I use AudioRecorder in the past but from last Android updates i have some fail with this

This sequence:
Ar.Initialize
Ar.AudioSource = Ar.AS_MIC
Ar.OutputFormat = Ar.OF_THREE_GPP
Ar.AudioEncoder = Ar.AE_AMR_NB
Ar.setOutputFile("","/dev/null")
Ar.prepare
Ar.start

ends with error:
java.lang.RuntimeException: start failed.

Any permission are done
So, Is it some additional changes in use of this lib ?
Hey nenemo,

my English is not very best, but i can help you.
So, i have the same problem for many times:mad:. And i have for many hours the solution::D

In my Project, i need the Audiolevel.

you must away Android 11 do that:

You must replace the Ar.setOutputFile("","/dev/null") to real Data File >>> Ar.setOutputFile(file.DirInternal,"example.wav")

And when you must limit the filesize from "example.wav" , then you must start a Timer with monitoring the filesize.

so, example my Timer:
when my example.wav bigger than 100 kb then i delete it and beginn a new empty file ! (so in Loop)


sub T1_tick

d=File.Size(file.DirInternal,"example.wav")
If d>100000 Then
ar.stop
File.Delete(file.DirInternal,"example.wav")
ar.AudioSource=micx.AS_MIC
ar.OutputFormat=micx.OF_THREE_GPP
ar.AudioEncoder=micx.AE_AMR_NB
ar.setOutputFile(ioHardware,"ref.wav")
ar.prepare
ar.start
Else
miclevel=ar.AudioMaxAmplitude 'miclevel >>> my Integer Variable for my Audiolevel.
End If

end sub

it is needed away Android 11 !!!!
so, i hope, i can help you for your project.

Best regards

Stefan
 
Upvote 0

boller2012

New Member
Licensed User
Longtime User
Hey nenemo,

my English is not very best, but i can help you.
So, i have the same problem for many times:mad:. And i have for many hours the solution::D

In my Project, i need the Audiolevel.

you must away Android 11 do that:

You must replace the Ar.setOutputFile("","/dev/null") to real Data File >>> Ar.setOutputFile(file.DirInternal,"example.wav")

And when you must limit the filesize from "example.wav" , then you must start a Timer with monitoring the filesize.

so, example my Timer:
when my example.wav bigger than 100 kb then i delete it and beginn a new empty file ! (so in Loop)


sub T1_tick

d=File.Size(file.DirInternal,"example.wav")
If d>100000 Then
ar.stop
File.Delete(file.DirInternal,"example.wav")
ar.AudioSource=micx.AS_MIC
ar.OutputFormat=micx.OF_THREE_GPP
ar.AudioEncoder=micx.AE_AMR_NB
ar.setOutputFile(ioHardware,"ref.wav")
ar.prepare
ar.start
Else
miclevel=ar.AudioMaxAmplitude 'miclevel >>> my Integer Variable for my Audiolevel.
End If

end sub

it is needed away Android 11 !!!!
so, i hope, i can help you for your project.

Best regards

Stefan
oh, an mistake in my example text: the row >> ar.setOutputFile(ioHardware,"ref.wav") must of course
ar.setOutputFile(file.DirInternal,"example.wav") mean.....sorry
 
Upvote 0
Top