Supporting both 32bit and 64 bit sample size without getting ugly

Hi Friends,

I am developing my first plugin with VST SDK.

I would like to know how to deal with the choice between Sample32 and/or Sample64.

I built a 32 bit prototype and was happy with the results. Next I tried to introduce support for both 32bit and 64 bit using C++ template and the code started becoming ugly at a very rapid rate even for my simple prototype.

Makes me wonder , how do others deal with it.

Here are some questions

  1. Is C++ template, the suggested way to target both ? Any suggestions on coding in general ?
  2. Is it better to keep two version of the code - so two builds - one targeted at 32 bit another at 64 bit ?
  3. If I had to keep only one version, would I cover more end users by sticking to 32 bit or 64 bit ?
  4. Some forums on the net claim that 64 bit would be more efficient. Is that somehow true ?

I searched the forum but could not find any discussions on the topic.
Any suggestions would be appreciated

I have been using template code and I don’t think it is ugly. Of course it helps to write all the code generic.

For example in my framework (Jamba), the way I do it is that the framework implements the processInputs(data) call and then dispatch to a genericProcessInputs which is templated (ex: jamba-sample-gain/JSGainProcessor.cpp at master · pongasoft/jamba-sample-gain · GitHub) and that individual plugins implement.

The code then use generic concepts like AudioBuffers (also part of Jamba) and delegate to generic methods like processChannel in this example.

I don’t think it ends up being ugly. You use SampleType instead of Sample32 or Sample64 and you can also use “auto” a lot (which is part of the C++ guidelines for modern code anyway).

Yan