startPlayerFromMic method
Starts the Microphone and plays what is recorded.
The Speaker is directely linked to the Microphone. There is no processing between the Microphone and the Speaker. If you want to process the data before playing them, actually you must define a loop between a FlutterSoundPlayer and a FlutterSoundRecorder. (Please, look to this example).
Later, we will implement the Tau Audio Graph concept, which will be a more general object.
startPlayerFromMic()
has two optional parameters :sampleRate:
the Sample Rate used. Optional. Only used on Android. The default value is probably a good choice and the App can ommit this optional parameter.numChannels:
1 for monophony, 2 for stereophony. Optional. Actually only monophony is implemented.
startPlayerFromMic()
returns a Future, which is completed when the Player is really started.
Example:
await myPlayer.startPlayerFromMic();
...
myPlayer.stopPlayer();
Implementation
Future<void> startPlayerFromMic({
int sampleRate = 44000, // The default value is probably a good choice.
int numChannels =
1, // 1 for monophony, 2 for stereophony (actually only monophony is supported).
}) async {
await _lock.synchronized(() async {
await _startPlayerFromMic(
sampleRate: sampleRate,
numChannels: numChannels,
);
});
}