


The liblame library was created for forum member Djembefola, and he has worked around these problems. Sometimes the decoder produces a small wav file of random noise.Īnd on at one test file the decoded crashed with a memory error (segment fault) that occured in the native C code. The decoder assumes that the file to be decoded has been encoded with default LAME properties such as the amount of frame padding. Sometime the decoding simply adds or removes a few audio frames from the start or end of the decoded file - the decoder fails to take account of the true amount of frame padding that the mp3 has been encoded with. It decodes these encoded mp3s with no problems.Įncoding wav files with different sample rates and mono wav files generally produces the expected encoded mp3, but trying to decode that mp3 tends to fail, read on.ĭecoding mp3s that have been encoded with a different encoder produces very unpredictable results. It encodes stereo 44100Hz 16 bit wav files to mp3 with no problems. Now you can compare the original wav file with the new wav file.
#Mp3 encoder library code#
The code copies a non-existent wav file from assets to external memory, to keep the attachment size down i have not included any wav file for you to test with.Ĭlick the Encode button and wait while the wav file is encoded to mp3, you can then click the Decode button and wait while that mp3 file is decoded back to wav format. Sub LameEncoder_EncodeComplete(Success As Boolean) Sub LameDecoder_DecodeComplete(Success As Boolean) Log("An error occurred while calling LameEncoder.SetFiles") ' LameEncoder.SetQuality(LameEncoder.LAME_PRESET_STANDARD) ' adjust to suit If LameEncoder.SetFiles(File.Combine(File.DirRootExternal, "file_to_encode.wav"), File.Combine(File.DirRootExternal, "encoded_file.mp3")) Then Log("An error occurred while calling LameDecoder.SetFiles")

If LameDecoder.SetFiles(File.Combine(File.DirRootExternal, "encoded_file.mp3"), File.Combine(File.DirRootExternal, "decoded_file.wav")) Then Sub Activity_Pause (UserClosed As Boolean) If File.Exists(File.DirRootExternal, "file_to_encode.wav")=False Thenįile.Copy(File.DirAssets, "file_to_encode.wav", File.DirRootExternal, "file_to_encode.wav")Īctivity.AddView(DecodeButton, 0, 0, 100%x, 75dip)Īctivity.AddView(EncodeButton, 0, 75dip, 100%x, 75dip) ' ** the example project does NOT contain file_to_encode.wav ** Sub Activity_Create(FirstTime As Boolean) The Encoder will default to Quality of Encoder.LAME_PRESET_DEFAULT. Set the source wav and destination mp3 file names. Initialize the Encoder with an event name. The event EncodeComplete(Success As Boolean) will be raised on completion. Set the source mp3 and destination wav file names.
#Mp3 encoder library android#

Here we have a fully functional stereo encoder and somewhat unpredictable decoder. Liblame MP3 encoder and decoder library for B4A
