void ClustMod::GetWorldBoundBox( TimeValue t,INode* inode, ViewExp *vpt, Box3& box, ModContext *mc) { // Need the correct bound box for proper damage rect calcs. #ifdef DESIGN_VER TimeValue rt = GetCOREInterface()->GetTime(); Matrix3 obtm = inode->GetObjectTM(rt); #else Matrix3 obtm = inode->GetObjectTM(t); #endif GraphicsWindow *gw = vpt->getGW(); Matrix3 ptm(1), ctm(1); if (posControl) posControl->GetValue(t,&ptm,FOREVER,CTRL_RELATIVE); if (tmControl) tmControl->GetValue(t,&ctm,FOREVER,CTRL_RELATIVE); //Matrix3 tm = DEFORMER_TM; Matrix3 tm = CompTM(ptm,ctm,mc->tm,1); ClustDeformer deformer(tm); BoxLineProc bp1(&obtm); DoModifiedBox(MakeBoxNotEmpty(*mc->box), deformer, bp1); box = bp1.Box(); //obtm = ctm * obtm; if (mc->tm) obtm = ctm * Inverse(*mc->tm) * obtm; else obtm = ctm * obtm; BoxLineProc bp2(&obtm); DrawCenterMark(bp2,MakeBoxNotEmpty(*mc->box)); box += bp2.Box(); }
// Initialization and runtime control static int control(struct af_instance* af, int cmd, void* arg) { af_equalizer_t* s = (af_equalizer_t*)af->priv; switch(cmd){ case AF_CONTROL_REINIT:{ int k =0, i =0; float F[KM] = CF; s->gain_factor=0.0; // Sanity check if(!arg) return AF_ERROR; mp_audio_copy_config(af->data, (struct mp_audio*)arg); mp_audio_set_format(af->data, AF_FORMAT_FLOAT); // Calculate number of active filters s->K=KM; while(F[s->K-1] > (float)af->data->rate/2.2) s->K--; if(s->K != KM) MP_INFO(af, "Limiting the number of filters to" " %i due to low sample rate.\n",s->K); // Generate filter taps for(k=0;k<s->K;k++) bp2(s->a[k],s->b[k],F[k]/((float)af->data->rate),Q); // Calculate how much this plugin adds to the overall time delay af->delay = 2.0 / (double)af->data->rate; // Calculate gain factor to prevent clipping at output for(k=0;k<AF_NCH;k++) { for(i=0;i<KM;i++) { if(s->gain_factor < s->g[k][i]) s->gain_factor=s->g[k][i]; } } s->gain_factor=log10(s->gain_factor + 1.0) * 20.0; if(s->gain_factor > 0.0) { s->gain_factor=0.1+(s->gain_factor/12.0); }else{ s->gain_factor=1; } return af_test_output(af,arg); } } return AF_UNKNOWN; }
void lower (int * p, int * a, int * b, int * c, int * d, int len) { int value; value = *(p - len); value = *(a - len); value = *(b - len); value = *(c - len); bp2 (value); value = *(d - len); }
void TaudioFilterEQ::Tequalizer::init(const TeqSettings *cfg, double freq) { reset(); static const double qmult = 1; for (int i = 0; i < AF_NCH; i++) for (int j = 0; j < KM; j++) { float db = (cfg->highdb - cfg->lowdb) * (&cfg->eq0)[j] / 200.0f + cfg->lowdb; g[i][j] = (float)(qmult * (db2value(db, 100)/* pow(10.0,db/(100*20.0))*/ - 1.0)); } K = KM; while (((&cfg->f0)[K - 1] / 100.0) > freq / 2.3) { K--; } for (int k = 0; k < K; k++) { bp2(a[k], b[k], ((&cfg->f0)[k] / 100.0) / freq, Q); } }
// Initialization and runtime control static int control(struct af_instance* af, int cmd, void* arg) { af_equalizer_t* s = (af_equalizer_t*)af->setup; switch(cmd){ case AF_CONTROL_REINIT:{ int k =0, i =0; float F[KM] = CF; s->gain_factor=0.0; // Sanity check if(!arg) return AF_ERROR; af->data->rate = ((struct mp_audio*)arg)->rate; af->data->nch = ((struct mp_audio*)arg)->nch; af->data->format = AF_FORMAT_FLOAT_NE; af->data->bps = 4; // Calculate number of active filters s->K=KM; while(F[s->K-1] > (float)af->data->rate/2.2) s->K--; if(s->K != KM) mp_msg(MSGT_AFILTER, MSGL_INFO, "[equalizer] Limiting the number of filters to" " %i due to low sample rate.\n",s->K); // Generate filter taps for(k=0;k<s->K;k++) bp2(s->a[k],s->b[k],F[k]/((float)af->data->rate),Q); // Calculate how much this plugin adds to the overall time delay af->delay = 2 * af->data->nch * af->data->bps; // Calculate gain factor to prevent clipping at output for(k=0;k<AF_NCH;k++) { for(i=0;i<KM;i++) { if(s->gain_factor < s->g[k][i]) s->gain_factor=s->g[k][i]; } } s->gain_factor=log10(s->gain_factor + 1.0) * 20.0; if(s->gain_factor > 0.0) { s->gain_factor=0.1+(s->gain_factor/12.0); }else{ s->gain_factor=1; } return af_test_output(af,arg); } case AF_CONTROL_COMMAND_LINE:{ float g[10]={0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0,0.0}; int i,j; sscanf((char*)arg,"%f:%f:%f:%f:%f:%f:%f:%f:%f:%f", &g[0], &g[1], &g[2], &g[3], &g[4], &g[5], &g[6], &g[7], &g[8] ,&g[9]); for(i=0;i<AF_NCH;i++){ for(j=0;j<KM;j++){ ((af_equalizer_t*)af->setup)->g[i][j] = pow(10.0,clamp(g[j],G_MIN,G_MAX)/20.0)-1.0; } } return AF_OK; } case AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_SET:{ float* gain = ((af_control_ext_t*)arg)->arg; int ch = ((af_control_ext_t*)arg)->ch; int k; if(ch >= AF_NCH || ch < 0) return AF_ERROR; for(k = 0 ; k<KM ; k++) s->g[ch][k] = pow(10.0,clamp(gain[k],G_MIN,G_MAX)/20.0)-1.0; return AF_OK; } case AF_CONTROL_EQUALIZER_GAIN | AF_CONTROL_GET:{ float* gain = ((af_control_ext_t*)arg)->arg; int ch = ((af_control_ext_t*)arg)->ch; int k; if(ch >= AF_NCH || ch < 0) return AF_ERROR; for(k = 0 ; k<KM ; k++) gain[k] = log10(s->g[ch][k]+1.0) * 20.0; return AF_OK; } } return AF_UNKNOWN; }