Recording audio in android - java

I want to record own voice or any through mic(In any way) into a file in my project and want to read later and listen to it.How can i do this? Anyone reply me please.

http://developer.android.com/guide/topics/media/index.html
About 3/4 the way down the page you'll see
Performing Audio Capture
Audio capture from the device is a bit more complicated than audio and video playback, but still fairly simple:
Create a new instance of android.media.MediaRecorder.
Set the audio source using MediaRecorder.setAudioSource(). You will probably want to use MediaRecorder.AudioSource.MIC.
Set output file format using MediaRecorder.setOutputFormat().
Set output file name using MediaRecorder.setOutputFile().
Set the audio encoder using MediaRecorder.setAudioEncoder().
Call MediaRecorder.prepare() on the MediaRecorder instance.
To start audio capture, call MediaRecorder.start().
To stop audio capture, call MediaRecorder.stop().
When you are done with the MediaRecorder instance, call MediaRecorder.release() on it. Calling MediaRecorder.release() is always recommended to free the resource immediately.
Followed by code showing exactly how to store audio input and play it back, hope this helps. (I tried to paste the code here but pasting from android's guides is difficult)

Related

Get input stream from USB device for decoding DAB+

I need to implement a DAB+ player. Therefore i ordered a DVBT stick which can also retreive DAB and DAB+ signals.
My simplified approach looks like this:
Read input stream, split for audio and further information, pass the audio part to the audio library and process the further information for displaying in a GUI.
So my first question is: how do i get the input stream delivered by the device?
Can i simply create a new file object and call something like getInputStream()?
Second question: Is anyone familiar with DAB decoding? How do i split the input stream for audio and other information? How can i synchronize it? Which audio library should i use?
Thanks a lot

Using MediaRecorder.AudioSource.VOICE_DOWNLINK in Google Cloud Speech API(Android App)

I'm developing an Android app that displays the text of voice of other party who's in the phone call. I'm using Google Cloud Speech API. I think I've two options:
Record Audio of other person(in regular intervals) and send it through API as InputStream and receive the corresponding text.
Change this line of code to something like MediaSource.AudioSource.VOICE_DOWNLINKwith proper AudioFormat Encodings.
In the first case, mApi object in SpeechService.java is becoming null (Although in onPostExcute() method, mApi isn't null. I'm sure I'm calling recognizeInputStream() method after mApi is assigned. I don't know what's wrong here.
In the second case, I don't know if it possible to change AudioSource from MIC to VOICE_DOWNLINK(I got Invalid Audio Source Error, when I changed). If it's possible, I don't know proper AudioFormat settings (like Channel and Encoding). Do I have to direct BroadcastReceiver method to make this case possible?

vlcj - audio callback

I need audio data callback while vlcj is playing the video file.
And then I want to add some effect (pitch shifting, etc..) on that audio and direct sound out.
I found vedio buffer call back in vlcj documentation, but not audio callback.
if i can get the audio callback, i can use other library such as soundtouch, etc...
or please let me know other alternative like as vlcj.
i just success with nVLC + NAudio on Windows.
It is possible with vlcj? Should I use gstreamer (gstreamer-java) or MPlayer?
regards,
-pph
vlcj 2.4.0 adds a new DirectAudioPlayer and associated DirectAudioPlayerComponent.
and sound touch wrapper
http://www.aplu.ch/home/apluhomex.jsp?site=44
make me complete.

MediaPlayer.snoop on android

I found the function MediaPlayer.snoop(short[], int) in Accessing the Android media stream for audio visualization but I couldn't use it.
I am wondering there is a method snoop in MediaPlayer.class.
Looks it is not public method but private one of MediaPlayer.
If there is how can i get audio stream from that method.
Thank you.
Look at the GrabAudio class of this open source wallpaper app,
https://bitbucket.org/Metastable/deadmau5-audio-visualizer/src/249150da7cfa2c20e8d1456a31aaabd46df6d26d/src/com/metastable/deadmau5?at=default
This is a magic class that will get tons of audio data. Very useful source.
This is the other open source app that you can look at but it doesn't seem to get audio data from the output, it just loads a media player and analyzes that one.
https://github.com/felixpalmer/android-visualizer

Android: mpeg4/H.264 packetization example

I need to split mpeg4 video stream (actually from android video camera) to send it through RTP.
The specification is little large for quick reference.
I wonder if there any example/open source code for mpeg4 packetization?
Thanks for any help !
Mpeg4 file format is also called ISO/IEC 14496-14. Google it any you will find specifications.
However, what you are trying to do (RTP publisher) will be hard for the following reasons:
Mpeg4 has header at the end of the file. Which means header will be written out only when video stream is finished. Since you want to do real time video streaming you will need to guess where audio and video packets start/end. This will not be the same on all Android devices as they might use different video sizes and codec parameters. So your code will be device-dependent and you'll need to support and test many different devices.
Some devices do not flush video data to file in regular intervals. Some only flush once a minute or so. This will break your real-time stream.
There is no example code. I know because I looked. There are a few companies that do something similar, but mainly they skip RTP. Instead they progressively upload the file to their own server and then implement video/audio stream "chopping" and then insert it into their video/transcoder backend. I used to work for one of those companies and that's how we did it. AFAIK competition took similar approaches. The upside is that all complexity is on server an you do not need to update clients when something breaks or new devices arrive on the market.

Categories