I want to ask you if there is an API that plays a sound file (mp3,...) instead of microphone or change the input from microphone to speaker like stereo mix on windows .
I think you're looking for this question:
Stream audio to a phone call Android
Summary: You need to be rooted if you want to achieve that
Related
Probably an unusual request, but here goes...
I'm trying to create a script (ideally in Python, but open to other options) that will stream an mp3 file from a computer to an Android Phone's microphone input. I guess this would require exposing the computer to the phone as a USB microphone, then playing the mp3 file out of that sound device. I can play the mp3 via sounddevice easily enough but don't know where to start setting the phone's mic input as a sound output or vice-versa. I wondered about ADB or something like that, but am well out of my depth now.
Basically I have some voice recordings that I'd like to put into a voice changer app, but the app can only record from the microphone and doesn't have an option to change pre-recorded files.
Maybe someone's seen or done something like this before?
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'm working with AudioRecord, when I plug the earphones in my device, it will record both the input sound from the microphone in earphones and the input sound from the mic in device.
How can I disable the input sound from the microphone programmatically?
Scratch previous answer, FOUND THE SOLUTION!
https://stackoverflow.com/a/21735706/5439782
Step 3 is CRUCIAL! Instead of calling default profile on all settings, call it before and store it in Profile. THEN set all the settings you need WITHOUT audio encoder and audio source. Worked for me on unrooted device :)
My problem is when I talk into the microphone, I want my sound to go to speaker of the phone which has Android OS. I think "MediaPlayer" class can't do it. Do you have any way?
Here you are not clear in which scenario you are going to do this but however it is possible to do using AudioManager, you can set your modes and audio services. For more details refer this link :
AudioManager
Hi i want to record sound that is currently played in android handset, actually i want to get access to audio played by speaker or headphones.
Is there any way to do it?
Not via the Android SDK, sorry.