Android Capture USB Mic Audio without root - android

My Android application is targeting non-rooted Samsung Galaxy Note 2 phones running Android 4.4.2.
When my USB microphone is plugged into the phone, it appears as /dev/snd/pcmC1D0c, so I know it is being recognizing as an audio capture device.
Is there a way to capture the Audio from this device into my app without rooting the Galaxy Note 2?
I tried AudioRecord with all the MediaRecorder.AudioSource options and they all use the phone's internal mic.
I did not find any option in Settings/Sound to change the input device.
I investigated Samsung's Professional Audio SDK and it looked very promising until I found the Galaxy Note 2 device I am targeting is unsupported by this SDK.
If there is no way to access it from Java, is it possible to use native c code (JNI) to access the existing tinyALSA driver and capture the audio without rooting the phone?
I know I can use use libusb to capture the audio packets directly, but I was hoping for an cleaner/easier way since the phone already recognizes my audio input device.

Related

Where to find Bluedroid config files on Android 5.0

I want to use a Lenovo Tab2 A7 (Android 5.0, rooted) as a A2DP sink. To do this, i have to edit the files:
/external/bluetooth/bluedroid/include/bt_target.h
and
/packages/apps/Bluetooth/res/values/config.xml
But i cant find them. I searched in every folder on the tablet. I also searched on the source which is provided by Lenovo:
http://support.lenovo.com/de/de/products/tablets/a-series/a7-10-2/downloads/ds105762
Can somebody give me a hint?
These files bt_target.h and config.xml actually do not exist on android device. These files are present in AOSP code. To enable A2DP sink you have to actually dig into the code, go to these files location as mentioned by you, make the changes and then compile either complete image or just bluedroid.
Also your device should be rooted if you just want to replace bluedroid library. In case of complete image, anyway you have to flash your complete image.
But, unfortunately it's not yet done for A2DP sink. With above steps you'll be able to enable sink profile and connect to it and start streaming from remote device to your device but the streaming data could not be played on your device. Reason being, AOSP does not have that portion of code available as of now which could play the streaming data on your phone speaker.
Refer below link for more info
A2DP sink discussion on android
But wait, there is one good news, with limitation though, Samsung Galaxy S7 and above series phones do support sink role. But right now there seems to be limitation in sink functionality of the phone. Galaxy S7 and above series phones can only connect with Tizen Smart TVs at present through in built quickconnect app.

Unable to record from USB microphone on Chrome on Android (Lollipop)

