llfbandit / record

Audio recorder from microphone to a given file path. No external dependencies, MediaRecorder is used for Android an AVAudioRecorder for iOS.
https://pub.dev/packages/record
235 stars 200 forks source link

Cannot choose a device to record #296

Closed HydroCarbon closed 4 months ago

HydroCarbon commented 7 months ago

Package version

Environment

Describe the bug

I use this config to record stream:

RecordConfig config = RecordConfig(
      device: _inputDevice,
      encoder: AudioEncoder.pcm16bits,
      sampleRate: 16000,
      numChannels: 1,
);

Stream<Uint8List> recordStream = await _audioRecorder.startStream(config);

Expected to record audio from choosen device(_inputDevice), and this is code to choose device:

_audioRecorder
        .listInputDevices()
        .then((devices) => devices.firstWhere(
            (device) => device.label == deviceLabel,
            orElse: () => devices.first))
        .then((device) => _inputDevice = device)

when I use diffenrent label, it always record from macos's microphone device. By the way, i use Blackhole create a virtual input device.

To Reproduce

Steps to reproduce the behavior:

  1. Create a virtual device use Blackholehttps://github.com/ExistentialAudio/BlackHole
  2. Choose virtual input device created by Blackhole to record stream.
  3. Still record from default macos's microphone input device.
  4. See error

Expected behavior

Record from device that i choosen

Additional context There is blackhole's url https://github.com/ExistentialAudio/BlackHole

HydroCarbon commented 7 months ago

And I found it always use the input device that setted in system setting.

image
austibwu commented 6 months ago

@llfbandit is device selection an intended feature of the plugin?

HydroCarbon commented 6 months ago

@llfbandit is device selection an intended feature of the plugin?

Record has a param of device.I think it's a param to select device. And document say it can choose device on macOS. 截图 2024-04-01 17-16-06

llfbandit commented 5 months ago

@HydroCarbon Device selection was missing on streaming code branch.

Are you able to test it from this repository on master branch?

HydroCarbon commented 5 months ago

@llfbandit OK,I will test it in two days. and I will reply to you .

llfbandit commented 4 months ago

Released in record_darwin 1.1.0