### Initialize AndroidLame with Defaults Source: https://github.com/naman14/tandroidlame/blob/master/README.md Use this snippet to create an AndroidLame instance with all default settings. No specific imports are needed beyond the AndroidLame class itself. ```java AndoridLame androidLame = new AndroidLame(); //everything set to defaults ``` -------------------------------- ### AndroidLame Initialization Source: https://github.com/naman14/tandroidlame/blob/master/README.md Demonstrates how to initialize the AndroidLame encoder, either with default settings or using a LameBuilder for custom configurations. ```APIDOC ## Initialization ### Default Initialization ```java AndroidLame androidLame = new AndroidLame(); // everything set to defaults ``` ### Custom Initialization with LameBuilder ```java LameBuilder builder = new LameBuilder() .setInSampleRate(inSamplerate) .setOutChannels(numChannels) .setOutBitrate(bitrate) .setOutSampleRate(outSamplerate) .setMode(mode) .setQuality(quality) .setVbrMode(vbrMode) .setVbrQuality(vbrQuality) .setScaleInput(scaleInput) .setId3tagTitle(title) .setId3tagAlbum(album) .setId3tagArtist(artist) .setId3tagYear(year) .setId3tagComment(comment) .setLowpassFreqency(freq) .setHighpassFreqency(freq) .setAbrMeanBitrate(meanBitRate); AndroidLame androidLame = builder.build(); // use this AndroidLame androidLame = new AndroidLame(builder); // or this ``` ``` -------------------------------- ### Initialize AndroidLame with LameBuilder Source: https://github.com/naman14/tandroidlame/blob/master/README.md Configure audio encoding parameters using LameBuilder before creating an AndroidLame instance. This allows for fine-grained control over sample rate, channels, bitrate, quality, and ID3 tags. ```java LameBuilder builder = new LameBuilder() .setInSampleRate(inSamplerate) .setOutChannels(numChannels) .setOutBitrate(bitrate) .setOutSampleRate(outSamplerate) .setMode(mode) .setQuality(quality) .setVbrMode(vbrMode) .setVbrQuality(vbrQuality) .setScaleInput(scaleInput) .setId3tagTitle(title) .setId3tagAlbum(album) .setId3tagArtist(artist) .setId3tagYear(year) .setId3tagComment(comment) .setLowpassFreqency(freq) .setHighpassFreqency(freq) .setAbrMeanBitrate(meanBitRate); AndroidLame androidLame = builder.build(); //use this AndroidLame androidLame = new AndroidLame(builder); //or this ``` -------------------------------- ### Apply Android Maven Plugin and Add Dependency Source: https://github.com/naman14/tandroidlame/blob/master/README.md Apply the 'com.github.dcendents.android-maven' plugin and add the AndroidLame library dependency to your app-level build.gradle file. ```gradle apply plugin: 'com.github.dcendents.android-maven' dependencies { compile 'com.github.naman14:TAndroidLame:1.1' } ``` -------------------------------- ### LameBuilder Configuration Options Source: https://github.com/naman14/tandroidlame/blob/master/README.md Details the various configuration parameters available through the LameBuilder for customizing the audio encoding process. ```APIDOC ## LameBuilder LameBuilder is a wrapper around the extra initialisation parameters in Lame. **inSampleRate** - input sample rate in Hz. default = 44100hz **numChannels** - number of channels in input stream. default=2 **bitrate** - set the bitrate of out stream **outSampleRate** - output sample rate in Hz. default = 0, which means LAME picks best value based on the amount of compression **quality** - quality = 0 to 9. 0=best (very slow). 9=worst. default = 5 **scaleInput** - scale the input by this amount before encoding. default=1 **Mode** - sets a preset mode ```java public enum Mode { STEREO, JSTEREO, MONO, DEFAULT } ``` **vbrMode** There are 3 bitrate modes in Lame - CBR, VBR, ABR **CBR** Constant Bit Rate (default) - CBR encodes every frame at the same bitrate. **VBR** Variable Bit Rate - The final file size of a VBR encode is less predictable, but the quality is usually better. **ABR** Average Bit rate - A compromise between VBR and CBR modes, ABR encoding varies bits around a specified target bitrate. use `setAbrBitrate` to set the mean bitrate to be used for encoding **setVbrMode** default = VBR_OFF = CBR ```java public enum VbrMode { VBR_OFF, VBR_RH, VBR_MTRH, VBR_ABR, VBR_DEFAUT } ``` If using ABR, use `setAbrBitrate` to set the mean bitrate in kbps, value is ignored if used with other vbr modes **vbrQuality** VBR quality level. 0=highest 9=lowest, Range [0,...,10[ **lowpassFrequency** freq in Hz to apply lowpass. Default = 0 = lame chooses. -1 = disabled **highpassFrequency** freq in Hz to apply highpass. Default = 0 = lame chooses. -1 = disabled **setId3...** - to set id3 tags ``` -------------------------------- ### AndroidLame Encoding Methods Source: https://github.com/naman14/tandroidlame/blob/master/README.md Provides details on the core encoding methods available in the AndroidLame class for processing audio data. ```APIDOC ## AndroidLame A wrapper class for actual native implementation and encoding `encode(short[] buffer_l, short[] buffer_r, int samples, byte[] mp3buf)` input pcm data returns number of bytes output in mp3buf `encodeBufferInterleaved(short[] pcm, int samples, byte[] mp3buf);` as above, but input has L & R channel data interleaved. num_samples = number of samples in the L (or R) channel, not the total number of samples in pcm[] `lameFlush(byte[] mp3buf);` flushes the intenal PCM buffers, and returns the final mp3 frames, will also write id3v1 tags (if any) into the bitstream returns number of bytes output to mp3buf ``` -------------------------------- ### Add JitPack Repository to Project Gradle Source: https://github.com/naman14/tandroidlame/blob/master/README.md Include the JitPack repository in your project-level build.gradle file to allow Gradle to resolve dependencies from JitPack. ```gradle allprojects { repositories { ... maven { url "https://jitpack.io" } } } ``` -------------------------------- ### AndroidLame Encoding Method Source: https://github.com/naman14/tandroidlame/blob/master/README.md Encodes a buffer of PCM data (left and right channels separately) into MP3 format. The output is written to the provided mp3buf, and the method returns the number of bytes written. ```java encode(short[] buffer_l, short[] buffer_r, int samples, byte[] mp3buf) ``` -------------------------------- ### AndroidLame Interleaved Encoding Method Source: https://github.com/naman14/tandroidlame/blob/master/README.md Encodes interleaved PCM data (left and right channels combined) into MP3 format. The number of samples refers to one channel (e.g., left channel samples). ```java encodeBufferInterleaved(short[] pcm, int samples, byte[] mp3buf); ``` -------------------------------- ### AndroidLame Flush Method Source: https://github.com/naman14/tandroidlame/blob/master/README.md Flushes internal PCM buffers and writes any remaining MP3 frames to the output buffer. This method also writes ID3v1 tags if they were set. It returns the number of bytes written to mp3buf. ```java lameFlush(byte[] mp3buf); ``` -------------------------------- ### LameBuilder Mode Enum Source: https://github.com/naman14/tandroidlame/blob/master/README.md Defines the channel modes for audio encoding: STEREO, JSTEREO (joint stereo), MONO, or DEFAULT. ```java public enum Mode { STEREO, JSTEREO, MONO, DEFAULT } ``` -------------------------------- ### LameBuilder VbrMode Enum Source: https://github.com/naman14/tandroidlame/blob/master/README.md Specifies the Variable Bit Rate (VBR) mode for encoding. Options include VBR_OFF (Constant Bit Rate), VBR_RH, VBR_MTRH, VBR_ABR (Average Bit Rate), and VBR_DEFAUT. ```java public enum VbrMode { VBR_OFF, VBR_RH, VBR_MTRH, VBR_ABR, VBR_DEFAUT } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.