{"id":18014543,"url":"https://github.com/alnitak/flutter_recorder","last_synced_at":"2025-07-27T20:07:30.782Z","repository":{"id":258322939,"uuid":"856456434","full_name":"alnitak/flutter_recorder","owner":"alnitak","description":"A low-level audio recorder plugin which uses miniaudio as backend and supporting all the platforms. It can detect silence and save to WAV audio file. Audio wave and FFT data can be get in real-time as for the volume level.","archived":false,"fork":false,"pushed_at":"2025-04-18T11:31:29.000Z","size":2875,"stargazers_count":39,"open_issues_count":9,"forks_count":10,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-19T00:40:31.616Z","etag":null,"topics":["audio","audio-recorder","audio-visualizer","flutter","flutter-plugin","miniaudio"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/alnitak.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["alnitak"]}},"created_at":"2024-09-12T15:51:47.000Z","updated_at":"2025-04-18T11:30:57.000Z","dependencies_parsed_at":"2024-11-15T22:31:01.763Z","dependency_job_id":"9bc97cc4-fa91-4855-a72a-37036fb23a48","html_url":"https://github.com/alnitak/flutter_recorder","commit_stats":null,"previous_names":["alnitak/flutter_recorder"],"tags_count":10,"template":false,"template_full_name":null,"purl":"pkg:github/alnitak/flutter_recorder","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alnitak%2Fflutter_recorder","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alnitak%2Fflutter_recorder/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alnitak%2Fflutter_recorder/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alnitak%2Fflutter_recorder/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alnitak","download_url":"https://codeload.github.com/alnitak/flutter_recorder/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alnitak%2Fflutter_recorder/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267417664,"owners_count":24083839,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","audio-recorder","audio-visualizer","flutter","flutter-plugin","miniaudio"],"created_at":"2024-10-30T04:10:07.206Z","updated_at":"2025-07-27T20:07:30.763Z","avatar_url":"https://github.com/alnitak.png","language":"C","funding_links":["https://github.com/sponsors/alnitak"],"categories":["C"],"sub_categories":[],"readme":"A low-level audio recorder plugin that uses miniaudio as the backend and supports all the platforms. It can detect silence and save to a WAV audio file. Audio wave and FFT data can be obtained in real-time as for the volume level.\n\n[![style: very good analysis](https://img.shields.io/badge/style-very_good_analysis-B22C89.svg)](https://pub.dev/packages/very_good_analysis)\n\n|Linux|Windows|Android|MacOS (under test)|iOS (under test)|web (WASM compatible)|\n|:-:|:-:|:-:|:-:|:-:|:-:|\n|💙|💙|💙|💙|💙|💙|\n\n## 🌟 Key Features:\n- 🖥️ **Cross-platform**: Supports Linux, Windows, Android, MacOS, iOS, and web.\n- ⚡ **High performance**: Built using the fast and efficient miniaudio C library with FFI.\n- 🎙️ **WAV Recording with Pause**: Record in WAV format with pause functionality.\n- ⚙️ **Choose Data Type**: samplerate, mono or stereo, audio format (u8, s8, s16le, s24le, s32le or f32le).\n- 🎛️ **Device Flexibility**: Choose your recording device.\n- 📢 **Stream audio data**: Listen to PCM audio data stream.\n- 🔇 **Silence Detection**: Automatically detects silence via callback or Stream.\n- 📊 **Customizable Silence Threshold**: Define what’s considered “silence” for your recordings.\n- ⏱️ **Adjustable Pause Timing**: Set how long silence lasts before pausing, and how soon to resume recording.\n- 🔊 **Real-time Audio Metrics**: Access volume, audio wave, and FFT data in real-time.\n- 🎚️ **Auto Gain**: Experimental Auto Gain filter.\n- 🌐 **Cross Platform**: Supports all platforms with WASM support for the web.\n\n[A web example compiled in WASM.](https://marcobavagnoli.com/flutter_recorder/)\n\n## 🚀 Setup\nAfter setting up permission for you Android, MacOS or iOS, in your app, you will need to ask for permission to use the microphone maybe using [permission_handler](https://pub.dev/packages/permission_handler) plugin.\nhttps://pub.dev/packages/permission_handler\n\n#### Android\nAdd the permission in the `AndroidManifest.xml`.\n```\n\u003cuses-permission android:name=\"android.permission.RECORD_AUDIO\" /\u003e\n```\n\n#### MacOS, iOS\nAdd the permission in `Runner/Info.plist`.\n```\n\u003ckey\u003eNSMicrophoneUsageDescription\u003c/key\u003e\n\u003cstring\u003eSome message to describe why you need this permission\u003c/string\u003e\n```\n\non **MacOS** :\n\nIn capabilities, activate \"Audio input\" in debug and release schemes or add in `macos/Runner/*.entitlements` files:\n```\n\u003ckey\u003ecom.apple.security.device.audio-input\u003c/key\u003e\n\u003ctrue/\u003e\n```\n\n#### Web\nAdd this in `web/index.html` under the `\u003chead\u003e` tag.\n```\n\u003cscript src=\"assets/packages/flutter_recorder/web/libflutter_recorder_plugin.js\" defer\u003e\u003c/script\u003e\n\u003cscript src=\"assets/packages/flutter_recorder/web/init_recorder_module.dart.js\" defer\u003e\u003c/script\u003e\n```\nThe plugin is **WASM** compatible and your app can be compiled and run locally with something like:\n```\nflutter run -d chrome --web-renderer canvaskit --web-browser-flag '--disable-web-security' -t lib/main.dart --release\n```\n\n#### Linux\n- [`GStreamer`](https://gstreamer.freedesktop.org/documentation/installing/index.html?gi-language=c) is installed by default on most distributions, but if not, please [install it](https://gstreamer.freedesktop.org/documentation/installing/on-linux.html?gi-language=c) through your distribution's package manager.\n- Installing Flutter using `snap` could cause compilation problems with native plugins. The only solution is to uninstall it with `sudo snap remove flutter` and install it the [official way](https://flutter-ko.dev/get-started/install/linux).\n\n## 🛠️ Usage Example\n```dart\nimport 'package:permission_handler/permission_handler.dart';\n[...]\n/// If you are running on Android, MacOS or iOS, ask the permission to use the microphone:\nif (defaultTargetPlatform == TargetPlatform.android ||\n    defaultTargetPlatform == TargetPlatform.iOS ||\n    defaultTargetPlatform == TargetPlatform.macOS) {\n    Permission.microphone.request().isGranted.then((value) async {\n    if (!value) {\n        await [Permission.microphone].request();\n    }\n});\n\n/// Initialize the capture device and start it:\ntry {\n    Recorder.instance.init();\n    Recorder.instance.start();\n} on Exception catch (e) {\n    debugPrint('init() error: $e\\n');\n}\n/// On Web platform it is better to initialize and wait the user to give\n/// mic permission. Then use `start()` when it's needed.\n\n//Start recording:\nRecorder.instance.startRecording(completeFilePath: 'audioCompleteFilenameWithPath.wav`);\n\n/// Stop recording:\nRecorder.instance.stopRecording();\n```\n**Tip**: Use `Recorder.instance.listCaptureDevices()` to see available devices and pass an optional `deviceID` to `init()`.\n**Tip2**: Use the `format`, `sampleRate` and `channels` with the `init()` method to define recorder parameters.\n**Tip3**: When recording with silence detection and want to record a little bit before the threshold db is reached, use the `setSecondsOfAudioToWriteBefore()` method.\n\n\n### 🔇 Silence Detection Example\n\nWant to skip the silence? Here’s how to configure it:\n\n```dart\nRecorder.instance.setSilenceDetection(\n    enable: true,\n    onSilenceChanged: (isSilent, decibel) {\n        /// Here you can check if silence is changed.\n        /// Or you can do the same thing with the Stream\n        /// [Recorder.instance.silenceChangedEvents]\n    },\n);\n/// the silence threshold in dB. A volume under this value is considered to be silence.\nRecorder.instance.setSilenceThresholdDb(-27);\n/// the value in seconds of silence after which silence is considered as such.\nRecorder.instance.setSilenceDuration(0.5);\n/// Set seconds of audio to write before starting recording again after silence.\nRecorder.instance.setSecondsOfAudioToWriteBefore(0.0);\n```\n\n### 📊 Audio, FFT, and Volume Data\nYou can also access raw audio data and volume information like this:\n\n```dart\n/// Get the current volume in dB in the [-100, 0] range.\ndouble volume = Recorder.instance.getVolumeDb();\n/// Return a 256 float array containing wave data in the range [-1.0, 1.0] not clamped.\nFloat32List waveAudio = Recorder.instance.getWave();\n/// Return a 256 float array containing FFT data in the range [-1.0, 1.0] not clamped.\nFloat32List fftAudio = Recorder.instance.getFft();\n```\n\n![Image](https://github.com/alnitak/flutter_recorder/raw/main/images/audio_data.png)\n\n***NOTE: this is only available when initializing the recorder with `PCMFormat.f32le` format.***\n\n### 📢 Audio data stream \n\n\n```dart\n/// Listen to audio data stream. The data is received in Uint8List.\nRecorder.instance.uint8ListStream.listen((data) {\n    /// the [data] is of type `AudioDataContainer` and, whatever format is passed to\n    /// the `init()` method, it is available with [data.rawData] which is of `Uint8List`\n    /// type. This is useful if we want to write into a file.\n    /// It is possible to convert audio data to the desired format using one of the\n    /// `data.to[*]List` methods. Be aware that the conversion is compute expensive and\n    /// should be avoided if possible initializing the recorder with the format\n    /// desired.\n});\n\n/// Start streaming:\nRecorder.instance.startStreamingData();\n/// Stop streaming:\nRecorder.instance.stopStreamingData();\n```\n\u003e [!CAUTION]\n\u003e Audio data must be processed as it is received. To optimize performance, the same memory is used to store data for all incoming streams, meaning the data will be overwritten. Therefore, you must copy the data if you need to populate a buffer while it arrives.\n\u003e For example, when using **RxDart.bufferTime**, it will fill a **List** of `AudioDataContainer` objects, but when you attempt to read them, you will find that all the items contain the same data.\n\n### 🎚️ Auto Gain Filter\n\n\u003e [!WARNING]\n\u003e This is an experimental feature, may change in the future.\n\n```\nfinal Recorder recorder = Recorder.instance;\n// Please look at the [Recorder.instance.autoGainFilter] doc to have a parameters overview.\nfinal AutoGain autoGain = recorder.filters.autoGainFilter;\n\n// You can now query or set parameters:\n// For example with [autoGain.queryTargetRms] you can query the \"human\" name, `min`, `max` and `def` values.\n\n// Set a new parameter value:\nautoGain.targetRms.value = newValue;\n\n// Get a new parameter value:\nfinal value = autoGain.targetRms.value;\n```\nAvailable parameters: `targetRMS`, `attackTime`, `releaseTime`, `gainSmoothing`, `maxGain`, `minGain`.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falnitak%2Fflutter_recorder","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falnitak%2Fflutter_recorder","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falnitak%2Fflutter_recorder/lists"}