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 *****************************************************************************/
36 #include "preset_types.h"
41 #include "expr_types.h"
44 #include "splaytree_types.h"
45 #include "splaytree.h"
46 #include "tree_types.h"
48 #include "per_frame_eqn_types.h"
49 #include "per_frame_eqn.h"
51 #include "per_pixel_eqn_types.h"
52 #include "per_pixel_eqn.h"
54 #include "init_cond_types.h"
55 #include "init_cond.h"
57 #include "param_types.h"
60 #include "func_types.h"
63 #include "custom_wave_types.h"
64 #include "custom_wave.h"
66 #include "custom_shape_types.h"
67 #include "custom_shape.h"
69 #include "idle_preset.h"
71 /* The maximum number of preset names loaded into buffer */
72 #define MAX_PRESETS_IN_DIR 50000
73 extern int per_frame_eqn_count;
74 extern int per_frame_init_eqn_count;
75 //extern int custom_per_frame_eqn_count;
77 extern splaytree_t * builtin_param_tree;
79 preset_t * active_preset = NULL;
80 preset_t * idle_preset = NULL;
81 FILE * write_stream = NULL;
84 int preset_index = -1;
85 int preset_name_buffer_size = 0;
86 splaytree_t * chrono_order_preset_name_tree = NULL;
87 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename);
88 preset_t * load_preset(char * pathname);
89 int is_valid_extension(char * name);
90 int load_preset_file(char * pathname, preset_t * preset);
91 int close_preset(preset_t * preset);
93 int write_preset_name(FILE * fs);
94 int write_per_pixel_equations(FILE * fs);
95 int write_per_frame_equations(FILE * fs);
96 int write_per_frame_init_equations(FILE * fs);
97 int write_init_conditions(FILE * fs);
98 void load_init_cond(param_t * param);
99 void load_init_conditions();
100 void write_init(init_cond_t * init_cond);
101 int init_idle_preset();
102 int destroy_idle_preset();
103 void load_custom_wave_init_conditions();
104 void load_custom_wave_init(custom_wave_t * custom_wave);
106 void load_custom_shape_init_conditions();
107 void load_custom_shape_init(custom_shape_t * custom_shape);
109 /* loadPresetDir: opens the directory buffer
110 denoted by 'dir' to load presets */
112 int loadPresetDir(char * dir) {
114 struct dirent ** name_list;
121 if (chrono_order_preset_name_tree != NULL) {
122 if (PRESET_DEBUG) printf("loadPresetDir: previous directory doesn't appear to be closed!\n");
123 /* Let this slide for now */
126 /* Scan the entire directory, storing each entry in a dirent struct array that needs
127 to be freed later. For more information, consult scandir(3) in the man pages */
128 if ((dir_size = scandir(dir, &name_list, 0, alphasort)) < 0) {
129 if (PRESET_DEBUG) printf("loadPresetDir: failed to open directory \"%s\"\n", dir);
133 chrono_order_preset_name_tree = create_splaytree(compare_int, copy_int, free_int);
135 /* Iterate through entire dirent name list, adding to the preset name list if it
137 for (i = 0; ((i < dir_size) && (i < MAX_PRESETS_IN_DIR));i++) {
139 /* Only perform the next set of operations if the preset name
140 contains a valid extension */
141 if (is_valid_extension(name_list[i]->d_name)) {
143 /* Handle the out of memory case. My guess is xmms would
144 crash before this program would, but whatever...*/
145 if ((preset_name = (char*)malloc(MAX_PATH_SIZE)) == NULL) {
146 if (PRESET_DEBUG) printf("loadPresetDir: out of memory! \n");
148 /* Free the rest of the dirent name list */
149 for (j = i; j < dir_size; j++)
151 destroy_splaytree(chrono_order_preset_name_tree);
152 return OUTOFMEM_ERROR;
155 /* Now create the full path */
156 if (get_preset_path(&preset_name, dir, name_list[i]->d_name) < 0) {
157 if (PRESET_DEBUG) printf("loadPresetDir: failed to generate full preset path name!\n");
159 /* Free the rest of the dirent name list */
160 for (j = i; j < dir_size; j++)
162 destroy_splaytree(chrono_order_preset_name_tree);
163 return OUTOFMEM_ERROR;
167 /* Insert the character string into the splay tree, with the key being its sequence number */
168 splay_insert(preset_name, &preset_name_buffer_size, chrono_order_preset_name_tree);
169 preset_name_buffer_size++;
172 /* Free the dirent struct */
179 /* No valid files in directory! */
180 if (chrono_order_preset_name_tree->root == NULL) {
181 if (PRESET_DEBUG) printf("loadPresetDir: no valid files in directory \"%s\"\n", dir);
182 destroy_splaytree(chrono_order_preset_name_tree);
183 chrono_order_preset_name_tree = NULL;
187 /* Start the prefix index right before the first entry, so next preset
188 starts at the top of the list */
191 /* Start the first preset */
193 switchPreset(ALPHA_NEXT, HARD_CUT);
198 /* closePresetDir: closes the current
199 preset directory buffer */
201 int closePresetDir() {
203 /* No preset director appears to be loaded */
204 if (chrono_order_preset_name_tree == NULL)
208 printf("closePresetDir: freeing directory buffer...");
212 /* Free each entry in the directory preset name tree */
213 splay_traverse(free_int, chrono_order_preset_name_tree);
215 /* Destroy the chronological order splay tree */
216 destroy_splaytree(chrono_order_preset_name_tree);
217 chrono_order_preset_name_tree = NULL;
218 preset_name_buffer_size = 0;
219 if (PRESET_DEBUG) printf("finished\n");
226 /* Converts a preset file name to a full path */
227 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename) {
231 /* An insanely paranoid sequence of argument checks */
232 if (preset_path_ptr == NULL)
234 if (*preset_path_ptr == NULL)
236 if (filename == NULL)
238 if (filepath == NULL)
241 /* Mostly here for looks */
242 preset_path = *preset_path_ptr;
244 /* Clear the name space first */
245 memset(preset_path, 0, MAX_PATH_SIZE);
247 /* Now create the string "PATH/FILENAME", where path is either absolute or relative location
248 of the .milk file, and filename is the name of the preset file itself */
261 /* switchPreset: loads the next preset from the directory stream.
262 loadPresetDir() must be called first. This is a
263 sequential load function */
265 int switchPreset(switch_mode_t switch_mode, int cut_type) {
267 preset_t * new_preset;
271 /* Make sure a preset directory list is in the buffer */
272 if (chrono_order_preset_name_tree == NULL) {
273 if (PRESET_DEBUG) printf("switchPreset: it helps if you open a directory first with a loadPresetDir() call\n");
278 switch (switch_mode) {
281 /* An index variable that iterates through the directory
282 buffer, doing wrap around when it reaches the end of
285 if (preset_index == (preset_name_buffer_size - 1))
286 switch_index = preset_index = 0;
288 switch_index = ++preset_index;
293 if (preset_index == 0)
294 switch_index = preset_index = preset_name_buffer_size - 1;
296 switch_index = --preset_index;
300 switch_index = (int) (preset_name_buffer_size*(rand()/(RAND_MAX+1.0)));
303 switch_index = preset_index;
310 /* Finally, load the preset using its actual path */
311 if ((new_preset = load_preset((char*)splay_find(&switch_index, chrono_order_preset_name_tree))) == NULL) {
312 if (PRESET_DEBUG) printf("switchPreset: failed to load preset\n");
316 /* Closes a preset currently loaded, if any */
317 if ((active_preset != NULL) && (active_preset != idle_preset))
318 close_preset(active_preset);
320 /* Sets global active_preset pointer */
321 active_preset = new_preset;
324 /* Reinitialize the engine variables to sane defaults */
327 /* Add any missing initial conditions */
328 load_init_conditions();
330 /* Add any missing initial conditions for each wave */
331 load_custom_wave_init_conditions();
333 /* Add any missing initial conditions for each shape */
334 load_custom_shape_init_conditions();
336 /* Need to evaluate the initial conditions once */
337 evalInitConditions();
340 // evalInitPerFrameEquations();
344 /* Loads a specific preset by absolute path */
345 int loadPresetByFile(char * filename) {
347 preset_t * new_preset;
349 /* Finally, load the preset using its actual path */
350 if ((new_preset = load_preset(filename)) == NULL) {
351 if (PRESET_DEBUG) printf("loadPresetByFile: failed to load preset!\n");
355 /* Closes a preset currently loaded, if any */
356 if ((active_preset != NULL) && (active_preset != idle_preset))
357 close_preset(active_preset);
359 /* Sets active preset global pointer */
360 active_preset = new_preset;
362 /* Reinitialize engine variables */
366 /* Add any missing initial conditions for each wave */
367 load_custom_wave_init_conditions();
369 /* Add any missing initial conditions for each wave */
370 load_custom_shape_init_conditions();
372 /* Add any missing initial conditions */
373 load_init_conditions();
375 /* Need to do this once for menu */
376 evalInitConditions();
377 // evalPerFrameInitEquations();
382 int init_idle_preset() {
387 /* Initialize idle preset struct */
388 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
392 strncpy(preset->name, "idlepreset", strlen("idlepreset"));
394 /* Initialize equation trees */
395 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
396 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
397 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
398 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
399 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
400 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
401 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
403 /* Set file path to dummy name */
404 strncpy(preset->file_path, "IDLE PRESET", MAX_PATH_SIZE-1);
406 /* Set initial index values */
407 preset->per_pixel_eqn_string_index = 0;
408 preset->per_frame_eqn_string_index = 0;
409 preset->per_frame_init_eqn_string_index = 0;
410 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
412 /* Clear string buffers */
413 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
414 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
415 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
417 idle_preset = preset;
422 int destroy_idle_preset() {
424 return close_preset(idle_preset);
428 /* initPresetLoader: initializes the preset
429 loading library. this should be done before
431 int initPresetLoader() {
433 /* Initializes the builtin parameter database */
434 init_builtin_param_db();
436 /* Initializes the builtin function database */
437 init_builtin_func_db();
439 /* Initializes all infix operators */
442 /* Set the seed to the current time in seconds */
445 /* Initialize the 'idle' preset */
452 active_preset = idle_preset;
453 load_init_conditions();
456 if (PRESET_DEBUG) printf("initPresetLoader: finished\n");
460 /* Sort of experimental code here. This switches
461 to a hard coded preset. Useful if preset directory
462 was not properly loaded, or a preset fails to parse */
464 void switchToIdlePreset() {
467 /* Idle Preset already activated */
468 if (active_preset == idle_preset)
472 /* Close active preset */
473 if (active_preset != NULL)
474 close_preset(active_preset);
476 /* Sets global active_preset pointer */
477 active_preset = idle_preset;
479 /* Reinitialize the engine variables to sane defaults */
482 /* Add any missing initial conditions */
483 load_init_conditions();
485 /* Need to evaluate the initial conditions once */
486 evalInitConditions();
490 /* destroyPresetLoader: closes the preset
491 loading library. This should be done when
492 projectM does cleanup */
494 int destroyPresetLoader() {
496 if ((active_preset != NULL) && (active_preset != idle_preset)) {
497 close_preset(active_preset);
500 active_preset = NULL;
502 destroy_idle_preset();
503 destroy_builtin_param_db();
504 destroy_builtin_func_db();
511 /* load_preset_file: private function that loads a specific preset denoted
512 by the given pathname */
513 int load_preset_file(char * pathname, preset_t * preset) {
517 if (pathname == NULL)
522 /* Open the file corresponding to pathname */
523 if ((fs = fopen(pathname, "r")) == 0) {
524 if (PRESET_DEBUG) printf("load_preset_file: loading of file %s failed!\n", pathname);
528 if (PRESET_DEBUG) printf("load_preset_file: file stream \"%s\" opened successfully\n", pathname);
530 /* Parse any comments */
531 if (parse_top_comment(fs) < 0) {
532 if (PRESET_DEBUG) printf("load_preset_file: no left bracket found...\n");
537 /* Parse the preset name and a left bracket */
538 if (parse_preset_name(fs, preset->name) < 0) {
539 if (PRESET_DEBUG) printf("load_preset_file: loading of preset name in file \"%s\" failed\n", pathname);
544 if (PRESET_DEBUG) printf("load_preset_file: preset \"%s\" parsed\n", preset->name);
546 /* Parse each line until end of file */
547 if (PRESET_DEBUG) printf("load_preset_file: beginning line parsing...\n");
548 while ((retval = parse_line(fs, preset)) != EOF) {
549 if (retval == PARSE_ERROR) {
550 if (PRESET_DEBUG > 1) printf("load_preset_file: parse error in file \"%s\"\n", pathname);
554 if (PRESET_DEBUG) printf("load_preset_file: finished line parsing successfully\n");
556 /* Now the preset has been loaded.
557 Evaluation calls can be made at appropiate
558 times in the frame loop */
562 if (PRESET_DEBUG) printf("load_preset_file: file \"%s\" closed, preset ready\n", pathname);
567 void evalInitConditions() {
568 splay_traverse(eval_init_cond, active_preset->init_cond_tree);
569 splay_traverse(eval_init_cond, active_preset->per_frame_init_eqn_tree);
572 void evalPerFrameEquations() {
573 splay_traverse(eval_per_frame_eqn, active_preset->per_frame_eqn_tree);
576 void evalPerFrameInitEquations() {
577 //printf("evalPerFrameInitEquations: per frame init unimplemented!\n");
578 // splay_traverse(eval_per_frame_eqn, active_preset->per_frame_init_eqn_tree);
581 /* Returns nonzero if string 'name' contains .milk or
582 (the better) .prjm extension. Not a very strong function currently */
583 int is_valid_extension(char * name) {
585 if (PRESET_DEBUG > 1) {
586 printf("is_valid_extension: scanning string \"%s\"...", name);
590 if (strstr(name, MILKDROP_FILE_EXTENSION)) {
591 if (PRESET_DEBUG > 1) printf("\".milk\" extension found in string [true]\n");
595 if (strstr(name, PROJECTM_FILE_EXTENSION)) {
596 if (PRESET_DEBUG > 1) printf("\".prjm\" extension found in string [true]\n");
600 if (PRESET_DEBUG > 1) printf("no valid extension found [false]\n");
604 /* Private function to close a preset file */
605 int close_preset(preset_t * preset) {
611 splay_traverse(free_init_cond, preset->init_cond_tree);
612 destroy_splaytree(preset->init_cond_tree);
614 splay_traverse(free_init_cond, preset->per_frame_init_eqn_tree);
615 destroy_splaytree(preset->per_frame_init_eqn_tree);
617 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
618 destroy_splaytree(preset->per_pixel_eqn_tree);
620 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
621 destroy_splaytree(preset->per_frame_eqn_tree);
623 splay_traverse(free_param, preset->user_param_tree);
624 destroy_splaytree(preset->user_param_tree);
626 splay_traverse(free_custom_wave, preset->custom_wave_tree);
627 destroy_splaytree(preset->custom_wave_tree);
629 splay_traverse(free_custom_shape, preset->custom_shape_tree);
630 destroy_splaytree(preset->custom_shape_tree);
638 void reloadPerPixel(char *s, preset_t * preset) {
651 /* Clear previous per pixel equations */
652 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
653 destroy_splaytree(preset->per_pixel_eqn_tree);
654 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
656 /* Convert string to a stream */
657 fs = fmemopen (s, strlen(s), "r");
659 while ((c = fgetc(fs)) != EOF) {
661 parse_per_pixel_eqn(fs, preset);
666 /* Clear string space */
667 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
669 /* Compute length of string */
672 /* Copy new string into buffer */
673 strncpy(preset->per_pixel_eqn_string_buffer, s, slen);
675 /* Yet again no bounds checking */
676 preset->per_pixel_eqn_string_index = slen;
683 /* Obviously unwritten */
684 void reloadPerFrameInit(char *s, preset_t * preset) {
688 void reloadPerFrame(char * s, preset_t * preset) {
694 per_frame_eqn_t * per_frame;
702 /* Clear previous per frame equations */
703 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
704 destroy_splaytree(preset->per_frame_eqn_tree);
705 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
707 /* Convert string to a stream */
708 fs = fmemopen (s, strlen(s), "r");
710 while ((c = fgetc(fs)) != EOF) {
712 if ((per_frame = parse_per_frame_eqn(fs, eqn_count, preset)) != NULL) {
713 splay_insert(per_frame, &eqn_count, preset->per_frame_eqn_tree);
720 /* Clear string space */
721 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
723 /* Compute length of string */
726 /* Copy new string into buffer */
727 strncpy(preset->per_frame_eqn_string_buffer, s, slen);
729 /* Yet again no bounds checking */
730 preset->per_frame_eqn_string_index = slen;
733 printf("reloadPerFrame: %d eqns parsed succesfully\n", eqn_count-1);
738 preset_t * load_preset(char * pathname) {
743 /* Initialize preset struct */
744 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
747 /* Initialize equation trees */
748 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
749 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
750 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
751 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
752 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
753 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
754 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
756 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
759 strncpy(preset->file_path, pathname, MAX_PATH_SIZE-1);
761 /* Set initial index values */
762 preset->per_pixel_eqn_string_index = 0;
763 preset->per_frame_eqn_string_index = 0;
764 preset->per_frame_init_eqn_string_index = 0;
767 /* Clear string buffers */
768 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
769 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
770 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
773 if (load_preset_file(pathname, preset) < 0) {
774 if (PRESET_DEBUG) printf("load_preset: failed to load file \"%s\"\n", pathname);
775 close_preset(preset);
779 /* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */
780 per_frame_eqn_count = 0;
781 per_frame_init_eqn_count = 0;
783 /* Finished, return new preset */
787 void savePreset(char * filename) {
791 if (filename == NULL)
794 /* Open the file corresponding to pathname */
795 if ((fs = fopen(filename, "w+")) == 0) {
796 if (PRESET_DEBUG) printf("savePreset: failed to create filename \"%s\"!\n", filename);
802 if (write_preset_name(fs) < 0) {
808 if (write_init_conditions(fs) < 0) {
814 if (write_per_frame_init_equations(fs) < 0) {
820 if (write_per_frame_equations(fs) < 0) {
826 if (write_per_pixel_equations(fs) < 0) {
837 int write_preset_name(FILE * fs) {
847 /* Format the preset name in a string */
848 sprintf(s, "[%s]\n", active_preset->name);
852 /* Write preset name to file stream */
853 if (fwrite(s, 1, len, fs) != len)
860 int write_init_conditions(FILE * fs) {
864 if (active_preset == NULL)
868 splay_traverse(write_init, active_preset->init_cond_tree);
873 void write_init(init_cond_t * init_cond) {
878 if (write_stream == NULL)
883 if (init_cond->param->type == P_TYPE_BOOL)
884 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.bool_val);
886 else if (init_cond->param->type == P_TYPE_INT)
887 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val);
889 else if (init_cond->param->type == P_TYPE_DOUBLE)
891 lldiv_t div = lldiv( init_cond->init_val.double_val * 1000000,1000000 );
892 sprintf(s, "%s="I64Fd".%06u\n", init_cond->param->name, div.quot,
893 (unsigned int) div.rem );
896 else { printf("write_init: unknown parameter type!\n"); return; }
900 if ((fwrite(s, 1, len, write_stream)) != len)
901 printf("write_init: failed writing to file stream! Out of disk space?\n");
906 int write_per_frame_init_equations(FILE * fs) {
912 if (active_preset == NULL)
915 len = strlen(active_preset->per_frame_init_eqn_string_buffer);
917 if (fwrite(active_preset->per_frame_init_eqn_string_buffer, 1, len, fs) != len)
924 int write_per_frame_equations(FILE * fs) {
930 if (active_preset == NULL)
933 len = strlen(active_preset->per_frame_eqn_string_buffer);
935 if (fwrite(active_preset->per_frame_eqn_string_buffer, 1, len, fs) != len)
942 int write_per_pixel_equations(FILE * fs) {
948 if (active_preset == NULL)
951 len = strlen(active_preset->per_pixel_eqn_string_buffer);
953 if (fwrite(active_preset->per_pixel_eqn_string_buffer, 1, len, fs) != len)
960 void load_init_conditions() {
962 splay_traverse(load_init_cond, builtin_param_tree);
967 void load_init_cond(param_t * param) {
969 init_cond_t * init_cond;
972 /* Don't count read only parameters as initial conditions */
973 if (param->flags & P_FLAG_READONLY)
976 /* If initial condition was not defined by the preset file, force a default one
977 with the following code */
978 if ((init_cond = splay_find(param->name, active_preset->init_cond_tree)) == NULL) {
980 /* Make sure initial condition does not exist in the set of per frame initial equations */
981 if ((init_cond = splay_find(param->name, active_preset->per_frame_init_eqn_tree)) != NULL)
984 if (param->type == P_TYPE_BOOL)
985 init_val.bool_val = 0;
987 else if (param->type == P_TYPE_INT)
988 init_val.int_val = *(int*)param->engine_val;
990 else if (param->type == P_TYPE_DOUBLE)
991 init_val.double_val = *(double*)param->engine_val;
993 //printf("%s\n", param->name);
994 /* Create new initial condition */
995 if ((init_cond = new_init_cond(param, init_val)) == NULL)
998 /* Insert the initial condition into this presets tree */
999 if (splay_insert(init_cond, init_cond->param->name, active_preset->init_cond_tree) < 0) {
1000 free_init_cond(init_cond);
1008 void load_custom_wave_init_conditions() {
1010 splay_traverse(load_custom_wave_init, active_preset->custom_wave_tree);
1014 void load_custom_wave_init(custom_wave_t * custom_wave) {
1016 load_unspecified_init_conds(custom_wave);
1021 void load_custom_shape_init_conditions() {
1023 splay_traverse(load_custom_shape_init, active_preset->custom_shape_tree);
1027 void load_custom_shape_init(custom_shape_t * custom_shape) {
1029 load_unspecified_init_conds_shape(custom_shape);