An open API service indexing awesome lists of open source software.

https://github.com/henkelmax/lame4j

A Java wrapper for LAME.
https://github.com/henkelmax/lame4j

java jna lame lame-wrapper lame4j

Last synced: about 1 year ago
JSON representation

A Java wrapper for LAME.

Awesome Lists containing this project

README

          

# Lame4J

A Java wrapper for [LAME](https://lame.sourceforge.io/index.php) written in Rust using JNI.
This also includes [minimp3](https://github.com/lieff/minimp3) to decode mp3 files.

This library includes natives for:

- `Windows x86`
- `Windows x64`
- `MacOS x64`
- `MacOS aarch64`
- `Linux x86`
- `Linux x64`
- `Linux aarch64`

## Usage

**Maven**

``` xml

de.maxhenkel.lame4j
lame4j
2.0.3


henkelmax.public
https://maven.maxhenkel.de/repository/public

```

**Gradle**

``` groovy
dependencies {
implementation 'de.maxhenkel.lame4j:lame4j:2.0.3'
}

repositories {
maven {
name = "henkelmax.public"
url = 'https://maven.maxhenkel.de/repository/public'
}
}
```

## Example

``` java
DecodedAudio decodedAudio = Mp3Decoder.decode(Files.newInputStream(Paths.get("myfile.mp3")));

short[] decode = decodedAudio.getSamples();

System.out.println("Sample Rate: " + decodedAudio.getSampleRate());
System.out.println("Bit Rate: " + decodedAudio.getBitRate());
System.out.println("Channels: " + decodedAudio.getChannelCount());
System.out.println("Frame Size: " + decodedAudio.getSampleSizeInBits());

System.out.println("Length: " + decode.length + " samples");
System.out.println("Duration: " + ((float) decode.length / (float) decodedAudio.getSampleRate()) + " seconds");

Mp3Encoder encoder = new Mp3Encoder(decodedAudio.getChannelCount(), decodedAudio.getSampleRate(), decodedAudio.getBitRate(), 5, Files.newOutputStream(Paths.get(args[1])));
encoder.write(decode);
encoder.close();
```

## Credits

- [LAME](https://lame.sourceforge.io/)
- [LAME License](https://sourceforge.net/p/lame/svn/HEAD/tree/tags/RELEASE__3_100/lame/COPYING)
- [mp3lame-sys](https://github.com/DoumanAsh/mp3lame-sys)
- [minimp3-rs](https://github.com/germangb/minimp3-rs)
- [minimp3](https://github.com/lieff/minimp3)
- [jni-rs](https://github.com/jni-rs/jni-rs)

Other stuff

- [API](https://sourceforge.net/p/lame/svn/HEAD/tree/tags/RELEASE__3_100/lame/API)
- [Headers](https://sourceforge.net/p/lame/svn/HEAD/tree/tags/RELEASE__3_100/lame/include/lame.h)
- [Docs.rs](https://docs.rs/lame-sys/0.1.2/lame_sys/)