AMR Plugin for Flutter

pub package license

A Flutter plugin that provides AMR (Adaptive Multi-Rate) audio format conversion capabilities for iOS platform. This plugin supports both AMR-NB and AMR-WB formats and enables bidirectional conversion between AMR and WAV audio formats in your Flutter applications.

Features

  • AMR-NB Support: Encode and decode AMR-NB audio format
  • AMR-WB Support: Encode and decode AMR-WB audio format
  • WAV to AMR: Convert WAV audio files to AMR-NB/AMR-WB format
  • AMR to WAV: Convert AMR-NB/AMR-WB audio files to WAV format
  • iOS Platform: Optimized for iOS applications
  • High Performance: Built on top of OpenCore AMR libraries
  • Easy to Use: Simple API for audio conversion
  • Memory Efficient: Optimized for mobile applications

Installation

Add this to your package's pubspec.yaml file:

dependencies:
  amr_plugin: ^0.0.1

Then run:

flutter pub get

iOS Setup

For iOS, you need to add the following to your ios/Podfile:

platform :ios, '12.0'

The plugin will automatically handle the framework integration.

Platform Support

This plugin currently supports iOS only. Android support is not available.

Usage

Basic Example

import 'package:amr_plugin/amr_plugin.dart';

// Initialize the plugin
final amrPlugin = AmrPlugin();

// Convert WAV file to AMR format
try {
  final resultPath = await amrPlugin.convertWavToAmr(
    '/path/to/input.wav',
    sampleRate: 8000,
    bitRate: 12200,
  );
  if (resultPath != null) {
    print('Conversion successful: $resultPath');
  } else {
    print('Conversion failed');
  }
} catch (e) {
  print('Conversion failed: $e');
}

// Convert AMR file to WAV format
try {
  final resultPath = await amrPlugin.convertAmrToWav(
    '/path/to/input.amr',
    sampleRate: 8000,
  );
  if (resultPath != null) {
    print('Conversion successful: $resultPath');
  } else {
    print('Conversion failed');
  }
} catch (e) {
  print('Conversion failed: $e');
}

Advanced Usage

// Example: Play converted audio file
// You can use audio_player package to play the converted files
// import 'package:audioplayers/audioplayers.dart';
// 
// final audioPlayer = AudioPlayer();
// await audioPlayer.play(DeviceFileSource(resultPath));

API Reference

AmrPlugin

The main class for AMR audio operations.

Methods

  • convertWavToAmr(String inputPath, {int sampleRate = 8000, int bitRate = 12200}): Convert WAV file to AMR format
  • convertAmrToWav(String inputPath, {int sampleRate = 8000}): Convert AMR file to WAV format

Supported Conversions

This plugin supports the following format conversions:

  • WAV → AMR: Convert WAV audio files to AMR format
  • AMR → WAV: Convert AMR audio files to WAV format

Supported Formats

Input Formats

  • WAV (.wav)

Output Formats

  • AMR (.amr)
  • WAV (.wav)

Requirements

  • iOS: 12.0+
  • Flutter: 3.0.0+

Dependencies

This plugin uses the following native libraries:

  • OpenCore AMR: For AMR encoding/decoding

Contributing

We welcome contributions! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

Development Setup

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

Support

If you encounter any issues or have questions, please:

  1. Check the Issues page
  2. Create a new issue if your problem isn't already reported
  3. Join our Discussions for general questions

Changelog

See CHANGELOG.md for a list of changes and version history.