TrackNativeInfo.fromNative constructor

TrackNativeInfo.fromNative(
  1. AETrackInfoNative native
)

Implementation

factory TrackNativeInfo.fromNative(AETrackInfoNative native) {
  final bytes = <int>[];
  for (int i = 0; i < 32; i++) {
    final b = native.format_name[i];
    if (b == 0) break;
    bytes.add(b);
  }
  final fmtStr = String.fromCharCodes(bytes).trim();
  return TrackNativeInfo(
    sampleRate: native.sample_rate,
    bitDepth: native.bit_depth,
    channels: native.channels,
    bitrateKbps: native.bitrate_kbps,
    isFloat: native.is_float != 0,
    durationSecs: native.duration_secs,
    fileSizeBytes: native.file_size_bytes,
    formatName: fmtStr.isNotEmpty ? fmtStr : 'AUDIO',
  );
}