/** * @brief Database::depthTypeSearch * @param typeId * @return */ entity::SharedType Database::depthTypeSearch(const QString &typeId) const { entity::SharedType result; for (auto &&scope : m_Scopes.values()) { getDepthType(scope, typeId, result); if (result) break; } return result; }
/** * @brief Database::getDepthType * @param scope * @param id * @param result */ void Database::getDepthType(const entity::SharedScope &scope, const QString &id, entity::SharedType &result) const { if (scope->containsType(id)) { result = scope->type(id); return; } else if (scope->hasChildScopes()){ for (auto &&child_scope : scope->scopes()) { if (result) break; getDepthType(child_scope, id, result); } } }
int WIGGLE::init(double p[], int n_args) { const float outskip = p[0]; const float dur = p[1]; depth_type = (n_args > 4) ? getDepthType(p[4]) : NoModOsc; filter_type = (n_args > 5) ? getFiltType(p[5]) : NoFilter; float ringdur; if (filter_type == NoFilter) { nfilts = 0; ringdur = 0.0f; } else { if (filter_type != LowPass && filter_type != HighPass) return die("WIGGLE", "Filter type (p5) must be 0, 1, or 2."); nfilts = (n_args > 6) ? int(p[6]) : 1; if (nfilts < 1 || nfilts > MAXFILTS) return die("WIGGLE", "Steepness (p6) must be an integer between 1 and %d.", MAXFILTS); if (n_args > 7) do_balance = bool(p[7]); if (do_balance) { balancer = new Balance(SR); balancer->setWindowSize(BALANCE_WINDOW_SIZE); } ringdur = 0.1f; } if (rtsetoutput(outskip, dur + ringdur, this) == -1) return DONT_SCHEDULE; if (outputChannels() < 1 || outputChannels() > 2) return die("WIGGLE", "Output must be mono or stereo."); for (int i = 0; i < nfilts; i++) filt[i] = new Butter(SR); double *array = floc(AMP_FUNC); if (array) { int len = fsize(AMP_FUNC); amp_table = new TableL(SR, dur, array, len); } int len; if (n_args > 8) carwave_array = (double *) getPFieldTable(8, &len); if (carwave_array == NULL) { carwave_array = floc(CAR_WAVE_FUNC); if (carwave_array == NULL) return die("WIGGLE", "Either use the carrier wavetable pfield (p8), " "or make an old-style gen function in slot %d.", CAR_WAVE_FUNC); len = fsize(CAR_WAVE_FUNC); } carrier = new OscilL(SR, 0.0, carwave_array, len); array = floc(CAR_GLISS_FUNC); if (array) { len = fsize(CAR_GLISS_FUNC); cargliss_table = new TableN(SR, dur, array, len); } if (depth_type != NoModOsc) { if (n_args > 9) modwave_array = (double *) getPFieldTable(9, &len); if (modwave_array == NULL) { modwave_array = floc(MOD_WAVE_FUNC); if (modwave_array == NULL) return die("WIGGLE", "Either use the modulator wavetable pfield " "(p9), or make an old-style gen function " "in slot %d.", MOD_WAVE_FUNC); len = fsize(MOD_WAVE_FUNC); } modulator = new OscilL(SR, 0.0, modwave_array, len); array = floc(MOD_FREQ_FUNC); if (array) { len = fsize(MOD_FREQ_FUNC); modfreq_table = new TableL(SR, dur, array, len); } else if (n_args < 11) // no p10 mod freq return die("WIGGLE", "Either use the modulator frequency pfield " "(p10), or make an old-style gen function in " "slot %d.", MOD_FREQ_FUNC); array = floc(MOD_DEPTH_FUNC); if (array) { len = fsize(MOD_DEPTH_FUNC); moddepth_table = new TableL(SR, dur, array, len); } else if (n_args < 12) // no p11 mod depth return die("WIGGLE", "Either use the modulator depth pfield " "(p11), or make an old-style gen function in " "slot %d.", MOD_DEPTH_FUNC); } if (filter_type != NoFilter) { array = floc(FILTER_CF_FUNC); if (array) { len = fsize(FILTER_CF_FUNC); filtcf_table = new TableL(SR, dur, array, len); } else if (n_args < 13) // no p12 filter cf return die("WIGGLE", "Either use the filter cutoff frequency pfield " "(p12), or make an old-style gen function in " "slot %d.", FILTER_CF_FUNC); } if (outputChannels() == 2) { array = floc(PAN_FUNC); if (array) { len = fsize(PAN_FUNC); pan_table = new TableL(SR, dur, array, len); } else if (n_args < 14) // no p13 pan return die("WIGGLE", "Either use the pan pfield (p13), or make an " "old-style gen function in slot %d.", PAN_FUNC); } cpsoct10 = cpsoct(10.0); return nSamps(); }