Media :: System Sleep While AudioRecord Is Recording?
Sep 8, 2009
I am new to Android and has been trying to find out if Android 1.5 on HTC magic is able to put system to sleep while collecting audio data through microphone.
What I am trying to accomplish is to continously collecting audio (PCM 16bit at 8K Hz) from microphone as long as possible. I have tested with AudioRecord class and is able to record audio continously for 7 hours before battery running out. 7 hours is good but not enough.
I noticed that during recording, although screen is turned off automatically, the system is never put into sleep mode. I wish sleep mode will allow recording go much longer. I found out by comparing SystemClock.uptimeMillis() and System.currentTimeMillis() before and after recording.
However as I reviewed David Sparks presentation at Google I/O (Google I/O - Mastering the Android Media Framework). David suggested at the end of the presentation that system should be automatically go to sleep mode while AudioRecord is collecting data into the preconfigured buffer(1 M bytes in my example). There are two problems I was facing while trying a simple recording 8k PCM 16bit using buffer of 1 Mbytes.
1. AudioRecord.setPositionNotificationPeriod() or AudioReocrd.setNotificationMarkerPosition() does not seem to work. I wish to periodically wake up to retrieve data by calling AudioRecord.read().
However, I do not get call back at all as I configured. Eventually AudioRecord stopped when record buffer overflowed. Below is the code.
2. With problem 1, I have to call AudioRecord.read() in a while loop from a separate thread. When I read(), the thread will block on the read() until read buffer is filled. During the block, I hope the system may go to sleep mode. My program works and audio data were successfully read but system never went to sleep during the block.
My idea of putting system into sleep while recording audio continously.
CODE:.........................
View 2 Replies
Apr 6, 2010
How can I get the amplitude/volume when recording with AudioRecord?
View 2 Replies
View Related
May 25, 2009
Record audio using the native AudioRecord interface? I'm trying to do this on my Neo Freerunner but all I get in logcat is:
I/AudioHardwareALSA( 787): Initialized ALSA CAPTURE device AndroidRecord_Microphone
D/AudioHardwareALSA( 787): Set CAPTURE PCM format to S16_LE (Signed 16 bit Little Endian)
D/AudioHardwareALSA( 787): Using 1 channel for CAPTURE.
D/AudioHardwareALSA( 787): Set CAPTURE sample rate to 8000 HZ
E/AudioFlinger( 787): Error reading audio input
W/AudioRecord( 947): obtainBuffer timed out (is the CPU pegged?) user=00000000, server=00000000
The android::AudioRecord::read() function returns the number of bytes I'm trying to read, but the resulting buffer is filled with zeroes.
View 1 Replies
View Related
Sep 10, 2010
Have an iPhone and part rely on it for diction and recordings. However a new software upgrade has meant when it's recording it tells you on the home screen if you press the button to wake it up, even if locked. Does the android have voice recording in sleep mode and if so does it do so without it stating it on the screen?
View 2 Replies
View Related
Feb 9, 2009
Is it possible to write data or create folder in system directory like /system/media/audio/alarms. i.e other than our respective package.
View 2 Replies
View Related
Nov 9, 2009
Im trying to record audio directly from the system. Using the standard API, you can only record from the MIC or phonecalls, ala: MediaRecorder.Some ways I've tried is to read from /dev/audio and /dev/eac from my app, but I think the sandbox of the app is preventing this.Im thinking about using the NDK, but Im not sure if that would overcome the sandbox aspect ? Ideally, there is some solution outthere to access the audio sub- system directly. Whether it be directly to alsa, to the AudioFlinger, to /dev/eac
View 16 Replies
View Related
Jul 26, 2010
I am trying to write the system setting using:
Settings.System.putInt(getApplicationContext().getContentResolver(), Settings.System.WIFI_SLEEP_POLICY, Settings.System.WIFI_SLEEP_POLICY_NEVER_WHILE_PLUGGED);
But it force closes my application. Any Idea? My has user following permissions:
<uses-permission android:name="android.permission.WRITE_SETTING"/>
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/
View 3 Replies
View Related
Oct 7, 2010
Is it possible to do a line-in recording with a droid?
headphone jacks can accept corded headsets with microphones with 3 "contact points" on the plug so you can plug in the corded headset to listen to audio, plus speak through the in-line microphone for calls. So it would seem possible but I can't find anything that says if it can or not
and witch app can record in mp3?
View 2 Replies
View Related
Feb 6, 2009
When i added a media file to the sdcard an update in the MediaProvider database is not happening. When i bootup the emulator it happens. Is this the expected behaviour?
View 2 Replies
View Related
Dec 1, 2010
After noticing my battery was draining quickly, and then after reading this thread, I installed Android System Info to see what was draining my battery so fast. I notice that whenever I would turn on WiFi, the phone will never go to sleep , regardless of what I set the WiFi sleep policy to. After turning off WiFi, the battery still drains heavily.
The WiFi will shut off after 15mins (if you set it to "When screen turns off" or "never when plugged in"). However it seems to keep the CPU on causing it to drain down the battery.
It would seem that whenever WiFi is enabled, the Android system process creates a partial wakelock that does not go away even if you turn off WiFi. The only way to resolve this is by powering off or rebooting the phone.
You can verify this in Android System Info by going into Battery-History-Other Usage-Partial Wake usage to see how much time the "Android System" process holding a partial wake.
I even did a factory reset on the device; and it is still happening so it doesn't appear to be any app that caused the issue. As I said, it works fine as long as I don't enable WiFi.
I already know of two users having this issue, but I'm wondering if folks having battery problems are going through this as well. Is anyone else having similar issues after using WiFi? I'm hoping someone will be able to identify what exactly is putting the wakelock on and we'll be able to find a fix for it. Other than not using WiFi at all or rebooting the phone after using Wifi.
View 17 Replies
View Related
Apr 1, 2009
Has anyone found a way to change the G1s system sounds? For example I want my G1 to have a different "Audible selection" noise. Instead of the click noise I would like to use an MP3.
View 3 Replies
View Related
Mar 1, 2010
Basically I would really enjoy the ability to customize the sound for plugging my phone in, and a different one for unplugging. Even better if these could be "outside" the default notification sounds. I realize this sounds crazy, but my phone has a mario theme to it, and the plug in is "gain a mushroom" sound, and I would love it if it did the "loose a powerup" sound when I unplugged.
View 3 Replies
View Related
Jan 5, 2010
I apologize if these topics were already covered in previous threads.I wasn't able to find anything related in my searches. Auto-rotation for keyboard when answering a text message received in sleep mode does not work. If I actively send a text when phone is already awake, keyboard rotates with no problem but when I go to reply to a text that I received while phone is in sleep mode, the keyboard does not rotate. Is this the norm?I am also experiencing a delay when the I wake the phone. After unlocking the phone, I used to go straight to my home page, now I get a "loading" message which takes several seconds. Is this due to the number of apps I have loaded? Is it possibly due to number of photo frames I have on my home screen or the complexity of the wallpaper?
View 5 Replies
View Related
May 15, 2009
I'm trying to figure out how to use the AudioRecord class.I created a callback with a logging message, but don't ever see it called.Do you see anything wrong with what I'm doing? Do you have an example of how to use the API?
View 6 Replies
View Related
Apr 30, 2009
I want to use AudioRecord and AudioTrack classes(in SDK 1.5) in my program. Where can I find how to use it. Is there any API demo program for this?. If not it is greatly appreciated if someone can post a sample code in this forum.
View 7 Replies
View Related
Jan 21, 2010
My application uses AudioTrack in streaming mode and AudioRecord simultaneously.My problem is that I start them at the same time, but I have no guarantee that they will actually start playback ecording in the same timestamp. The reason I need this kind of accuracy is because I use echo cancellation (subtracting audio played to speaker from the recording).My echo canceller doesn't require an exact delay, but the delay introduced between AudioTrack and AudioRecord moves in the range of 250ms (between different runs), and that's too much - each run is different because they start themselves asynchronously. The API doesn't provide me a way to make sure they start in the same time, so I thought about measuring this starting delay somehow and then using it in my calculation.Does anyone have an idea how to do that, utilizing their API or in any other way?
View 2 Replies
View Related
Mar 10, 2010
I currently have a Loop back program for testing Audio on Android devices.It uses AudioRecord and AudioTrack to record PCM audio from the Mic and play PCM audio out the earpiece. So as you can see in the creation of the AudioTrack and AudioRecord the Encoding is supplied via the AudioFormat but this only allows 16 bit or 8 bit PCM.I have my own G711 Codec implementation now and I want to be able to encode the audio from the Mic and decode it going into the EarPiece, So I have encode(short lin[], int offset, byte enc[], int frames) and decode(byte enc[], short lin[], int frames) methods but I'm unsure as to how to use them to encode and the decode the audio from the AudioRecord and AudioTrack.
View 2 Replies
View Related
Nov 11, 2010
I used AudioRecord on emulator and phone. I found that AudioRecord is not working on phone: 1> the min-buffer-size on simulator is much smaller than phone 2> The audio data I read from phone is all zero.
View 2 Replies
View Related
Mar 25, 2010
I'm doing a voice recording using AudioRecord class and the main requirement that the frequency must be 16000 Hz. I'm using only emulator in development process for now and met the problem that I can't set frequency more than 8000, otherwise I get bufferSize -2, and can't create instance of AudioRecord with such buffer. Thank you to Szabolcs Vrbos, he told me that this problem is only with emulator and several Samsung phones, device can record with higher frequency.I need a word from Android engineers that I will be able to record voice with 16000 Hz frequency on for instance HTC Hero (Android 1.5)or similar device with os 1.5 or higher.
View 2 Replies
View Related
Apr 1, 2010
the location where the audioflinger, surfaceflinger and cameraservice talk to MediaRecorder's APIs? Is there any relation between MediaRecorder and AudioRecord?
View 6 Replies
View Related
Sep 25, 2010
We have been getting reports of audio recording not working on Samsung Moment phones on 2.1-update1.
int bufferSize = AudioRecord.getMinBufferSize(sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT); this.audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC, sampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);
generates these logs: I/AudioPolicyManager( 1889): getInput() inputSource 1, samplingRate 16000, format 1, channels 10, acoustics 0 W/AudioHardwareALSA( 1889): openInputStream : mInput already exists!! E/AudioRecord( 2618): Could not get audio input for record source 1 E/AudioRecord-JNI( 2618): Error creating AudioRecord instance: initialization check failed. E/AudioRecord-Java( 2618): [ android.media.AudioRecord ] Error code -20 when initializing native AudioRecord object. I can't find the "mInput already exists". anywhere in the source base, could this perhaps be an error message included by the OEM?
View 4 Replies
View Related
Nov 12, 2010
I've been having an issue with using AudioRecord for Android. I've read as much as I can find online about it, but I cannot seem to get a good initialization. I have tried the Android 2.2 emulator, 1.5 emulator and my phone, an HTC Incredible running Froyo. The emulators and my phone fail initialization. I've tried sampling rates of 8000, 11025, and 44100, formats of CHANNEL_IN_MONO/STEREO and CHANNEL_CONFIGURATION_MONO/STEREO, 8bit and 16bit encoding (8 bit makes the getMinBufferSize fail), and Audio Source of MIC and DEFAULT. All result in the variable test becoming 0 after running a get state(failed initialization). It seems from everything I've read that this should correctly initialize the object. I have played around with the multiplier on buflen, to have it range from 512 (the result of the function) to 102400 because I had heard that HTC devices require something above 8192. For testing my problem I made a new, small project that recreates my problem as simply as possible. I pull out the constants needed into local ints then run the constructor and access the getState method for checking if it worked. Code...
View 1 Replies
View Related
Dec 6, 2009
Here is my AudioRecorder class, using audio record, why is it not producing any sound data?
import java.io.FileOutputStream; import java.io.IOException; import android.content.Context; import android.media.AudioFormat; import android.media.AudioRecord; import android.media.MediaRecorder; public class AudioRecorder implements Runnable {public boolean isRecording = false; byte[] tempBuffer = new byte[AudioRecord.getMinBufferSize(44100, AudioFormat.CHANNEL_CONFIGURATION_STEREO,......
View 4 Replies
View Related
May 27, 2010
I am using the AudioRecord class to analize raw pcm bytes as it comes in the mic.
So thats working nicely. Now i need convert the pcm bytes into decibel.
I have a formula that takes sound presure in Pa into db. db = 20 * log10(Pa/ref Pa)
So the question is the bytes i am getting from audiorecorder from the buffer what is it is it amplitude pascal sound pressure or what.
I tried to putting the value into te formula but it comes back with very hight db so i do not think its right
View 4 Replies
View Related
Oct 12, 2010
I am doing recording in following way and storing byte array in a binary file. But the binary file I am getting is not in any format. what can be the problem? code...
View 3 Replies
View Related
Feb 15, 2010
My Android Java Application needs to record audio data into the RAM and process it. This is why I use the class "AudioRecord" and not the "MediaRecorder" (records only to file).
Till now, I used a busy loop polling with "read()" for the audio data. this has been working so far, but it peggs the CPU too much. Between two polls, I put the thread to sleep to avoid 100% CPU usage. However, this is not really a clean solution, since the time of the sleep is not guaranteed and you must subtract a security time in order not to loose audio snippets. This is not CPU optimal. I need as many free CPU cycles as possible for a parallel running thread.
Now I implemented the recording using the "OnRecordPositionUpdateListener". This looks very promising and the right way to do it according the SDK Docs. Everything seems to work (opening the audio device, read()ing the data etc.) but the Listner is never called.
I am working with a real Device, not under the Emulator. The Recording using a Busy Loop basically works (however not satifiying). Only the Callback Listener is never called.
Here is a snippet from my Sourcecode:
CODE:.........................
View 2 Replies
View Related
May 9, 2010
On the nexus one, my app goes into Audio Record Stanby randomly after 0-40 seconds. I'm using the AudioRecord class, and while the standby is reported in the terminal, the AudioRecord instance reports the same states of RECORDSTATE_RECORDING and STATE_INITIALIZED throughout the entire sequence.
The bottom line is that when this anomaly occurs, audio is not captured. and this is what im working to prevent was only able to reproduce on nexus one android2.1 not g1 android1.6
I have looked extensively through the Android C/C++ libraries such as at this file: http://android.git.kernel.org/?p=platform/hardware/msm7k.git;a=blob_p... and [url]
Most interesting to me, is this line in AudioFlinger: [url]
Specifically the bool AudioFlinger::RecordThread::threadLoop()
As you can see, minput->standby() occurs in 4 different places in the code.
View 3 Replies
View Related
May 13, 2010
I've seen posts regarding problems with the AudioRecord OnRecordPositionUpdateListener, but I haven't seen any real answers.
I'm using AudioRecord to record from the mic, and I want to get the input from the mic periodically so I can check sound levels and update a meter.
I set up the listener like this:
CODE:...........
What happens is that onMarkerReached gets called once, after the recorder is released, so that's not very useful.
Do I need to change the marker position and notification period? Is the listener working? Is there another way to accomplish periodically getting the mic input?
View 4 Replies
View Related
Jun 19, 2009
In the Eclipse log I can clearly see a warning pop up (something about buffer overflow) every time I don't read from the AudioRecord buffer fast enough and consequently miss a chunk of audio samples. Is there any way I can detect that notification programatically so I know exactly when I have missed a chunk?
View 2 Replies
View Related
May 4, 2010
I'm having this problem only on Motorola Milestone. Code:
CODE:................
The errorinformation I have (can't find more for the moment since I don't have a milestone myself for debugging):
CODE:..........................
Apparantly I'm not the only one with this problem. Some very similar threads I found (without solution):
http://groups.google.com/group/android-developers/browse_thread/thread/6dd24aeb484b2e40
[url]
[url]
[url]
[url]
View 4 Replies
View Related