Android :: AudioRecord Class To Analize Raw Pcm Bytes As It Comes In The Mic
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
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
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 3 Replies
View Related
Apr 23, 2009
I captured an image by android G1, now trying to display it as ImageView but it gives me memory allocation exception.
CODE:.............
The default image resolution of G1 camera is 2048 * 1536
I also tried to compress image on selection but still same exception.
CODE:.............
View 4 Replies
View Related
Aug 13, 2010
I have a 16mb binary file and I want to read bytes without using any loop. like if i want to read 16 byte i can pass 16 to some method(if there is any) and it give me my desired result... right now i am using loop for reading bytes but my application is so huge i am afraid that it do not get slow.
View 4 Replies
View Related
May 24, 2010
I have a frame of 22 bytes. The frame is the input stream from an accelerometer via bluetooth. The acceleromter readings are a 16 bit number split over two bytes.
When i try to merge the bytes with buffer[1] + buffer[2], rather than adding the bytes, it just puts the results side by side. so 1+2 = 12.
How to combine these two bytes to obtain the original number. (btw the bytes are sent little endian)
View 1 Replies
View Related
Nov 27, 2009
I'm trying to get a byte array of an image saved locally on the phone. I'm using the code...
How can I get the Bytes?
View 1 Replies
View Related
Nov 24, 2009
I wrote a simple test driver to test the bluetooth apis. Anyone can verify whether I am using the API correctly?
Everything seems good but no data read:
Before calling the following, inquiry scan successfully returned, and the remote device is pre-paired.
CODE:..............
View 16 Replies
View Related
Jan 22, 2010
I have a function I am using to upload files. How can I get the number of bytes of the file that have been uploaded (transferred)? Can I setup a timer that does this? If so, what variable to I read to get the number of bytes uploaded?
Here is my code:
CODE:....................
View 2 Replies
View Related
Feb 16, 2010
An Android app I'm writing involves quite a lot of downloading of content (think podcatcher/RSS).
I would like to be able to give the user an indication of how many bytes they've downloaded, so they can make the decision whether they want to use Wifi or not.
To this end, I have found a way of counting the number of bytes read by the app, by wrapping an InputStream in a simple CountingInputStream.
However, this does not take into consideration basic things like packet headers and HTTP headers. More importantly, it does not take into consideration any compression that content may be encoded with.
So, how many bytes did my application download over the network? I'm not so interested in the number of bytes uploaded, but if know how, don't be shy.
I have gone down a fairly low level approach as I am feeding the input stream into an XML PullParser. I will also be needing to do a similar exercise with dumping bytes (images in this case) straight onto the SD Card.
View 3 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
Oct 13, 2010
I create data file in android for my application in the app's data directory. The write is successful with no exceptions but file contents are not complete. It truncates at 90112 bytes. Any idea what is going on ? Is there a limit ?
Here is the snippet
CODE:....................
View 2 Replies
View Related
Nov 24, 2010
I have a problem.
1 - From a webservice. NET 2008 (vb), I have a method that returns an array of bytes, the byte array is actually a string "Hola Mundo" ("Hello World" in English) compressed with the Class of System.IO.Compression GZipStream.
2 - The method returns the string "Hola Mundo" compressed, and this is what the webservice returns:
CODE:..............
3 - if I do a test from a windows application from Visual Basic. NET to run this method returns me this string and Unzip with another function I have, it brings me the "Hola Mundo" ....
4 - On Android (Eclipse) and I managed to make the request and bring me the previous string ... but do not know how to decompress and show me "Hola Mundo" ...
5 - I have tried several codes from the web, but none work.
View 3 Replies
View Related
Sep 27, 2010
Am trying to store all images in my server, then i need to show based on requirements, i am able to store and restore bitmap bytes but i cant recreate the bitmap using stored bytes , pls find my code below and suggest me a solution if i doing wrong.
Converting Bitmap to Bytes. Code...
View 13 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
Sep 22, 2010
I'm developing an android video uploading app and uploading large amounts of video is a problem, I get different type of exception sometimes (host not resolved, pipe broken), I do a multipart POST but I have a feeling if I upload chunk of bytes one at at time that'll increase upload speed as well as solve connection timeout and these type of problems.
View 1 Replies
View Related
Feb 1, 2010
I am trying to follow the instructions on this page to create a trace file. I can see the file in File Explorer in DDMS and can pull it onto my PC but it is zero bytes long.
Any suggestions as to what I might be doing wrong, please?
View 1 Replies
View Related
Jul 11, 2010
I've tried recording video using MediaRecorder API but the file that gets saved each time is of 0 bytes.
I use the MediaRecorder recorder = new MediaRecorder(); ad then recorder.setVideoSource . . .recorder.prepare() to generate the preview and when the user clicks record, i say recorder.start() but the file recorded is of 0 bytes. And after some time, recorder.stop() -on user click that is.
View 2 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
Jul 7, 2010
I'm creating a new class, using eclipse "New Java Class" dialog box. I can write the superclass I want (I can't find using "browse" button), but I can't write or select an interface to implement. I click "add" but ther is nothing to select. What I'm doing wrong?
View 4 Replies
View Related
Aug 30, 2010
I'm building an android app and I'm currently having trouble retrieving a bitmap from an URL.
Here is the code I'm using :
CODE:..........
Everything works fine when the picture's write but when some bytes are wrong, result gets null. I think it's basically expectable as it's written this in the doc of BitmapFactory.decodeStream :
If the input stream is null, or cannot be used to decode a bitmap, the function returns null. The stream's position will be where ever it was after the encoded data was read.
The problem is, my wrong picture is well interpreted by my web browser and I can do so on iPhone platform.
Is there a way to sort of ignore those wrong pixels? maybe with the option parameter?
View 1 Replies
View Related
Sep 1, 2013
I bought iball andi 5li android smart phone a few days back. The configuration of the phone is:
512mb ram
4gb internal
1.2ghz cortex a9 processor
android 4.1.2
Although my device runs almost every app out there (including temple run, subway surfers etc.) but occasionally im facing problems.
Problem occurs after 3-4 days of restarting the phone. When i restart and check the ram usage it says 350 mb (approx) as used and 150mb(approx) as free ram every app runs smoothly but as days pass by gradually the free ram starts decreasing down to 30 mb where all the apps (games and browsers) start crashing with a low memory message. then the conditions get worse after approx 2 hrs free ram is now 0.0 bytes and even the launcher,settings etc crash with a low memory message. The only solution out is to restart the phone.
[used androids before and is quite aware of closing or killing apps but none is working]
Already Tried:
# removing apps from recent list
# stopping apps from Setting>apps>running apps & cached apps as well
# restoring to factory defaults
# used ram freeing apps (no change on ram)
View 2 Replies
View Related
Apr 6, 2010
How can I get the amplitude/volume when recording with AudioRecord?
View 2 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