fastcos, fastsine, fasttan etc. definition and tips

Artur Dobija's icon

Hello!
Recently I discovered [fastcos] operator for [gen~]. I wanted to learn more about it (how it works etc) but the docs are not that much revealing.

I was wondering if one can build a cheap-but-decent fm synth based on the [fastcos] rather than [cycle].

[cycle] has pretty short wavetable anyway and would be avoided in a more professional application. It is still antialiased though.

One can then use [cos] with [phasor], but it turns out to be much more cpu expensive.

Maybe [fastcos] could be a golden mean for that approach?

There is also gen~ code made by Ernest (published recently here: https://cycling74.com/forums/synthcore-v2-4-gen~-library-available-for-free-download ):
qcos(x){
    x *= x;
    x = x*(x*(x*(x*(x *-.0000002605 +.000024709
        )- .00138884)+.416667)- .499923)+ 1;
    return x;
}

and as far as I know it is an approximation based on the Taylor series. How is it different from [fastcos]?

Ernest's icon

Hi. I dont know about fastcos in gen~ but what would be most effiicent would be to use the lookup table for sine and wrap it by 0.25 I think, if I remember correctly the table lookup works 0 to 1 for a complete wave. Table-based lookup should at least theoretically be more efficient than any algorithmic computation, I think I tested the fastcos against it and found it so, but it was a long time ago, Im not sure.

Roman Thilenius's icon


i believe going in and out between gen and msp for only 1-2 functions already causes a little overhead in itself - similar to using poly~ for only 1-2 objects - so it wont save much i think.

using the MSP cos~ object might be a lot more expensive than using a wavetable, but well, how many oscillators do you use in an FM synth voice? more than... 50?

and dont forget that cycle~, but you know that of course, has always the benefit of using different waveforms.

Ernest's icon

oh, you can use a wavetable in gen~ too. I think it's a mode of the cycle, I can't remember lol. I've bene programming in PHP a while, and programming in one language makes me forget others. I guess I could refresh my memory of the gen syntax pretty quickly, but what I notice is that there has been a real drop in users over the last year, and I was planning to wait to see if it picked up now colleges arent doing video classes any more, or if there really has been a general departure for something else. I dont know.

Roman Thilenius's icon


oh of course, yes, wavetable in gen~ is the 4th option - and the second compromise solution, which is what he was looking for.