Skip to content

patchandthat/wave-generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

wave_generator

A dart package to generate audio wave data on the fly.

Usage

To use this plugin, add wave_generator as a dependency in your pubspec.yaml file.

Example

import 'package:wave_generator/wave_generator.dart';

() async {

    var generator = WaveGenerator(
        /* sample rate */ 44100,
        BitDepth.Depth8bit);

    var note = Note(
        /* frequency */ 220,
        /* msDuration */ 3000,
        /* waveform */ Waveform.Triangle,
        /* volume */ 0.5);

    var file = new File('output.wav');

    List<int> bytes = List<int>();
    await for (int byte in generator.generate(note)) {
      bytes.add(byte);
    }

    file.writeAsBytes(bytes, mode: FileMode.append);
  });

Or string together a sequence of Notes

 await for (int byte in generator.generateSequence([note1, note2, note3 /* etc */])) {
   // ...
 }

Features

  • Sin, Square, Triangle waves
  • 8 Bit depth

About

A dart package to generate audio wave data on the fly.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages