I want to control zoom or focus of my Android phone's camera using audio jack. It is common to use audio jack to take picture or probably we may call it as shutter. It is done by connecting the mic port and the ground as shown in the picture 2 (I took it from here. It is not Android, but probably the same idea is possible with Android). Is it possible to do zoom or focus using the audio jack? Say, like we manipulate or rearrange it something like explained in picture 1? Picture 1 taken from here.
The Android specification for the audio Jack, this gives you the input/key events that can be generated by the audio jack. Your camera application should listen for these events and do the appropriate action.
How to create hardware to generate the events is here
Related
I'm developing an app that records audio input from the device's microphone(s). We'd like to record unprocessed/raw audio (i.e. with no effects applied like noise suppression or automatic gain control) and also give users the option to specify which microphone (e.g. top, front, back, etc.) to use for recording.
According to Android documentation, the only way to get an input audio stream that's guaranteed to be unprocessed is by selecting VOICE_RECOGNITION on setAudioSource()
That said, what would be the correct way to choose the physical microphone to use?
In more recent API levels, there are the following methods that seem to allow for the selection of specific microphones:
Android 6+: AudioRecord.setPreferredDevice() accepts a target input device to use for input. We may use AudioManager.getDevices() to get a list of available microphones, but it seems it's not possible to tell the position (front, back, etc.) of the microphones returned by that method.
Android 11+: AudioRecord.setPreferredMicrophoneDirection() receives a direction constant that specifies the "logical microphone (for processing)". That "logical microphone" seems to map well to what I'm calling a microphone's position (front, back, etc.), but I'm not sure about how this method works in conjunction with setPreferredDevice().
Does anybody know how to achieve my goals, i.e. get unprocessed audio input while also specifying the physical microphone to use?
The microphone selection is done with MediaRecorder.AudioSource.MIC (front) / MediaRecorder.AudioSource.CAMCORDER (back) / MediaRecorder.AudioSource.DEFAULT (default).
VOICE_RECOGNITION is used to enable/disable AGC but can only be used with the front microphone (MediaRecorder.AudioSource.MIC).
Does the ARCore SDK allow to configure the video source as the input for processing to others than the embedded cameras? Similar functionality is available in Wikitude and ARToolkit for instance, where the camera input can be replaced by custom video frames from other sources.
I don't think that there is such option. Remember that ARCore is using not only frames from camera but also position of your device as one set of input data. When you will push the video frames as a source of what app see it will not correspond with the position. This will probably be cause of situation where your app will not be able to map the world.
Remember that ARCore is not working only based on the camera/vide but it combines all other elements like gyroscope or accelerometer
I would like to record the sound of the jack entry of my android phone. I've been searching about the Audio Capture class in Android, and i've found this:
https://developer.android.com/guide/topics/media/audio-capture.html
In the settings of this class, there are many options to choose the rec default mic, as this:
Set the audio source using MediaRecorder.setAudioSource(). You will probably want to use MediaRecorder.AudioSource.MIC.
What should I use to get the sound of the jack entry? Is there any example?
Thank you!
The API you provided is the correct one.
Calling mediaRecorder.setAudioSource(MediaRecorder.AudioSource.MIC) (assuming the correct initialization of MediaRecorder as described here https://developer.android.com/guide/topics/media/camera.html -> Capturing Videos) will behave like this:
When you launch your app and start recording without any Jacks connected, phone's default microphones will be used. As soon as Jack microphone pin has detected a microphone connected, the system will use the Jack mic pin as an audio imput. Hovewer, you need to know that even though the audio record will have two channels, they will be identical, as Jack microphone can only record mono stream.
I am developing an Android application which is supposed to capture audio with the built-in mic of the smartphone and save it.
For the further processing purposes I would like to have some control over the quality of audio captured. For instance, to my knowledge some smartphones have high-quality audio recording mode and I would like to make use of it, if that is possible.
I am aware of mediaRecorder, but I am not sure how to use its methods or input arguments to get the best quality of sound possible. I would be very grateful if somebody could point out that for me or provide references to other libraries that allow to adjust the quality of recorded sound.
I've been asking around in developer circles about this, but so far no one has been able to confirm if it is possible. The default behavior for recording video in Android is to not use the external mic. I'd like to create an app that uses an external mic if it is available, but it seems like this might be tricky for some reason. Anyone have insight into this?
It seems like it would just be a matter of selecting it at this point in the recording setup:
recorder.setAudioSource(MediaRecorder.AudioSource.DEFAULT);
but it seems like there may be some oddness in doing that.
Thanks,
Jon
Default behavior in Android 12 (and I understand starting at 8 or 9) is that external microphones become the primary and default source for input.
It probably depends on the app, but at least video in the default camera app takes my external mic as default.
Take a look at the documentation here (look in the section titled "Performing Audio Capture") it covers setting up the audio capture.