openFile method

Device openFile(
  1. int driverId,
  2. String filename, {
  3. int bits = 16,
  4. int rate = 44100,
  5. int channels = 2,
  6. ByteFormat byteFormat = ByteFormat.little,
  7. String? matrix,
})

Open a file for audio output. The file format is determined by the audio driver used.

Implementation

Device openFile(
  int driverId,
  String filename, {
  int bits = 16,
  int rate = 44100,
  int channels = 2,
  ByteFormat byteFormat = ByteFormat.little,
  String? matrix,
}) {
  final sampleFormat = calloc<_SampleFormat>();
  sampleFormat.ref.bits = bits;
  sampleFormat.ref.rate = rate;
  sampleFormat.ref.channels = channels;
  sampleFormat.ref.byteFormat = _byteFormatToInt(byteFormat);
  if (matrix != null) sampleFormat.ref.matrix = matrix.toNativeUtf8();

  final device =
      _openFile(driverId, filename.toNativeUtf8(), 1, sampleFormat, nullptr)
          .address;

  calloc.free(sampleFormat);

  return Device._(Pointer.fromAddress(device));
}