1 /* Goom Project
2  * Copyright (C) <2003> iOS-Software
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 #ifndef _PLUGIN_INFO_H
20 #define _PLUGIN_INFO_H
21 
22 #include "goom_typedefs.h"
23 
24 #include "goom_config.h"
25 
26 #include "goom_graphic.h"
27 #include "goom_config_param.h"
28 #include "goom_visual_fx.h"
29 #include "goom_filters.h"
30 #include "goom_tools.h"
31 
32 typedef struct {
33 	char drawIFS;
34 	char drawPoints;
35 	char drawTentacle;
36 
37 	char drawScope;
38 	int farScope;
39 
40 	int rangemin;
41 	int rangemax;
42 } GoomState;
43 
44 #define STATES_MAX_NB 128
45 
46 /**
47  * Gives informations about the sound.
48  */
49 struct _SOUND_INFO {
50 
51 	/* nota : a Goom is just a sound event... */
52 
53 	int timeSinceLastGoom;   /* >= 0 */
54 	float goomPower;         /* power of the last Goom [0..1] */
55 
56 	int timeSinceLastBigGoom;   /* >= 0 */
57 
58 	float volume;     /* [0..1] */
59 	short samples[2][512];
60 
61 	/* other "internal" datas for the sound_tester */
62 	float goom_limit; /* auto-updated limit of goom_detection */
63 	float bigGoomLimit;
64 	float accelvar;   /* acceleration of the sound - [0..1] */
65 	float speedvar;   /* speed of the sound - [0..100] */
66 	int allTimesMax;
67 	int totalgoom;    /* number of goom since last reset
68 			   * (a reset every 64 cycles) */
69 
70 	float prov_max;   /* accel max since last reset */
71 
72 	int cycle;
73 
74 	/* private */
75 	PluginParam volume_p;
76 	PluginParam speed_p;
77 	PluginParam accel_p;
78 	PluginParam goom_limit_p;
79         PluginParam goom_power_p;
80 	PluginParam last_goom_p;
81 	PluginParam last_biggoom_p;
82 	PluginParam biggoom_speed_limit_p;
83 	PluginParam biggoom_factor_p;
84 
85 	PluginParameters params; /* contains the previously defined parameters. */
86 };
87 
88 
89 /**
90  * Allows FXs to know the current state of the plugin.
91  */
92 struct _PLUGIN_INFO {
93 
94 	/* public datas */
95 
96 	int nbParams;
97 	PluginParameters *params;
98 
99 	/* private datas */
100 
101 	struct _SIZE_TYPE {
102 		int width;
103 		int height;
104 		int size;   /* == screen.height * screen.width. */
105 	} screen;
106 
107 	SoundInfo sound;
108 
109 	int nbVisuals;
110 	VisualFX **visuals; /* pointers on all the visual fx */
111 
112 	/** The known FX */
113 	VisualFX convolve_fx;
114 	VisualFX star_fx;
115 	VisualFX zoomFilter_fx;
116 	VisualFX tentacles_fx;
117 	VisualFX ifs_fx;
118 
119 	/** image buffers */
120 	guint32 *pixel;
121 	guint32 *back;
122 	Pixel *p1, *p2;
123 	Pixel *conv;
124   Pixel *outputBuf;
125 
126 	/** state of goom */
127 	guint32 cycle;
128 	GoomState states[STATES_MAX_NB];
129 	int statesNumber;
130 	int statesRangeMax;
131 
132 	GoomState *curGState;
133 
134 	/** effet de ligne.. */
135 	GMLine *gmline1;
136 	GMLine *gmline2;
137 
138 	/** sinus table */
139 	int sintable[0x10000];
140 
141 	/* INTERNALS */
142 
143 	/** goom_update internals.
144 	 * I took all static variables from goom_update and put them here.. for the moment.
145 	 */
146 	struct {
147 		int lockvar;               /* pour empecher de nouveaux changements */
148 		int goomvar;               /* boucle des gooms */
149 		int loopvar;               /* mouvement des points */
150 		int stop_lines;
151 		int ifs_incr;              /* dessiner l'ifs (0 = non: > = increment) */
152 		int decay_ifs;             /* disparition de l'ifs */
153 		int recay_ifs;             /* dedisparition de l'ifs */
154 		int cyclesSinceLastChange; /* nombre de Cycle Depuis Dernier Changement */
155 		int drawLinesDuration;     /* duree de la transition entre afficher les lignes ou pas */
156 		int lineMode;              /* l'effet lineaire a dessiner */
157 		float switchMultAmount;    /* SWITCHMULT (29.0f/30.0f) */
158 		int switchIncrAmount;      /* 0x7f */
159 		float switchMult;          /* 1.0f */
160 		int switchIncr;            /*  = SWITCHINCR; */
161 		int stateSelectionRnd;
162 		int stateSelectionBlocker;
163 		int previousZoomSpeed;
164 		ZoomFilterData zoomFilterData;
165 	} update;
166 
167 	struct {
168 		void (*draw_line) (Pixel *data, int x1, int y1, int x2, int y2, int col, int screenx, int screeny);
169 		void (*zoom_filter) (int sizeX, int sizeY, Pixel *src, Pixel *dest, int *brutS, int *brutD, int buffratio, int precalCoef[16][16]);
170 	} methods;
171 
172 	GoomRandom *gRandom;
173 };
174 
175 void plugin_info_init(PluginInfo *p, int nbVisual);
176 void plugin_info_free(PluginInfo *p);
177 
178 /* i = [0..p->nbVisual-1] */
179 void plugin_info_add_visual(PluginInfo *p, int i, VisualFX *visual);
180 
181 #endif
182