Another alternative to calling sin() repeatedly is to use some kind of
recursive oscillator which just takes a few operations to output each
sample.

This article is a very readable starting point and presents a few options:
http://vicanek.de/articles/QuadOsc.pdf

As for whether an FFT would do the job, that depends on exactly what you're
trying to do. If you have an array of harmonic strengths which don't vary
over time, the harmonics are always perfectly aligned (no detuning), and
you just want to generate one period of the waveform, then an FFT is
perfect. That's exactly what an FFT does, it generates a weighted sum of
complex exponentials (I guess usually we think of the inverse FFT as doing
this, rather than the forward one, but they're really the same thing). If
any one of those assumptions about what you're doing is relaxed it might
not do what you want any more.

-Ethan



On Sun, Apr 15, 2018 at 5:07 PM, robert bristow-johnson <
r...@audioimagination.com> wrote:

>
>
> ---------------------------- Original Message ----------------------------
> Subject: [music-dsp] Build waveform sample array from array of harmonic
> strengths?
> From: "Frank Sheeran" <fshee...@gmail.com>
> Date: Sun, April 15, 2018 2:55 pm
> To: music-dsp@music.columbia.edu
> --------------------------------------------------------------------------
>
>
> > I'm currently just looping and calling sin() a lot. I use trivial 4-way
> > symmetry of sin() and build a "mipmap" of progressively octave-higher
> > versions of a wave, to play for higher notes, by copying samples off the
> > lowest-frequency waveform. That still is only 8x faster than the naive
> way
> > to do it.
> >
> > I know in theory that a FFT or DFT will turn a CONTINUOUS graph of
> > frequency into a graph of time, and vice versa, but if I don't have a a
> > continuous graph of frequency but rather an array of strengths, can I
> still
> > use it?
> >
> > I thought of making a continuous graph of frequency from my harmonics,
> but
> > 1) sounds quite imprecise and 2) I note real FFT graphs have smooth
> "hills"
> > where harmonics are, rather than point peaks, and am wondering whether
> I'd
> > get expected output if I didn't generate those hills.
>
> are you making wavetables, Frank?  is that what you're doing?
>
>
> --
>
> r b-j                         r...@audioimagination.com
>
> "Imagination is more important than knowledge."
>
>
>
>
>
>
>
>
> _______________________________________________
> dupswapdrop: music-dsp mailing list
> music-dsp@music.columbia.edu
> https://lists.columbia.edu/mailman/listinfo/music-dsp
>
_______________________________________________
dupswapdrop: music-dsp mailing list
music-dsp@music.columbia.edu
https://lists.columbia.edu/mailman/listinfo/music-dsp

Reply via email to