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 :smiley: 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