# startPlayerFromMic method

Future<void> startPlayerFromMic({

1. int sampleRate = 48000,
2. int numChannels = 1,
3. int bufferSize = 8192,
4. dynamic enableVoiceProcessing = false,

})

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 four 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.
- bufferSize: the size of the internal buffers. Probably the default choice is OK
- enableVoiceProcessing: is a flag that you can enable

`startPlayerFromMic()` returns a Future, which is completed when the Player is really started.

Example:

        await myPlayer.startPlayerFromMic();
        ...
        myPlayer.stopPlayer();

'This function can very easily be emulated with a RecordToStream + a PlayFromStream',

## Implementation

    Future<void> startPlayerFromMic({
      int sampleRate = 48000, // The default value is probably a good choice.
      int numChannels =
          1, // 1 for monophony, 2 for stereophony (actually only monophony is supported).
      int bufferSize = 8192,
      enableVoiceProcessing = false,
    }) async {
      await _lock.synchronized(() async {
        await _startPlayerFromMic(
          sampleRate: sampleRate,
          numChannels: numChannels,
          bufferSize: bufferSize,
          enableVoiceProcessing: enableVoiceProcessing,
        );
      });
    }