Class Overview
Builder class for AudioRecord
objects.
Use this class to configure and create an AudioRecord
instance. By setting the
recording source and audio format parameters, you indicate which of
those vary from the default behavior on the device.
Here is an example where Builder
is used to specify all AudioFormat
parameters, to be used by a new AudioRecord
instance:
AudioRecord recorder = new AudioRecord.Builder()
.setAudioSource(MediaRecorder.AudioSource.VOICE_COMMUNICATION)
.setAudioFormat(new AudioFormat.Builder()
.setEncoding(AudioFormat.ENCODING_PCM_16BIT)
.setSampleRate(32000)
.setChannelMask(AudioFormat.CHANNEL_IN_MONO)
.build())
.setBufferSize(2*minBuffSize)
.build();
If the audio source is not set with setAudioSource(int)
,
DEFAULT
is used.
If the audio format is not specified or is incomplete, its sample rate will be the
default output sample rate of the device (see
PROPERTY_OUTPUT_SAMPLE_RATE
), its channel configuration will be
CHANNEL_IN_MONO
, and the encoding will be
ENCODING_PCM_16BIT
.
If the buffer size is not specified with setBufferSizeInBytes(int)
,
the minimum buffer size for the source is used.
Summary
Public Constructors |
|
AudioRecord.Builder()
Constructs a new Builder with the default values as described above.
|
[Expand]
Inherited Methods |
From class
java.lang.Object
Object
|
clone()
Creates and returns a copy of this Object .
|
boolean
|
equals(Object o)
Compares this instance with the specified object and indicates if they
are equal.
|
void
|
finalize()
Invoked when the garbage collector has detected that this instance is no longer reachable.
|
final
Class<?>
|
getClass()
Returns the unique instance of Class that represents this
object's class.
|
int
|
hashCode()
Returns an integer hash code for this object.
|
final
void
|
notify()
Causes a thread which is waiting on this object's monitor (by means of
calling one of the wait() methods) to be woken up.
|
final
void
|
notifyAll()
Causes all threads which are waiting on this object's monitor (by means
of calling one of the wait() methods) to be woken up.
|
String
|
toString()
Returns a string containing a concise, human-readable description of this
object.
|
final
void
|
wait()
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object.
|
final
void
|
wait(long millis, int nanos)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
final
void
|
wait(long millis)
Causes the calling thread to wait until another thread calls the notify() or notifyAll() method of this object or until the
specified timeout expires.
|
|
Public Constructors
public
AudioRecord.Builder
()
Constructs a new Builder with the default values as described above.
Public Methods
Returns
- a new
AudioRecord
instance successfully initialized with all
the parameters set on this Builder
.
Throws
UnsupportedOperationException
| if the parameters set on the Builder
were incompatible, or if they are not supported by the device,
or if the device was not available.
|
Sets the format of the audio data to be captured.
Returns
- the same Builder instance.
Returns
- the same Builder instance.
public
AudioRecord.Builder
setBufferSizeInBytes
(int bufferSizeInBytes)
Sets the total size (in bytes) of the buffer where audio data is written
during the recording. New audio data can be read from this buffer in smaller chunks
than this size. See getMinBufferSize(int, int, int)
to determine the minimum
required buffer size for the successful creation of an AudioRecord instance.
Since bufferSizeInBytes may be internally increased to accommodate the source
requirements, use getBufferSizeInFrames()
to determine the actual buffer size
in frames.
Parameters
bufferSizeInBytes
| a value strictly greater than 0 |
Returns
- the same Builder instance.