Android Audio Development - Recording (17)

        AudioRecord is a tool for recording audio in the Android multimedia framework. It supports the recording of original audio data, that is, PCM data. PCM data cannot be played directly by the player, and needs to be encoded and compressed into a common audio format before it can be recognized by the player. The AudioTrack in the native api we analyzed before can play PCM data directly.

1. Basics of recording

1. Process

        AudioRecord continuously reads the data stream (byte stream) input from the audio source through the read method, and then saves the data stream as PCM data.

        When recording starts, AudioRecord needs to create a buffer. This buffer is mainly used to save new audio data. It is used to identify how long an AudioRecord object can record before the sound data is read (synchronized) (that is, the sound capacity that can be recorded at one time). The sound data is continuously read from the audio hardware, and the size of the data read each time does not exceed the capacity of the initialization buffer (the size of the recording data).

        The basic steps to record with AudioRecord are:

Determine recording parameters -> apply for buffer -> create AudioRecord object -> start recording -> loop read data to buffer and process data -> stop recording -> release resources

        Note: The recording parameters that need to be determined include: sample rate sample rate

Supongo que te gusta

Origin blog.csdn.net/c19344881x/article/details/131169245
Recomendado
Clasificación