Example #1
0
// set parameter by value (fix16)
void module_set_param(u32 idx, pval v) {
    switch(idx) {
    case eParamAmp:
        filter_1p_fix16_in(ampLp, v.fix);
        break;
    case eParamDry:
        dry = v.fix;
        break;
    case eParamTime:
        set_time(v.fix);
        break;
    case eParamRate:
        filter_1p_fix16_in(rateLp, v.fix);
        break;
    case eParamFb:
        fb =  FIX16_FRACT_TRUNC(v.fix);
        break;
    case eParamAmpSmooth:
        filter_1p_fix16_set_hz(ampLp, v.fix);
        break;
    case eParamTimeSmooth:
        filter_1p_fix16_set_hz(timeLp, v.fix);
        break;
    case eParamRateSmooth:
        filter_1p_fix16_set_hz(rateLp, v.fix);
        break;
    default:
        break;
    }
}
Example #2
0
// read
fract32 buffer_tapN_read(bufferTapN *tap) {
  fract32 a, b;
  fix16 tmp;

#if 1
  if(tap->divCount == 0) {
    return tap->buf->data[tap->idx];
  } else { // interpolate during phase-division
    a = tap->buf->data[tap->idx];
    if( (tap->idx + 1) >= tap->loop) {
      b = tap->buf->data[0];
    } else {
      b = tap->buf->data[ tap->idx + 1 ];
    }
    tmp = FRACT_FIX16( sub_fr1x32(b, a) );
    tmp = fix16_mul(tmp, fix16_from_int(tap->divCount));
    return add_fr1x32(a, FIX16_FRACT_TRUNC(tmp));
  }
#else
    return tap->buf->data[tap->idx];
#endif
}
Example #3
0
// convert
void fix16_to_fix32(fix16* in, fix32* out) {
  out->fr = FIX16_FRACT_TRUNC(*in);
  out->i = (s32)(FIX16_TO_S16(*in));
}
Example #4
0
// frame calculation
static void calc_frame(void) {
    // ----- smoothers:
    // amp
    amp = filter_1p_fix16_next(ampLp);
    // time
    if(timeLp->sync) {
        ;;
    } else {
        time = filter_1p_fix16_next(timeLp);
        buffer_tap_sync(&tapRd, &tapWr, time);

#if ARCH_LINUX
        if(dbgFlag) {
            fprintf(dbgFile, "%d \t %f \r\n",
                    dbgCount,
                    fix16_to_float(time)
                   );
            dbgCount++;
        }

#endif


    }

    // rate
    //// NOTE: setting a different rate is pretty much pointless in this simple application.
    /// leaving it in just to test fractional interpolation methods.
    if(rateLp->sync) {
        ;;
    } else {
        rate = filter_1p_fix16_next(rateLp);
        buffer_tap_set_rate(&tapRd, rate);
        buffer_tap_set_rate(&tapWr, rate);
    }

    // get interpolated echo value

    echoVal = buffer_tap_read(&tapRd);

    /* // store interpolated input+fb value */
    //  buffer_tap_write(&tapWr, add_fr1x32(in0, mult_fr1x32x32(echoVal, fb ) ) );
    buffer_tap_write(&tapWr, add_fr1x32(in0 >> 1, mult_fr1x32x32(echoVal, fb ) ) );

    //FIXME: clip / saturate input buf here
    //// potentially, scale input by inverse feedback

/// test: no fb
    //buffer_tap_write(&tapWr, in0);

    /* // output */
    frameVal = add_fr1x32(
                   mult_fr1x32x32( echoVal, FIX16_FRACT_TRUNC(amp) ),
                   mult_fr1x32x32( in0,  FIX16_FRACT_TRUNC(dry) )
               );
    //// test: no dry
    //  frameVal = echoVal;
    /// FIXME: clip here

    buffer_tap_next(&tapRd);
    buffer_tap_next(&tapWr);
}