コード例 #1
0
ファイル: SignalEnvelope.c プロジェクト: section6/harpy
static void sEnv_sendMessage(HvBase *_c, SignalEnvelope *o, float rms,
    void (*sendMessage)(HvBase *, int, const HvMessage *)) {
  // finish RMS calculation. sqrt is removed as it can be combined with the log operation.
  // result is normalised such that 1 RMS == 100 dB
  rms = 10.0f * log10f(rms) + 100.0f;

  // prepare the outgoing message. Schedule it at the beginning of the next block.
  HvMessage *const m = HV_MESSAGE_ON_STACK(1);

  msg_initWithFloat(m, ctx_getBlockStartTimestamp(_c) + HV_N_SIMD, (rms < 0.0f) ? 0.0f : rms);
  ctx_scheduleMessage(Base(_c), m, sendMessage, 0);

  hv_memcpy(o->buffer, o->buffer+o->period, sizeof(float)*(o->numSamplesInBuffer - o->period));
  o->numSamplesInBuffer -= o->period;
}
コード例 #2
0
ファイル: SignalSample.c プロジェクト: reactify/Buffers
void __hv_sample_f(HvBase *_c, SignalSample *o, hv_bInf_t bIn,
    void (*sendMessage)(HvBase *, int, const HvMessage *)) {
  if (o->i != __HV_SAMPLE_NULL) {

#if HV_SIMD_AVX || HV_SIMD_SSE
    float out = bIn[o->i & HV_N_SIMD_MASK];
#elif HV_SIMD_NEON
    float out = bIn[o->i & HV_N_SIMD_MASK];
#else // HV_SIMD_NONE
    float out = bIn;
#endif

    HvMessage *n = HV_MESSAGE_ON_STACK(1);
    hv_uint32_t ts = (o->i + HV_N_SIMD) & ~HV_N_SIMD_MASK; // start of next block
    msg_initWithFloat(n, ts, out);
    ctx_scheduleMessage(_c, n, sendMessage, 0);
    o->i = __HV_SAMPLE_NULL; // reset the index
  }
}