Scenario One: Use Avaudiorecorder to record the PCM data format file, and then start the sub-thread loop through the file, read the PCM data transcoding MP3 and write to the mp3 file (most of the current online information is like this)
1.lame Initialize & Open PCM, MP3 file get file pointer
Single channel does not need to set Lame_set_model, because API has been described Default:lame picks based on compression ration and input channels (according to Brate and channels default settings)
Ability to expand: Write header information such as Id3tag_set_artist = = = Author, the header information must be set before Lame_init_param ()
Ability to expand: Write a cover view (image) Id3tag_set_albumart
Open file Get file pointer (point to byte position)
2. Traverse PCM file, get byte data, transcode, write to MP3 file
Const int pcm_size = 8192;//equivalent to 8192 cartons of beer, one box of 16 bottles (beer = bytes, 8,192 16 bytes of data length)
Short int pcm_buffer[pcm_size * self. Realchannels]; How many arrays of PCM format data elements are populated
do{}while () loop Read the PCM file to determine if the number of bytes is greater than the set standard
Skip opening fseek (PCM, 4 * 1024x768, seek_cur); Filter noise
The condition is ripe to begin reading the PCM file data and depositing it into Pcm_buffer (the file pointer is offset to the end of the read byte)
Transcode data in Pcm_buffer into MP3 format data and into Mp3_buffer, differentiating between single & dual channels
Note that write has the potential to be abnormal, as the API says
Write the data in the Mp3_buffer to the mp3 file
When the while condition does not conform, jumps out, still should consider the insufficient standard remaining byte data, also must transcode and writes the MP3 file
Finally close the file
IOS Lame Library PCM to MP3 analysis (scenario i)