pongasoft / jamba

A lightweight VST2/3 framework
https://jamba.dev/
Apache License 2.0
121 stars 3 forks source link

Add support for array of parameters #15

Closed ypujante closed 1 year ago

ypujante commented 1 year ago

Example of what Jamba should support natively.

// Parameters
  std::array<VstParam<bool>, 2> fLEDs;

// RT State
  std::array<RTVstParam<bool>, 2> fLEDs;

The issue is initialing in the state. Here is a quick implementation that works:

template<typename T, std::size_t N, std::size_t... I>
std::array<RTVstParam<T>, N> addMultiple_impl(RTState *iState, std::array<VstParam<T>, N> const &iArray, std::index_sequence<I...>)
{
  return {iState->add(iArray[I])...};
}

template<typename T, std::size_t N, typename Indices = std::make_index_sequence<N>>
std::array<RTVstParam<T>, N> addMultiple(RTState *iState, std::array<VstParam<T>, N> const &iArray)
{
  return addMultiple_impl(iState, iArray, Indices{});
}

// Constructor
    fLEDs{addMultiple(this, iParams.fLEDs)}

Note that addMultiple should be added to RTState for the "real" implementation

ypujante commented 1 year ago

Implemented in 6.1.0