First of all, what I have to say is not everything goes ok at the first attempt, I'm telling this because I decided to upgrade my LG gt540 to 2.1 Android version, but something went wrong during the process :(
While I was updating it, my computer stuck so I had to restart it. Then I tried to power on my LG device and never came back on again, I could only see the LG logo. That's why I need to reboot my device, but I don't think this take my long time because there is a lot of information about it on the internet.
Well, while I try to fix this accident I'm working on how to demodulate the signals from the arduino in an Android device.
I'm trying some classes in API Level 3:
1. AudioRecord:
The AudioRecord class manages the audio resources for Java applications to record audio from the audio input hardware of the platform. This is achieved by "pulling" (reading) the data from the AudioRecord object. The application is responsible for polling the AudioRecord object in time using one of the following three methods:
read(byte[], int, int)
, read(short[], int, int)
or read(ByteBuffer, int)
. The choice of which method to use will be based on the audio data storage format that is the most convenient for the user of AudioRecord.
Upon creation, an AudioRecord object initializes its associated audio buffer that it will fill with the new audio data. The size of this buffer, specified during the construction, determines how long an AudioRecord can record before "over-running" data that has not been read yet. Data should be read from the audio hardware in chunks of sizes inferior to the total recording buffer size.
public AudioRecord (int audioSource, int sampleRateInHz, int channelConfig, int audioFormat, int bufferSizeInBytes)
int audioSource: MIC
int sampleRateInHz: he sample rate expressed in Hertz. 44100Hz is currently the only rate that is guaranteed to work on all devices
int audioFormat: the format in which the audio data is represented. PCM 16 bit per sample. Guaranteed to be supported by devices.
int bufferSizeInBytes: getMinBufferSize
1a. getMinBufferSize
public static int getMinBufferSize (int sampleRateInHz, int channelConfig, int audioFormat)
Returns the minimum buffer size required for the successful creation of an AudioRecord object. Note that this size doesn't guarantee a smooth recording under load, and higher values should be chosen according to the expected frequency at which the AudioRecord instance will be polled for new data.
- AudioTrack
The AudioTrack class manages and plays a single audio resource for Java applications. It allows to stream PCM audio buffers to the audio hardware for playback. This is achieved by "pushing" the data to the AudioTrack object using one of the
write(byte[], int, int)
and write(short[], int, int)
methods.public AudioTrack (int streamType, int samplieRateInHz, int channelConfig, int audioFormat, intBufferSizeInBytes, int mode)
int streamType: STREAM_MUSIC
int samplieRateInHz: 44100
int audioFormat: PCM 16 bit
int bufferSizeInBytes: getMinBufferSize
int mode: MODE_STREAM
Source: android-developers
No comments:
Post a Comment