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 *****************************************************************************/
30 #include <vlc_charset.h>
39 #include "preset_types.h"
44 #include "expr_types.h"
47 #include "splaytree_types.h"
48 #include "splaytree.h"
49 #include "tree_types.h"
51 #include "per_frame_eqn_types.h"
52 #include "per_frame_eqn.h"
54 #include "per_pixel_eqn_types.h"
55 #include "per_pixel_eqn.h"
57 #include "init_cond_types.h"
58 #include "init_cond.h"
60 #include "param_types.h"
63 #include "func_types.h"
66 #include "custom_wave_types.h"
67 #include "custom_wave.h"
69 #include "custom_shape_types.h"
70 #include "custom_shape.h"
72 #include "idle_preset.h"
74 /* The maximum number of preset names loaded into buffer */
75 #define MAX_PRESETS_IN_DIR 50000
76 extern int per_frame_eqn_count;
77 extern int per_frame_init_eqn_count;
78 //extern int custom_per_frame_eqn_count;
80 extern splaytree_t * builtin_param_tree;
82 preset_t * active_preset = NULL;
83 preset_t * idle_preset = NULL;
84 FILE * write_stream = NULL;
87 int preset_index = -1;
88 int preset_name_buffer_size = 0;
89 splaytree_t * chrono_order_preset_name_tree = NULL;
90 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename);
91 preset_t * load_preset(char * pathname);
92 int is_valid_extension(char * name);
93 int load_preset_file(char * pathname, preset_t * preset);
94 int close_preset(preset_t * preset);
96 int write_preset_name(FILE * fs);
97 int write_per_pixel_equations(FILE * fs);
98 int write_per_frame_equations(FILE * fs);
99 int write_per_frame_init_equations(FILE * fs);
100 int write_init_conditions(FILE * fs);
101 void load_init_cond(param_t * param);
102 void load_init_conditions();
103 void write_init(init_cond_t * init_cond);
104 int init_idle_preset();
105 int destroy_idle_preset();
106 void load_custom_wave_init_conditions();
107 void load_custom_wave_init(custom_wave_t * custom_wave);
109 void load_custom_shape_init_conditions();
110 void load_custom_shape_init(custom_shape_t * custom_shape);
112 /* loadPresetDir: opens the directory buffer
113 denoted by 'dir' to load presets */
115 int loadPresetDir(char * dir) {
117 struct dirent ** name_list;
124 if (chrono_order_preset_name_tree != NULL) {
125 if (PRESET_DEBUG) printf("loadPresetDir: previous directory doesn't appear to be closed!\n");
126 /* Let this slide for now */
129 /* Scan the entire directory, storing each entry in a dirent struct array that needs
130 to be freed later. For more information, consult scandir(3) in the man pages */
131 if ((dir_size = scandir(dir, &name_list, 0, alphasort)) < 0) {
132 if (PRESET_DEBUG) printf("loadPresetDir: failed to open directory \"%s\"\n", dir);
136 chrono_order_preset_name_tree = create_splaytree(compare_int, copy_int, free_int);
138 /* Iterate through entire dirent name list, adding to the preset name list if it
140 for (i = 0; ((i < dir_size) && (i < MAX_PRESETS_IN_DIR));i++) {
142 /* Only perform the next set of operations if the preset name
143 contains a valid extension */
144 if (is_valid_extension(name_list[i]->d_name)) {
146 /* Handle the out of memory case. My guess is xmms would
147 crash before this program would, but whatever...*/
148 if ((preset_name = (char*)malloc(MAX_PATH_SIZE)) == NULL) {
149 if (PRESET_DEBUG) printf("loadPresetDir: out of memory! \n");
151 /* Free the rest of the dirent name list */
152 for (j = i; j < dir_size; j++)
154 destroy_splaytree(chrono_order_preset_name_tree);
155 return OUTOFMEM_ERROR;
158 /* Now create the full path */
159 if (get_preset_path(&preset_name, dir, name_list[i]->d_name) < 0) {
160 if (PRESET_DEBUG) printf("loadPresetDir: failed to generate full preset path name!\n");
162 /* Free the rest of the dirent name list */
163 for (j = i; j < dir_size; j++)
165 destroy_splaytree(chrono_order_preset_name_tree);
166 return OUTOFMEM_ERROR;
170 /* Insert the character string into the splay tree, with the key being its sequence number */
171 splay_insert(preset_name, &preset_name_buffer_size, chrono_order_preset_name_tree);
172 preset_name_buffer_size++;
175 /* Free the dirent struct */
182 /* No valid files in directory! */
183 if (chrono_order_preset_name_tree->root == NULL) {
184 if (PRESET_DEBUG) printf("loadPresetDir: no valid files in directory \"%s\"\n", dir);
185 destroy_splaytree(chrono_order_preset_name_tree);
186 chrono_order_preset_name_tree = NULL;
190 /* Start the prefix index right before the first entry, so next preset
191 starts at the top of the list */
194 /* Start the first preset */
196 switchPreset(ALPHA_NEXT, HARD_CUT);
201 /* closePresetDir: closes the current
202 preset directory buffer */
204 int closePresetDir() {
206 /* No preset director appears to be loaded */
207 if (chrono_order_preset_name_tree == NULL)
211 printf("closePresetDir: freeing directory buffer...");
215 /* Free each entry in the directory preset name tree */
216 splay_traverse(free_int, chrono_order_preset_name_tree);
218 /* Destroy the chronological order splay tree */
219 destroy_splaytree(chrono_order_preset_name_tree);
220 chrono_order_preset_name_tree = NULL;
221 preset_name_buffer_size = 0;
222 if (PRESET_DEBUG) printf("finished\n");
229 /* Converts a preset file name to a full path */
230 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename) {
234 /* An insanely paranoid sequence of argument checks */
235 if (preset_path_ptr == NULL)
237 if (*preset_path_ptr == NULL)
239 if (filename == NULL)
241 if (filepath == NULL)
244 /* Mostly here for looks */
245 preset_path = *preset_path_ptr;
247 /* Clear the name space first */
248 memset(preset_path, 0, MAX_PATH_SIZE);
250 /* Now create the string "PATH/FILENAME", where path is either absolute or relative location
251 of the .milk file, and filename is the name of the preset file itself */
264 /* switchPreset: loads the next preset from the directory stream.
265 loadPresetDir() must be called first. This is a
266 sequential load function */
268 int switchPreset(switch_mode_t switch_mode, int cut_type) {
270 preset_t * new_preset;
274 /* Make sure a preset directory list is in the buffer */
275 if (chrono_order_preset_name_tree == NULL) {
276 if (PRESET_DEBUG) printf("switchPreset: it helps if you open a directory first with a loadPresetDir() call\n");
281 switch (switch_mode) {
284 /* An index variable that iterates through the directory
285 buffer, doing wrap around when it reaches the end of
288 if (preset_index == (preset_name_buffer_size - 1))
289 switch_index = preset_index = 0;
291 switch_index = ++preset_index;
296 if (preset_index == 0)
297 switch_index = preset_index = preset_name_buffer_size - 1;
299 switch_index = --preset_index;
303 switch_index = (int) (preset_name_buffer_size*(rand()/(RAND_MAX+1.0)));
306 switch_index = preset_index;
313 /* Finally, load the preset using its actual path */
314 if ((new_preset = load_preset((char*)splay_find(&switch_index, chrono_order_preset_name_tree))) == NULL) {
315 if (PRESET_DEBUG) printf("switchPreset: failed to load preset\n");
319 /* Closes a preset currently loaded, if any */
320 if ((active_preset != NULL) && (active_preset != idle_preset))
321 close_preset(active_preset);
323 /* Sets global active_preset pointer */
324 active_preset = new_preset;
327 /* Reinitialize the engine variables to sane defaults */
330 /* Add any missing initial conditions */
331 load_init_conditions();
333 /* Add any missing initial conditions for each wave */
334 load_custom_wave_init_conditions();
336 /* Add any missing initial conditions for each shape */
337 load_custom_shape_init_conditions();
339 /* Need to evaluate the initial conditions once */
340 evalInitConditions();
343 // evalInitPerFrameEquations();
347 /* Loads a specific preset by absolute path */
348 int loadPresetByFile(char * filename) {
350 preset_t * new_preset;
352 /* Finally, load the preset using its actual path */
353 if ((new_preset = load_preset(filename)) == NULL) {
354 if (PRESET_DEBUG) printf("loadPresetByFile: failed to load preset!\n");
358 /* Closes a preset currently loaded, if any */
359 if ((active_preset != NULL) && (active_preset != idle_preset))
360 close_preset(active_preset);
362 /* Sets active preset global pointer */
363 active_preset = new_preset;
365 /* Reinitialize engine variables */
369 /* Add any missing initial conditions for each wave */
370 load_custom_wave_init_conditions();
372 /* Add any missing initial conditions for each wave */
373 load_custom_shape_init_conditions();
375 /* Add any missing initial conditions */
376 load_init_conditions();
378 /* Need to do this once for menu */
379 evalInitConditions();
380 // evalPerFrameInitEquations();
385 int init_idle_preset() {
389 /* Initialize idle preset struct */
390 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
394 strncpy(preset->name, "idlepreset", strlen("idlepreset"));
396 /* Initialize equation trees */
397 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
398 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
399 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
400 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
401 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
402 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
403 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
405 /* Set file path to dummy name */
406 strncpy(preset->file_path, "IDLE PRESET", MAX_PATH_SIZE-1);
408 /* Set initial index values */
409 preset->per_pixel_eqn_string_index = 0;
410 preset->per_frame_eqn_string_index = 0;
411 preset->per_frame_init_eqn_string_index = 0;
412 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
414 /* Clear string buffers */
415 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
416 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
417 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
419 idle_preset = preset;
424 int destroy_idle_preset() {
426 return close_preset(idle_preset);
430 /* initPresetLoader: initializes the preset
431 loading library. this should be done before
433 int initPresetLoader() {
435 /* Initializes the builtin parameter database */
436 init_builtin_param_db();
438 /* Initializes the builtin function database */
439 init_builtin_func_db();
441 /* Initializes all infix operators */
444 /* Set the seed to the current time in seconds */
447 /* Initialize the 'idle' preset */
454 active_preset = idle_preset;
455 load_init_conditions();
458 if (PRESET_DEBUG) printf("initPresetLoader: finished\n");
462 /* Sort of experimental code here. This switches
463 to a hard coded preset. Useful if preset directory
464 was not properly loaded, or a preset fails to parse */
466 void switchToIdlePreset() {
469 /* Idle Preset already activated */
470 if (active_preset == idle_preset)
474 /* Close active preset */
475 if (active_preset != NULL)
476 close_preset(active_preset);
478 /* Sets global active_preset pointer */
479 active_preset = idle_preset;
481 /* Reinitialize the engine variables to sane defaults */
484 /* Add any missing initial conditions */
485 load_init_conditions();
487 /* Need to evaluate the initial conditions once */
488 evalInitConditions();
492 /* destroyPresetLoader: closes the preset
493 loading library. This should be done when
494 projectM does cleanup */
496 int destroyPresetLoader() {
498 if ((active_preset != NULL) && (active_preset != idle_preset)) {
499 close_preset(active_preset);
502 active_preset = NULL;
504 destroy_idle_preset();
505 destroy_builtin_param_db();
506 destroy_builtin_func_db();
513 /* load_preset_file: private function that loads a specific preset denoted
514 by the given pathname */
515 int load_preset_file(char * pathname, preset_t * preset) {
519 if (pathname == NULL)
524 /* Open the file corresponding to pathname */
525 if ((fs = utf8_fopen(pathname, "r")) == 0) {
526 if (PRESET_DEBUG) printf("load_preset_file: loading of file %s failed!\n", pathname);
530 if (PRESET_DEBUG) printf("load_preset_file: file stream \"%s\" opened successfully\n", pathname);
532 /* Parse any comments */
533 if (parse_top_comment(fs) < 0) {
534 if (PRESET_DEBUG) printf("load_preset_file: no left bracket found...\n");
539 /* Parse the preset name and a left bracket */
540 if (parse_preset_name(fs, preset->name) < 0) {
541 if (PRESET_DEBUG) printf("load_preset_file: loading of preset name in file \"%s\" failed\n", pathname);
546 if (PRESET_DEBUG) printf("load_preset_file: preset \"%s\" parsed\n", preset->name);
548 /* Parse each line until end of file */
549 if (PRESET_DEBUG) printf("load_preset_file: beginning line parsing...\n");
550 while ((retval = parse_line(fs, preset)) != EOF) {
551 if (retval == PARSE_ERROR) {
552 if (PRESET_DEBUG > 1) printf("load_preset_file: parse error in file \"%s\"\n", pathname);
556 if (PRESET_DEBUG) printf("load_preset_file: finished line parsing successfully\n");
558 /* Now the preset has been loaded.
559 Evaluation calls can be made at appropiate
560 times in the frame loop */
564 if (PRESET_DEBUG) printf("load_preset_file: file \"%s\" closed, preset ready\n", pathname);
569 void evalInitConditions() {
570 splay_traverse(eval_init_cond, active_preset->init_cond_tree);
571 splay_traverse(eval_init_cond, active_preset->per_frame_init_eqn_tree);
574 void evalPerFrameEquations() {
575 splay_traverse(eval_per_frame_eqn, active_preset->per_frame_eqn_tree);
578 void evalPerFrameInitEquations() {
579 //printf("evalPerFrameInitEquations: per frame init unimplemented!\n");
580 // splay_traverse(eval_per_frame_eqn, active_preset->per_frame_init_eqn_tree);
583 /* Returns nonzero if string 'name' contains .milk or
584 (the better) .prjm extension. Not a very strong function currently */
585 int is_valid_extension(char * name) {
587 if (PRESET_DEBUG > 1) {
588 printf("is_valid_extension: scanning string \"%s\"...", name);
592 if (strstr(name, MILKDROP_FILE_EXTENSION)) {
593 if (PRESET_DEBUG > 1) printf("\".milk\" extension found in string [true]\n");
597 if (strstr(name, PROJECTM_FILE_EXTENSION)) {
598 if (PRESET_DEBUG > 1) printf("\".prjm\" extension found in string [true]\n");
602 if (PRESET_DEBUG > 1) printf("no valid extension found [false]\n");
606 /* Private function to close a preset file */
607 int close_preset(preset_t * preset) {
613 splay_traverse(free_init_cond, preset->init_cond_tree);
614 destroy_splaytree(preset->init_cond_tree);
616 splay_traverse(free_init_cond, preset->per_frame_init_eqn_tree);
617 destroy_splaytree(preset->per_frame_init_eqn_tree);
619 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
620 destroy_splaytree(preset->per_pixel_eqn_tree);
622 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
623 destroy_splaytree(preset->per_frame_eqn_tree);
625 splay_traverse(free_param, preset->user_param_tree);
626 destroy_splaytree(preset->user_param_tree);
628 splay_traverse(free_custom_wave, preset->custom_wave_tree);
629 destroy_splaytree(preset->custom_wave_tree);
631 splay_traverse(free_custom_shape, preset->custom_shape_tree);
632 destroy_splaytree(preset->custom_shape_tree);
640 void reloadPerPixel(char *s, preset_t * preset) {
653 /* Clear previous per pixel equations */
654 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
655 destroy_splaytree(preset->per_pixel_eqn_tree);
656 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
658 /* Convert string to a stream */
659 fs = fmemopen (s, strlen(s), "r");
661 while ((c = fgetc(fs)) != EOF) {
663 parse_per_pixel_eqn(fs, preset);
668 /* Clear string space */
669 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
671 /* Compute length of string */
674 /* Copy new string into buffer */
675 strncpy(preset->per_pixel_eqn_string_buffer, s, slen);
677 /* Yet again no bounds checking */
678 preset->per_pixel_eqn_string_index = slen;
685 /* Obviously unwritten */
686 void reloadPerFrameInit(char *s, preset_t * preset) {
690 void reloadPerFrame(char * s, preset_t * preset) {
696 per_frame_eqn_t * per_frame;
704 /* Clear previous per frame equations */
705 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
706 destroy_splaytree(preset->per_frame_eqn_tree);
707 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
709 /* Convert string to a stream */
710 fs = fmemopen (s, strlen(s), "r");
712 while ((c = fgetc(fs)) != EOF) {
714 if ((per_frame = parse_per_frame_eqn(fs, eqn_count, preset)) != NULL) {
715 splay_insert(per_frame, &eqn_count, preset->per_frame_eqn_tree);
722 /* Clear string space */
723 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
725 /* Compute length of string */
728 /* Copy new string into buffer */
729 strncpy(preset->per_frame_eqn_string_buffer, s, slen);
731 /* Yet again no bounds checking */
732 preset->per_frame_eqn_string_index = slen;
735 printf("reloadPerFrame: %d eqns parsed succesfully\n", eqn_count-1);
740 preset_t * load_preset(char * pathname) {
744 /* Initialize preset struct */
745 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
748 /* Initialize equation trees */
749 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
750 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
751 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
752 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
753 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
754 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
755 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
757 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
760 strncpy(preset->file_path, pathname, MAX_PATH_SIZE-1);
762 /* Set initial index values */
763 preset->per_pixel_eqn_string_index = 0;
764 preset->per_frame_eqn_string_index = 0;
765 preset->per_frame_init_eqn_string_index = 0;
768 /* Clear string buffers */
769 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
770 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
771 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
774 if (load_preset_file(pathname, preset) < 0) {
775 if (PRESET_DEBUG) printf("load_preset: failed to load file \"%s\"\n", pathname);
776 close_preset(preset);
780 /* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */
781 per_frame_eqn_count = 0;
782 per_frame_init_eqn_count = 0;
784 /* Finished, return new preset */
788 void savePreset(char * filename) {
792 if (filename == NULL)
795 /* Open the file corresponding to pathname */
796 if ((fs = utf8_fopen(filename, "w+")) == 0) {
797 if (PRESET_DEBUG) printf("savePreset: failed to create filename \"%s\"!\n", filename);
803 if (write_preset_name(fs) < 0) {
809 if (write_init_conditions(fs) < 0) {
815 if (write_per_frame_init_equations(fs) < 0) {
821 if (write_per_frame_equations(fs) < 0) {
827 if (write_per_pixel_equations(fs) < 0) {
838 int write_preset_name(FILE * fs) {
848 /* Format the preset name in a string */
849 sprintf(s, "[%s]\n", active_preset->name);
853 /* Write preset name to file stream */
854 if (fwrite(s, 1, len, fs) != len)
861 int write_init_conditions(FILE * fs) {
865 if (active_preset == NULL)
869 splay_traverse(write_init, active_preset->init_cond_tree);
874 void write_init(init_cond_t * init_cond) {
879 if (write_stream == NULL)
884 if (init_cond->param->type == P_TYPE_BOOL)
885 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.bool_val);
887 else if (init_cond->param->type == P_TYPE_INT)
888 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val);
890 else if (init_cond->param->type == P_TYPE_DOUBLE)
892 lldiv_t div = lldiv( init_cond->init_val.double_val * 1000000,1000000 );
893 sprintf(s, "%s=%"PRId64".%06u\n", init_cond->param->name, div.quot,
894 (unsigned int) div.rem );
897 else { printf("write_init: unknown parameter type!\n"); return; }
901 if ((fwrite(s, 1, len, write_stream)) != len)
902 printf("write_init: failed writing to file stream! Out of disk space?\n");
907 int write_per_frame_init_equations(FILE * fs) {
913 if (active_preset == NULL)
916 len = strlen(active_preset->per_frame_init_eqn_string_buffer);
918 if (fwrite(active_preset->per_frame_init_eqn_string_buffer, 1, len, fs) != len)
925 int write_per_frame_equations(FILE * fs) {
931 if (active_preset == NULL)
934 len = strlen(active_preset->per_frame_eqn_string_buffer);
936 if (fwrite(active_preset->per_frame_eqn_string_buffer, 1, len, fs) != len)
943 int write_per_pixel_equations(FILE * fs) {
949 if (active_preset == NULL)
952 len = strlen(active_preset->per_pixel_eqn_string_buffer);
954 if (fwrite(active_preset->per_pixel_eqn_string_buffer, 1, len, fs) != len)
961 void load_init_conditions() {
963 splay_traverse(load_init_cond, builtin_param_tree);
968 void load_init_cond(param_t * param) {
970 init_cond_t * init_cond;
973 /* Don't count read only parameters as initial conditions */
974 if (param->flags & P_FLAG_READONLY)
977 /* If initial condition was not defined by the preset file, force a default one
978 with the following code */
979 if ((init_cond = splay_find(param->name, active_preset->init_cond_tree)) == NULL) {
981 /* Make sure initial condition does not exist in the set of per frame initial equations */
982 if ((init_cond = splay_find(param->name, active_preset->per_frame_init_eqn_tree)) != NULL)
985 if (param->type == P_TYPE_BOOL)
986 init_val.bool_val = 0;
988 else if (param->type == P_TYPE_INT)
989 init_val.int_val = *(int*)param->engine_val;
991 else if (param->type == P_TYPE_DOUBLE)
992 init_val.double_val = *(double*)param->engine_val;
994 //printf("%s\n", param->name);
995 /* Create new initial condition */
996 if ((init_cond = new_init_cond(param, init_val)) == NULL)
999 /* Insert the initial condition into this presets tree */
1000 if (splay_insert(init_cond, init_cond->param->name, active_preset->init_cond_tree) < 0) {
1001 free_init_cond(init_cond);
1009 void load_custom_wave_init_conditions() {
1011 splay_traverse(load_custom_wave_init, active_preset->custom_wave_tree);
1015 void load_custom_wave_init(custom_wave_t * custom_wave) {
1017 load_unspecified_init_conds(custom_wave);
1022 void load_custom_shape_init_conditions() {
1024 splay_traverse(load_custom_shape_init, active_preset->custom_shape_tree);
1028 void load_custom_shape_init(custom_shape_t * custom_shape) {
1030 load_unspecified_init_conds_shape(custom_shape);