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 *****************************************************************************/
33 #include "preset_types.h"
38 #include "expr_types.h"
41 #include "splaytree_types.h"
42 #include "splaytree.h"
43 #include "tree_types.h"
45 #include "per_frame_eqn_types.h"
46 #include "per_frame_eqn.h"
48 #include "per_pixel_eqn_types.h"
49 #include "per_pixel_eqn.h"
51 #include "init_cond_types.h"
52 #include "init_cond.h"
54 #include "param_types.h"
57 #include "func_types.h"
60 #include "custom_wave_types.h"
61 #include "custom_wave.h"
63 #include "custom_shape_types.h"
64 #include "custom_shape.h"
66 #include "idle_preset.h"
68 /* The maximum number of preset names loaded into buffer */
69 #define MAX_PRESETS_IN_DIR 50000
70 extern int per_frame_eqn_count;
71 extern int per_frame_init_eqn_count;
72 //extern int custom_per_frame_eqn_count;
74 extern splaytree_t * builtin_param_tree;
76 preset_t * active_preset = NULL;
77 preset_t * idle_preset = NULL;
78 FILE * write_stream = NULL;
81 int preset_index = -1;
82 int preset_name_buffer_size = 0;
83 splaytree_t * chrono_order_preset_name_tree = NULL;
84 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename);
85 preset_t * load_preset(char * pathname);
86 int is_valid_extension(char * name);
87 int load_preset_file(char * pathname, preset_t * preset);
88 int close_preset(preset_t * preset);
90 int write_preset_name(FILE * fs);
91 int write_per_pixel_equations(FILE * fs);
92 int write_per_frame_equations(FILE * fs);
93 int write_per_frame_init_equations(FILE * fs);
94 int write_init_conditions(FILE * fs);
95 void load_init_cond(param_t * param);
96 void load_init_conditions();
97 void write_init(init_cond_t * init_cond);
98 int init_idle_preset();
99 int destroy_idle_preset();
100 void load_custom_wave_init_conditions();
101 void load_custom_wave_init(custom_wave_t * custom_wave);
103 void load_custom_shape_init_conditions();
104 void load_custom_shape_init(custom_shape_t * custom_shape);
106 /* loadPresetDir: opens the directory buffer
107 denoted by 'dir' to load presets */
109 int loadPresetDir(char * dir) {
111 struct dirent ** name_list;
118 if (chrono_order_preset_name_tree != NULL) {
119 if (PRESET_DEBUG) printf("loadPresetDir: previous directory doesn't appear to be closed!\n");
120 /* Let this slide for now */
123 /* Scan the entire directory, storing each entry in a dirent struct array that needs
124 to be freed later. For more information, consult scandir(3) in the man pages */
125 if ((dir_size = scandir(dir, &name_list, 0, alphasort)) < 0) {
126 if (PRESET_DEBUG) printf("loadPresetDir: failed to open directory \"%s\"\n", dir);
130 chrono_order_preset_name_tree = create_splaytree(compare_int, copy_int, free_int);
132 /* Iterate through entire dirent name list, adding to the preset name list if it
134 for (i = 0; ((i < dir_size) && (i < MAX_PRESETS_IN_DIR));i++) {
136 /* Only perform the next set of operations if the preset name
137 contains a valid extension */
138 if (is_valid_extension(name_list[i]->d_name)) {
140 /* Handle the out of memory case. My guess is xmms would
141 crash before this program would, but whatever...*/
142 if ((preset_name = (char*)malloc(MAX_PATH_SIZE)) == NULL) {
143 if (PRESET_DEBUG) printf("loadPresetDir: out of memory! \n");
145 /* Free the rest of the dirent name list */
146 for (j = i; j < dir_size; j++)
148 destroy_splaytree(chrono_order_preset_name_tree);
149 return OUTOFMEM_ERROR;
152 /* Now create the full path */
153 if (get_preset_path(&preset_name, dir, name_list[i]->d_name) < 0) {
154 if (PRESET_DEBUG) printf("loadPresetDir: failed to generate full preset path name!\n");
156 /* Free the rest of the dirent name list */
157 for (j = i; j < dir_size; j++)
159 destroy_splaytree(chrono_order_preset_name_tree);
160 return OUTOFMEM_ERROR;
164 /* Insert the character string into the splay tree, with the key being its sequence number */
165 splay_insert(preset_name, &preset_name_buffer_size, chrono_order_preset_name_tree);
166 preset_name_buffer_size++;
169 /* Free the dirent struct */
176 /* No valid files in directory! */
177 if (chrono_order_preset_name_tree->root == NULL) {
178 if (PRESET_DEBUG) printf("loadPresetDir: no valid files in directory \"%s\"\n", dir);
179 destroy_splaytree(chrono_order_preset_name_tree);
180 chrono_order_preset_name_tree = NULL;
184 /* Start the prefix index right before the first entry, so next preset
185 starts at the top of the list */
188 /* Start the first preset */
190 switchPreset(ALPHA_NEXT, HARD_CUT);
195 /* closePresetDir: closes the current
196 preset directory buffer */
198 int closePresetDir() {
200 /* No preset director appears to be loaded */
201 if (chrono_order_preset_name_tree == NULL)
205 printf("closePresetDir: freeing directory buffer...");
209 /* Free each entry in the directory preset name tree */
210 splay_traverse(free_int, chrono_order_preset_name_tree);
212 /* Destroy the chronological order splay tree */
213 destroy_splaytree(chrono_order_preset_name_tree);
214 chrono_order_preset_name_tree = NULL;
215 preset_name_buffer_size = 0;
216 if (PRESET_DEBUG) printf("finished\n");
223 /* Converts a preset file name to a full path */
224 int get_preset_path(char ** preset_path_ptr, char * filepath, char * filename) {
228 /* An insanely paranoid sequence of argument checks */
229 if (preset_path_ptr == NULL)
231 if (*preset_path_ptr == NULL)
233 if (filename == NULL)
235 if (filepath == NULL)
238 /* Mostly here for looks */
239 preset_path = *preset_path_ptr;
241 /* Clear the name space first */
242 memset(preset_path, 0, MAX_PATH_SIZE);
244 /* Now create the string "PATH/FILENAME", where path is either absolute or relative location
245 of the .milk file, and filename is the name of the preset file itself */
258 /* switchPreset: loads the next preset from the directory stream.
259 loadPresetDir() must be called first. This is a
260 sequential load function */
262 int switchPreset(switch_mode_t switch_mode, int cut_type) {
264 preset_t * new_preset;
268 /* Make sure a preset directory list is in the buffer */
269 if (chrono_order_preset_name_tree == NULL) {
270 if (PRESET_DEBUG) printf("switchPreset: it helps if you open a directory first with a loadPresetDir() call\n");
275 switch (switch_mode) {
278 /* An index variable that iterates through the directory
279 buffer, doing wrap around when it reaches the end of
282 if (preset_index == (preset_name_buffer_size - 1))
283 switch_index = preset_index = 0;
285 switch_index = ++preset_index;
290 if (preset_index == 0)
291 switch_index = preset_index = preset_name_buffer_size - 1;
293 switch_index = --preset_index;
297 switch_index = (int) (preset_name_buffer_size*(rand()/(RAND_MAX+1.0)));
300 switch_index = preset_index;
307 /* Finally, load the preset using its actual path */
308 if ((new_preset = load_preset((char*)splay_find(&switch_index, chrono_order_preset_name_tree))) == NULL) {
309 if (PRESET_DEBUG) printf("switchPreset: failed to load preset\n");
313 /* Closes a preset currently loaded, if any */
314 if ((active_preset != NULL) && (active_preset != idle_preset))
315 close_preset(active_preset);
317 /* Sets global active_preset pointer */
318 active_preset = new_preset;
321 /* Reinitialize the engine variables to sane defaults */
324 /* Add any missing initial conditions */
325 load_init_conditions();
327 /* Add any missing initial conditions for each wave */
328 load_custom_wave_init_conditions();
330 /* Add any missing initial conditions for each shape */
331 load_custom_shape_init_conditions();
333 /* Need to evaluate the initial conditions once */
334 evalInitConditions();
337 // evalInitPerFrameEquations();
341 /* Loads a specific preset by absolute path */
342 int loadPresetByFile(char * filename) {
344 preset_t * new_preset;
346 /* Finally, load the preset using its actual path */
347 if ((new_preset = load_preset(filename)) == NULL) {
348 if (PRESET_DEBUG) printf("loadPresetByFile: failed to load preset!\n");
352 /* Closes a preset currently loaded, if any */
353 if ((active_preset != NULL) && (active_preset != idle_preset))
354 close_preset(active_preset);
356 /* Sets active preset global pointer */
357 active_preset = new_preset;
359 /* Reinitialize engine variables */
363 /* Add any missing initial conditions for each wave */
364 load_custom_wave_init_conditions();
366 /* Add any missing initial conditions for each wave */
367 load_custom_shape_init_conditions();
369 /* Add any missing initial conditions */
370 load_init_conditions();
372 /* Need to do this once for menu */
373 evalInitConditions();
374 // evalPerFrameInitEquations();
379 int init_idle_preset() {
384 /* Initialize idle preset struct */
385 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
389 strncpy(preset->name, "idlepreset", strlen("idlepreset"));
391 /* Initialize equation trees */
392 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
393 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
394 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
395 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
396 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
397 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
398 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
400 /* Set file path to dummy name */
401 strncpy(preset->file_path, "IDLE PRESET", MAX_PATH_SIZE-1);
403 /* Set initial index values */
404 preset->per_pixel_eqn_string_index = 0;
405 preset->per_frame_eqn_string_index = 0;
406 preset->per_frame_init_eqn_string_index = 0;
407 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
409 /* Clear string buffers */
410 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
411 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
412 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
414 idle_preset = preset;
419 int destroy_idle_preset() {
421 return close_preset(idle_preset);
425 /* initPresetLoader: initializes the preset
426 loading library. this should be done before
428 int initPresetLoader() {
430 /* Initializes the builtin parameter database */
431 init_builtin_param_db();
433 /* Initializes the builtin function database */
434 init_builtin_func_db();
436 /* Initializes all infix operators */
439 /* Set the seed to the current time in seconds */
442 /* Initialize the 'idle' preset */
449 active_preset = idle_preset;
450 load_init_conditions();
453 if (PRESET_DEBUG) printf("initPresetLoader: finished\n");
457 /* Sort of experimental code here. This switches
458 to a hard coded preset. Useful if preset directory
459 was not properly loaded, or a preset fails to parse */
461 void switchToIdlePreset() {
464 /* Idle Preset already activated */
465 if (active_preset == idle_preset)
469 /* Close active preset */
470 if (active_preset != NULL)
471 close_preset(active_preset);
473 /* Sets global active_preset pointer */
474 active_preset = idle_preset;
476 /* Reinitialize the engine variables to sane defaults */
479 /* Add any missing initial conditions */
480 load_init_conditions();
482 /* Need to evaluate the initial conditions once */
483 evalInitConditions();
487 /* destroyPresetLoader: closes the preset
488 loading library. This should be done when
489 projectM does cleanup */
491 int destroyPresetLoader() {
493 if ((active_preset != NULL) && (active_preset != idle_preset)) {
494 close_preset(active_preset);
497 active_preset = NULL;
499 destroy_idle_preset();
500 destroy_builtin_param_db();
501 destroy_builtin_func_db();
508 /* load_preset_file: private function that loads a specific preset denoted
509 by the given pathname */
510 int load_preset_file(char * pathname, preset_t * preset) {
514 if (pathname == NULL)
519 /* Open the file corresponding to pathname */
520 if ((fs = utf8_fopen(pathname, "r")) == 0) {
521 if (PRESET_DEBUG) printf("load_preset_file: loading of file %s failed!\n", pathname);
525 if (PRESET_DEBUG) printf("load_preset_file: file stream \"%s\" opened successfully\n", pathname);
527 /* Parse any comments */
528 if (parse_top_comment(fs) < 0) {
529 if (PRESET_DEBUG) printf("load_preset_file: no left bracket found...\n");
534 /* Parse the preset name and a left bracket */
535 if (parse_preset_name(fs, preset->name) < 0) {
536 if (PRESET_DEBUG) printf("load_preset_file: loading of preset name in file \"%s\" failed\n", pathname);
541 if (PRESET_DEBUG) printf("load_preset_file: preset \"%s\" parsed\n", preset->name);
543 /* Parse each line until end of file */
544 if (PRESET_DEBUG) printf("load_preset_file: beginning line parsing...\n");
545 while ((retval = parse_line(fs, preset)) != EOF) {
546 if (retval == PARSE_ERROR) {
547 if (PRESET_DEBUG > 1) printf("load_preset_file: parse error in file \"%s\"\n", pathname);
551 if (PRESET_DEBUG) printf("load_preset_file: finished line parsing successfully\n");
553 /* Now the preset has been loaded.
554 Evaluation calls can be made at appropiate
555 times in the frame loop */
559 if (PRESET_DEBUG) printf("load_preset_file: file \"%s\" closed, preset ready\n", pathname);
564 void evalInitConditions() {
565 splay_traverse(eval_init_cond, active_preset->init_cond_tree);
566 splay_traverse(eval_init_cond, active_preset->per_frame_init_eqn_tree);
569 void evalPerFrameEquations() {
570 splay_traverse(eval_per_frame_eqn, active_preset->per_frame_eqn_tree);
573 void evalPerFrameInitEquations() {
574 //printf("evalPerFrameInitEquations: per frame init unimplemented!\n");
575 // splay_traverse(eval_per_frame_eqn, active_preset->per_frame_init_eqn_tree);
578 /* Returns nonzero if string 'name' contains .milk or
579 (the better) .prjm extension. Not a very strong function currently */
580 int is_valid_extension(char * name) {
582 if (PRESET_DEBUG > 1) {
583 printf("is_valid_extension: scanning string \"%s\"...", name);
587 if (strstr(name, MILKDROP_FILE_EXTENSION)) {
588 if (PRESET_DEBUG > 1) printf("\".milk\" extension found in string [true]\n");
592 if (strstr(name, PROJECTM_FILE_EXTENSION)) {
593 if (PRESET_DEBUG > 1) printf("\".prjm\" extension found in string [true]\n");
597 if (PRESET_DEBUG > 1) printf("no valid extension found [false]\n");
601 /* Private function to close a preset file */
602 int close_preset(preset_t * preset) {
608 splay_traverse(free_init_cond, preset->init_cond_tree);
609 destroy_splaytree(preset->init_cond_tree);
611 splay_traverse(free_init_cond, preset->per_frame_init_eqn_tree);
612 destroy_splaytree(preset->per_frame_init_eqn_tree);
614 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
615 destroy_splaytree(preset->per_pixel_eqn_tree);
617 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
618 destroy_splaytree(preset->per_frame_eqn_tree);
620 splay_traverse(free_param, preset->user_param_tree);
621 destroy_splaytree(preset->user_param_tree);
623 splay_traverse(free_custom_wave, preset->custom_wave_tree);
624 destroy_splaytree(preset->custom_wave_tree);
626 splay_traverse(free_custom_shape, preset->custom_shape_tree);
627 destroy_splaytree(preset->custom_shape_tree);
635 void reloadPerPixel(char *s, preset_t * preset) {
648 /* Clear previous per pixel equations */
649 splay_traverse(free_per_pixel_eqn, preset->per_pixel_eqn_tree);
650 destroy_splaytree(preset->per_pixel_eqn_tree);
651 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
653 /* Convert string to a stream */
654 fs = fmemopen (s, strlen(s), "r");
656 while ((c = fgetc(fs)) != EOF) {
658 parse_per_pixel_eqn(fs, preset);
663 /* Clear string space */
664 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
666 /* Compute length of string */
669 /* Copy new string into buffer */
670 strncpy(preset->per_pixel_eqn_string_buffer, s, slen);
672 /* Yet again no bounds checking */
673 preset->per_pixel_eqn_string_index = slen;
680 /* Obviously unwritten */
681 void reloadPerFrameInit(char *s, preset_t * preset) {
685 void reloadPerFrame(char * s, preset_t * preset) {
691 per_frame_eqn_t * per_frame;
699 /* Clear previous per frame equations */
700 splay_traverse(free_per_frame_eqn, preset->per_frame_eqn_tree);
701 destroy_splaytree(preset->per_frame_eqn_tree);
702 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
704 /* Convert string to a stream */
705 fs = fmemopen (s, strlen(s), "r");
707 while ((c = fgetc(fs)) != EOF) {
709 if ((per_frame = parse_per_frame_eqn(fs, eqn_count, preset)) != NULL) {
710 splay_insert(per_frame, &eqn_count, preset->per_frame_eqn_tree);
717 /* Clear string space */
718 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
720 /* Compute length of string */
723 /* Copy new string into buffer */
724 strncpy(preset->per_frame_eqn_string_buffer, s, slen);
726 /* Yet again no bounds checking */
727 preset->per_frame_eqn_string_index = slen;
730 printf("reloadPerFrame: %d eqns parsed succesfully\n", eqn_count-1);
735 preset_t * load_preset(char * pathname) {
740 /* Initialize preset struct */
741 if ((preset = (preset_t*)malloc(sizeof(preset_t))) == NULL)
744 /* Initialize equation trees */
745 preset->init_cond_tree = create_splaytree(compare_string, copy_string, free_string);
746 preset->user_param_tree = create_splaytree(compare_string, copy_string, free_string);
747 preset->per_frame_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
748 preset->per_pixel_eqn_tree = create_splaytree(compare_int, copy_int, free_int);
749 preset->per_frame_init_eqn_tree = create_splaytree(compare_string, copy_string, free_string);
750 preset->custom_wave_tree = create_splaytree(compare_int, copy_int, free_int);
751 preset->custom_shape_tree = create_splaytree(compare_int, copy_int, free_int);
753 memset(preset->per_pixel_flag, 0, sizeof(int)*NUM_OPS);
756 strncpy(preset->file_path, pathname, MAX_PATH_SIZE-1);
758 /* Set initial index values */
759 preset->per_pixel_eqn_string_index = 0;
760 preset->per_frame_eqn_string_index = 0;
761 preset->per_frame_init_eqn_string_index = 0;
764 /* Clear string buffers */
765 memset(preset->per_pixel_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
766 memset(preset->per_frame_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
767 memset(preset->per_frame_init_eqn_string_buffer, 0, STRING_BUFFER_SIZE);
770 if (load_preset_file(pathname, preset) < 0) {
771 if (PRESET_DEBUG) printf("load_preset: failed to load file \"%s\"\n", pathname);
772 close_preset(preset);
776 /* It's kind of ugly to reset these values here. Should definitely be placed in the parser somewhere */
777 per_frame_eqn_count = 0;
778 per_frame_init_eqn_count = 0;
780 /* Finished, return new preset */
784 void savePreset(char * filename) {
788 if (filename == NULL)
791 /* Open the file corresponding to pathname */
792 if ((fs = utf8_fopen(filename, "w+")) == 0) {
793 if (PRESET_DEBUG) printf("savePreset: failed to create filename \"%s\"!\n", filename);
799 if (write_preset_name(fs) < 0) {
805 if (write_init_conditions(fs) < 0) {
811 if (write_per_frame_init_equations(fs) < 0) {
817 if (write_per_frame_equations(fs) < 0) {
823 if (write_per_pixel_equations(fs) < 0) {
834 int write_preset_name(FILE * fs) {
844 /* Format the preset name in a string */
845 sprintf(s, "[%s]\n", active_preset->name);
849 /* Write preset name to file stream */
850 if (fwrite(s, 1, len, fs) != len)
857 int write_init_conditions(FILE * fs) {
861 if (active_preset == NULL)
865 splay_traverse(write_init, active_preset->init_cond_tree);
870 void write_init(init_cond_t * init_cond) {
875 if (write_stream == NULL)
880 if (init_cond->param->type == P_TYPE_BOOL)
881 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.bool_val);
883 else if (init_cond->param->type == P_TYPE_INT)
884 sprintf(s, "%s=%d\n", init_cond->param->name, init_cond->init_val.int_val);
886 else if (init_cond->param->type == P_TYPE_DOUBLE)
888 lldiv_t div = lldiv( init_cond->init_val.double_val * 1000000,1000000 );
889 sprintf(s, "%s="I64Fd".%06u\n", init_cond->param->name, div.quot,
890 (unsigned int) div.rem );
893 else { printf("write_init: unknown parameter type!\n"); return; }
897 if ((fwrite(s, 1, len, write_stream)) != len)
898 printf("write_init: failed writing to file stream! Out of disk space?\n");
903 int write_per_frame_init_equations(FILE * fs) {
909 if (active_preset == NULL)
912 len = strlen(active_preset->per_frame_init_eqn_string_buffer);
914 if (fwrite(active_preset->per_frame_init_eqn_string_buffer, 1, len, fs) != len)
921 int write_per_frame_equations(FILE * fs) {
927 if (active_preset == NULL)
930 len = strlen(active_preset->per_frame_eqn_string_buffer);
932 if (fwrite(active_preset->per_frame_eqn_string_buffer, 1, len, fs) != len)
939 int write_per_pixel_equations(FILE * fs) {
945 if (active_preset == NULL)
948 len = strlen(active_preset->per_pixel_eqn_string_buffer);
950 if (fwrite(active_preset->per_pixel_eqn_string_buffer, 1, len, fs) != len)
957 void load_init_conditions() {
959 splay_traverse(load_init_cond, builtin_param_tree);
964 void load_init_cond(param_t * param) {
966 init_cond_t * init_cond;
969 /* Don't count read only parameters as initial conditions */
970 if (param->flags & P_FLAG_READONLY)
973 /* If initial condition was not defined by the preset file, force a default one
974 with the following code */
975 if ((init_cond = splay_find(param->name, active_preset->init_cond_tree)) == NULL) {
977 /* Make sure initial condition does not exist in the set of per frame initial equations */
978 if ((init_cond = splay_find(param->name, active_preset->per_frame_init_eqn_tree)) != NULL)
981 if (param->type == P_TYPE_BOOL)
982 init_val.bool_val = 0;
984 else if (param->type == P_TYPE_INT)
985 init_val.int_val = *(int*)param->engine_val;
987 else if (param->type == P_TYPE_DOUBLE)
988 init_val.double_val = *(double*)param->engine_val;
990 //printf("%s\n", param->name);
991 /* Create new initial condition */
992 if ((init_cond = new_init_cond(param, init_val)) == NULL)
995 /* Insert the initial condition into this presets tree */
996 if (splay_insert(init_cond, init_cond->param->name, active_preset->init_cond_tree) < 0) {
997 free_init_cond(init_cond);
1005 void load_custom_wave_init_conditions() {
1007 splay_traverse(load_custom_wave_init, active_preset->custom_wave_tree);
1011 void load_custom_wave_init(custom_wave_t * custom_wave) {
1013 load_unspecified_init_conds(custom_wave);
1018 void load_custom_shape_init_conditions() {
1020 splay_traverse(load_custom_shape_init, active_preset->custom_shape_tree);
1024 void load_custom_shape_init(custom_shape_t * custom_shape) {
1026 load_unspecified_init_conds_shape(custom_shape);