Tone constructor

Tone({
  1. dynamic context,
  2. int? frequency1,
  3. int? frequency2,
})

constructor

Implementation

Tone({this.context, this.frequency1, this.frequency2}) {
  _osc1 = context.createOscillator();
  _osc2 = context.createOscillator();
  _osc1.frequency.value = this.frequency1;
  _osc2.frequency.value = this.frequency2;

  _gainNode = context.createGain();
  _gainNode.gain.value = 0.25;

  _filter = context.createBiquadFilter();
  _filter.type = "lowpass";
  _filter.frequency = 8000;

  _osc1.connect(_gainNode);
  _osc2.connect(_gainNode);

  _gainNode.connect(_filter);
  _filter.connect(context.destination);
}