AudioRecorder Library V1.00

NeoTechni

Well-Known Member
Licensed User
Longtime User
What parameters for OutputFormat and AudioEncoder do I use to record as MP3?
 

Gravy Jones

Member
Licensed User
Longtime User
Audio Library

I am interested in just capturing the audio for analysis without it actually having to record to the internal storage. Is it possible to use this library in that way? e.g. The program captures the microphone and allows the program to analyze the data in real time.
 

stevel05

Expert
Licensed User
Longtime User
You will need to use the AudioRecord Library for that, Have a look at the demo.
 
Last edited:

Djembefola

Active Member
Licensed User
Longtime User
What parameters for OutputFormat and AudioEncoder do I use to record as MP3?
 

Highwinder

Active Member
Licensed User
Longtime User
What parameters for OutputFormat and AudioEncoder do I use to record as MP3?

Ditto.

How do I use this AudioRecorder library to record to an MP3 file?

It was originally posted that this library can record to MP3. This question has been asked several times now. Is there an answer?
 

NeoTechni

Well-Known Member
Licensed User
Longtime User
This is what I used

B4X:
Sub ActivateMic(Dir As String, Filename As String) As Boolean 
   A.Initialize 
   If Not( A.isRecording) Then' a.stop 
      Try
         A.AudioSource=A.AS_MIC 'a.AS_VOICE_RECOGNITION 
         If Filename.length = 0 Then 
            Filename = "/dev/null"
            A.OutputFormat=A.OF_THREE_GPP
         Else
            A.AudioChannels=1
            'A.AudioEncodingBitRate=64
            'A.AudioSamplingRate=44000
            A.OutputFormat=A.OF_MPEG_4 
         End If
         A.AudioEncoder=A.AE_AMR_NB
         A.setOutputFile(Dir,Filename)
         A.prepare
         A.Start
         'Log("Mic Started")
      Catch
         'Log("MIC failed to init")
         Return False
      End Try
   End If
   Return True
End Sub

Since B4A doesnt support optional parameters (yet?) you have to pass it empty strings if you're just trying to monitor the peak
 

Highwinder

Active Member
Licensed User
Longtime User
This is what I used

...Else
A.AudioChannels=1
'A.AudioEncodingBitRate=64
'A.AudioSamplingRate=44000
A.OutputFormat=A.OF_MPEG_4
End If...


Since B4A doesnt support optional parameters (yet?) you have to pass it empty strings if you're just trying to monitor the peak


Is your code sample above (bold) recording to an output file in MP3 format? Forgive me for the possibly stupid question, I'm not a sound format guru. It also appears to be a mono (single channel) file as you have it set. Is this correct?

And also, just to confirm, this is using XverhelstX's AudioRecorder library for the above example? ("A.Initialize")

Thanks for the edumacation. :)
 
Last edited:

NeoTechni

Well-Known Member
Licensed User
Longtime User
Yes, that's for MP3 using this library.

You can change the bitrates, but most cellphones only have 1 mic
 

Djembefola

Active Member
Licensed User
Longtime User
Yes, that's for MP3 using this library.


The resulting file is not at all an mp3 file.

It can be played with the android media player, but it is not encoded in the mp3 format.

Try to open the file with standard software like wavelab or winamp: you will get an error message.
 

Highwinder

Active Member
Licensed User
Longtime User
The resulting file is not at all an mp3 file.

It can be played with the android media player, but it is not encoded in the mp3 format.

Try to open the file with standard software like wavelab or winamp: you will get an error message.


Hmmm, that's good to know. And unfortunate.
 

Highwinder

Active Member
Licensed User
Longtime User
Arrrgghhh!

For the life of me, I cannot get this to work. I am using this library to monitor the microphone level, which is wroking very well (recording to null). But when the sound level reaches a certain threshold, the idea is to shift over from recording to null to actually recording to a file. Kind of like an automatic dictaphone type app. This file will then need to be played back later.

However, I cannot get this library to record a sound file. Even the sample app that comes with the library is failing to produce a sound file.
The sample app is giving no errors, but where's the file it's supposedly producing? I can't find it anywhere. Am I supposed to be rooted to be able to find the file in some hidden or protected folder somewhere?

Attention XverhelstX, you haven't been heard in here for a very long time. Have you abandoned supporting this library?

Help!

:BangHead:

EDIT: Nevermind, I found some example code in the forums for comparison and was able to get it worked out.
 
Last edited:

Highwinder

Active Member
Licensed User
Longtime User
Hey Highwinder,

I have updated the library to Version 2.10.
Not many changes has been made, but it should be easier to create the output file. (It does work for me.)

Tomas

Tomas,

Thanks for the update. I had already solved the problem, but it's truly appreciated.

Huge Question:

What specific sound file format is this library TRULY recording? It's not recording true MP3s. Is it producing uncompressed WAV files? How does one find out? How is this library specifically supposed to be used to create true uncompressed WAV files? What about header information?

The reason I ask is because I need to produce a sound file with your library and then play it back using Stevel05's insanely complex AudioTrack library, which requires uncompressed WAV files to play, preferably with header.

How does one do this with AudioRecorder?

Thanks!
 

Djembefola

Active Member
Licensed User
Longtime User
After 17 months and a whole bunch of unanswered questions regarding mp3 in this thread, wouldn't it be a good idea to update the first post and remove the word "mp3" in the the following sentence? Finally?

You can record in various file formats including wav, mp3,

I wonder how many people (including me) spent hours to find out: it isn't true.
 

Highwinder

Active Member
Licensed User
Longtime User
After 17 months and a whole bunch of unanswered questions regarding mp3 in this thread, wouldn't it be a good idea to update the first post and remove the word "mp3" in the the following sentence? Finally?



I wonder how many people (including me) spent hours to find out: it isn't true.


Yes, very frustrating. But I would just be happy to get answers to my questions above. What kind of file IS this library producing? According to Stevel05, it's most likely producing uncompressed WAV. Confirmation would be nice.
 

XverhelstX

Well-Known Member
Licensed User
Longtime User
For the AudioRecorder, i'm using the MediaRecorder interface.
You should take a look here:
MediaRecorder | Android Developers

B4X:
public void setOutputFormat (int output_format)

Since: API Level 1
Sets the format of the output file produced during recording. Call this after setAudioSource()/setVideoSource() but before prepare().

It is recommended to always use 3GP format when using the H.263 video encoder and AMR audio encoder. Using an MPEG-4 container format may confuse some desktop players.

So indeed, mp3 is not supported by this library.
 

Djembefola

Active Member
Licensed User
Longtime User
it's most likely producing uncompressed WAV. Confirmation would be nice.

XVerhelstX, correct me if i'm wrong, but im pretty sure, this library does neither record uncompressed wav files nor mp3 files. When using the default settings (OF_Default, AE_Default) you will end up with a 3gp file.

The only way (that i have found until now in b4a) to record pure wav audio is Stevel05's AudioRecord library. With short wavs Audiorecord works fine and is easy to use. Things get a little bit more complicated, when it comes to recording long wav files (threading required).

So please edit your first post once again and remove the word "Wav" from the following sentence:

You can record in various file formats including wav...
 
Last edited:

stevel05

Expert
Licensed User
Longtime User
According to Stevel05, it's most likely producing uncompressed WAV.

You actually asked me if you were to record a WAV file with the audiorecorder library, what format would it be, to which the answer is that it will probably be an uncompressed wav.

Having looked quickly at the audiorecorder library, I can see no option to record an MP3.
 
Top