Simple reader and writer for WAVE files.

It reads the ByteData of the contents, and create a list of channels. Each channel is Int16List.

Features

  • Can read 16bit & 24bit PCM files.
  • Can read 32bit float files.
  • Can write to 16bit PCM file.

Getting started

Add wav_io package to your pubspec.yaml file.

Usage

This example can be found in /example folder.


import 'dart:io';

import 'package:wav_io/wav_io.dart';

void main() {
  var f = File("example/hello_float.wav").openSync(); 
  var buf = f.readSync(f.lengthSync());
  f.closeSync();
  // loads
  var wav = WavContent.fromBytes(buf.buffer.asByteData());

  print(wav.numChannels);
  print(wav.numSamples);
  print(wav.sampleRate);
  print(wav.bitsPerSample);
  // actual samples store in wav.samplesForChannel
  f = File("example/hello2.wav").openSync(mode: FileMode.writeOnly);
  f.writeFromSync(wav.toBytes().buffer.asInt8List());
  f.flushSync();
  f.closeSync();
}

Additional information

WavContent stores each sample in 16 bit pcm format.

Libraries

wav_io
Support for doing something awesome.