1 /*****************************************************************************
3 *****************************************************************************
4 * Copyright (C) 2004 the VideoLAN team
7 * Authors: Cyril Deguet <asmax@videolan.org>
8 * code from projectM http://xmms-projectm.sourceforge.net
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
34 #include "preset_types.h"
39 #include "expr_types.h"
42 #include "splaytree_types.h"
43 #include "splaytree.h"
44 #include "tree_types.h"
46 #include "per_frame_eqn_types.h"
47 #include "per_frame_eqn.h"
49 #include "per_pixel_eqn_types.h"
50 #include "per_pixel_eqn.h"
52 #include "init_cond_types.h"
53 #include "init_cond.h"
55 #include "param_types.h"
58 #include "func_types.h"
61 #include "custom_wave_types.h"
62 #include "custom_wave.h"
64 #include "custom_shape_types.h"
65 #include "custom_shape.h"
67 #include "idle_preset.h"
69 /* The maximum number of preset names loaded into buffer */
70 #define MAX_PRESETS_IN_DIR 50000
71 extern int per_frame_eqn_count;
72 extern int per_frame_init_eqn_count;
73 //extern int custom_per_frame_eqn_count;
75 extern splaytree_t * builtin_param_tree;
77 preset_t * active_preset = NULL;
78 preset_t * idle_preset = NULL;
79 FILE * write_stream = NULL;
82 int preset_index = -1;
83 int preset_name_buffer_size = 0;
84 splaytree_t * chrono_order_preset_name_tree = NULL;
85 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename);
86 preset_t * load_preset(char * pathname);
87 int is_valid_extension(char * name);
88 int load_preset_file(char * pathname, preset_t * preset);
89 int close_preset(preset_t * preset);
91 int write_preset_name(FILE * fs);
92 int write_per_pixel_equations(FILE * fs);
93 int write_per_frame_equations(FILE * fs);
94 int write_per_frame_init_equations(FILE * fs);
95 int write_init_conditions(FILE * fs);
96 void load_init_cond(param_t * param);
97 void load_init_conditions();
98 void write_init(init_cond_t * init_cond);
99 int init_idle_preset();
100 int destroy_idle_preset();
101 void load_custom_wave_init_conditions();
102 void load_custom_wave_init(custom_wave_t * custom_wave);
104 void load_custom_shape_init_conditions();
105 void load_custom_shape_init(custom_shape_t * custom_shape);
107 /* loadPresetDir: opens the directory buffer
108 denoted by 'dir' to load presets */
110 int loadPresetDir(char * dir) {
112 struct dirent ** name_list;
119 if (chrono_order_preset_name_tree != NULL) {
120 if (PRESET_DEBUG) printf("loadPresetDir: previous directory doesn't appear to be closed!\n");
121 /* Let this slide for now */
124 /* Scan the entire directory, storing each entry in a dirent struct array that needs
125 to be freed later. For more information, consult scandir(3) in the man pages */
126 if ((dir_size = scandir(dir, &name_list, 0, alphasort)) < 0) {
127 if (PRESET_DEBUG) printf("loadPresetDir: failed to open directory \"%s\"\n", dir);
131 chrono_order_preset_name_tree = create_splaytree(compare_int, copy_int, free_int);
133 /* Iterate through entire dirent name list, adding to the preset name list if it
135 for (i = 0; ((i < dir_size) && (i < MAX_PRESETS_IN_DIR));i++) {
137 /* Only perform the next set of operations if the preset name
138 contains a valid extension */
139 if (is_valid_extension(name_list[i]->d_name)) {
141 /* Handle the out of memory case. My guess is xmms would
142 crash before this program would, but whatever...*/
143 if ((preset_name = (char*)malloc(MAX_PATH_SIZE)) == NULL) {
144 if (PRESET_DEBUG) printf("loadPresetDir: out of memory! \n");
146 /* Free the rest of the dirent name list */
147 for (j = i; j < dir_size; j++)
149 destroy_splaytree(chrono_order_preset_name_tree);
150 return OUTOFMEM_ERROR;
153 /* Now create the full path */
154 if (get_preset_path(&preset_name, dir, name_list[i]->d_name) < 0) {
155 if (PRESET_DEBUG) printf("loadPresetDir: failed to generate full preset path name!\n");
157 /* Free the rest of the dirent name list */
158 for (j = i; j < dir_size; j++)
160 destroy_splaytree(chrono_order_preset_name_tree);
161 return OUTOFMEM_ERROR;
165 /* Insert the character string into the splay tree, with the key being its sequence number */
166 splay_insert(preset_name, &preset_name_buffer_size, chrono_order_preset_name_tree);
167 preset_name_buffer_size++;
170 /* Free the dirent struct */
177 /* No valid files in directory! */
178 if (chrono_order_preset_name_tree->root == NULL) {
179 if (PRESET_DEBUG) printf("loadPresetDir: no valid files in directory \"%s\"\n", dir);
180 destroy_splaytree(chrono_order_preset_name_tree);
181 chrono_order_preset_name_tree = NULL;
185 /* Start the prefix index right before the first entry, so next preset
186 starts at the top of the list */
189 /* Start the first preset */
191 switchPreset(ALPHA_NEXT, HARD_CUT);
196 /* closePresetDir: closes the current
197 preset directory buffer */
199 int closePresetDir() {
201 /* No preset director appears to be loaded */
202 if (chrono_order_preset_name_tree == NULL)
206 printf("closePresetDir: freeing directory buffer...");
210 /* Free each entry in the directory preset name tree */
211 splay_traverse(free_int, chrono_order_preset_name_tree);
213 /* Destroy the chronological order splay tree */
214 destroy_splaytree(chrono_order_preset_name_tree);
215 chrono_order_preset_name_tree = NULL;
216 preset_name_buffer_size = 0;
217 if (PRESET_DEBUG) printf("finished\n");
224 /* Converts a preset file name to a full path */
225 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename) {
229 /* An insanely paranoid sequence of argument checks */
230 if (preset_path_ptr == NULL)
232 if (*preset_path_ptr == NULL)
234 if (filename == NULL)
236 if (filepath == NULL)
239 /* Mostly here for looks */
240 preset_path = *preset_path_ptr;
242 /* Clear the name space first */
243 memset(preset_path, 0, MAX_PATH_SIZE);
245 /* Now create the string "PATH/FILENAME", where path is either absolute or relative location
246 of the .milk file, and filename is the name of the preset file itself */
259 /* switchPreset: loads the next preset from the directory stream.
260 loadPresetDir() must be called first. This is a
261 sequential load function */
263 int switchPreset(switch_mode_t switch_mode, int cut_type) {
265 preset_t * new_preset;
269 /* Make sure a preset directory list is in the buffer */
270 if (chrono_order_preset_name_tree == NULL) {
271 if (PRESET_DEBUG) printf("switchPreset: it helps if you open a directory first with a loadPresetDir() call\n");
276 switch (switch_mode) {
279 /* An index variable that iterates through the directory
280 buffer, doing wrap around when it reaches the end of
283 if (preset_index == (preset_name_buffer_size - 1))
284 switch_index = preset_index = 0;
286 switch_index = ++preset_index;
291 if (preset_index == 0)
292 switch_index = preset_index = preset_name_buffer_size - 1;
294 switch_index = --preset_index;
298 switch_index = (int) (preset_name_buffer_size*(rand()/(RAND_MAX+1.0)));
301 switch_index = preset_index;
308 /* Finally, load the preset using its actual path */
309 if ((new_preset = load_preset((char*)splay_find(&switch_index, chrono_order_preset_name_tree))) == NULL) {
310 if (PRESET_DEBUG) printf("switchPreset: failed to load preset\n");
314 /* Closes a preset currently loaded, if any */
315 if ((active_preset != NULL) && (active_preset != idle_preset))
316 close_preset(active_preset);
318 /* Sets global active_preset pointer */
319 active_preset = new_preset;
322 /* Reinitialize the engine variables to sane defaults */
325 /* Add any missing initial conditions */
326 load_init_conditions();
328 /* Add any missing initial conditions for each wave */
329 load_custom_wave_init_conditions();
331 /* Add any missing initial conditions for each shape */
332 load_custom_shape_init_conditions();
334 /* Need to evaluate the initial conditions once */
335 evalInitConditions();
338 // evalInitPerFrameEquations();
342 /* Loads a specific preset by absolute path */
343 int loadPresetByFile(char * filename) {
345 preset_t * new_preset;
347 /* Finally, load the preset using its actual path */
348 if ((new_preset = load_preset(filename)) == NULL) {
349 if (PRESET_DEBUG) printf("loadPresetByFile: failed to load preset!\n");
353 /* Closes a preset currently loaded, if any */
354 if ((active_preset != NULL) && (active_preset != idle_preset))
355 close_preset(active_preset);
357 /* Sets active preset global pointer */
358 active_preset = new_preset;
360 /* Reinitialize engine variables */
364 /* Add any missing initial conditions for each wave */
365 load_custom_wave_init_conditions();
367 /* Add any missing initial conditions for each wave */
368 load_custom_shape_init_conditions();
370 /* Add any missing initial conditions */
371 load_init_conditions();
373 /* Need to do this once for menu */
374 evalInitConditions();
375 // evalPerFrameInitEquations();
380 int init_idle_preset() {
385 /* Initialize idle preset struct */
386 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
390 strncpy(preset->name, "idlepreset", strlen("idlepreset"));
392 /* Initialize equation trees */
393 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
394 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
395 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
396 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
397 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
398 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
399 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
401 /* Set file path to dummy name */
402 strncpy(preset->file_path, "IDLE PRESET", MAX_PATH_SIZE-1);
404 /* Set initial index values */
405 preset->per_pixel_eqn_string_index = 0;
406 preset->per_frame_eqn_string_index = 0;
407 preset->per_frame_init_eqn_string_index = 0;
408 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
410 /* Clear string buffers */
411 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
412 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
413 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
415 idle_preset = preset;
420 int destroy_idle_preset() {
422 return close_preset(idle_preset);
426 /* initPresetLoader: initializes the preset
427 loading library. this should be done before
429 int initPresetLoader() {
431 /* Initializes the builtin parameter database */
432 init_builtin_param_db();
434 /* Initializes the builtin function database */
435 init_builtin_func_db();
437 /* Initializes all infix operators */
440 /* Set the seed to the current time in seconds */
443 /* Initialize the 'idle' preset */
450 active_preset = idle_preset;
451 load_init_conditions();
454 if (PRESET_DEBUG) printf("initPresetLoader: finished\n");
458 /* Sort of experimental code here. This switches
459 to a hard coded preset. Useful if preset directory
460 was not properly loaded, or a preset fails to parse */
462 void switchToIdlePreset() {
465 /* Idle Preset already activated */
466 if (active_preset == idle_preset)
470 /* Close active preset */
471 if (active_preset != NULL)
472 close_preset(active_preset);
474 /* Sets global active_preset pointer */
475 active_preset = idle_preset;
477 /* Reinitialize the engine variables to sane defaults */
480 /* Add any missing initial conditions */
481 load_init_conditions();
483 /* Need to evaluate the initial conditions once */
484 evalInitConditions();
488 /* destroyPresetLoader: closes the preset
489 loading library. This should be done when
490 projectM does cleanup */
492 int destroyPresetLoader() {
494 if ((active_preset != NULL) && (active_preset != idle_preset)) {
495 close_preset(active_preset);
498 active_preset = NULL;
500 destroy_idle_preset();
501 destroy_builtin_param_db();
502 destroy_builtin_func_db();
509 /* load_preset_file: private function that loads a specific preset denoted
510 by the given pathname */
511 int load_preset_file(char * pathname, preset_t * preset) {
515 if (pathname == NULL)
520 /* Open the file corresponding to pathname */
521 if ((fs = utf8_fopen(pathname, "r")) == 0) {
522 if (PRESET_DEBUG) printf("load_preset_file: loading of file %s failed!\n", pathname);
526 if (PRESET_DEBUG) printf("load_preset_file: file stream \"%s\" opened successfully\n", pathname);
528 /* Parse any comments */
529 if (parse_top_comment(fs) < 0) {
530 if (PRESET_DEBUG) printf("load_preset_file: no left bracket found...\n");
535 /* Parse the preset name and a left bracket */
536 if (parse_preset_name(fs, preset->name) < 0) {
537 if (PRESET_DEBUG) printf("load_preset_file: loading of preset name in file \"%s\" failed\n", pathname);
542 if (PRESET_DEBUG) printf("load_preset_file: preset \"%s\" parsed\n", preset->name);
544 /* Parse each line until end of file */
545 if (PRESET_DEBUG) printf("load_preset_file: beginning line parsing...\n");
546 while ((retval = parse_line(fs, preset)) != EOF) {
547 if (retval == PARSE_ERROR) {
548 if (PRESET_DEBUG > 1) printf("load_preset_file: parse error in file \"%s\"\n", pathname);
552 if (PRESET_DEBUG) printf("load_preset_file: finished line parsing successfully\n");
554 /* Now the preset has been loaded.
555 Evaluation calls can be made at appropiate
556 times in the frame loop */
560 if (PRESET_DEBUG) printf("load_preset_file: file \"%s\" closed, preset ready\n", pathname);
565 void evalInitConditions() {
566 splay_traverse(eval_init_cond, active_preset->init_cond_tree);
567 splay_traverse(eval_init_cond, active_preset->per_frame_init_eqn_tree);
570 void evalPerFrameEquations() {
571 splay_traverse(eval_per_frame_eqn, active_preset->per_frame_eqn_tree);
574 void evalPerFrameInitEquations() {
575 //printf("evalPerFrameInitEquations: per frame init unimplemented!\n");
576 // splay_traverse(eval_per_frame_eqn, active_preset->per_frame_init_eqn_tree);
579 /* Returns nonzero if string 'name' contains .milk or
580 (the better) .prjm extension. Not a very strong function currently */
581 int is_valid_extension(char * name) {
583 if (PRESET_DEBUG > 1) {
584 printf("is_valid_extension: scanning string \"%s\"...", name);
588 if (strstr(name, MILKDROP_FILE_EXTENSION)) {
589 if (PRESET_DEBUG > 1) printf("\".milk\" extension found in string [true]\n");
593 if (strstr(name, PROJECTM_FILE_EXTENSION)) {
594 if (PRESET_DEBUG > 1) printf("\".prjm\" extension found in string [true]\n");
598 if (PRESET_DEBUG > 1) printf("no valid extension found [false]\n");
602 /* Private function to close a preset file */
603 int close_preset(preset_t * preset) {
609 splay_traverse(free_init_cond, preset->init_cond_tree);
610 destroy_splaytree(preset->init_cond_tree);
612 splay_traverse(free_init_cond, preset->per_frame_init_eqn_tree);
613 destroy_splaytree(preset->per_frame_init_eqn_tree);
615 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
616 destroy_splaytree(preset->per_pixel_eqn_tree);
618 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
619 destroy_splaytree(preset->per_frame_eqn_tree);
621 splay_traverse(free_param, preset->user_param_tree);
622 destroy_splaytree(preset->user_param_tree);
624 splay_traverse(free_custom_wave, preset->custom_wave_tree);
625 destroy_splaytree(preset->custom_wave_tree);
627 splay_traverse(free_custom_shape, preset->custom_shape_tree);
628 destroy_splaytree(preset->custom_shape_tree);
636 void reloadPerPixel(char *s, preset_t * preset) {
649 /* Clear previous per pixel equations */
650 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
651 destroy_splaytree(preset->per_pixel_eqn_tree);
652 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
654 /* Convert string to a stream */
655 fs = fmemopen (s, strlen(s), "r");
657 while ((c = fgetc(fs)) != EOF) {
659 parse_per_pixel_eqn(fs, preset);
664 /* Clear string space */
665 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
667 /* Compute length of string */
670 /* Copy new string into buffer */
671 strncpy(preset->per_pixel_eqn_string_buffer, s, slen);
673 /* Yet again no bounds checking */
674 preset->per_pixel_eqn_string_index = slen;
681 /* Obviously unwritten */
682 void reloadPerFrameInit(char *s, preset_t * preset) {
686 void reloadPerFrame(char * s, preset_t * preset) {
692 per_frame_eqn_t * per_frame;
700 /* Clear previous per frame equations */
701 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
702 destroy_splaytree(preset->per_frame_eqn_tree);
703 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
705 /* Convert string to a stream */
706 fs = fmemopen (s, strlen(s), "r");
708 while ((c = fgetc(fs)) != EOF) {
710 if ((per_frame = parse_per_frame_eqn(fs, eqn_count, preset)) != NULL) {
711 splay_insert(per_frame, &eqn_count, preset->per_frame_eqn_tree);
718 /* Clear string space */
719 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
721 /* Compute length of string */
724 /* Copy new string into buffer */
725 strncpy(preset->per_frame_eqn_string_buffer, s, slen);
727 /* Yet again no bounds checking */
728 preset->per_frame_eqn_string_index = slen;
731 printf("reloadPerFrame: %d eqns parsed succesfully\n", eqn_count-1);
736 preset_t * load_preset(char * pathname) {
741 /* Initialize preset struct */
742 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
745 /* Initialize equation trees */
746 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
747 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
748 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
749 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
750 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
751 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
752 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
754 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
757 strncpy(preset->file_path, pathname, MAX_PATH_SIZE-1);
759 /* Set initial index values */
760 preset->per_pixel_eqn_string_index = 0;
761 preset->per_frame_eqn_string_index = 0;
762 preset->per_frame_init_eqn_string_index = 0;
765 /* Clear string buffers */
766 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
767 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
768 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
771 if (load_preset_file(pathname, preset) < 0) {
772 if (PRESET_DEBUG) printf("load_preset: failed to load file \"%s\"\n", pathname);
773 close_preset(preset);
777 /* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */
778 per_frame_eqn_count = 0;
779 per_frame_init_eqn_count = 0;
781 /* Finished, return new preset */
785 void savePreset(char * filename) {
789 if (filename == NULL)
792 /* Open the file corresponding to pathname */
793 if ((fs = utf8_fopen(filename, "w+")) == 0) {
794 if (PRESET_DEBUG) printf("savePreset: failed to create filename \"%s\"!\n", filename);
800 if (write_preset_name(fs) < 0) {
806 if (write_init_conditions(fs) < 0) {
812 if (write_per_frame_init_equations(fs) < 0) {
818 if (write_per_frame_equations(fs) < 0) {
824 if (write_per_pixel_equations(fs) < 0) {
835 int write_preset_name(FILE * fs) {
845 /* Format the preset name in a string */
846 sprintf(s, "[%s]\n", active_preset->name);
850 /* Write preset name to file stream */
851 if (fwrite(s, 1, len, fs) != len)
858 int write_init_conditions(FILE * fs) {
862 if (active_preset == NULL)
866 splay_traverse(write_init, active_preset->init_cond_tree);
871 void write_init(init_cond_t * init_cond) {
876 if (write_stream == NULL)
881 if (init_cond->param->type == P_TYPE_BOOL)
882 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.bool_val);
884 else if (init_cond->param->type == P_TYPE_INT)
885 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val);
887 else if (init_cond->param->type == P_TYPE_DOUBLE)
889 lldiv_t div = lldiv( init_cond->init_val.double_val * 1000000,1000000 );
890 sprintf(s, "%s="I64Fd".%06u\n", init_cond->param->name, div.quot,
891 (unsigned int) div.rem );
894 else { printf("write_init: unknown parameter type!\n"); return; }
898 if ((fwrite(s, 1, len, write_stream)) != len)
899 printf("write_init: failed writing to file stream! Out of disk space?\n");
904 int write_per_frame_init_equations(FILE * fs) {
910 if (active_preset == NULL)
913 len = strlen(active_preset->per_frame_init_eqn_string_buffer);
915 if (fwrite(active_preset->per_frame_init_eqn_string_buffer, 1, len, fs) != len)
922 int write_per_frame_equations(FILE * fs) {
928 if (active_preset == NULL)
931 len = strlen(active_preset->per_frame_eqn_string_buffer);
933 if (fwrite(active_preset->per_frame_eqn_string_buffer, 1, len, fs) != len)
940 int write_per_pixel_equations(FILE * fs) {
946 if (active_preset == NULL)
949 len = strlen(active_preset->per_pixel_eqn_string_buffer);
951 if (fwrite(active_preset->per_pixel_eqn_string_buffer, 1, len, fs) != len)
958 void load_init_conditions() {
960 splay_traverse(load_init_cond, builtin_param_tree);
965 void load_init_cond(param_t * param) {
967 init_cond_t * init_cond;
970 /* Don't count read only parameters as initial conditions */
971 if (param->flags & P_FLAG_READONLY)
974 /* If initial condition was not defined by the preset file, force a default one
975 with the following code */
976 if ((init_cond = splay_find(param->name, active_preset->init_cond_tree)) == NULL) {
978 /* Make sure initial condition does not exist in the set of per frame initial equations */
979 if ((init_cond = splay_find(param->name, active_preset->per_frame_init_eqn_tree)) != NULL)
982 if (param->type == P_TYPE_BOOL)
983 init_val.bool_val = 0;
985 else if (param->type == P_TYPE_INT)
986 init_val.int_val = *(int*)param->engine_val;
988 else if (param->type == P_TYPE_DOUBLE)
989 init_val.double_val = *(double*)param->engine_val;
991 //printf("%s\n", param->name);
992 /* Create new initial condition */
993 if ((init_cond = new_init_cond(param, init_val)) == NULL)
996 /* Insert the initial condition into this presets tree */
997 if (splay_insert(init_cond, init_cond->param->name, active_preset->init_cond_tree) < 0) {
998 free_init_cond(init_cond);
1006 void load_custom_wave_init_conditions() {
1008 splay_traverse(load_custom_wave_init, active_preset->custom_wave_tree);
1012 void load_custom_wave_init(custom_wave_t * custom_wave) {
1014 load_unspecified_init_conds(custom_wave);
1019 void load_custom_shape_init_conditions() {
1021 splay_traverse(load_custom_shape_init, active_preset->custom_shape_tree);
1025 void load_custom_shape_init(custom_shape_t * custom_shape) {
1027 load_unspecified_init_conds_shape(custom_shape);