MicAudioCapture class
Class for capturing audio from microphone input devices.
This class allows you to capture audio from connected microphones, including built-in microphones, external USB microphones, and Bluetooth microphones. It requires microphone permissions.
Example:
final micCapture = MicAudioCapture(
config: MicAudioConfig(
sampleRate: 44100,
channels: 1,
gainBoost: 2.5,
),
);
// Check for available devices
final devices = await micCapture.getAvailableInputDevices();
print('Available microphones: ${devices.length}');
await micCapture.startCapture();
// Listen to audio stream
micCapture.audioStream?.listen((audioData) {
// Process audio bytes
print('Received ${audioData.length} bytes');
});
// Listen to status updates
micCapture.statusStream?.listen((status) {
print('Mic active: ${status.isActive}, Device: ${status.deviceName}');
});
// Listen to decibel readings
micCapture.decibelStream?.listen((data) {
print('Mic level: ${data.decibel} dB');
});
// Stop when done
await micCapture.stopCapture();
- Inheritance
-
- Object
- AudioCapture
- MicAudioCapture
Constructors
- MicAudioCapture({MicAudioConfig? config})
- Creates a new MicAudioCapture instance.
Properties
-
audioStream
→ Stream<
Uint8List> ? -
Stream of raw audio data bytes from microphone capture.
no setter
-
decibelStream
→ Stream<
DecibelData> ? -
Stream of microphone decibel (dB) readings.
no setter
- hashCode → int
-
The hash code for this object.
no setterinherited
- isRecording → bool
-
Whether microphone capture is currently recording.
no setteroverride
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
statusStream
→ Stream<
MicAudioStatus> ? -
Stream of microphone status updates.
no setter
Methods
-
getAvailableInputDevices(
) → Future< List< InputDevice> > - Gets a list of all available input devices (microphones).
-
hasInputDevice(
) → Future< bool> - Checks if there is any available input device (microphone).
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
requestPermissions(
) → Future< bool> - Requests necessary permissions for microphone capture.
-
startCapture(
{MicAudioConfig? config}) → Future< void> - Starts capturing audio from the microphone.
-
stopCapture(
) → Future< void> - Stops capturing microphone audio.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateConfig(
MicAudioConfig config) → void - Updates the audio capture configuration.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited