Recording Audio

By now you should have a general idea of how the recording process works. You will request a Player, configure it for your desired capture, start it to begin recording, and then stop it once the recording is complete. At that point you can retrieve the recorded audio data.

Before you start, though, you should ask yourself whether you care what format that data will be in. RIM offers several choices for audio encoding. Your choices are described in Table 2-3. Note that each choice has a required minimum device software version and will not work on versions below this. Table 2-3. Audio Capture Formats

URL Recorded Format Available with Version capture://audio AMR 4.2

capture://audio?encoding=amr AMR 4.2

capture://audio?encoding=audio/amr AMR 4.2

capture://audio?encoding=pcm PCM 4.2

capture://audio?encoding=audio/basic PCM 4.2

capture://audio?encoding=gsm GSM 4.6

capture://audio?encoding=x-gsm GSM 4.6

capture://audio?encoding=qcelp QCELP 4.7

Note: BlackBerry devices currently support AMR narrow band, not the higher quality AMR wide band. PCM recording is mono, 8 kHz, 16-bit.

Compared to what's available for playback, this isn't as rich a set of choices; for example, there is no option to record in MP3 format. However, depending on your application needs, some formats may be better than others. Some are more widely compatible, some are more compressed, and others offer more fidelity. AMR is a very highly compressed format that is optimized for speech, so it would be perfect for applications like a voice memo recorder. On the other hand, PCM is more appropriate for general nonvoice audio capture, and it produces files that are more likely to be compatible with other programs.

You can determine at runtime what formats are supported by calling System.getProperty("audio.encodings"). This is helpful if you prefer to record in a particular format, but can fall back on another format if it is unavailable. This is especially important because even if a device has the appropriate software version number, not every capture mode is necessarily supported. For example, CDMA devices (such as phones on the Sprint or Verizon networks in the United States) may not support PCM regardless of their version.

0 0

Post a comment

  • Receive news updates via email from this site