<commit_before>import $ from 'jquery';
import 'jquery-ui/widgets/slider';

import { EffectUIBase, EffectParameterObjectBase, EffectNodeBase } from './base';

import template from './templates/delay.marko';

import Signal from '../../../utils/signal';

class DelayEffectUI extends EffectUIBase {
  constructor(target, effect, location) {
    super(target, effect, location);
  }

  render() {
    this.panel = $(template.renderToString());
    $(this.target).append(this.panel);
    this.bindParameterToUI("#delay-slider", "#delay-value", 1, 10000, 1, "delay");
    this.bindParameterToUI("#feedback-slider", "#feedback-value", 0, 1, 0.001, "feedback");
    this.bindParameterToUI("#wet-slider", "#wet-value", 0, 1, 0.001, "wet");
    this.bindParameterToUI("#dry-slider", "#dry-value", 0, 1, 0.001, "dry");
    this.bindParameterToUI("#cutoff-slider", "#cutoff-value", 20, 22050, 1, "cutoff");
    this.panel.find("#bypass").on("change", (e) => {
      this.effect.bypass = !e.target.checked;
      this.effectChanged(this.location, this.effect);
    });
  }

}

class DelayEffectParameterObject extends EffectParameterObjectBase {
  constructor() {
    super();

    this.type = "delay",
    this.bypass = false,
    this.parameters = {
      delay: 150,
      feedback: 0.45,
      wet: 0.25,
      dry: 1.0,
      cutoff: 2000,
    };
  }

  createEffectNode(tuna) {
    return new DelayEffectNode(tuna, this);
  }
}


class DelayEffectNode extends EffectNodeBase {
  constructor(tuna, po) {
    super(tuna, po);

    this.fx = new tuna.Delay({
      feedback: po.parameters.feedback,
      delayTime: po.parameters.delay,
      wetLevel: po.parameters.wet,
      dryLevel: po.parameters.dry,
      cutoff: po.parameters.cutoff,
      bypass: po.bypass,
    });
  }

  updateFromParameterObject(po) {
    this.fx.bypass = po.bypass;
    this.fx.feedback = po.parameters.feedback;
    this.fx.delayTime = po.parameters.delay;
    this.fx.wetLevel = po.parameters.wet;
    this.fx.dryLevel = po.parameters.dry;
    this.fx.cutoff = po.parameters.cutoff;
  }
}

export const NAME = "Delay";
export const TYPE = "delay";
export { DelayEffectUI as UI, DelayEffectNode as Node, DelayEffectParameterObject as ParameterObject }
<commit_msg>Update delay effect.<commit_after>import $ from 'jquery';
import 'jquery-ui/widgets/slider';

import { EffectUIBase, EffectParameterObjectBase, EffectNodeBase } from './base';

import template from './templates/delay.marko';

import Signal from '../../../utils/signal';

export const NAME = "Delay";
export const TYPE = "delay";

class DelayEffectUI extends EffectUIBase {
  constructor(target, effect, location) {
    super(target, effect, location);
  }

  render() {
    this.panel = $(template.renderToString());
    $(this.target).append(this.panel);
    this.bindParameterToUI("#delay-slider", "#delay-value", 1, 10000, 1, "delay");
    this.bindParameterToUI("#feedback-slider", "#feedback-value", 0, 1, 0.001, "feedback");
    this.bindParameterToUI("#wet-slider", "#wet-value", 0, 1, 0.001, "wet");
    this.bindParameterToUI("#dry-slider", "#dry-value", 0, 1, 0.001, "dry");
    this.bindParameterToUI("#cutoff-slider", "#cutoff-value", 20, 22050, 1, "cutoff");
    this.panel.find("#bypass").on("change", (e) => {
      this.effect.bypass = !e.target.checked;
      this.effectChanged(this.location, this.effect);
    });
  }

}

class DelayEffectParameterObject extends EffectParameterObjectBase {
  constructor() {
    super();

    this.type = TYPE,
    this.bypass = false,
    this.parameters = {
      delay: 150,
      feedback: 0.45,
      wet: 0.25,
      dry: 1.0,
      cutoff: 2000,
    };
  }

  createEffectNode(tuna) {
    return new DelayEffectNode(tuna, this);
  }
}


class DelayEffectNode extends EffectNodeBase {
  constructor(tuna, po) {
    super(tuna, po);

    this.fx = new tuna.Delay({
      feedback: po.parameters.feedback,
      delayTime: po.parameters.delay,
      wetLevel: po.parameters.wet,
      dryLevel: po.parameters.dry,
      cutoff: po.parameters.cutoff,
      bypass: po.bypass,
    });
  }

  updateFromParameterObject(po) {
    this.fx.bypass = po.bypass;
    this.fx.feedback = po.parameters.feedback;
    this.fx.delayTime = po.parameters.delay;
    this.fx.wetLevel = po.parameters.wet;
    this.fx.dryLevel = po.parameters.dry;
    this.fx.cutoff = po.parameters.cutoff;
  }
}

export { DelayEffectUI as UI, DelayEffectNode as Node, DelayEffectParameterObject as ParameterObject }

{'fraction_non_alphanumeric': 0.15396648044692737, 'fraction_numerical': 0.021452513966480447, 'mean_word_length': 3.43607532210109, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '817105', 'n_tokens_mistral': 1585, 'n_tokens_neox': 1470, 'n_words': 300}