Commit d6008a8b authored by Rafaël Carré's avatar Rafaël Carré

Reverts [21943] for galaktos as it is external to vlc.

Just in case it is merged one day with upstream source.
parent c6eafbbb
......@@ -48,13 +48,13 @@ int new; //how many new samples
void initPCM(int samples)
{
int i;
int i;
//Allocate memory for PCM data buffer
PCMd = (double **)malloc(2 * sizeof(double *));
PCMd[0] = (double *)malloc(samples * sizeof(double));
PCMd[1] = (double *)malloc(samples * sizeof(double));
maxsamples=samples;
new=0;
......@@ -83,15 +83,15 @@ void addPCM(int16_t PCMdata[2][512])
int i,j;
int samples=512;
for(i=0;i<samples;i++)
{
j=i+start;
PCMd[0][j%maxsamples]=(PCMdata[0][i]/16384.0);
PCMd[1][j%maxsamples]=(PCMdata[1][i]/16384.0);
}
for(i=0;i<samples;i++)
{
j=i+start;
PCMd[0][j%maxsamples]=(PCMdata[0][i]/16384.0);
PCMd[1][j%maxsamples]=(PCMdata[1][i]/16384.0);
}
// printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]);
// printf("Added %d samples %d %d %f\n",samples,start,(start+samples)%maxsamples,PCM[0][start+10]);
start+=samples;
start=start%maxsamples;
......@@ -113,28 +113,28 @@ void addPCM(int16_t PCMdata[2][512])
void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothing, int derive)
{
int i,index;
index=start-1;
if (index<0) index=maxsamples+index;
PCMdata[0]=PCMd[channel][index];
for(i=1;i<samples;i++)
{
index=start-1-i;
if (index<0) index=maxsamples+index;
PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1];
}
//return derivative of PCM data
if(derive)
{
for(i=0;i<samples-1;i++)
{
PCMdata[i]=PCMdata[i]-PCMdata[i+1];
}
{
PCMdata[i]=PCMdata[i]-PCMdata[i+1];
}
PCMdata[samples-1]=0;
}
......@@ -142,7 +142,7 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin
if (freq) rdft(samples, 1, PCMdata, ip, w);
}
//getPCMnew
......@@ -154,28 +154,28 @@ void getPCM(double *PCMdata, int samples, int channel, int freq, double smoothin
int getPCMnew(double *PCMdata, int channel, int freq, double smoothing, int derive, int reset)
{
int i,index;
index=start-1;
if (index<0) index=maxsamples+index;
PCMdata[0]=PCMd[channel][index];
for(i=1;i<new;i++)
{
index=start-1-i;
if (index<0) index=maxsamples+index;
PCMdata[i]=(1-smoothing)*PCMd[channel][index]+smoothing*PCMdata[i-1];
}
//return derivative of PCM data
if(derive)
{
for(i=0;i<new-1;i++)
{
PCMdata[i]=PCMdata[i]-PCMdata[i+1];
}
{
PCMdata[i]=PCMdata[i]-PCMdata[i+1];
}
PCMdata[new-1]=0;
}
......
......@@ -41,7 +41,7 @@ double vol_buffer[80],vol_instant,vol_history;
void initBeatDetect()
{
int x,y;
int x,y;
vol_instant=0;
vol_history=0;
......@@ -65,12 +65,12 @@ void initBeatDetect()
beat_att[x]=1.0;
beat_variance[x]=0;
for (y=0;y<80;y++)
{
beat_buffer[x][y]=0;
}
{
beat_buffer[x][y]=0;
}
}
}
}
void getBeatVals(double *vdataL,double *vdataR, double *vol)
{
......@@ -80,29 +80,29 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
vol_instant=0;
for ( x=0;x<16;x++)
{
beat_instant[x]=0;
for ( y=linear*2;y<(linear+8+x)*2;y++)
{
beat_instant[x]+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/(8+x));
vol_instant+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/512.0);
}
linear=y/2;
beat_history[x]-=(beat_buffer[x][beat_buffer_pos])*.0125;
beat_buffer[x][beat_buffer_pos]=beat_instant[x];
beat_history[x]+=(beat_instant[x])*.0125;
beat_val[x]=(beat_instant[x])/(beat_history[x]);
beat_att[x]+=(beat_instant[x])/(beat_history[x]);
}
{
beat_instant[x]=0;
for ( y=linear*2;y<(linear+8+x)*2;y++)
{
beat_instant[x]+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/(8+x));
vol_instant+=((vdataL[y]*vdataL[y])+(vdataR[y]*vdataR[y]))*(1.0/512.0);
}
linear=y/2;
beat_history[x]-=(beat_buffer[x][beat_buffer_pos])*.0125;
beat_buffer[x][beat_buffer_pos]=beat_instant[x];
beat_history[x]+=(beat_instant[x])*.0125;
beat_val[x]=(beat_instant[x])/(beat_history[x]);
beat_att[x]+=(beat_instant[x])/(beat_history[x]);
}
vol_history-=(vol_buffer[beat_buffer_pos])*.0125;
vol_buffer[beat_buffer_pos]=vol_instant;
vol_history+=(vol_instant)*.0125;
......@@ -110,33 +110,33 @@ void getBeatVals(double *vdataL,double *vdataR, double *vol)
double temp2=0;
mid=0;
for(x=1;x<10;x++)
{
mid+=(beat_instant[x]);
temp2+=(beat_history[x]);
}
mid=mid/(1.5*temp2);
temp2=0;
treb=0;
for(x=10;x<16;x++)
{
treb+=(beat_instant[x]);
temp2+=(beat_history[x]);
}
treb=treb/(1.5*temp2);
*vol=vol_instant/(1.5*vol_history);
bass=(beat_instant[0])/(1.5*beat_history[0]);
treb_att=.6 * treb_att + .4 * treb;
mid_att=.6 * mid_att + .4 * mid;
bass_att=.6 * bass_att + .4 * bass;
//printf("%f %f %f %f\n",bass,mid,treb,*vol);
// *vol=(beat_instant[3])/(beat_history[3]);
beat_buffer_pos++;
if( beat_buffer_pos>79)beat_buffer_pos=0;
{
mid+=(beat_instant[x]);
temp2+=(beat_history[x]);
}
mid=mid/(1.5*temp2);
temp2=0;
treb=0;
for(x=10;x<16;x++)
{
treb+=(beat_instant[x]);
temp2+=(beat_history[x]);
}
treb=treb/(1.5*temp2);
*vol=vol_instant/(1.5*vol_history);
bass=(beat_instant[0])/(1.5*beat_history[0]);
treb_att=.6 * treb_att + .4 * treb;
mid_att=.6 * mid_att + .4 * mid;
bass_att=.6 * bass_att + .4 * bass;
//printf("%f %f %f %f\n",bass,mid,treb,*vol);
// *vol=(beat_instant[3])/(beat_history[3]);
beat_buffer_pos++;
if( beat_buffer_pos>79)beat_buffer_pos=0;
}
void freeBeatDetect()
{
......
......@@ -25,8 +25,8 @@
#include <math.h>
/* Values to optimize the sigmoid function */
#define R 32767
#define RR 65534
#define R 32767
#define RR 65534
inline double int_wrapper(double * arg_list) {
......@@ -36,57 +36,57 @@ inline double int_wrapper(double * arg_list) {
inline double sqr_wrapper(double * arg_list) {
return pow(2, arg_list[0]);
}
inline double sign_wrapper(double * arg_list) {
return -arg_list[0];
}
return pow(2, arg_list[0]);
}
inline double sign_wrapper(double * arg_list) {
return -arg_list[0];
}
inline double min_wrapper(double * arg_list) {
if (arg_list[0] > arg_list[1])
return arg_list[1];
return arg_list[0];
}
if (arg_list[0] > arg_list[1])
return arg_list[1];
return arg_list[0];
}
inline double max_wrapper(double * arg_list) {
if (arg_list[0] > arg_list[1])
return arg_list[0];
if (arg_list[0] > arg_list[1])
return arg_list[0];
return arg_list[1];
return arg_list[1];
}
/* consult your AI book */
inline double sigmoid_wrapper(double * arg_list) {
return (RR / (1 + exp( -(((double)(arg_list[0])) * arg_list[1]) / R) - R));
}
inline double bor_wrapper(double * arg_list) {
return (double)((int)arg_list[0] || (int)arg_list[1]);
}
return (double)((int)arg_list[0] || (int)arg_list[1]);
}
inline double band_wrapper(double * arg_list) {
return (double)((int)arg_list[0] && (int)arg_list[1]);
}
return (double)((int)arg_list[0] && (int)arg_list[1]);
}
inline double bnot_wrapper(double * arg_list) {
return (double)(!(int)arg_list[0]);
}
return (double)(!(int)arg_list[0]);
}
inline double if_wrapper(double * arg_list) {
if ((int)arg_list[0] == 0)
return arg_list[2];
return arg_list[1];
}
if ((int)arg_list[0] == 0)
return arg_list[2];
return arg_list[1];
}
inline double rand_wrapper(double * arg_list) {
......@@ -96,48 +96,48 @@ inline double rand_wrapper(double * arg_list) {
l = (double)((rand()) % ((int)arg_list[0]));
//printf("VAL: %f\n", l);
return l;
}
}
inline double equal_wrapper(double * arg_list) {
return (arg_list[0] == arg_list[1]);
}
return (arg_list[0] == arg_list[1]);
}
inline double above_wrapper(double * arg_list) {
return (arg_list[0] > arg_list[1]);
}
return (arg_list[0] > arg_list[1]);
}
inline double below_wrapper(double * arg_list) {
return (arg_list[0] < arg_list[1]);
return (arg_list[0] < arg_list[1]);
}
inline double sin_wrapper(double * arg_list) {
return (sin (arg_list[0]));
return (sin (arg_list[0]));
}
inline double cos_wrapper(double * arg_list) {
return (cos (arg_list[0]));
return (cos (arg_list[0]));
}
inline double tan_wrapper(double * arg_list) {
return (tan(arg_list[0]));
return (tan(arg_list[0]));
}
inline double asin_wrapper(double * arg_list) {
return (asin (arg_list[0]));
return (asin (arg_list[0]));
}
inline double acos_wrapper(double * arg_list) {
return (acos (arg_list[0]));
return (acos (arg_list[0]));
}
inline double atan_wrapper(double * arg_list) {
return (atan (arg_list[0]));
return (atan (arg_list[0]));
}
inline double atan2_wrapper(double * arg_list) {
......@@ -193,9 +193,9 @@ inline double fact_wrapper(double * arg_list) {
int result = 1;
int n = (int)arg_list[0];
while (n > 1) {
result = result * n;
n--;
......
/* Wrappers for all the builtin functions
/* Wrappers for all the builtin functions
The arg_list pointer is a list of doubles. Its
size is equal to the number of arguments the parameter
takes */
......
......@@ -13,7 +13,7 @@
#endif
#ifndef FALSE
#define FALSE 0
#endif
#endif
#define PROJECTM_FILE_EXTENSION ".prjm"
#define MILKDROP_FILE_EXTENSION ".milk"
......
......@@ -77,25 +77,25 @@ custom_shape_t * new_custom_shape(int id) {
/* Initialize tree data structures */
if ((custom_shape->param_tree =
if ((custom_shape->param_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_shape(custom_shape);
return NULL;
}
if ((custom_shape->per_frame_eqn_tree =
if ((custom_shape->per_frame_eqn_tree =
create_splaytree(compare_int, copy_int, free_int)) == NULL) {
free_custom_shape(custom_shape);
return NULL;
}
if ((custom_shape->init_cond_tree =
if ((custom_shape->init_cond_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_shape(custom_shape);
return NULL;
}
if ((custom_shape->per_frame_init_eqn_tree =
if ((custom_shape->per_frame_init_eqn_tree =
create_splaytree(compare_string, copy_string, free_string)) == NULL) {
free_custom_shape(custom_shape);
return NULL;
......@@ -125,7 +125,7 @@ custom_shape_t * new_custom_shape(int id) {
if ((param = new_param_double("b", P_FLAG_NONE, &custom_shape->b, NULL, 1.0, 0.0, .5)) == NULL){
free_custom_shape(custom_shape);
return NULL;
return NULL;
}
if (insert_param(param, custom_shape->param_tree) < 0) {
......@@ -165,7 +165,7 @@ custom_shape_t * new_custom_shape(int id) {
if ((param = new_param_double("border_b", P_FLAG_NONE, &custom_shape->border_b, NULL, 1.0, 0.0, .5)) == NULL){
free_custom_shape(custom_shape);
return NULL;
return NULL;
}
if (insert_param(param, custom_shape->param_tree) < 0) {
......@@ -205,7 +205,7 @@ custom_shape_t * new_custom_shape(int id) {
if ((param = new_param_double("b2", P_FLAG_NONE, &custom_shape->b2, NULL, 1.0, 0.0, .5)) == NULL){
free_custom_shape(custom_shape);
return NULL;
return NULL;
}
if (insert_param(param, custom_shape->param_tree) < 0) {
......@@ -217,7 +217,7 @@ custom_shape_t * new_custom_shape(int id) {
free_custom_shape(custom_shape);
return NULL;
}
if (insert_param(param, custom_shape->param_tree) < 0) {
free_custom_shape(custom_shape);
return NULL;
......@@ -322,7 +322,7 @@ custom_shape_t * new_custom_shape(int id) {
free_custom_shape(custom_shape);
return NULL;
}
if ((param = new_param_double("tex_ang", P_FLAG_NONE, &custom_shape->tex_ang, NULL, MAX_DOUBLE_SIZE, -MAX_DOUBLE_SIZE, 0.0)) == NULL) {
free_custom_shape(custom_shape);
return NULL;
......@@ -409,7 +409,7 @@ custom_shape_t * new_custom_shape(int id) {
}
/* End of parameter loading. Note that the read only parameters associated
with custom shapes (ie, sample) are global variables, and not specific to
with custom shapes (ie, sample) are global variables, and not specific to
the custom shape datastructure. */
......@@ -475,7 +475,7 @@ void free_custom_shape(custom_shape_t * custom_shape) {
destroy_init_cond_tree_shape(custom_shape->init_cond_tree);
destroy_param_db_tree_shape(custom_shape->param_tree);
destroy_per_frame_init_eqn_tree_shape(custom_shape->per_frame_init_eqn_tree);
free(custom_shape);
return;
......@@ -489,32 +489,32 @@ custom_shape_t * find_custom_shape(int id, preset_t * preset, int create_flag) {
if (preset == NULL)
return NULL;
if ((custom_shape = splay_find(&id, preset->custom_shape_tree)) == NULL) {
if (CUSTOM_SHAPE_DEBUG) { printf("find_custom_shape: creating custom shape (id = %d)...", id);fflush(stdout);}
if (create_flag == FALSE) {
if (CUSTOM_SHAPE_DEBUG) printf("you specified not to (create flag = false), returning null\n");
return NULL;
}
if ((custom_shape = new_custom_shape(id)) == NULL) {
if (CUSTOM_SHAPE_DEBUG) printf("failed...out of memory?\n");
return NULL;
}
if (CUSTOM_SHAPE_DEBUG) { printf("success.Inserting..."); fflush(stdout);}
if (splay_insert(custom_shape, &custom_shape->id, preset->custom_shape_tree) < 0) {
if (CUSTOM_SHAPE_DEBUG) printf("failed, probably a duplicated!!\n");
free_custom_shape(custom_shape);
return NULL;
}
if (CUSTOM_SHAPE_DEBUG) printf("done.\n");
}
return custom_shape;
}
......@@ -555,14 +555,14 @@ void load_unspec_init_cond_shape(param_t * param) {
/* If initial condition was not defined by the preset file, force a default one
with the following code */
if ((init_cond = splay_find(param->name, interface_shape->init_cond_tree)) == NULL) {
/* Make sure initial condition does not exist in the set of per frame initial equations */
if ((init_cond = splay_find(param->name, interface_shape->per_frame_init_eqn_tree)) != NULL)
return;
if (param->type == P_TYPE_BOOL)
init_val.bool_val = 0;
else if (param->type == P_TYPE_INT)
init_val.int_val = *(int*)param->engine_val;
......@@ -573,13 +573,13 @@ void load_unspec_init_cond_shape(param_t * param) {
/* Create new initial condition */
if ((init_cond = new_init_cond(param, init_val)) == NULL)
return;
/* Insert the initial condition into this presets tree */
if (splay_insert(init_cond, init_cond->param->name, interface_shape->init_cond_tree) < 0) {
free_init_cond(init_cond);
return;
}
}
}
......
......@@ -23,7 +23,7 @@ typedef struct CUSTOM_SHAPE_T {
double tex_zoom;
double tex_ang;
double x; /* x position for per point equations */
double y; /* y position for per point equations */