desc:Real FFT sawtooth oscillator

// Copyright (C) 2015-2017 Theo Niessink <theo@taletn.com>
// This work is free. You can redistribute it and/or modify it under the
// terms of the Do What The Fuck You Want To Public License, Version 2,
// as published by Sam Hocevar. See http://www.wtfpl.net/ for more details.

slider1:440<20,20000,1>Freq (Hz)

import Tale/fft_real_synth.jsfx-inc
import Tale/wavetable.jsfx-inc

@init

function render_saw(buf, size, gain)
  local(x, dx)
(
  x = -gain;
  dx = 2 * gain / (size - 1);
  loop(size,
    buf[] = x;
    buf += 1;
    x += dx;
  );
);

osc.four_init(0, 1024);
render_saw(osc.buf, osc.size, 0.25);
osc.four_fft();

@slider

osc.four_setf(slider1);
osc.four_update() ? osc.four_ifft();

@sample

spl0 = spl1 = osc.wave_lerp();
