void setup_this(void){ noise_amp = 1.0; r_val = 4.0; g_val = 100.0; cntr = 0; noise = noise_init(1); install_obj(&noise->od); rk_moog = (t_rk_mother *)rk_mother_init(&rk_moog_func, 4,//4 filter stages plus 1 oscillator 0, 1, 1); install_obj(&rk_moog->od); rk_moog->i_sigs[0] = noise->o_sigs[0]; relay_sig = init_one_tlsig(O_TYPE, 1); c_cutoff = init_lin_ctl(0, CTL_T_LIN, 1); c_res = init_lin_ctl(1, CTL_T_LIN, 1); c_output_amp = init_lin_ctl(2, CTL_T_LIN, 1); level_lin_ctl(c_cutoff, g_val); level_lin_ctl(c_res, r_val); level_lin_ctl(c_output_amp, .707); imp = 1.0; fp1 = fopen("moog_printout", "w"); }
static void *_init(void *arg) { _t *data = (_t *)arg; void *p = noise_init(&data->noise); if (p != &data->noise) return p; noise_configure(&data->noise, &data->opts.n); data->gain = dB_to_linear(data->opts.dBgain); return arg; }
struct noise *noise_create(int ndim, unsigned int seed) { struct noise *n = malloc(sizeof(*n)); noise_init(n, ndim, seed); return n; }
void fractal_init(struct fractal *frac, int ndim, unsigned int seed, float H, float lacunarity) { noise_init(&frac->noise, ndim, seed); frac->H = H; frac->lacunarity = lacunarity; float f = 1; for(int i = 0; i < MAX_OCTAVES; i++) { frac->exponent[i] = powf(f, -H); f *= lacunarity; } }
int main(int argc, char **argv) { srand(time(0)); noise_init(time(0)); SDL_Init(SDL_INIT_VIDEO); s = SDL_SetVideoMode(WIDTH, HEIGHT, 0, SDL_SWSURFACE); init_veronoi(s); apply_veronoi(s); while (running){ handle_events(); SDL_Flip(s); } return 0; }
int main(int argc, char *argv[]) { if (noise_init() != NOISE_ERROR_NONE) { fprintf(stderr, "Noise initialization failed\n"); return 1; } /* Print the header */ printf("Algorithm MB/sec MD5 units\n"); /* Calibrate the performance measurements */ calibrate_md5(); printf("%-20s%8.2f %8.2f\n", "MD5 calibration", 1.0 / units, 1.0); /* Measure the performance of the hashing primitives */ perf_hash(NOISE_HASH_BLAKE2s); perf_hash(NOISE_HASH_BLAKE2b); perf_hash(NOISE_HASH_SHA256); perf_hash(NOISE_HASH_SHA512); /* Measure the performance of the AEAD primitives */ perf_cipher(NOISE_CIPHER_CHACHAPOLY); perf_cipher(NOISE_CIPHER_AESGCM); /* Measure the performance of the DH primitives */ printf("\n"); printf("Pubkey algorithm ops/sec MD5 units\n"); perf_dh_derive(NOISE_DH_CURVE25519); perf_dh_derive(NOISE_DH_CURVE448); perf_dh_calculate(NOISE_DH_CURVE25519); perf_dh_calculate(NOISE_DH_CURVE448); perf_dh_ephemeral_only(NOISE_DH_NEWHOPE); /* Measure the performance of the signing primitives */ perf_sign_derive(NOISE_SIGN_ED25519); perf_sign_sign(NOISE_SIGN_ED25519); perf_sign_verify(NOISE_SIGN_ED25519); /* Done */ return 0; }
/* ************************************************** */ int do_init(void) { if (das_init() || /* das */ sodas_init() || /* sodas */ spadas_init() || /* spadas */ hadas_init() || /* hadas */ rng_init() || /* rng */ timer_init() || /* timer */ bundle_init() || /* bundle */ entity_init() || /* entity */ monitor_init() || /* monitor */ measure_init() || /* mesure */ medium_init() || /* medium */ mobility_init() || /* mobility */ modulation_init() || /* modulation */ noise_init() || /* noise */ node_init() || /* node */ packet_init() || /* packet */ scheduler_init()) { /* scheduler */ return -1; } return 0; }
int render_init(void) { IF_FAILED0(!init); if(!init_opengl) { ERROR_MSG("OpenGL not initialised\n"); return 0; } log_init(); TRACE_MSG("init base render system\n"); TRACE_MSG("init noise\n"); noise_init(); glViewport(0, 0, window_width, window_height); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); glEnable(GL_DEPTH_TEST); glClearDepth(1.0f); glDepthFunc(GL_LESS); glEnable(GL_DEPTH_CLAMP); DEBUG_MSG("OpenGL version: %s\n", glGetString(GL_VERSION)); DEBUG_MSG("GLSL version: %s\n", (char*) glGetString(GL_SHADING_LANGUAGE_VERSION)); // настраиваем основную камеру TRACE_MSG("init main camera\n"); camera_init(&camera, vec3f(0.0f, 0.0f, 0.5f), vec3f(0.0f, 1.0f, 0.0f), vec3f(0.0f, 0.0f, -1.0f)); camera_set_limit(&camera, -95.0f, 95.0f, -360.0f, 360.0f); camera_set_fov(&camera, camera_fov); camera_set_move_velocity(&camera, camera_move_speed); camera_set_rotate_velocity(&camera, camera_rotate_speed); camera_set_aspect(&camera, (float) window_width / (float) window_height); camera_set_zplanes(&camera, 0.001f, 1000.0f); camera_update(&camera, 0.0); isolevel = 30.0f; isolevel_animate = 0; // устанавливаем функцию по-умолчанию parser_create(&parser); const char *default_func = "d = y;"; str_function = (char*) malloc(sizeof(char) * (strlen(default_func) + 1)); strcpy(str_function, default_func); // настраиваем и создаем скалярное поле render_set_volume_size(vec3ui(128, 128, 128), 1); render_set_grid_size(vec3ui(64, 64, 64)); render_update_volume_tex(); CHECK_GL_ERRORS(); // инициализируем шейдер if(!init_shader()) return 0; // инициализируем буферы с данными init_buffers(); // устанавливаем параметры по-умолчанию new_light_position = light_position = vec3f(1.0f, 1.0f, 1.0f); rot_axis = vec3f(0.0f, 1.0f, 0.0f); num_threads = 1; rot_angle = 0.0f; light_animate = 0; light_rot_angle = 0.0f; mat4(rotmat, 1.0f); mat4(modelmat, 1.0f); material_front_color = vec3f(0.5f, 0.5f, 0.5f); material_back_color = vec3f(0.5f, 0.0f, 0.0f); light_color = vec3f(1.0f, 1.0f, 1.0f); light_spec_color = vec3f(1.0f, 1.0f, 1.0f); input_set_wheel_limits(20, 150); init = 1; // полигонизируем ск. п. render_update_mc(); // обновляем рендер render_update(0.0f); return 1; }
int main(int argc, char *argv[]) { /* Scene */ scene mine; mine.materials = NULL; mine.spheres = NULL; mine.triangles = NULL; mine.lights = NULL; myScene = &mine; perlin noise; myNoise = &noise; noise_init(myNoise); /* Threads */ thread_info *tinfo; pthread_attr_t attr; int t; /* Allocate memory for pthread_create() arguments */ tinfo = calloc(NUMTHREADS, sizeof(thread_info)); if (tinfo == NULL) { printf("Error allocating memory for pthread_create() arguments. \n"); return -1; } if (argc < 2) { printf("specify scene file. \n"); return -1; } /* Build the scene */ if (tokenizer(argv[1], myScene) == -1) { exit(-1); } /* Let's try the 3ds loader... */ if (argc == 3) { obj_type object; Load3DS(&object, argv[2]); /* spaceship.3ds */ int index; printf("Polygons: %d \n", object.polygons_qty); myScene->triangles = (triangle *)realloc(myScene->triangles, object.polygons_qty*(sizeof(triangle))); memset(myScene->triangles,0,sizeof(triangle)); myScene->numTriangles = object.polygons_qty; for (index=0;index<object.polygons_qty;index++) { /* First Vertex */ myScene->triangles[index].v2.x = object.vertex[object.polygon[index].a].x+130; myScene->triangles[index].v2.y = object.vertex[object.polygon[index].a].y+150; myScene->triangles[index].v2.z = object.vertex[object.polygon[index].a].z+350; myScene->triangles[index].v2 = vectorScale(2,&myScene->triangles[index].v2); /* Second Vertex */ myScene->triangles[index].v1.x = object.vertex[object.polygon[index].b].x+130; myScene->triangles[index].v1.y = object.vertex[object.polygon[index].b].y+150; myScene->triangles[index].v1.z = object.vertex[object.polygon[index].b].z+350; myScene->triangles[index].v1 = vectorScale(2,&myScene->triangles[index].v1); /* Third Vertex */ myScene->triangles[index].v3.x = object.vertex[object.polygon[index].c].x+130; myScene->triangles[index].v3.y = object.vertex[object.polygon[index].c].y+150; myScene->triangles[index].v3.z = object.vertex[object.polygon[index].c].z+350; myScene->triangles[index].v3 = vectorScale(2,&myScene->triangles[index].v3); /* Default Material */ myScene->triangles[index].material = 3; } } /* Allocate memory for the image */ if (img) free(img); img = (unsigned char *)malloc(3*myScene->width*myScene->height); memset(img, 0, 3*myScene->width*myScene->height); /* Calculate section size per thread */ sectionsize = myScene->height/NUMTHREADS; if ((sectionsize % 2)!=0) printf("Warning: Height/numthreads not even - there will be errors in the image! \n"); /* Pthread options */ pthread_attr_init(&attr); pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE); /* Create the render threads */ for (t=0; t<NUMTHREADS; t++) { tinfo[t].thread_num = t; if (pthread_create(&tinfo[t].thread_id, &attr, renderThread, &tinfo[t])) { printf("Creation of thread %d failed. \n", t); exit(-1); } } if (pthread_attr_destroy(&attr)) { printf("Error destroying thread attributes. \n"); } /* Wait for render threads to finish */ for (t=0; t<NUMTHREADS; t++) { if (pthread_join(tinfo[t].thread_id, NULL)) { printf("Error waiting for thread. \n"); } } /* Save the image */ savebmp("out.bmp", img, myScene); /* Free allocated memory */ if (img) free(img); if (myScene->lights) free(myScene->lights); if (myScene->triangles) free(myScene->triangles); if (myScene->spheres) free(myScene->spheres); if (myScene->materials) free(myScene->materials); /* Exit */ pthread_exit(NULL); if (tinfo) free(tinfo); return 0; }