audio_io 0.1.4

  • Readme
  • Changelog
  • Example
  • Installing
  • 70

audio_io #

The goal

Simple audio data streaming from platform to flutter. Minimum code needed to get PCM data into a dart environment for cross platform processing / recording / visualising

Input audio stream of List

Currently only ios suppored.

Getting Started #

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

0.0.1 #

Kiss release Input from mic at fixed sample rate and buffer size, no output

0.0.2 #

Kiss MVP release

Input from mic at fixed sample rate and buffer size, output fixed at mono at the same sample rate as input. Simple quick and dirty ringbuffer for output (needs optimisation)

0.0.3 #

Bugfix Fix 32-64bit mismatch of data.

0.0.4 #

Improvement Allow muliple listeners on audio input

0.0.5 #

Bugfix Thread safety - memory leak fixed :)

0.0.6 #

Improvement Main thread call for sink removed (attempt to reduce latency introduced in 0.0.5)

0.0.7 #

Rollback 0.0.6

0.0.8 #

Improvement Handle audio session changes Reset audio when entering foreground

0.0.9 #

Improvement Handle audio interruptions Using simpler binary message system to send data (2x cpu optimisation) Replaced invoking method with binary message for output audio Less format conversions when sending data in and out Prep work for upcoming buffer and samplerate selection features

0.1.0 #

New Interface Added inteface for getting format and buffer size selection (audio frame size) Using serial queue for read and writes to buffer

0.1.1 #

Performance Fixing Dart side audio format to double (everything is 64bit these days, 64bit is great for processing) Optimised data conversion

0.1.2 #

Bugfix Fix bug which stopped audio when coming back from background

0.1.3 #

Bugfix Fixed issue with route swapping from speaker to headphones

0.1.4 #

Bugfix Better way to detect changes in audio format, removed old methods

Upcoming features

  • More Optimised for RAM and CPU
  • Support multiple channels
  • File sinks for saving and compressing audio


import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:audio_io/audio_io.dart';

void main() => runApp(MyApp());

final _latencyValues = {
  AudioIoLatency.Realtime: 'Realtime',
  AudioIoLatency.Balanced: 'Balanced',
  AudioIoLatency.Powersave: 'Powersave',

class MyApp extends StatefulWidget {
  _MyAppState createState() => _MyAppState();

class _MyAppState extends State<MyApp> {
  String _status = 'Unknown';
  AudioIoLatency _latencyValue = AudioIoLatency.Balanced;
  void initState() {

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    AudioIo.instance.input.listen((data) {
      final out = List<double>.generate(
          data.length, (index) => data[index] * 0.9); // do things :)
          .add(out); // send back out to output (headset speaker or headphones)

    if (!mounted) return;
    setState(() {
      _status = _status;

  void startAudio() async {
    try {
      await AudioIo.instance.start();
      final latency = await AudioIo.instance.currentLatency();
      final lstring = latency.toStringAsPrecision(2);
      final format = await AudioIo.instance.getFormat();
      setState(() {
        _status = 'Started ($lstring ms)';
    } on PlatformException {
      setState(() {
        _status = 'Failed';

  void stopAudio() async {
    try {
      await AudioIo.instance.stop();
      setState(() {
        _status = 'Stopped';
    } on PlatformException {
      setState(() {
        _status = 'Failed';

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        body: Center(
          child: Column(children: [
            Text('Status: $_status\n'),
            FlatButton(onPressed: startAudio, child: Text('Start')),
            FlatButton(onPressed: stopAudio, child: Text('Stop')),

  Widget latencyDropdown(BuildContext context) {
    return DropdownButton<AudioIoLatency>(
      value: _latencyValue,
      icon: Icon(Icons.arrow_downward),
      iconSize: 24,
      elevation: 16,
      underline: Container(
        height: 2,
        color: Colors.blueAccent,
      onChanged: (AudioIoLatency newValue) {
        setState(() {
          _latencyValue = newValue;
      items: <AudioIoLatency>[
      ].map<DropdownMenuItem<AudioIoLatency>>((AudioIoLatency value) {
        return DropdownMenuItem<AudioIoLatency>(
          value: value,
          child: Text(_latencyValues[value]),

Use this package as a library

1. Depend on it

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

  audio_io: ^0.1.4

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:audio_io/audio_io.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on May 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.2
  • pana: 0.13.8-dev
  • Flutter: 1.17.1

Health suggestions

Fix lib/audio_io.dart. (-0.50 points)

Analysis of lib/audio_io.dart reported 1 hint:

line 11 col 16: The value of the field 'requestFormat' isn't used.

Maintenance suggestions

The package description is too short. (-1 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies