old one was less artifacty; convert beatpad to new sample func
parent
4c6c135617
commit
a78d41b134
|
@ -40,8 +40,8 @@ const std::array<std::array<double, LUT_TAPS>, LUT_STEPS> Xybrid::NodeLib::resam
|
|||
double sv = static_cast<double>(step) / LUT_STEPS; // subvalue (offset of tap position)
|
||||
for (size_t tap = 0; tap < LUT_TAPS; tap++) {
|
||||
double x = static_cast<double>(tap) - sv; // x position of tap;
|
||||
//double kaiser = cyl_bessel_i(0, KAISER_BETA * std::sqrt(1 - std::pow(((2 * (x+1)) / (LUT_TAPS)) - 1, 2))) / denom; // old kaiser window generation
|
||||
double kaiser = cyl_bessel_i(0, KAISER_BETA * std::sqrt(1.0 - std::pow( (2.0*x)/(LUT_TAPS-2) - 1.0, 2 ) ) ) / denom; // kaiser window of length LUT_TAPS-1
|
||||
double kaiser = cyl_bessel_i(0, KAISER_BETA * std::sqrt(1.0 - std::pow( ( (2.0*(x+1))/(LUT_TAPS) ) - 1.0, 2 ) ) ) / denom; // original kaiser window generation
|
||||
//double kaiser = cyl_bessel_i(0, KAISER_BETA * std::sqrt(1.0 - std::pow( (2.0*x)/(LUT_TAPS-2) - 1.0, 2 ) ) ) / denom; // by-the-book kaiser window of length LUT_TAPS-1
|
||||
//double idl = (2.0*PI)/(LUT_TAPS-1);
|
||||
//double kaiser = 0.40243 - 0.49804 * std::cos(idl * x) + 0.09831 * std::cos(2.0 * idl * x) - 0.00122 * std::cos(3.0 * idl * x); // approximate
|
||||
t[step][tap] = sinc(x-(LUT_TAPS/2-1)) * std::max(kaiser, 0.0); // sinc function centered on main tap, offset by subvalue, multiplied by window
|
||||
|
|
|
@ -105,19 +105,9 @@ void BeatPad::init() {
|
|||
|
||||
// actual sample pos
|
||||
double sp = static_cast<double>(start) + data.sampleTime * rate;
|
||||
if (sp >= static_cast<double>(end)) return core.deleteNote(note);
|
||||
|
||||
double ip = std::floor(sp);
|
||||
double fp = sp - ip;
|
||||
size_t lutIndex = static_cast<size_t>(fp*NodeLib::LUT_STEPS) % NodeLib::LUT_STEPS;
|
||||
auto& pt = NodeLib::resamplerLUT[lutIndex];
|
||||
AudioFrame out(0.0);
|
||||
auto ii = static_cast<ptrdiff_t>(ip) - 3;
|
||||
for (size_t i = 0; i < 8; i++) {
|
||||
auto si = ii+static_cast<ptrdiff_t>(i);
|
||||
if (si >= start && si < static_cast<ptrdiff_t>(end)) out += (*smp)[static_cast<size_t>(si)] * pt[i];
|
||||
}
|
||||
|
||||
// stuff
|
||||
auto out = NodeLib::resamp(smp.get(), sp, rate);
|
||||
|
||||
(*p)[i] += out.gainBalance(0, note.pan) * note.ampMult();
|
||||
data.sampleTime += 1;
|
||||
|
|
Loading…
Reference in New Issue