# Function alternatives and useful snippets of code

Since the Reaper forum has one thread for JS programming i thought it would be a good idea to have one here for plugin development. Starting here you can find some great pieces of code which you can adapt to vcv rack: https://forum.cockos.com/showthread.php?t=39781

Also you can share:

• code optimization techniques - what is faster?
• any snippets of code - that may be useful to future coders.
• "dsp explained" notes - how does a filter work? how to do convolution?
• any interesting dsp related articles - books and lectures.
1 Like

There is a fantastic guide for writing efficient plugins from @Squinky:

3 Likes

Thanks for the shout-out!

There are two things I wish I could add to my (old) paper. First is the sin approximation that now comes with the sdk. The other is the SSE library built into the sdk which is especially useful for polyphonic modules. Unfortunately I not an expert in either area.

2 Likes

I was planning to write a paper explaining both the standard sin approximation, and the SSE version. Iâ€™ll move it up my list of priorities.

5 Likes

Itâ€™s not finished, but itâ€™s more than half done:

Should be finished within the week.

5 Likes

Now completed. It covers:

• the general idea of the algorithm
• a step-by-step breakdown of the standard cephes implementation
• a matching step-by-step breakdown of the SSE implementation

Itâ€™s intended for an audience that can already program in C.

8 Likes

Nice thanks.

WOW ! SUPER! did you do also a speed comparison against sine LUTs ? (Various dimensions) + Harmonic distortions differentials ?

BRAVO !

Iâ€™ve been using a linear interpolating LUT forâ€¦ decades? But these approximations are pretty cool - Iâ€™d consider using them.

1 Like

hehe Hal Chamberlin inheritance !

Very informative paper David, thank you for putting this together!

In this section:

And because the sine curve is cyclical, anything to the right of 2Ď€ can be handled if we reduce x by modulo 2Ď€

Shouldnâ€™t the formula be:

\sin x= \sin(x - 2n\pi) ?

Also only require math that we learning when we were 10 years old.

1 Like

Thank you. Corrected.

1 Like