⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 custom_wave.c

📁 video linux conference
💻 C
📖 第 1 页 / 共 2 页
字号:
/***************************************************************************** * custom_wave.c: ***************************************************************************** * Copyright (C) 2004 VideoLAN * $Id: custom_wave.c 10101 2005-03-02 16:47:31Z robux4 $ * * Authors: Cyril Deguet <asmax@videolan.org> *          code from projectM http://xmms-projectm.sourceforge.net * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA. *****************************************************************************/#include <stdio.h>#include <string.h>#include <stdlib.h>#include "common.h"#include "fatal.h"#include "param_types.h"#include "param.h"#include "expr_types.h"#include "eval.h"#include "splaytree_types.h"#include "splaytree.h"#include "tree_types.h"#include "per_frame_eqn_types.h"#include "per_frame_eqn.h"#include "init_cond_types.h"#include "init_cond.h"#include "preset_types.h"#include "custom_wave_types.h"#include "custom_wave.h"#include "init_cond_types.h"#include "init_cond.h"#include "engine_vars.h"#define MAX_SAMPLE_SIZE 4096extern int mesh_i;custom_wave_t * interface_wave = NULL;int interface_id = 0;extern preset_t * active_preset;inline void eval_custom_wave_init_conds(custom_wave_t * custom_wave);void load_unspec_init_cond(param_t * param);void destroy_per_point_eqn_tree(splaytree_t * tree);void destroy_param_db_tree(splaytree_t * tree);void destroy_per_frame_eqn_tree(splaytree_t * tree);void destroy_per_frame_init_eqn_tree(splaytree_t * tree);void destroy_init_cond_tree(splaytree_t * tree);inline void evalPerPointEqn(per_point_eqn_t * per_point_eqn);custom_wave_t * new_custom_wave(int id) {  custom_wave_t * custom_wave;  param_t * param;    if ((custom_wave = (custom_wave_t*)malloc(sizeof(custom_wave_t))) == NULL)    return NULL;  custom_wave->id = id;  custom_wave->per_frame_count = 0;  custom_wave->samples = 512;  custom_wave->bSpectrum = 0;  custom_wave->enabled = 1;  custom_wave->sep = 1;  custom_wave->smoothing = 0.0;  custom_wave->bUseDots = 0;  custom_wave->bAdditive = 0;  custom_wave->r = custom_wave->g = custom_wave->b = custom_wave->a = 0.0;  custom_wave->scaling = 1.0;  custom_wave->per_frame_eqn_string_index = 0;  custom_wave->per_frame_init_eqn_string_index = 0;  custom_wave->per_point_eqn_string_index = 0;  custom_wave->r_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double));  custom_wave->g_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double));  custom_wave->b_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double));  custom_wave->a_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double));  custom_wave->x_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double));  custom_wave->y_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double));  custom_wave->value1 = malloc(MAX_SAMPLE_SIZE*sizeof(double));  custom_wave->value2 = malloc(MAX_SAMPLE_SIZE*sizeof(double));  custom_wave->sample_mesh = malloc(MAX_SAMPLE_SIZE*sizeof(double));  /* Initialize tree data structures */    if ((custom_wave->param_tree =        create_splaytree(compare_string, copy_string, free_string)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if ((custom_wave->per_point_eqn_tree =        create_splaytree(compare_int, copy_int, free_int)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if ((custom_wave->per_frame_eqn_tree =        create_splaytree(compare_int, copy_int, free_int)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if ((custom_wave->init_cond_tree =        create_splaytree(compare_string, copy_string, free_string)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }    if ((custom_wave->per_frame_init_eqn_tree =        create_splaytree(compare_string, copy_string, free_string)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }    /* Start: Load custom wave parameters */  if ((param = new_param_double("r", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->r, custom_wave->r_mesh, 1.0, 0.0, .5)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }   if ((param = new_param_double("g", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->g,  custom_wave->g_mesh, 1.0, 0.0, .5)) == NULL){    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("b", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->b,  custom_wave->b_mesh, 1.0, 0.0, .5)) == NULL){    free_custom_wave(custom_wave);    return NULL;				         }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("a", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->a,  custom_wave->a_mesh, 1.0, 0.0, .5)) == NULL){    free_custom_wave(custom_wave);    return NULL;  }    if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("x", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->x,  custom_wave->x_mesh, 1.0, 0.0, .5)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("y", P_FLAG_DONT_FREE_MATRIX | P_FLAG_PER_POINT, &custom_wave->y,  custom_wave->y_mesh, 1.0, 0.0, .5)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_bool("enabled", P_FLAG_NONE, &custom_wave->enabled, 1, 0, 0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_int("sep", P_FLAG_NONE, &custom_wave->sep, 100, -100, 0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_bool("bSpectrum", P_FLAG_NONE, &custom_wave->bSpectrum, 1, 0, 0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_bool("bDrawThick", P_FLAG_NONE, &custom_wave->bDrawThick, 1, 0, 0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_bool("bUseDots", P_FLAG_NONE, &custom_wave->bUseDots, 1, 0, 0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }   if ((param = new_param_bool("bAdditive", P_FLAG_NONE, &custom_wave->bAdditive, 1, 0, 0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_int("samples", P_FLAG_NONE, &custom_wave->samples, 2048, 1, 512)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }   if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("sample", P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX | P_FLAG_ALWAYS_MATRIX | P_FLAG_PER_POINT,				&custom_wave->sample, custom_wave->sample_mesh, 1.0, 0.0, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    printf("failed to insert sample\n");    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("value1", P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX | P_FLAG_ALWAYS_MATRIX | P_FLAG_PER_POINT, &custom_wave->v1, custom_wave->value1, 1.0, -1.0, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("value2", P_FLAG_READONLY | P_FLAG_DONT_FREE_MATRIX | P_FLAG_ALWAYS_MATRIX | P_FLAG_PER_POINT, &custom_wave->v2, custom_wave->value2, 1.0, -1.0, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("smoothing", P_FLAG_NONE, &custom_wave->smoothing, NULL, 1.0, 0.0, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("scaling", P_FLAG_NONE, &custom_wave->scaling, NULL, MAX_DOUBLE_SIZE, 0.0, 1.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }   if ((param = new_param_double("t1", P_FLAG_PER_POINT | P_FLAG_TVAR, &custom_wave->t1, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("t2",  P_FLAG_PER_POINT |P_FLAG_TVAR, &custom_wave->t2, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("t3",  P_FLAG_PER_POINT |P_FLAG_TVAR, &custom_wave->t3, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("t4",  P_FLAG_PER_POINT |P_FLAG_TVAR, &custom_wave->t4, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }  if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("t5", P_FLAG_TVAR, &custom_wave->t5, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) {    free_custom_wave(custom_wave);    return NULL;  }   if (insert_param(param, custom_wave->param_tree) < 0) {    free_custom_wave(custom_wave);    return NULL;  }  if ((param = new_param_double("t6", P_FLAG_TVAR | P_FLAG_PER_POINT, &custom_wave->t6, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -