flutter_detect_pitch 0.0.1+1 copy "flutter_detect_pitch: ^0.0.1+1" to clipboard
flutter_detect_pitch: ^0.0.1+1 copied to clipboard

A Flutter plugin for real-time pitch detection using the device microphone with native audio processing for iOS and Android.

[# flutter_detect_pitch

A Flutter plugin for real-time pitch detection using the device microphone (iOS and Android).
It uses AVAudioEngine and Accelerate (iOS) or AudioRecord (Android) for fast and reliable frequency estimation.


๐Ÿš€ Features #

  • ๐ŸŽค Real-time microphone input
  • โš™๏ธ Native audio processing (AVAudioEngine on iOS, AudioRecord on Android)
  • ๐Ÿ“ก Pitch detection via FFT (iOS) or zero-crossing (Android)
  • ๐Ÿ“ถ Stream interface for live frequency values
  • ๐Ÿ”’ Works offline and privacy-friendly

Platform Support: iOS โœ…, Android โœ…


๐Ÿ“ฆ Installation #

Add to your pubspec.yaml:

dependencies:
  flutter_detect_pitch: ^0.0.1+1

Then run:

flutter pub get

โš™๏ธ iOS Configuration #

Add this to your Info.plist:

<key>NSMicrophoneUsageDescription</key>
<string>This app uses the microphone to detect pitch.</string>

โš™๏ธ Android Configuration #

Add this permission to your android/app/src/main/AndroidManifest.xml:

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

Make sure your minSdkVersion is 21 or higher in android/app/build.gradle:

defaultConfig {
    minSdk = 21
}

For Android 6.0+ you must also request runtime permission using e.g. the permission_handler plugin.


๐Ÿ’ก Usage #

import 'package:flutter_detect_pitch/flutter_detect_pitch.dart';

void startListening() async {
  // Request permission if needed
  if (await Permission.microphone.request().isGranted) {
    PitchDetector.pitchStream.listen((frequency) {
      print('Detected frequency: ${frequency.toStringAsFixed(2)} Hz');
    });
  }
}

You can start this from a button or widget lifecycle like initState.


๐Ÿ” API #

PitchDetector.pitchStream #

A broadcast stream that emits a new frequency value (as double) every ~100ms.


๐Ÿ“ฑ Example #

A simple example is available under example/. To run it:

cd example
flutter run

๐Ÿ“‹ Roadmap #

  • โœ… iOS pitch detection via FFT
  • โœ… Android pitch detection via AudioRecord
  • โŒ Frequency โ†’ musical note conversion
  • โŒ Visual pitch indicator widget
  • โŒ Replace Android zero-crossing with FFT or Yin

๐Ÿงช Known Limitations #

  • Android detection is basic (zero-crossing only)
  • Background noise can impact accuracy
  • Outputs raw frequency only (not musical notes)

๐Ÿ“„ License #

MIT License. See LICENSE.


๐Ÿ‘ค Author #

Developed by Felix L โ€“ feel free to contribute or open issues!

GitHub: https://github.com/felix-ml/pitch_detector ]()

0
likes
150
points
0
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for real-time pitch detection using the device microphone with native audio processing for iOS and Android.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on flutter_detect_pitch

Packages that implement flutter_detect_pitch