Based on previous thread, getUserMedia is supported in Chrome on Android now (version 40).
I got this working using the usual getUserMedia idiom (see, for example, http://www.html5rocks.com/en/tutorials/getusermedia/intro/).
This works on desktop (any mic) and on mobile (default mic).
However, when a USB mic is plugged in, this does not seem to work. The usual permission dialog is shown. However, the input audio will actually come from the phone's default mic (ie, scratching/tapping the usb mic produced no noise), even though the USBmic is clearly connected (ie, it lit up).
On desktop, you can fix this by selecting the audio input source, but I'm not sure how to do that on Android.
The really funny thing is that typical audio recording APPs can actually CORRECTLY get the audio input from the USB mic on the same device.
Has anyone experienced this problem?
I can reproduce this issue it appears to be specific to some Android phones and Android tablet devices that I have tested, including a Samsung Tab A7 and the Amazon Fire 10".
Currently testing Samsung Tab A7 with Chrome 103.0.5060.129 Android 11; SM-T220 Build/RP1A.200720.012
I do not have this issue in chrome on my Android Oneplus 8 running Android 11.
More information for reproducing:
The expected behavior does not work in Chrome, but does work as expected in Firefox.
Plug in an external USB microphone device
Open a site such as https://vdo.ninja/ or a https://www.webrtc-experiment.com/
Capture audio.
The default audio will be captured from the devices internal microphone instead of the USB microphone.
On sites such as the vdo.ninja, where you are able to select the audio source, even if the source is listed, such as "Wired Headset", changing the input will result in using the internal microphone.

Testing Voice Recognition App ~ Audio Out to Mic In Adapter

I'm developing an Android voice recognition app for my master thesis.
The app comes with different algorithms that transcribe voice.
To test which of them works best I want to feed the devices microphone with the same speech sample over and over again. I decided to use an open audio book from http://www.librivox.org.
I need an adapter to feed the audio book into my devices microphone input port since the Android VD (Emulator) does not support microphone input.
I have tested a direct connection:
AUDIO OUT (LAPTOP) ─────┐
├─[SPLITTER]─────HEADSET PORT (Device)
─────┘
* Splitter
This does sometimes work on my Sony Xperia ZL even though the quality is really bad.
I also tried an iRig instead of the splitter - but I think the input for the iRig is only for guitars' line out.
So: Is there a way to feed some audio output to my Android devices microphone input?
Although I didn't manage to feed my real device's mic with audio from my laptop I found a solution.
THE DIGITAL WAY
Step 1: To test my app I now use an Android-x86 in a VirtualBox on Ubuntu.
The Android-x86 is a Cyanogen modded Android 4.4 running on (virtual) machines and has microphone support (contrary to the original Android AVD). I tried this on Windows 8.1 but the mic stayed silent.
Step 2: I have to map my main audio output channel to a virtual audio input (virtual microphone). I mostly followed the instructions of this answer using PulseAudio, PulseAudio Volume Control and the magic command: sudo modprobe snd_aloop
Step 3: Set "Monitor of Built-In Analog Stereo" in PulseAudio Volume Control to standard device. Then set the Host Audio Driver to ALSA and run the machine.
THE ANALOG WAY
However I'm not giving up on the cable thing and will update this answer onSuccess().

Turn pc to a dock for android phones

I'm trying to get all the audio from my phone to go through my computer speakers via connecting through USB. Does anyone know how to achieve it? I'm trying to write some codes to let my pc being recognized as a dock for my galaxy s2 cell phone.
Thank you
There's no standard way of doing that, unless a given vendor has implemented it as a custom extension.
It's actually going to be easier to do some stream-over-wifi mechanism than to do it over the USB cable, unless you leverage the SDK's adb tool or a USB-tethering capability to get a network connection via the cable.
But a key problem that you will face is that 3rd party android apps on non-rooted devices cannot get permission to intercept audio coming from other unrelated applications.
Silly as it sounds, if you want your pc to be a "dock" for arbitrary application audio, you'll probably need a 3.5mm analog stereo patch cord. Or there might be a few PC bluetooth adapters which can be hacked to look like stereo headsets to the phone.
If you are content to play songs chosen by special software, I'm sure you can find a wifi streamer applications on the market or make your own; or you can access the files on the device from the PC using usb mass storage or MTP (depending on Android version) and play them in a PC-based player.
EDIT Guess what just got announced at Google IO 2012
http://developer.android.com/tools/adk/adk2.html#audio-dock
USB Audio Dock Implementation One of the important new features
introduced with the ADK 2012 is the ability to play audio over a USB
connection. This innovation was introduced as an update to Android
Open Accessory (AOA) protocol 2.0 and is available on devices running
Android 4.1 (API Level 16) and higher.
The ADK 2012 provides a reference implementation of this functionality
for accessory developers. No software application is required to be
installed on the connected Android device, accessory developers only
need to support AOA v2.
The assumption there is that the USB host would be a small embedded board, but I don't see why you couldn't get a PC to do that end of the task, at least if you manage to get any existing drivers installed on the PC out of the way.
Of course the downside is that you need an Android 4.1 or greater device... not many phones like that out. But if you go with the rooting method, you could try to create a compatible or at least similar interface.

MediaLauncher on emulator(virtual device)

Is it possible to play and record speech on android emulator? or it must require physical device?
Sorry, but its require a physical device... At least to recording:
Note that the emulator doesn't have hardware to capture audio or video, but actual mobile devices are likely to provide these capabilities
http://developer.android.com/guide/topics/media/index.html

Categories

Resources