int set_points_in_curve_ext( GtkWidget *curve, unsigned char *blob, int id, int fx_entry, int *lo, int *hi, int *curve_type) { int parameter_id = 0; int start = 0, end =0,type=0; int entry = 0; int n = sscanf( (char*) blob, "key%2d%2d%8d%8d%2d", &entry, ¶meter_id, &start, &end,&type ); int len = end - start; int i; int min = 0, max = 0; #ifdef STRICT_CHECKING assert( fx_entry == entry ); #endif if(n != 5 || len <= 0 ) { veejay_msg(0, "Error parsing FX Anim KF header"); return -1; } _effect_get_minmax(id, &min, &max, parameter_id ); unsigned int k = 0; unsigned char *in = blob + 25; float *vec = (float*) vj_calloc(sizeof(float) * len ); for(i = start ; i < end; i ++ ) { unsigned char *ptr = in + (k * 4); int value = ( ptr[0] | (ptr[1] << 8) | (ptr[2] << 16) | (ptr[3] << 24) ); float top = 1.0 / (float) max; float val = ( (float)value * top ); veejay_msg(4, "Load FX Anim position %d, value %f", i, val ); vec[k] = val; k++; } gtk_curve_set_vector( GTK_CURVE( curve ), len, vec ); switch( type ) { case 1: *curve_type = GTK_CURVE_TYPE_SPLINE; break; case 2: *curve_type = GTK_CURVE_TYPE_FREE; break; default: *curve_type = GTK_CURVE_TYPE_LINEAR; break; } gtk_curve_set_curve_type( GTK_CURVE(curve), *curve_type ); *lo = start; *hi = end; free(vec); return parameter_id; }
value ml_gtk_curve_set_vector (value curve, value points) { guint len = Wosize_val(points) / Double_wosize; gfloat* vect = g_malloc(len * sizeof(gfloat)); int i; for (i = 0; i < len; i++) vect[i] = Double_field(points,i); gtk_curve_set_vector(GtkCurve_val(curve), len, vect); g_free(vect); return Val_unit; }
void upload(void) { #define SCALING 1 gfloat g; gfloat sample[256]; for(int i=0;i<256/SCALING;i++) { sample[i]=scaler[i*SCALING]; } gtk_curve_set_vector(GTK_CURVE(WID(curve1)),256/SCALING,sample); //gtk_curve_set_curve_type(GTK_CURVE(WID(curve1)),GTK_CURVE_TYPE_LINEAR); }
/* Sets the vector of points on the curve. The curve type is set to GTK_CURVE_TYPE_FREE. */ int clip_GTK_CURVESETVECTOR(ClipMachine * cm) { C_widget *ccur = _fetch_cw_arg(cm); int veclen = _clip_parni(cm,2); ClipVar *cvvec = _clip_spar(cm,3); gfloat* vector = calloc(veclen,sizeof(gfloat)); long i; CHECKCWID(ccur,GTK_CURVE); CHECKARG(2,NUMERIC_t); CHECKARG(3,ARRAY_t); for (i = 0; i < veclen; i++) { if (cvvec->a.items[i].t.type == NUMERIC_t) vector[i] = cvvec->a.items[i].n.d; } gtk_curve_set_vector(GTK_CURVE(ccur->widget),veclen,vector); return 0; err: return 1; }
void get_resource_cpu_info(void) { //user, nice, system, idle FILE *fp; //float cpu_rate; long cal[7]; //char *tmp; char buffer[80]; //设置成数组定时器不能用 char label_status_cpu[4]; char label_status_cpu_final[10]; int tmp2; //* int i = 499, j = 0; //int i= 49, j = 0; fp = fopen("/proc/stat", "r"); // i , j; //fp = fopen("/proc/stat", "r"); fgets(buffer, 80, fp); strtok(buffer, " "); // tmp = strtok (NULL, " "); while (cal[j] = atoi(strtok(NULL, " "))) { //printf("%d\n", cal[j]); j++; } //cpu_rate = (cal[3]-idle_time)/(cal[0]+cal[1]+cal[2]+cal[3]+cal[4]+cal[5]+cal[6] - cpu_time); while (i > 0) { resource_info.vector[i] = resource_info.vector[i - 1]; i--; } resource_info.vector[0] = 1 - 0.1 * (cal[3] - resource_info.idle_time) / (cal[0] + cal[1] + cal[2] + cal[3] + - resource_info. cpu_time) * 10; //printf("%f\n", resource_info.vector[0]); gtk_curve_set_vector(resource_info.cpu_resource_curve, 500, resource_info.vector); tmp2 = (int)(resource_info.vector[0] * 100); if ((resource_info.vector[0] * 100 - tmp2) >= 0.5) tmp2 += 1; label_status_cpu[0] = tmp2 / 100 + '0'; tmp2 = tmp2 - tmp2 / 100 * 100; label_status_cpu[0] = tmp2 / 10 + '0'; tmp2 = tmp2 - tmp2 / 10 * 10; label_status_cpu[1] = tmp2 + '0'; label_status_cpu[2] = '\0'; //printf("%s\n", label_status_cpu); strcpy(label_status_cpu_final, "CPU:"); strcat(label_status_cpu_final, label_status_cpu); strcat(label_status_cpu_final, "%"); gtk_label_set_text(status_bar.cpu, label_status_cpu_final); resource_info.idle_time = cal[3]; resource_info.cpu_time =cal[0] + cal[1] + cal[2] + cal[3] ; // cal[0] + cal[1] + cal[2] + cal[3] + cal[4] + cal[5] + cal[6]; fclose(fp); //*/ }