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 *****************************************************************************/
26 #include <vlc_charset.h>
35 #include "preset_types.h"
40 #include "expr_types.h"
43 #include "splaytree_types.h"
44 #include "splaytree.h"
45 #include "tree_types.h"
47 #include "per_frame_eqn_types.h"
48 #include "per_frame_eqn.h"
50 #include "per_pixel_eqn_types.h"
51 #include "per_pixel_eqn.h"
53 #include "init_cond_types.h"
54 #include "init_cond.h"
56 #include "param_types.h"
59 #include "func_types.h"
62 #include "custom_wave_types.h"
63 #include "custom_wave.h"
65 #include "custom_shape_types.h"
66 #include "custom_shape.h"
68 #include "idle_preset.h"
70 /* The maximum number of preset names loaded into buffer */
71 #define MAX_PRESETS_IN_DIR 50000
72 extern int per_frame_eqn_count;
73 extern int per_frame_init_eqn_count;
74 //extern int custom_per_frame_eqn_count;
76 extern splaytree_t * builtin_param_tree;
78 preset_t * active_preset = NULL;
79 preset_t * idle_preset = NULL;
80 FILE * write_stream = NULL;
83 int preset_index = -1;
84 int preset_name_buffer_size = 0;
85 splaytree_t * chrono_order_preset_name_tree = NULL;
86 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename);
87 preset_t * load_preset(char * pathname);
88 int is_valid_extension(char * name);
89 int load_preset_file(char * pathname, preset_t * preset);
90 int close_preset(preset_t * preset);
92 int write_preset_name(FILE * fs);
93 int write_per_pixel_equations(FILE * fs);
94 int write_per_frame_equations(FILE * fs);
95 int write_per_frame_init_equations(FILE * fs);
96 int write_init_conditions(FILE * fs);
97 void load_init_cond(param_t * param);
98 void load_init_conditions();
99 void write_init(init_cond_t * init_cond);
100 int init_idle_preset();
101 int destroy_idle_preset();
102 void load_custom_wave_init_conditions();
103 void load_custom_wave_init(custom_wave_t * custom_wave);
105 void load_custom_shape_init_conditions();
106 void load_custom_shape_init(custom_shape_t * custom_shape);
108 /* loadPresetDir: opens the directory buffer
109 denoted by 'dir' to load presets */
111 int loadPresetDir(char * dir) {
113 struct dirent ** name_list;
120 if (chrono_order_preset_name_tree != NULL) {
121 if (PRESET_DEBUG) printf("loadPresetDir: previous directory doesn't appear to be closed!\n");
122 /* Let this slide for now */
125 /* Scan the entire directory, storing each entry in a dirent struct array that needs
126 to be freed later. For more information, consult scandir(3) in the man pages */
127 if ((dir_size = scandir(dir, &name_list, 0, alphasort)) < 0) {
128 if (PRESET_DEBUG) printf("loadPresetDir: failed to open directory \"%s\"\n", dir);
132 chrono_order_preset_name_tree = create_splaytree(compare_int, copy_int, free_int);
134 /* Iterate through entire dirent name list, adding to the preset name list if it
136 for (i = 0; ((i < dir_size) && (i < MAX_PRESETS_IN_DIR));i++) {
138 /* Only perform the next set of operations if the preset name
139 contains a valid extension */
140 if (is_valid_extension(name_list[i]->d_name)) {
142 /* Handle the out of memory case. My guess is xmms would
143 crash before this program would, but whatever...*/
144 if ((preset_name = (char*)malloc(MAX_PATH_SIZE)) == NULL) {
145 if (PRESET_DEBUG) printf("loadPresetDir: out of memory! \n");
147 /* Free the rest of the dirent name list */
148 for (j = i; j < dir_size; j++)
150 destroy_splaytree(chrono_order_preset_name_tree);
151 return OUTOFMEM_ERROR;
154 /* Now create the full path */
155 if (get_preset_path(&preset_name, dir, name_list[i]->d_name) < 0) {
156 if (PRESET_DEBUG) printf("loadPresetDir: failed to generate full preset path name!\n");
158 /* Free the rest of the dirent name list */
159 for (j = i; j < dir_size; j++)
161 destroy_splaytree(chrono_order_preset_name_tree);
162 return OUTOFMEM_ERROR;
166 /* Insert the character string into the splay tree, with the key being its sequence number */
167 splay_insert(preset_name, &preset_name_buffer_size, chrono_order_preset_name_tree);
168 preset_name_buffer_size++;
171 /* Free the dirent struct */
178 /* No valid files in directory! */
179 if (chrono_order_preset_name_tree->root == NULL) {
180 if (PRESET_DEBUG) printf("loadPresetDir: no valid files in directory \"%s\"\n", dir);
181 destroy_splaytree(chrono_order_preset_name_tree);
182 chrono_order_preset_name_tree = NULL;
186 /* Start the prefix index right before the first entry, so next preset
187 starts at the top of the list */
190 /* Start the first preset */
192 switchPreset(ALPHA_NEXT, HARD_CUT);
197 /* closePresetDir: closes the current
198 preset directory buffer */
200 int closePresetDir() {
202 /* No preset director appears to be loaded */
203 if (chrono_order_preset_name_tree == NULL)
207 printf("closePresetDir: freeing directory buffer...");
211 /* Free each entry in the directory preset name tree */
212 splay_traverse(free_int, chrono_order_preset_name_tree);
214 /* Destroy the chronological order splay tree */
215 destroy_splaytree(chrono_order_preset_name_tree);
216 chrono_order_preset_name_tree = NULL;
217 preset_name_buffer_size = 0;
218 if (PRESET_DEBUG) printf("finished\n");
225 /* Converts a preset file name to a full path */
226 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename) {
230 /* An insanely paranoid sequence of argument checks */
231 if (preset_path_ptr == NULL)
233 if (*preset_path_ptr == NULL)
235 if (filename == NULL)
237 if (filepath == NULL)
240 /* Mostly here for looks */
241 preset_path = *preset_path_ptr;
243 /* Clear the name space first */
244 memset(preset_path, 0, MAX_PATH_SIZE);
246 /* Now create the string "PATH/FILENAME", where path is either absolute or relative location
247 of the .milk file, and filename is the name of the preset file itself */
260 /* switchPreset: loads the next preset from the directory stream.
261 loadPresetDir() must be called first. This is a
262 sequential load function */
264 int switchPreset(switch_mode_t switch_mode, int cut_type) {
266 preset_t * new_preset;
270 /* Make sure a preset directory list is in the buffer */
271 if (chrono_order_preset_name_tree == NULL) {
272 if (PRESET_DEBUG) printf("switchPreset: it helps if you open a directory first with a loadPresetDir() call\n");
277 switch (switch_mode) {
280 /* An index variable that iterates through the directory
281 buffer, doing wrap around when it reaches the end of
284 if (preset_index == (preset_name_buffer_size - 1))
285 switch_index = preset_index = 0;
287 switch_index = ++preset_index;
292 if (preset_index == 0)
293 switch_index = preset_index = preset_name_buffer_size - 1;
295 switch_index = --preset_index;
299 switch_index = (int) (preset_name_buffer_size*(rand()/(RAND_MAX+1.0)));
302 switch_index = preset_index;
309 /* Finally, load the preset using its actual path */
310 if ((new_preset = load_preset((char*)splay_find(&switch_index, chrono_order_preset_name_tree))) == NULL) {
311 if (PRESET_DEBUG) printf("switchPreset: failed to load preset\n");
315 /* Closes a preset currently loaded, if any */
316 if ((active_preset != NULL) && (active_preset != idle_preset))
317 close_preset(active_preset);
319 /* Sets global active_preset pointer */
320 active_preset = new_preset;
323 /* Reinitialize the engine variables to sane defaults */
326 /* Add any missing initial conditions */
327 load_init_conditions();
329 /* Add any missing initial conditions for each wave */
330 load_custom_wave_init_conditions();
332 /* Add any missing initial conditions for each shape */
333 load_custom_shape_init_conditions();
335 /* Need to evaluate the initial conditions once */
336 evalInitConditions();
339 // evalInitPerFrameEquations();
343 /* Loads a specific preset by absolute path */
344 int loadPresetByFile(char * filename) {
346 preset_t * new_preset;
348 /* Finally, load the preset using its actual path */
349 if ((new_preset = load_preset(filename)) == NULL) {
350 if (PRESET_DEBUG) printf("loadPresetByFile: failed to load preset!\n");
354 /* Closes a preset currently loaded, if any */
355 if ((active_preset != NULL) && (active_preset != idle_preset))
356 close_preset(active_preset);
358 /* Sets active preset global pointer */
359 active_preset = new_preset;
361 /* Reinitialize engine variables */
365 /* Add any missing initial conditions for each wave */
366 load_custom_wave_init_conditions();
368 /* Add any missing initial conditions for each wave */
369 load_custom_shape_init_conditions();
371 /* Add any missing initial conditions */
372 load_init_conditions();
374 /* Need to do this once for menu */
375 evalInitConditions();
376 // evalPerFrameInitEquations();
381 int init_idle_preset() {
386 /* Initialize idle preset struct */
387 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
391 strncpy(preset->name, "idlepreset", strlen("idlepreset"));
393 /* Initialize equation trees */
394 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
395 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
396 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
397 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
398 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
399 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
400 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
402 /* Set file path to dummy name */
403 strncpy(preset->file_path, "IDLE PRESET", MAX_PATH_SIZE-1);
405 /* Set initial index values */
406 preset->per_pixel_eqn_string_index = 0;
407 preset->per_frame_eqn_string_index = 0;
408 preset->per_frame_init_eqn_string_index = 0;
409 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
411 /* Clear string buffers */
412 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
413 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
414 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
416 idle_preset = preset;
421 int destroy_idle_preset() {
423 return close_preset(idle_preset);
427 /* initPresetLoader: initializes the preset
428 loading library. this should be done before
430 int initPresetLoader() {
432 /* Initializes the builtin parameter database */
433 init_builtin_param_db();
435 /* Initializes the builtin function database */
436 init_builtin_func_db();
438 /* Initializes all infix operators */
441 /* Set the seed to the current time in seconds */
444 /* Initialize the 'idle' preset */
451 active_preset = idle_preset;
452 load_init_conditions();
455 if (PRESET_DEBUG) printf("initPresetLoader: finished\n");
459 /* Sort of experimental code here. This switches
460 to a hard coded preset. Useful if preset directory
461 was not properly loaded, or a preset fails to parse */
463 void switchToIdlePreset() {
466 /* Idle Preset already activated */
467 if (active_preset == idle_preset)
471 /* Close active preset */
472 if (active_preset != NULL)
473 close_preset(active_preset);
475 /* Sets global active_preset pointer */
476 active_preset = idle_preset;
478 /* Reinitialize the engine variables to sane defaults */
481 /* Add any missing initial conditions */
482 load_init_conditions();
484 /* Need to evaluate the initial conditions once */
485 evalInitConditions();
489 /* destroyPresetLoader: closes the preset
490 loading library. This should be done when
491 projectM does cleanup */
493 int destroyPresetLoader() {
495 if ((active_preset != NULL) && (active_preset != idle_preset)) {
496 close_preset(active_preset);
499 active_preset = NULL;
501 destroy_idle_preset();
502 destroy_builtin_param_db();
503 destroy_builtin_func_db();
510 /* load_preset_file: private function that loads a specific preset denoted
511 by the given pathname */
512 int load_preset_file(char * pathname, preset_t * preset) {
516 if (pathname == NULL)
521 /* Open the file corresponding to pathname */
522 if ((fs = utf8_fopen(pathname, "r")) == 0) {
523 if (PRESET_DEBUG) printf("load_preset_file: loading of file %s failed!\n", pathname);
527 if (PRESET_DEBUG) printf("load_preset_file: file stream \"%s\" opened successfully\n", pathname);
529 /* Parse any comments */
530 if (parse_top_comment(fs) < 0) {
531 if (PRESET_DEBUG) printf("load_preset_file: no left bracket found...\n");
536 /* Parse the preset name and a left bracket */
537 if (parse_preset_name(fs, preset->name) < 0) {
538 if (PRESET_DEBUG) printf("load_preset_file: loading of preset name in file \"%s\" failed\n", pathname);
543 if (PRESET_DEBUG) printf("load_preset_file: preset \"%s\" parsed\n", preset->name);
545 /* Parse each line until end of file */
546 if (PRESET_DEBUG) printf("load_preset_file: beginning line parsing...\n");
547 while ((retval = parse_line(fs, preset)) != EOF) {
548 if (retval == PARSE_ERROR) {
549 if (PRESET_DEBUG > 1) printf("load_preset_file: parse error in file \"%s\"\n", pathname);
553 if (PRESET_DEBUG) printf("load_preset_file: finished line parsing successfully\n");
555 /* Now the preset has been loaded.
556 Evaluation calls can be made at appropiate
557 times in the frame loop */
561 if (PRESET_DEBUG) printf("load_preset_file: file \"%s\" closed, preset ready\n", pathname);
566 void evalInitConditions() {
567 splay_traverse(eval_init_cond, active_preset->init_cond_tree);
568 splay_traverse(eval_init_cond, active_preset->per_frame_init_eqn_tree);
571 void evalPerFrameEquations() {
572 splay_traverse(eval_per_frame_eqn, active_preset->per_frame_eqn_tree);
575 void evalPerFrameInitEquations() {
576 //printf("evalPerFrameInitEquations: per frame init unimplemented!\n");
577 // splay_traverse(eval_per_frame_eqn, active_preset->per_frame_init_eqn_tree);
580 /* Returns nonzero if string 'name' contains .milk or
581 (the better) .prjm extension. Not a very strong function currently */
582 int is_valid_extension(char * name) {
584 if (PRESET_DEBUG > 1) {
585 printf("is_valid_extension: scanning string \"%s\"...", name);
589 if (strstr(name, MILKDROP_FILE_EXTENSION)) {
590 if (PRESET_DEBUG > 1) printf("\".milk\" extension found in string [true]\n");
594 if (strstr(name, PROJECTM_FILE_EXTENSION)) {
595 if (PRESET_DEBUG > 1) printf("\".prjm\" extension found in string [true]\n");
599 if (PRESET_DEBUG > 1) printf("no valid extension found [false]\n");
603 /* Private function to close a preset file */
604 int close_preset(preset_t * preset) {
610 splay_traverse(free_init_cond, preset->init_cond_tree);
611 destroy_splaytree(preset->init_cond_tree);
613 splay_traverse(free_init_cond, preset->per_frame_init_eqn_tree);
614 destroy_splaytree(preset->per_frame_init_eqn_tree);
616 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
617 destroy_splaytree(preset->per_pixel_eqn_tree);
619 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
620 destroy_splaytree(preset->per_frame_eqn_tree);
622 splay_traverse(free_param, preset->user_param_tree);
623 destroy_splaytree(preset->user_param_tree);
625 splay_traverse(free_custom_wave, preset->custom_wave_tree);
626 destroy_splaytree(preset->custom_wave_tree);
628 splay_traverse(free_custom_shape, preset->custom_shape_tree);
629 destroy_splaytree(preset->custom_shape_tree);
637 void reloadPerPixel(char *s, preset_t * preset) {
650 /* Clear previous per pixel equations */
651 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
652 destroy_splaytree(preset->per_pixel_eqn_tree);
653 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
655 /* Convert string to a stream */
656 fs = fmemopen (s, strlen(s), "r");
658 while ((c = fgetc(fs)) != EOF) {
660 parse_per_pixel_eqn(fs, preset);
665 /* Clear string space */
666 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
668 /* Compute length of string */
671 /* Copy new string into buffer */
672 strncpy(preset->per_pixel_eqn_string_buffer, s, slen);
674 /* Yet again no bounds checking */
675 preset->per_pixel_eqn_string_index = slen;
682 /* Obviously unwritten */
683 void reloadPerFrameInit(char *s, preset_t * preset) {
687 void reloadPerFrame(char * s, preset_t * preset) {
693 per_frame_eqn_t * per_frame;
701 /* Clear previous per frame equations */
702 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
703 destroy_splaytree(preset->per_frame_eqn_tree);
704 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
706 /* Convert string to a stream */
707 fs = fmemopen (s, strlen(s), "r");
709 while ((c = fgetc(fs)) != EOF) {
711 if ((per_frame = parse_per_frame_eqn(fs, eqn_count, preset)) != NULL) {
712 splay_insert(per_frame, &eqn_count, preset->per_frame_eqn_tree);
719 /* Clear string space */
720 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
722 /* Compute length of string */
725 /* Copy new string into buffer */
726 strncpy(preset->per_frame_eqn_string_buffer, s, slen);
728 /* Yet again no bounds checking */
729 preset->per_frame_eqn_string_index = slen;
732 printf("reloadPerFrame: %d eqns parsed succesfully\n", eqn_count-1);
737 preset_t * load_preset(char * pathname) {
742 /* Initialize preset struct */
743 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
746 /* Initialize equation trees */
747 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
748 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
749 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
750 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
751 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
752 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
753 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
755 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
758 strncpy(preset->file_path, pathname, MAX_PATH_SIZE-1);
760 /* Set initial index values */
761 preset->per_pixel_eqn_string_index = 0;
762 preset->per_frame_eqn_string_index = 0;
763 preset->per_frame_init_eqn_string_index = 0;
766 /* Clear string buffers */
767 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
768 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
769 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
772 if (load_preset_file(pathname, preset) < 0) {
773 if (PRESET_DEBUG) printf("load_preset: failed to load file \"%s\"\n", pathname);
774 close_preset(preset);
778 /* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */
779 per_frame_eqn_count = 0;
780 per_frame_init_eqn_count = 0;
782 /* Finished, return new preset */
786 void savePreset(char * filename) {
790 if (filename == NULL)
793 /* Open the file corresponding to pathname */
794 if ((fs = utf8_fopen(filename, "w+")) == 0) {
795 if (PRESET_DEBUG) printf("savePreset: failed to create filename \"%s\"!\n", filename);
801 if (write_preset_name(fs) < 0) {
807 if (write_init_conditions(fs) < 0) {
813 if (write_per_frame_init_equations(fs) < 0) {
819 if (write_per_frame_equations(fs) < 0) {
825 if (write_per_pixel_equations(fs) < 0) {
836 int write_preset_name(FILE * fs) {
846 /* Format the preset name in a string */
847 sprintf(s, "[%s]\n", active_preset->name);
851 /* Write preset name to file stream */
852 if (fwrite(s, 1, len, fs) != len)
859 int write_init_conditions(FILE * fs) {
863 if (active_preset == NULL)
867 splay_traverse(write_init, active_preset->init_cond_tree);
872 void write_init(init_cond_t * init_cond) {
877 if (write_stream == NULL)
882 if (init_cond->param->type == P_TYPE_BOOL)
883 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.bool_val);
885 else if (init_cond->param->type == P_TYPE_INT)
886 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val);
888 else if (init_cond->param->type == P_TYPE_DOUBLE)
890 lldiv_t div = lldiv( init_cond->init_val.double_val * 1000000,1000000 );
891 sprintf(s, "%s="I64Fd".%06u\n", init_cond->param->name, div.quot,
892 (unsigned int) div.rem );
895 else { printf("write_init: unknown parameter type!\n"); return; }
899 if ((fwrite(s, 1, len, write_stream)) != len)
900 printf("write_init: failed writing to file stream! Out of disk space?\n");
905 int write_per_frame_init_equations(FILE * fs) {
911 if (active_preset == NULL)
914 len = strlen(active_preset->per_frame_init_eqn_string_buffer);
916 if (fwrite(active_preset->per_frame_init_eqn_string_buffer, 1, len, fs) != len)
923 int write_per_frame_equations(FILE * fs) {
929 if (active_preset == NULL)
932 len = strlen(active_preset->per_frame_eqn_string_buffer);
934 if (fwrite(active_preset->per_frame_eqn_string_buffer, 1, len, fs) != len)
941 int write_per_pixel_equations(FILE * fs) {
947 if (active_preset == NULL)
950 len = strlen(active_preset->per_pixel_eqn_string_buffer);
952 if (fwrite(active_preset->per_pixel_eqn_string_buffer, 1, len, fs) != len)
959 void load_init_conditions() {
961 splay_traverse(load_init_cond, builtin_param_tree);
966 void load_init_cond(param_t * param) {
968 init_cond_t * init_cond;
971 /* Don't count read only parameters as initial conditions */
972 if (param->flags & P_FLAG_READONLY)
975 /* If initial condition was not defined by the preset file, force a default one
976 with the following code */
977 if ((init_cond = splay_find(param->name, active_preset->init_cond_tree)) == NULL) {
979 /* Make sure initial condition does not exist in the set of per frame initial equations */
980 if ((init_cond = splay_find(param->name, active_preset->per_frame_init_eqn_tree)) != NULL)
983 if (param->type == P_TYPE_BOOL)
984 init_val.bool_val = 0;
986 else if (param->type == P_TYPE_INT)
987 init_val.int_val = *(int*)param->engine_val;
989 else if (param->type == P_TYPE_DOUBLE)
990 init_val.double_val = *(double*)param->engine_val;
992 //printf("%s\n", param->name);
993 /* Create new initial condition */
994 if ((init_cond = new_init_cond(param, init_val)) == NULL)
997 /* Insert the initial condition into this presets tree */
998 if (splay_insert(init_cond, init_cond->param->name, active_preset->init_cond_tree) < 0) {
999 free_init_cond(init_cond);
1007 void load_custom_wave_init_conditions() {
1009 splay_traverse(load_custom_wave_init, active_preset->custom_wave_tree);
1013 void load_custom_wave_init(custom_wave_t * custom_wave) {
1015 load_unspecified_init_conds(custom_wave);
1020 void load_custom_shape_init_conditions() {
1022 splay_traverse(load_custom_shape_init, active_preset->custom_shape_tree);
1026 void load_custom_shape_init(custom_shape_t * custom_shape) {
1028 load_unspecified_init_conds_shape(custom_shape);