dart_lame 1.0.3 copy "dart_lame: ^1.0.3" to clipboard
dart_lame: ^1.0.3 copied to clipboard

Dart native bindings to LAME (MP3 encoder).

Dart native bindings to LAME (MP3 encoder)

Features #

  • Encode WAV (PCM-16 or PCM IEEE Double) to MP3

Getting started #

To use this library, you must have libmp3lame installed on your system. Please make sure the following library is available on your system or place it under your program's working directory.

  • Windows: mp3lame.dll
  • Linux: libmp3lame.so
  • macOS: libmp3lame.dylib

Alternatively, you can manually load libmp3lame:

import 'dart:ffi' as ffi;
import 'package:dart_lame/dart_lame.dart' as lame;

class CustomLoader extends lame.LameLibraryLoader {
  @override
  ffi.DynamicLibrary load() {
    return ffi.DynamicLibrary.open("path_to_libmp3lame");
  }
}

lame.lameLoader = CustomLoader(); 

For Flutter user, please use flutter_lame instead.

Usage #

final File f = File("output.mp3");
final IOSink sink = f.openWrite();
final LameMp3Encoder encoder = LameMp3Encoder(sampleRate: 44100, numChannels: 2);


Float64List leftChannelSamples;
Float64List rightChannelSamples;
// Get samples from file or from microphone.

final mp3Frame = await encoder.encode(
  leftChannel: leftChannelSamples,
  rightChannel: rightChannelSamples);
sink.add(mp3Frame);
// continue until all samples have been encoded

// finally, flush encoder buffer
final lastMp3Frame = await encoder.flush();
sink.add(lastMp3Frame);

For a complete example, please go to /example folder.

0
likes
130
pub points
19%
popularity

Publisher

unverified uploader

Dart native bindings to LAME (MP3 encoder).

Repository (GitHub)
View/report issues

Documentation

API reference

License

LGPL-3.0 (license)

Dependencies

ffi

More

Packages that depend on dart_lame