Example #1
0
  MOCsim(ParameterContextModel _shared_pars, int _index) {
    shared_pars_ref = _shared_pars;
    circBuff_ptr =
        new CircularBuffer(
            MainActivity.AUDIO_SAMPLING_RATE / 100); // new CircularBuffer<Float>(441);
    index = _index;
    sampleRate = (float) MainActivity.AUDIO_SAMPLING_RATE; // 44100.0f;
    tc = 0.050f;
    latency = 0.010f;
    factor = 0.5f;
    thresh_dB = 25.0f;
    thresh_pa = Utils.dbspl2pa(thresh_dB);
    isStereo = false;
    isSample2of2 = false;
    stereoAccumulator = 0.0f;
    updatePars();

    // The MOC only needs to know about the stuff shared between both chans
    // The object itself is shared between chans and so this fact should not change!
    cS = shared_pars_ref.addSubscriber(this);
  }
Example #2
0
  public void updatePars() {
    tc = shared_pars_ref.getParam("Band_" + index + "_MOCtc", tc);
    factor = shared_pars_ref.getParam("Band_" + index + "_MOCfactor", factor);
    latency = shared_pars_ref.getParam("Band_" + index + "_MOClatency", latency);
    sampleRate = shared_pars_ref.getParam("SampleRate", sampleRate);

    isStereo =
        (shared_pars_ref.getParam("IsStereo") > 0.5f); // Logical statement to get bool from float

    thresh_dB = shared_pars_ref.getParam("Band_" + index + "_MOCthreshold_dBspl", thresh_dB);
    thresh_pa = Utils.dbspl2pa(thresh_dB);

    MOCfilt.initOnePoleCoeffs(tc, 1.f / sampleRate);

    int bufferSamples =
        (int) (1 + Math.floor(latency * sampleRate)); // Add 1 to prevent a buffersize of zero
    circBuff_ptr.set_capacity(bufferSamples);
    for (int nn = 0; nn < bufferSamples; ++nn) {
      circBuff_ptr.push_back(1.0f); // populate with ones
    }
  }