mic_stream 0.2.0+2

  • Readme
  • Changelog
  • Example
  • Installing
  • 82

mic_stream: 0.2.0 #

[Flutter Plugin] Provides a tool to get the microphone input as 8 or 16 bit PCM Stream (Stream<List

About mic_stream: #

As Flutter still lacks some functionality, this plugin aims to provide the possibility to easily get an audio stream from the microphone, using a simple java implementation [=> Android only, iOS Support planned in the future].

How to use: #

Permissions #

Make sure you have microphone recording permissions enabled for your project. To do so, add this line to the AndroidManifest.xml:

<uses-permission android:name="android.permission.RECORD_AUDIO"/>

The plugin provides one method:

Stream<List<int>> microphone({options})

Listening to this stream starts the audio recorder while cancelling the subscription stops the stream.

Example: #

// Init a new Stream
Stream<List<int>> stream = microphone(sampleRate: 44100);

// Start listening to the stream
StreamSubscription<List<int>> listener = stream.listen((samples) => print(samples));
// Cancel the subscription

Flutter #

About Flutter Plugins: https://flutter.io/developing-packages/

Flutter Documentation: https://flutter.io/docs

0.0.1 #

Initial release - Android support only!

Provides the Class Microphone inheriting StreamController

Constructor takes the Sample Rate as optional argument.

Provides methods to: #
  • platformVersion: Getter to return current platform version
  • bufferSize: Getter to return current buffer size (calculated from the sample size)
  • isRecording: Returns the state of the class
  • sampleRate: Setter to manually update the sample rate (use with caution, though)
  • close: Closes the internal StreamController
  • toString: Pass-through to internal StreamController

0.0.2 #

  • Getter for internal stream: microphone.stream

0.0.3 #

  • pause: Pauses writing data to the stream
  • resume: Resumes a paused stream

0.0.4 #

  • Changed Values for default and maximum sample rate (to 32 kHZ and 48 kHZ, respectively)

0.0.5 #

  • Setter for microphone (audioSource, sampleRate, channelConfig, audioFormat)

0.0.6 #

  • Smaller changes

0.0.7 #

  • Fixed crucial bug from 0.0.6

0.0.8 #

  • Calculations of durations, as multi-threading currently makes it not working. Will be included in future releases
  • Some unit tests (Will be extended in the future to fully ensure the plugin's working)

0.1.0 #

  • Rewritten Plugin to make use of EventChannel.StreamHandlers (Much nicer than before)

  • microphone({Options}) returns a Stream<List

    • The stream starts upon onListen() and runs until onCancel()
  • listen to the stream to start recording

  • stop the subscription to stop

0.1.1 #

  • Added customisability for the recorder
  • Added some error handling of the input params

0.1.2 #

  • Added 16Bit PCM mode

0.1.3 #

  • Updated README.

0.1.4 #

  • Removed Debug output
  • Fixed casting issue
  • Added Error handling for exceptions thrown on wrong AudioRecord params

0.1.5 #

  • Fixed Issue #8, causing immediate crashes in the latest flutter update

0.2.0 #

  • Fixed value truncation, now ensuring correct values for 16BIT_PCM
  • Added a better example application in ./example/lib/main.dart

0.2.0+1 #

  • Updated README.

0.2.0+2 #

  • Formatted Code.


mic_stream_example #

Demonstrates how to use the mic_stream plugin.

Getting Started #

This project is a starting point for a Flutter application.

A few resources to get you started if this is your first Flutter project:

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

Use this package as a library

1. Depend on it

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

  mic_stream: ^0.2.0+2

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:mic_stream/mic_stream.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 Jan 16, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.0
  • pana: 0.13.4
  • Flutter: 1.12.13+hotfix.5

Health issues and suggestions

Document public APIs. (-1 points)

24 out of 24 API elements have no dartdoc comment.Providing good documentation for libraries, classes, functions, and other API elements improves code readability and helps developers find and use your API.

Format lib/mic_stream.dart.

Run flutter format to format lib/mic_stream.dart.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (permission).


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.68.0 <3.0.0
flutter 0.0.0
permission 0.1.1 0.1.1 0.1.5
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8