• Stars
    star
    249
  • Rank 157,476 (Top 4 %)
  • Language
    C
  • Created over 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Android/Java wrapper around Lame mp3 encoder

AndroidLame

AndroidLame is a wrapper Library for Android/Java around Lame MP3 encoder (http://lame.sourceforge.net/)
Built using NDK and Andorid studio with experimental gradle plugin.

Gradle dependency

build.gradle (project)

allprojects {
		repositories {
			...
			maven { url "https://jitpack.io" }
		}
	}

app/build.gradle

apply plugin: 'com.github.dcendents.android-maven' //add it to top of app level build.gradle  

dependencies {
	        compile 'com.github.naman14:TAndroidLame:1.1'
	}

Usage

AndoridLame androidLame = new AndroidLame(); //everything set to defaults
or
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

Documentation

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

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

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

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

Demo

A sample apk is avilable in releases.
(Remember to grant permissions from settings on Marshmallow devices or app will crash)

Sample apk has two demos -

  • Encoding .wav to mp3 and
  • Recording audio using AudioRecorder and encoding in real time to mp3

alt text

alt text

License

(c) 2015 Naman Dwivedi

This is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

This software is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this app. If not, see https://www.gnu.org/licenses/.

More Repositories

1

Timber

Material Design Music Player
Java
6,950
star
2

TimberX

Material theme music player that works across all form factors (phones, wear, auto, cast, assistant) and uses latest tools (Kotlin, Architecture components, Room, Databinding)
Kotlin
1,483
star
3

AlgorithmVisualizer-Android

Visualize algorithms and data structures using animations
Java
1,117
star
4

adb-tools-mac

Mac menu bar app for common adb tools
Swift
950
star
5

MaterialPowerMenu

A demo of the power menu with Reveal and other animations
Java
884
star
6

PlayAnimations

A demo of various animation in latest PlayGames app
Java
410
star
7

WashingMachineView

An interactive view with water waves flowing like in a Washing machine
Java
362
star
8

PlayNewsStandDemo

Demo app for achieving UI like the one used in latest Google Play Newsstand app.
Java
329
star
9

Muzei-macOS

Muzei wallpaper app for macOS
Swift
245
star
10

S-Tools

Keep track of your CPU and Sensors alongwith useful features like Color Picker,Compass and device information
Java
196
star
11

Arcade

Neural style in Android
Lua
104
star
12

Hacktoberfest-Android

Android app to check Hacktoberfest status and explore projects and issues
Java
83
star
13

FieldMapView

A demo of MapView as in FieldTrip with smooth animations
Java
82
star
14

Spider

Monitor and modify network requests
Kotlin
80
star
15

gnome-android-tool

Gnome shell extension for adb tools
JavaScript
73
star
16

TerminalScreensaver

OSX screensaver simulating a terminal
Swift
66
star
17

csgolive

CS:GO live scorebot using game state integration
JavaScript
18
star
18

neural-style-android

Torch 7 + Android port of Neural style algorithm
C
11
star
19

Accord

Automated performance monitoring for Android
Kotlin
11
star
20

FaisalCrush

Java
11
star
21

NDKSample

Sample app showing the usage of Android NDK
C++
5
star
22

Armageddon-2014

App for the Annual Tech Week of IET DTU
Java
5
star
23

naman14.github.io

JavaScript
4
star
24

VolumeMediaControl

Control media volume instead of ringer volume for selected apps
Kotlin
4
star
25

timber-cast-receiver

HTML
2
star
26

linux-rog

Kernel patches for asus rog support
C
1
star
27

ethglobal-ny

TypeScript
1
star
28

Spar

Swift
1
star
29

XposedUI

[WIP]
Java
1
star
30

zkbnb-android-sdk

Android SDK for zkbnb APIs
Kotlin
1
star
31

ethglobal-sf

JavaScript
1
star
32

CodingBlocks_CustomViews

Java
1
star
33

AdbToolsElectron

do not look here
CSS
1
star