Android Question Recording sound from an external microphone

Lakhtin_V

Active Member
Licensed User
Longtime User
I created an application that analyzes the sound from the built-in microphone.
streamer to record to a buffer and Audio.dll:
'        streamer.Initialize2(1,"streamer",44100,True,16, streamer.VOLUME_MUSIC)       
        streamer.Initialize("streamer", Hz, True, 16, streamer.VOLUME_MUSIC)
        streamer.StartRecording
But I can not perform the same actions after connecting a studio external microphone to the 3.5 jack. I can assume that I always record the sound from the internal microphone and ignore the external one. How can I solve this problem?
 

John Naylor

Active Member
Licensed User
Longtime User
What Android device? What microphone? Specifically what jack does the microphone use? Can you confirm the microphone actually works with the phone using any other software? Does it have a TRRS jack plug?
ttrs.PNG
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
I've not used the Audio library so can't really shed any light there but can you try the attached example which uses Javaobject.

I've tried it with and without a TRRS mic and on my Galaxy A71 it works fine. It's just a simple test which should display in the logs the volume of your voice when you speak into the mic
 

Attachments

  • Audio.zip
    9.6 KB · Views: 57
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
I've not used the Audio library so can't really shed any light there but can you try the attached example which uses Javaobject.

I've tried it with and without a TRRS mic and on my Galaxy A71 it works fine. It's just a simple test which should display in the logs the volume of your voice when you speak into the mic
Thank you for your advice. If I understood your logic correctly, you suggest measuring the volume with and without a microphone. But your code does not explain how the sound source should be changed. For me, the main problem is that my version of sound analysis works without an external microphone and with an external one connected. But I do not see a difference in volume levels and in the signal spectrum. I want to be 100% sure that I am analyzing the signal from an external microphone. I understand that I am currently testing a cheap external microphone. But nevertheless, I want to programmatically control by selecting an external or built-in microphone as a sound source.
Maybe Android senses the microphone connection when a headset is used and the wire acts as an antenna for the radio receiver? Perhaps it is possible to programmatically detect only a headset + headphones + microphone. Android ignores only a separate microphone?
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
Thank you for your advice. If I understood your logic correctly, you suggest measuring the volume with and without a microphone. But your code does not explain how the sound source should be changed. For me, the main problem is that my version of sound analysis works without an external microphone and with an external one connected. But I do not see a difference in volume levels and in the signal spectrum. I want to be 100% sure that I am analyzing the signal from an external microphone. I understand that I am currently testing a cheap external microphone. But nevertheless, I want to programmatically control by selecting an external or built-in microphone as a sound source.
Maybe Android senses the microphone connection when a headset is used and the wire acts as an antenna for the radio receiver? Perhaps it is possible to programmatically detect only a headset + headphones + microphone. Android ignores only a separate microphone?
My code just works with whatever microphone is in use it doesn't need telling which mic to use. If there's one plugged in it works immediately with that and with the normal phone mic if not. As such I was just tring to figure out if it’s an issue with the audio class you are using or the phone / external mic. Can you isolate the phone somehow when your external mic is plugged in? Then do the sam with the external mic to see if they are indeed being seperated?
 
Upvote 0

John Naylor

Active Member
Licensed User
Longtime User
My code just works with whatever microphone is in use it doesn't need telling which mic to use. If there's one plugged in it works immediately with that and with the normal phone mic if not. As such I was just trying to figure out if it’s an issue with the audio class you are using or the phone / external mic. Can you isolate the phone somehow when your external mic is plugged in? Then do the same with the external mic to see if they are indeed being seperated? On mine the external mic simply takes priority and the in built one on the phone stops working.
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
I have tested several smartphones. I connected an external microphone directly to the jack without an adapter. And with an adapter to the microphone jack. After that, I covered the microphone with a cloth, wrapped the microphone with a towel and a scarf many times. The microphone should not hear external sounds, but my application still registered them. I conclude that in my case the signal always comes from the built-in microphone. So far, I still do not understand how to programmatically disable the built-in microphone and use only the external one...
 
Upvote 0

teddybear

Well-Known Member
Licensed User
1.Place your phone under a thick pillow, cover it tightly, and start recording to see what happens.
2.Take a wired headphone with a built-in microphone like this, connect it to your phone, do the same thing, and see what happens.
 
Upvote 0

Lakhtin_V

Active Member
Licensed User
Longtime User
What does the sound source parameter mean, located in the first position. If I set 0, the signal is written regardless of the presence of an external microphone. The same thing happens when I set 1, the sound is recorded by both the external microphone and the internal one. My task is to record sound only from an external microphone. How should my code look correctly?
streamer.StartRecording:
        streamer.Initialize2(1,"streamer",44100,True,16, streamer.VOLUME_MUSIC)
        streamer.StartRecording
 
Upvote 0
Top