/* type: * 2 - function parameters changed * 1 - just modifiers changed * 0 - all intact, redrawing previous */ void draw(int type, int color) { int i; MTYPE x; if(type==2) { f_h = f_max(&toPlot, lb, rb) - f_min(&toPlot, lb, rb); ymin = f_min(&toPlot, lb, rb); ymax = f_max(&toPlot, lb, rb); } if(type>=1) { pixels_in_cell = MIN( height/f_h, width/(rb-lb) ); pixels_in_cell *= shift_pix; } if( color==0 ) XSetForeground(dpy, cont, white); /* drawing spline */ if(color!=0) XSetForeground(dpy, cont, red.pixel); for(x=lb; x<rb; x+=0.05) XDrawLine(dpy, win, cont, (x-lb)*pixels_in_cell + shift_x, F(x,1), (x+0.05-lb)*pixels_in_cell + shift_x, F(x+0.05,1)); sprintf(buffer, "spline function"); XDrawString(dpy, win, cont, 20, 40, buffer, strlen(buffer)); /* original function */ if(color!=0) XSetForeground(dpy, cont, green.pixel); for(x=lb; x<rb; x+=0.05) XDrawLine(dpy, win, cont, (x-lb)*pixels_in_cell + shift_x, F(x,0), (x+0.05-lb)*pixels_in_cell + shift_x, F(x+0.05,0)); sprintf(buffer, "initial function"); XDrawString(dpy, win, cont, 20, 20, buffer, strlen(buffer)); /* points of intersection */ if(color!=0) XSetForeground(dpy, cont, blue.pixel); for(i=0; i<=k; i++) XFillArc(dpy, win, cont, (xx[i]-lb)*pixels_in_cell + shift_x - CDIAM/2, (ymax - fx[i])*pixels_in_cell + shift_y + height/2 - CDIAM/2, CDIAM, CDIAM, 0, 360*64); XFlush(dpy); }
/* Compute the global maximum of all velocities / accelerations. */ double compute_norm (const fish_t* fish, const int n_fish) { int i; double max_norm = 0.0; for (i = 0; i < n_fish; ++i) { max_norm = f_max (max_norm, fabs(fish[i].vx)); max_norm = f_max (max_norm, fabs(fish[i].vy)); max_norm = f_max (max_norm, fabs(fish[i].ax)); max_norm = f_max (max_norm, fabs(fish[i].ay)); } return max_norm; }
void durations(SPN *ps, ACOUSTIC *as) { int durdist; int interdist; float multiplier_i; float proportion; int i; int j; for(i=0;i<ps->p_sz;i++) ps->scale[i] = (float)ps->duration[i] / (float)((ps->pb[i+1]-ps->pb[i])*FR_SZ); ps->cum_dur[0] = 0; /* do cumulative at same time */ for(i=0,j=0;i<as->f_sz;i++) { if(i == ps->pb[j]) { if(j != 0) { ps->cum_dur[j] = ps->duration[j-1] + ps->cum_dur[j-1]; } as->duration[i] = FR_SZ; ps->duration[j] = FR_SZ; /* saves adding later */ j++; } else { durdist = min(i-ps->pb[j-1],ps->pb[j]-i); interdist = ps->pb[j] - ps->pb[j-1]; proportion = (float)durdist/(float)interdist; multiplier_i = f_max(0.01,4.0*proportion*(ps->scale[j-1]-1.0)+1.0); as->duration[i] = FR_SZ*multiplier_i; ps->duration[j-1] += as->duration[i]; } } }
static void runAddingFadDelay(LADSPA_Handle instance, unsigned long sample_count) { FadDelay *plugin_data = (FadDelay *)instance; LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* Delay (seconds) (float value) */ const LADSPA_Data delay = *(plugin_data->delay); /* Feedback (dB) (float value) */ const LADSPA_Data fb_db = *(plugin_data->fb_db); /* Input (array of floats of length sample_count) */ const LADSPA_Data * const input = plugin_data->input; /* Output (array of floats of length sample_count) */ LADSPA_Data * const output = plugin_data->output; LADSPA_Data * buffer = plugin_data->buffer; unsigned long buffer_mask = plugin_data->buffer_mask; unsigned long buffer_size = plugin_data->buffer_size; LADSPA_Data last_in = plugin_data->last_in; int last_phase = plugin_data->last_phase; float phase = plugin_data->phase; long sample_rate = plugin_data->sample_rate; #line 51 "fad_delay_1192.xml" long int pos; float increment = (float)buffer_size / ((float)sample_rate * f_max(fabs(delay), 0.01)); float lin_int, lin_inc; int track; int fph; LADSPA_Data out; const float fb = DB_CO(fb_db); for (pos = 0; pos < sample_count; pos++) { fph = f_round(floor(phase)); last_phase = fph; lin_int = phase - (float)fph; out = LIN_INTERP(lin_int, buffer[(fph+1) & buffer_mask], buffer[(fph+2) & buffer_mask]); phase += increment; lin_inc = 1.0f / (floor(phase) - last_phase + 1); lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc; lin_int = 0.0f; for (track = last_phase; track < phase; track++) { lin_int += lin_inc; buffer[track % buffer_size] = out * fb + LIN_INTERP(lin_int, last_in, input[pos]); } last_in = input[pos]; buffer_write(output[pos], out); if (phase >= buffer_size) { phase -= buffer_size; } } // Store current phase in instance plugin_data->phase = phase; plugin_data->last_phase = last_phase; plugin_data->last_in = last_in; }
static void runFadDelay(LV2_Handle instance, uint32_t sample_count) { FadDelay *plugin_data = (FadDelay *)instance; const float delay = *(plugin_data->delay); const float fb_db = *(plugin_data->fb_db); const float * const input = plugin_data->input; float * const output = plugin_data->output; float * buffer = plugin_data->buffer; float phase = plugin_data->phase; int last_phase = plugin_data->last_phase; float last_in = plugin_data->last_in; unsigned long buffer_size = plugin_data->buffer_size; unsigned long buffer_mask = plugin_data->buffer_mask; long sample_rate = plugin_data->sample_rate; long int pos; float increment = (float)buffer_size / ((float)sample_rate * f_max(fabs(delay), 0.01)); float lin_int, lin_inc; int track; int fph; float out; const float fb = DB_CO(fb_db); for (pos = 0; pos < sample_count; pos++) { fph = f_round(floor(phase)); last_phase = fph; lin_int = phase - (float)fph; out = LIN_INTERP(lin_int, buffer[(fph+1) & buffer_mask], buffer[(fph+2) & buffer_mask]); phase += increment; lin_inc = 1.0f / (floor(phase) - last_phase + 1); lin_inc = lin_inc > 1.0f ? 1.0f : lin_inc; lin_int = 0.0f; for (track = last_phase; track < phase; track++) { lin_int += lin_inc; buffer[track % buffer_size] = out * fb + LIN_INTERP(lin_int, last_in, input[pos]); } last_in = input[pos]; buffer_write(output[pos], out); if (phase >= buffer_size) { phase -= buffer_size; } } // Store current phase in instance plugin_data->phase = phase; plugin_data->last_phase = last_phase; plugin_data->last_in = last_in; }
bool TestExtMath::test_max() { VS(f_max(4, 2, CREATE_VECTOR4(3, 1, 6, 7)), 7); VS(f_max(0, CREATE_VECTOR3(2, 4, 5)), 5); VS(f_max(1, 0, CREATE_VECTOR1("hello")), 0); VS(f_max(1, "hello", CREATE_VECTOR1(0)), "hello"); VS(f_max(1, "hello", CREATE_VECTOR1(-1)), "hello"); VS(f_max(1, CREATE_VECTOR3(2, 4, 8), CREATE_VECTOR1(CREATE_VECTOR3(2, 5, 1))), CREATE_VECTOR3(2, 5, 1)); VS(f_max(1, "string", CREATE_VECTOR2(CREATE_VECTOR3(2, 5, 7), 42)), CREATE_VECTOR3(2, 5, 7)); VS(f_max(1, CREATE_MAP1(1, "1236150163")), "1236150163"); return Count(true); }
/**************************************************************************** Desc: Searches for an available DRN in the dictionary container. Differs from FlmReserveNextDrn in that it will attempt to reuse dictionary DRNS. ****************************************************************************/ FLMEXP RCODE FLMAPI FlmFindUnusedDictDrn( HFDB hDb, FLMUINT uiStartDrn, FLMUINT uiEndDrn, FLMUINT * puiDrnRV) { RCODE rc; FDB * pDb = (FDB *)hDb; FLMBOOL bIgnore = FALSE; FDICT * pDict; FLMUINT uiCurrDrn; FLMUINT uiStopSearch; if( RC_BAD( rc = fdbInit( pDb, FLM_UPDATE_TRANS, FDB_TRANS_GOING_OK, 0, &bIgnore))) { *puiDrnRV = (FLMUINT)-1; goto Exit; } // Search through the ITT table looking for the first occurance // of ITT_EMPTY_SLOT pDict = pDb->pDict; uiCurrDrn = f_max( uiStartDrn, 1); uiStopSearch = f_min( uiEndDrn, pDict->uiIttCnt - 1); while (uiCurrDrn <= uiStopSearch) { if (pDict->pIttTbl[ uiCurrDrn].uiType == ITT_EMPTY_SLOT) { break; } else { uiCurrDrn++; } } if (uiCurrDrn > uiEndDrn) { rc = RC_SET( FERR_NO_MORE_DRNS); goto Exit; } *puiDrnRV = uiCurrDrn; Exit: fdbExit( pDb); return( rc); }
void Compressor::process(int frames, float* ip, float *op) { const float ga = _attack < 2.0f ? 0.0f : as[f_round(_attack * 0.001f * (float)(A_TBL-1))]; const float gr = as[f_round(_release * 0.001f * (float)(A_TBL-1))]; const float rs = (_ratio - 1.0f) / _ratio; const float mug = db2lin(_makeupGain); const float knee_min = db2lin(_threshold - _knee); const float knee_max = db2lin(_threshold + _knee); const float ef_a = ga * 0.25f; const float ef_ai = 1.0f - ef_a; for (int pos = 0; pos < frames; pos++) { const float la = fabs(ip[pos * 2]); const float ra = fabs(ip[pos * 2 + 1]); const float lev_in = f_max(la, ra); sum += lev_in * lev_in; if (amp > env_rms) env_rms = env_rms * ga + amp * (1.0f - ga); else env_rms = env_rms * gr + amp * (1.0f - gr); round_to_zero(&env_rms); if (lev_in > env_peak) env_peak = env_peak * ga + lev_in * (1.0f - ga); else env_peak = env_peak * gr + lev_in * (1.0f - gr); round_to_zero(&env_peak); if ((count++ & 3) == 3) { amp = rms.process(sum * 0.25f); sum = 0.0f; if (qIsNaN(env_rms)) // This can happen sometimes, but I don't know why env_rms = 0.0f; env = LIN_INTERP(rms_peak, env_rms, env_peak); if (env <= knee_min) gain_t = 1.0f; else if (env < knee_max) { const float x = -(_threshold - _knee - lin2db(env)) / _knee; gain_t = db2lin(-_knee * rs * x * x * 0.25f); } else gain_t = db2lin((_threshold - lin2db(env)) * rs); } gain = gain * ef_a + gain_t * ef_ai; op[pos * 2] = ip[pos * 2] * gain * mug; op[pos * 2+1] = ip[pos * 2 + 1] * gain * mug; } // printf("gain %f\n", gain); // amplitude = lin2db(env); // gain_red = lin2db(gain); }
int main (){ int a, b, z; printf("Input a : "); scanf("%d", &a); printf("Input b : "); scanf("%d", &b); z = f_max(a, b); printf("Max is : %d ", z); getch(); }
//Fonction min trouve le minimum des noeuds fils int f_min(Pion *etat, int profondeur, int joueur, int *la, int *ca, int *lb, int *cb) { int minimumVal = INFINI; if (profondeur == 0 || f_gagnant() != 0) { if (f_test_mouvement(etat, *la, *ca, *lb, *cb, joueur) == 0) { return f_eval(etat, joueur); } else { return -minimumVal; } } for (int i = 0; i < NB_LIGNES; i++){ for (int j = 0; j < NB_COLONNES; j++){ for (int a = -1; a <= 1; a++){ for (int b = -1; b <= 1; b++){ Pion *nouveauJeu = f_raz_plateau(); f_copie_plateau(etat, nouveauJeu); if (f_test_mouvement(nouveauJeu, i, j, i + a, j + b, joueur) == 0) { f_bouge_piece(nouveauJeu, i, j, i + a, j + b, joueur); int max = f_max(nouveauJeu, profondeur - 1, joueur, la, ca, lb, cb); if (max < minimumVal){ minimumVal = max; *la = i; *ca = j; *lb = i + a; *cb = j + b; } } free(nouveauJeu); } } } } return minimumVal; }
/** * Calcule et joue le meilleur cout * */ void f_IA(int joueur) { #ifdef DEBUG printf("dbg: entering %s %d\n", __FUNCTION__, __LINE__); #endif /** A remplir **/ int la = 0, ca = 0, lb = 0, cb = 0; int ret = f_max(plateauDeJeu, PROFONDEUR_MAX, joueur, &la, &ca, &lb, &cb); printf("Mouvement du joueur %d : %c%d-%c%d\nValeur : %d\n", joueur, f_convert_int2char(ca), la, f_convert_int2char(cb), lb, ret); f_bouge_piece(plateauDeJeu, la, ca, lb, cb, joueur); #ifdef DEBUG printf("dbg: exiting %s %d\n", __FUNCTION__, __LINE__); #endif }
int main(int argc, char **argv) { double sum_total_timer, total_timer = 0.0; double sum_gather_timer, gather_timer = 0.0; double sum_mpi_timer, mpi_timer = 0.0; double curr_time; double output_time; double dt = 0.0; double local_max_norm = 0.1; double max_norm = 0; int steps; int* fish_off; int* n_fish_split; MPI_Init (&argc, &argv); #ifdef TRACE_WITH_VAMPIR VT_symdef(TRACE_LOCAL_COMP, "Local computation", "Computation"); VT_symdef(TRACE_FISH_GATHER, "Gathering to 0", "Communication"); VT_symdef(TRACE_MAX_NORM, "Collecting max norm", "Communication"); VT_symdef(TRACE_OUTPUT, "Output", "Output"); #endif MPI_Comm_size (comm, &n_proc); MPI_Comm_rank (comm, &rank); make_fishtype (&fishtype); get_options(argc, argv); srand48(clock()); //MPI_Allreduce (&local_max_norm, &max_norm, 1, MPI_DOUBLE, MPI_MAX, comm); //printf("local_max_norm = %g, max_norm = %g\n", local_max_norm, max_norm); #ifdef TRACE_WITH_VAMPIR VT_traceoff(); #endif if (output_filename) { outputp = 1; if (0 == rank) { output_fp = fopen(output_filename, "w"); if (output_fp == NULL) { printf("Could not open %s for output\n", output_filename); exit(1); } fprintf(output_fp, "n_fish: %d\n", n_fish); } } fish_off = malloc ( (n_proc+1) * sizeof(int) ); n_fish_split = malloc ( (n_proc) * sizeof(int) ); //split each fish to different processors. //fish_off: offset index of the fish in that processor //n_fish_split is the # of fish in each processor //ALL FUNCTIONALITY OF split_fish SHOULD BE DONE AFTER init_fish //split_fish (n_proc, fish_off, n_fish_split); //n_local_fish = n_fish_split[rank]; /* All fish are generated on proc 0 to ensure same random numbers. (Yes, the circle case could be parallelized. Feel free to do it.) */ //split physical box sizes row = (int)sqrt((double)n_proc); column = n_proc/row; double rowSep = WALL_SEP/row; double columnSep = WALL_SEP/column; int rowIndex = rank / column; int columnIndex = rank % column; topBound = rowSep * rowIndex; bottomBound = topBound + rowSep; leftBound = columnSep * columnIndex; rightBound = leftBound + columnSep; assert(n_proc % row == 0); // Add n_proc # of arrays each holding ID of local fishes fish_t fishProc[n_proc][n_fish]; int n_fish_proc[n_proc]; int k; for (k = 0; k < n_proc; k++) n_fish_proc[k] = 0; ////////////////////////////////// init_fish (rank, fish_off, n_fish_split, row, column, fishProc, n_fish_proc); // distribute initial conditions to all processes if (rank == 0) { local_fish = fishProc[0]; n_local_fish = n_fish_proc[0]; // Functionality of MPI_Scatterv is done here with Isends //MPI_Request request[n_proc-1]; int mesTag = 0; MPI_Request *req; for (k = 1; k < n_proc; ++k) { //printf("n_fish_proc[%d], %d\n", k, n_fish_proc[k]); MPI_Isend(fishProc[k], n_fish_proc[k], fishtype, k, mesTag, comm, req); } } else { MPI_Status status; // Processors of rank != 0 receives. MPI_Recv( local_fish, n_fish, fishtype, 0, MPI_ANY_TAG, comm, &status); MPI_Get_count(&status, fishtype, &n_local_fish); } printf("rank[%d], n_local_fish = %d\n", rank, n_local_fish); ///* //MPI_Scatterv (fish, n_fish_split, fish_off, fishtype, // local_fish, n_local_fish, fishtype, // 0, comm); //*/ #ifdef TRACE_WITH_VAMPIR tracingp = 1; VT_traceon(); #endif start_mpi_timer(&total_timer); for (output_time = 0.0, curr_time = 0.0, steps = 0; curr_time <= end_time && steps < max_steps; curr_time += dt, ++steps) { #ifdef TRACE_WITH_VAMPIR if (steps >= STEPS_TO_TRACE) { tracingp = 0; VT_traceoff(); } #endif trace_begin(TRACE_FISH_GATHER); start_mpi_timer (&gather_timer); start_mpi_timer (&mpi_timer); /* Pull in all the fish. Obviously, this is not a good idea. You will be greatly expanding this one line... However, feel free to waste memory when producing output. If you're dumping fish to a file, go ahead and do an Allgatherv _in the output steps_ if you want. Or you could pipeline dumping the fish. MPI_Allgatherv (local_fish, n_local_fish, fishtype, fish, n_fish_split, fish_off, fishtype, comm); */ //MPI_Request* sendReq, recvReq; // Set aside buffer for fish received from other processes. /* for (j = 0; j < NUM_NEIGHBOR; ++j) { //FIXME: which neighbors does not exist? if (rankNeighbor[j] >= 0) { MPI_Isend(local_fish, n_local_fish, fishtype, rankNeighbor[j], MPI_ANY_TAG, comm, &sendReqArray); MPI_Irecv(impact_fish, n_fish, fishtype, rankNeighbor[NUM_NEIGHBOR - j], MPI_ANY_TAG, comm, &sendReqArray); MPI_Wait(recvReq, MPI_STATUS_IGNORE); interact_fish_mpi(local_fish, n_local_fish, impact_fish, sizeof(impact_fish)); } } */ // get migrate fish // send migrate fish // receive migrate fish // update local fish // get impact fish // send impact fish // receive impact fish // interact impact fish // interact local fish // move MPI_Request sendReqArray[NUM_NEIGHBOR]; MPI_Request recvReqArray[NUM_NEIGHBOR]; fish_t receive_impact_fish[NUM_NEIGHBOR][n_fish]; int n_receive_impact_fish[NUM_NEIGHBOR]; fish_t receive_migrate_fish[NUM_NEIGHBOR][n_fish]; int n_receive_migrate_fish[NUM_NEIGHBOR]; int n_send_impact_fish[NUM_NEIGHBOR]; fish_t* send_impact_fish[NUM_NEIGHBOR]; int n_send_migrate_fish[NUM_NEIGHBOR]; fish_t* send_migrate_fish[NUM_NEIGHBOR]; get_interacting_fish( local_fish, n_local_fish, send_migrate_fish, n_send_migrate_fish, 1); int tmp; for (tmp = 0; tmp < NUM_NEIGHBOR; tmp++) { printf("rank[%d], iter[%d] ------- get [%d] migrate fish for neig[%d]. \n", rank, iter, n_send_migrate_fish[tmp], tmp); } Isend_receive_fish(send_migrate_fish, n_send_migrate_fish, receive_migrate_fish, n_fish, sendReqArray, recvReqArray); wait_for_fish(recvReqArray, n_receive_migrate_fish); // FIXME: Have not implement update on local fish. //update_local_fish(); get_interacting_fish(local_fish, n_local_fish, send_impact_fish, n_send_impact_fish, 0); for (tmp = 0; tmp < NUM_NEIGHBOR; tmp++) { printf("rank[%d], iter[%d] ------- get [%d] impact fish for neig[%d]. \n", rank, iter, n_send_impact_fish[tmp], tmp); } Isend_receive_fish(send_impact_fish, n_send_impact_fish, receive_impact_fish, n_fish, sendReqArray, recvReqArray); wait_for_fish(recvReqArray, n_receive_impact_fish); int index; for (index = 0; index < NUM_NEIGHBOR; index++) { if (n_receive_impact_fish[index] > 0) { interact_fish_mpi(local_fish, n_local_fish, receive_impact_fish[index], n_receive_impact_fish[index]); } } //*/ // make sure we are sending and receiving the same # msg. //assert(dbg == 0); // While waiting, interact with fish in its own pocket first printf("rank[%d], iter[%d] ------- interact [%d] local fishes\n", rank, iter, n_local_fish); interact_fish_mpi(local_fish, n_local_fish, local_fish, n_local_fish); printf("rank[%d], iter[%d] ------- finished interact local fish\n", rank, iter); stop_mpi_timer (&gather_timer); stop_mpi_timer (&mpi_timer); trace_end(TRACE_FISH_GATHER); /* We only output once every output_interval time unit, at most. Without that restriction, we can easily create a huge output file. Printing a record for ten fish takes about 300 bytes, so for every 1000 steps, we could dump 300K of info. Now scale the number of fish by 1000... */ trace_begin(TRACE_OUTPUT); if (outputp && curr_time >= output_time) { if (0 == rank) output_fish (output_fp, curr_time, dt, fish, n_fish); output_time = curr_time + output_interval; } trace_end(TRACE_OUTPUT); trace_begin (TRACE_LOCAL_COMP); //interact_fish (local_fish, n_local_fish, fish, n_fish); local_max_norm = compute_norm (local_fish, n_local_fish); trace_end (TRACE_LOCAL_COMP); trace_begin (TRACE_MAX_NORM); start_mpi_timer (&mpi_timer); printf("rank[%d], iter[%d] ------- Allreduce max_norm, \n", rank, iter); MPI_Allreduce (&local_max_norm, &max_norm, 1, MPI_DOUBLE, MPI_MAX, comm); printf("rank[%d], iter[%d] ------- local_max_norm: %g, max_norm: %g\n", local_max_norm, max_norm); stop_mpi_timer (&mpi_timer); trace_end (TRACE_MAX_NORM); trace_begin (TRACE_LOCAL_COMP); dt = max_norm_change / max_norm; dt = f_max(dt, min_dt); dt = f_min(dt, max_dt); printf("rank[%d], iter[%d] ------- moving [%d] local_fish, \n", rank, iter, n_local_fish); move_fish(local_fish, n_local_fish, dt); printf("rank[%d], iter[%d] ------- finished moving.\n", rank, iter); trace_end (TRACE_LOCAL_COMP); iter++; } stop_mpi_timer(&total_timer); #ifdef TRACE_WITH_VAMPIR VT_traceoff(); #endif if (outputp) { MPI_Allgatherv (local_fish, n_local_fish, fishtype, fish, n_fish_split, fish_off, fishtype, comm); if (0 == rank) { output_fish (output_fp, curr_time, dt, fish, n_fish); printf("\tEnded at %g (%g), %d (%d) steps\n", curr_time, end_time, steps, max_steps); } } printf("rank[%d], ------- 39, \n", rank); MPI_Reduce (&total_timer, &sum_total_timer, 1, MPI_DOUBLE, MPI_SUM, 0, comm); printf("rank[%d], ------- 40, \n", rank); MPI_Reduce (&gather_timer, &sum_gather_timer, 1, MPI_DOUBLE, MPI_SUM, 0, comm); printf("rank[%d], ------- 41, \n", rank); MPI_Reduce (&mpi_timer, &sum_mpi_timer, 1, MPI_DOUBLE, MPI_SUM, 0, comm); printf("rank[%d], ------- 42, \n", rank); if (0 == rank) { printf("Number of PEs: %d\n" "Time taken on 0: %g (avg. %g)\n" "Time in gathers on 0: %g (avg %g)\n" "Time in MPI on 0: %g (avg %g)\n", n_proc, total_timer, sum_total_timer / n_proc, gather_timer, sum_gather_timer / n_proc, mpi_timer, sum_mpi_timer / n_proc); } printf("rank[%d], ------- 43, \n", rank); MPI_Barrier (comm); printf("rank[%d], ------- 44, \n", rank); MPI_Finalize (); printf("rank[%d], ------- done!!, \n", rank); return 0; }
MTYPE f_height(function _f, MTYPE minx, MTYPE maxx) { return f_max(_f, minx, maxx) - f_min(_f, minx, maxx); }
static void runAddingSc4(LADSPA_Handle instance, unsigned long sample_count) { Sc4 *plugin_data = (Sc4 *)instance; LADSPA_Data run_adding_gain = plugin_data->run_adding_gain; /* RMS/peak (float value) */ const LADSPA_Data rms_peak = *(plugin_data->rms_peak); /* Attack time (ms) (float value) */ const LADSPA_Data attack = *(plugin_data->attack); /* Release time (ms) (float value) */ const LADSPA_Data release = *(plugin_data->release); /* Threshold level (dB) (float value) */ const LADSPA_Data threshold = *(plugin_data->threshold); /* Ratio (1:n) (float value) */ const LADSPA_Data ratio = *(plugin_data->ratio); /* Knee radius (dB) (float value) */ const LADSPA_Data knee = *(plugin_data->knee); /* Makeup gain (dB) (float value) */ const LADSPA_Data makeup_gain = *(plugin_data->makeup_gain); /* Left input (array of floats of length sample_count) */ const LADSPA_Data * const left_in = plugin_data->left_in; /* Right input (array of floats of length sample_count) */ const LADSPA_Data * const right_in = plugin_data->right_in; /* Left output (array of floats of length sample_count) */ LADSPA_Data * const left_out = plugin_data->left_out; /* Right output (array of floats of length sample_count) */ LADSPA_Data * const right_out = plugin_data->right_out; float amp = plugin_data->amp; float * as = plugin_data->as; unsigned int count = plugin_data->count; float env = plugin_data->env; float env_peak = plugin_data->env_peak; float env_rms = plugin_data->env_rms; float gain = plugin_data->gain; float gain_t = plugin_data->gain_t; rms_env * rms = plugin_data->rms; float sum = plugin_data->sum; #line 51 "sc4_1434.xml" unsigned long pos; const float ga = attack < 2.0f ? 0.0f : as[f_round(attack * 0.001f * (float)(A_TBL-1))]; const float gr = as[f_round(release * 0.001f * (float)(A_TBL-1))]; const float rs = (ratio - 1.0f) / ratio; const float mug = db2lin(makeup_gain); const float knee_min = db2lin(threshold - knee); const float knee_max = db2lin(threshold + knee); const float ef_a = ga * 0.25f; const float ef_ai = 1.0f - ef_a; for (pos = 0; pos < sample_count; pos++) { const float la = fabs(left_in[pos]); const float ra = fabs(right_in[pos]); const float lev_in = f_max(la, ra); sum += lev_in * lev_in; if (amp > env_rms) { env_rms = env_rms * ga + amp * (1.0f - ga); } else { env_rms = env_rms * gr + amp * (1.0f - gr); } if (lev_in > env_peak) { env_peak = env_peak * ga + lev_in * (1.0f - ga); } else { env_peak = env_peak * gr + lev_in * (1.0f - gr); } if ((count++ & 3) == 3) { amp = rms_env_process(rms, sum * 0.25f); sum = 0.0f; if (isnan(env_rms)) { // This can happen sometimes, but I don't know why env_rms = 0.0f; } env = LIN_INTERP(rms_peak, env_rms, env_peak); if (env <= knee_min) { gain_t = 1.0f; } else if (env < knee_max) { const float x = -(threshold - knee - lin2db(env)) / knee; gain_t = db2lin(-knee * rs * x * x * 0.25f); } else { gain_t = db2lin((threshold - lin2db(env)) * rs); } } gain = gain * ef_a + gain_t * ef_ai; buffer_write(left_out[pos], left_in[pos] * gain * mug); buffer_write(right_out[pos], right_in[pos] * gain * mug); } plugin_data->sum = sum; plugin_data->amp = amp; plugin_data->gain = gain; plugin_data->gain_t = gain_t; plugin_data->env = env; plugin_data->env_rms = env_rms; plugin_data->env_peak = env_peak; plugin_data->count = count; *(plugin_data->amplitude) = lin2db(env); *(plugin_data->gain_red) = lin2db(gain); }