aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2009-04-24 04:16:56 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2009-04-24 04:16:56 +0000
commit0ed2e0aa2d03af0a2bc6c594aee46511a0758df8 (patch)
treef9107f04979bf3bbdd88ae09b68fa7a4b8a04d90
parented884cfd2d33f197c7c4625f05b84e8a9e9597c3 (diff)
- completed the port of Ville Pulkki's vbap 1.0.3, it builds and works in Pd
- removed gain inlet/outlet since its stupid. Just use a [*~] on the input source, its really the same thing, there is no difference. - added a third argument for the default 'spread' value - updated help patches somewhat svn path=/trunk/externals/vbap/; revision=11110
-rw-r--r--define_loudspeakers-help.pd38
-rw-r--r--vbap-help.pd107
-rw-r--r--vbap.c44
-rw-r--r--vbap.h3
4 files changed, 115 insertions, 77 deletions
diff --git a/define_loudspeakers-help.pd b/define_loudspeakers-help.pd
index 44ccce1..ad4524f 100644
--- a/define_loudspeakers-help.pd
+++ b/define_loudspeakers-help.pd
@@ -1,20 +1,36 @@
-#N canvas 413 238 598 438 10;
-#X text 113 179 In two dimensions \, only specify the azimuth. (for
+#N canvas 95 333 792 481 10;
+#X text 22 149 In two dimensions \, only specify the azimuth. (for
example "define_loudspeakers 2 -45 45 0 180";
-#X obj 15 276 define_loudspeakers 3 -45 0 45 0 0 45 180 45;
-#X msg 15 250 bang;
-#X obj 339 275 define_loudspeakers 2 -45 45 0 180;
-#X obj 290 359 vbap 0 0;
-#X text 113 39 [define_loudspeakers] works with;
-#X obj 345 39 vbap;
-#X obj 488 150 vbap;
-#X text 114 81 Use [define_loudspeakers] to list the speaker positions.
+#X obj 48 228 define_loudspeakers 3 -45 0 45 0 0 45 180 45;
+#X msg 48 207 bang;
+#X obj 148 280 define_loudspeakers 2 -45 45 0 180;
+#X obj 112 322 vbap 0 0;
+#X text 23 19 [define_loudspeakers] works with;
+#X obj 255 19 vbap;
+#X text 18 50 Use [define_loudspeakers] to list the speaker positions.
The example here defines loudspeakers in three dimensions (the first
parameter). For each speaker \, define its azimuth and elevation. Here
we have speakers front left and right with no elevation (-45 0 45 0)
and front and back with 45 degrees of elevation (0 45 180 45). Send
the data to:;
-#X text 214 392 (see [vbap] for more details);
+#X text 36 355 (see [vbap] for more details);
+#X msg 410 336 ls-directions 3 -30 0 30 0 -90 0 90 0 0 0 -150 0 150
+0 180 45 -45 45 45 45;
+#X msg 399 273 ls-triplets 1 2 7 2 7 8 1 3 7;
+#X obj 399 418 define_loudspeakers 2 -40 0 40 80 130 180 -130 -80;
+#X text 395 228 If you are not happy with triangle selections of define_loudspeakers
+\, you can define your own. (for experts only);
+#X text 415 383 2-D setup -> only loudspeaker azimuths specified:;
+#X text 414 398 (2 azi1 azi2 azi3 azi4...);
+#X text 411 302 3-D setup -> (azimuth elevation) pairs are specified:
+;
+#X text 411 317 (3 azi1 ele1 azi2 ele2 ...);
+#X msg 148 259 bang;
+#X text 190 259 a 2D setup;
+#X text 93 212 a 3D setup;
#X connect 1 0 4 0;
#X connect 2 0 1 0;
#X connect 3 0 4 0;
+#X connect 9 0 11 0;
+#X connect 10 0 11 0;
+#X connect 17 0 3 0;
diff --git a/vbap-help.pd b/vbap-help.pd
index 20696bb..a73a224 100644
--- a/vbap-help.pd
+++ b/vbap-help.pd
@@ -1,53 +1,66 @@
-#N canvas 91 360 953 497 10;
-#X obj 112 257 vbap 0 0;
-#X obj 134 319 print;
-#X obj 62 113 define_loudspeakers 3 -45 0 45 0 0 45 180 45;
-#X msg 62 87 bang;
-#X text 442 79 1 Use define_loudspeakers to list the speaker positions.
-The example here defines loudspeakers in three dimensions (the first
-parameter). For each speaker \, define its azimuth and elevation. Here
-we have speakers front left and right with no elevation (-45 0 45 0)
-and front and back with 45 degrees of elevation (0 45 180 45). Send
-the data to vbap.;
-#X floatatom 129 223 5 0 0 0 - - -;
-#X floatatom 173 223 5 0 0 0 - - -;
-#X floatatom 217 223 5 0 0 0 - - -;
-#X msg 112 179 bang;
-#X obj 112 356 route 0 1 2 3;
-#X floatatom 112 415 10 0 0 0 - - -;
-#X floatatom 191 415 10 0 0 0 - - -;
-#X floatatom 270 415 10 0 0 0 - - -;
-#X floatatom 349 415 10 0 0 0 - - -;
-#X text 442 169 In two dimensions \, only specify the azimuth. (for
+#N canvas 121 22 818 496 10;
+#X floatatom 129 208 5 0 0 2 - - -;
+#X floatatom 167 227 5 0 0 2 - - -;
+#X msg 101 158 bang;
+#X obj 102 396 route 0 1 2 3;
+#X floatatom 102 445 10 0 0 0 - - -;
+#X floatatom 181 445 10 0 0 0 - - -;
+#X floatatom 260 445 10 0 0 0 - - -;
+#X floatatom 339 445 10 0 0 0 - - -;
+#X text 441 159 In two dimensions \, only specify the azimuth. (for
example "define_loudspeakers 2 -45 45 0 180";
-#X text 151 201 azimuth \, elevation and spread;
-#X text 444 352 For an example of how to use vbap with matrix~ from
-zexy-library \, see vbap-demo.pd.;
-#X text 63 21 VBAP and define_loudspeakers;
-#X text 444 300 The spread-parameter can be used to prevent a situation
+#X text 53 21 VBAP and define_loudspeakers;
+#X text 442 281 The spread-parameter can be used to prevent a situation
where sound is coming from one speaker only \, which would make speaker
positions "visible". The range is 0 to 100;
-#X floatatom 152 286 5 0 0 0 - - -;
-#X floatatom 196 286 5 0 0 0 - - -;
-#X floatatom 240 286 5 0 0 0 - - -;
-#X text 178 306 actual location;
-#X text 444 222 2 For vbap \, give azimuth and elevation for the desired
+#X floatatom 199 369 0 0 0 3 actual_azimuth - -;
+#X floatatom 211 335 0 0 0 3 actual_elevation - -;
+#X floatatom 221 314 7 0 0 1 actual_spreading - -;
+#X text 443 202 2 For vbap \, give azimuth and elevation for the desired
location. Bang the first inlet and vbap will output gain-factors for
each speaker and the actual location produced. This can be different
from the desired one depending where your speakers are.;
-#X obj 600 390 vbap-demo;
-#X connect 0 0 1 0;
-#X connect 0 0 9 0;
-#X connect 0 1 19 0;
-#X connect 0 2 20 0;
-#X connect 0 3 21 0;
-#X connect 2 0 0 0;
-#X connect 3 0 2 0;
-#X connect 5 0 0 1;
-#X connect 6 0 0 2;
-#X connect 7 0 0 3;
-#X connect 8 0 0 0;
-#X connect 9 0 10 0;
-#X connect 9 1 11 0;
-#X connect 9 2 12 0;
-#X connect 9 3 13 0;
+#X obj 599 370 vbap-demo;
+#X msg 25 115 define_loudspeakers 2 -45 45 -135 135;
+#X text 24 64 loudspeaker position definition can also be sent directly
+to a vbap object. This changes the setup information only in a single
+vbap object.;
+#X text 443 332 For an example of how to use vbap with [matrix~] from
+zexy-library \, see vbap-demo.pd.;
+#X text 441 59 1 Use the define_loudspeakers object or message to list
+the speaker positions. The example here defines loudspeakers in three
+dimensions (the first parameter). For each speaker \, define its azimuth
+and elevation. Here we have speakers front left and right with no elevation
+(-45 0 45 0) and front and back with 45 degrees of elevation (0 45
+180 45). Send the data to vbap.;
+#X msg 51 135 define_loudspeakers 3 -45 45 -135 135 32 5 94 34 34 11
+;
+#X obj 132 192 hsl 100 13 0 360 0 0 empty empty azimuth 10 7 0 10 -262144
+-1 -1 3800 1;
+#X obj 170 210 hsl 100 13 0 360 0 0 empty empty elevation 10 7 0 10
+-262144 -1 -1 5100 1;
+#X floatatom 207 247 5 0 0 2 - - -;
+#X obj 210 230 hsl 100 13 0 360 0 0 empty empty spread 10 7 0 10 -262144
+-1 -1 2500 1;
+#X text 135 158 to output updated values;
+#X obj 102 277 vbap 90 0 30;
+#X text 450 417 You can also use [vbap] to control Cyclone's [matrix~]
+;
+#X obj 543 440 cyclone/matrix~ 1 4 1;
+#X connect 0 0 26 1;
+#X connect 1 0 26 2;
+#X connect 2 0 26 0;
+#X connect 3 0 4 0;
+#X connect 3 1 5 0;
+#X connect 3 2 6 0;
+#X connect 3 3 7 0;
+#X connect 16 0 26 0;
+#X connect 20 0 26 0;
+#X connect 21 0 0 0;
+#X connect 22 0 1 0;
+#X connect 23 0 26 3;
+#X connect 24 0 23 0;
+#X connect 26 0 3 0;
+#X connect 26 1 11 0;
+#X connect 26 2 12 0;
+#X connect 26 3 13 0;
diff --git a/vbap.c b/vbap.c
index 8eba0c1..f60f331 100644
--- a/vbap.c
+++ b/vbap.c
@@ -3,7 +3,7 @@
written by Ville Pulkki 1999-2003
Helsinki University of Technology
and
-University of California at Berkeley
+University of California at Berkeley
See copyright in file with name COPYRIGHT */
@@ -16,7 +16,7 @@ See copyright in file with name COPYRIGHT */
// Function prototypes
void new_spread_dir(t_vbap *x, float spreaddir[3], float vscartdir[3], float spread_base[3]);
void new_spread_base(t_vbap *x, float spreaddir[3], float vscartdir[3]);
-void *vbap_class;
+static void *vbap_class;
void vect_cross_prod(float v1[3], float v2[3],float v3[3]);
void additive_vbap(float *final_gs, float cartdir[3], t_vbap *x);
void vbap_bang(t_vbap *x);
@@ -28,7 +28,7 @@ void vbap_in3(t_vbap *x, long n);
void vbap_ft4(t_vbap *x, double g);
*/
void spread_it(t_vbap *x, float *final_gs);
-void *vbap_new(float azi,float ele);
+void *vbap_new(float azi, float ele, float spread);
void vbap(float g[3], long ls[3], t_vbap *x);
void angle_to_cart(float azi, float ele, float res[3]);
void cart_to_angle(float cvec[3], float avec[3]);
@@ -76,7 +76,8 @@ void vbap_assist(t_vbap *x, void *b, long m, long a, char *s)
#ifdef PD
void vbap_setup(void)
{
- vbap_class = class_new(gensym("vbap"), (t_newmethod)vbap_new, 0, (short)sizeof(t_vbap), 0, A_GIMME, 0);
+ vbap_class = class_new(gensym("vbap"), (t_newmethod)vbap_new, 0, (short)sizeof(t_vbap), 0,
+ A_DEFFLOAT, A_DEFFLOAT, A_DEFFLOAT, 0);
class_addbang(vbap_class, (t_method)vbap_bang);
/* these are for getting data from a cold inlet on Max/MSP, in Pd you use floatinlet_new() in new()
@@ -98,7 +99,8 @@ void vbap_setup(void)
#else /* MAX */
void main(void)
{
- setup((t_messlist **)&vbap_class, (method)vbap_new, 0L, (short)sizeof(t_vbap), 0L, A_DEFLONG,A_DEFLONG, 0);
+ setup((t_messlist **)&vbap_class, (method)vbap_new, 0L, (short)sizeof(t_vbap), 0L,
+ A_DEFLONG,A_DEFLONG,A_DEFLONG, 0);
addbang((method)vbap_bang);
addftx((method)vbap_ft1, 1);
@@ -136,21 +138,24 @@ void vbap_ft4(t_vbap *x, double g) { x->x_gain = g; }
/*--------------------------------------------------------------------------*/
// create new instance of object...
-void *vbap_new(float azi,float ele)
+#ifdef PD
+void *vbap_new(t_float azi, t_float ele, t_float spread)
{
t_vbap *x = (t_vbap *)newobject(vbap_class);
-#ifdef PD
floatinlet_new(&x->x_obj, &x->x_azi);
floatinlet_new(&x->x_obj, &x->x_ele);
floatinlet_new(&x->x_obj, &x->x_spread);
- x->x_outlet4 = outlet_new(&x->x_obj, gensym("float"));
- x->x_outlet3 = outlet_new(&x->x_obj, gensym("float"));
- x->x_outlet2 = outlet_new(&x->x_obj, gensym("float"));
- x->x_outlet1 = outlet_new(&x->x_obj, gensym("float"));
- x->x_outlet0 = outlet_new(&x->x_obj, gensym("list"));
+ x->x_outlet0 = outlet_new(&x->x_obj, &s_float);
+ x->x_outlet1 = outlet_new(&x->x_obj, &s_float);
+ x->x_outlet2 = outlet_new(&x->x_obj, &s_float);
+ x->x_outlet3 = outlet_new(&x->x_obj, &s_float);
#else /* Max */
+void *vbap_new(float azi,float ele)
+{
+ t_vbap *x = (t_vbap *)newobject(vbap_class);
+
floatin(x,4);
floatin(x,3);
floatin(x,2);
@@ -166,12 +171,11 @@ void *vbap_new(float azi,float ele)
x->x_spread_base[0] = 0.0;
x->x_spread_base[1] = 1.0;
x->x_spread_base[2] = 0.0;
- x->x_spread = 0;
+ x->x_spread = spread;
x->x_lsset_available =0;
x->x_azi = azi;
x->x_ele = ele;
- x->x_gain = 1.0;
return(x); /* return a reference to the object instance */
}
@@ -319,7 +323,7 @@ void vbap(float g[3], long ls[3], t_vbap *x)
} else new_cartdir[2] = 0;
cart_to_angle(new_cartdir,new_angle_dir);
x->x_azi = (new_angle_dir[0] );
- post("uus azi %g",x->x_azi );
+ post("[vbap] use azimuth %g",x->x_azi );
x->x_ele = (new_angle_dir[1]);
}
//}
@@ -558,14 +562,20 @@ void vbap_bang(t_vbap *x)
}
for(i=0;i<x->x_ls_amount;i++)
{
+#ifdef PD
+ SETFLOAT(&at[0], (t_float)i);
+ SETFLOAT(&at[1], (t_float)final_gs[i]);
+ outlet_list(x->x_obj.ob_outlet, &s_list, 2, at);
+#else /* Max */
SETLONG(&at[0], i);
- SETFLOAT(&at[1], final_gs[i]*x->x_gain); // gain is applied here
+ SETFLOAT(&at[1], final_gs[i]*x->x_gain); // freeverb gain is applied here
outlet_list(x->x_outlet0, 0L, 2, at);
+#endif /* PD */
}
outlet_float(x->x_outlet1, x->x_azi);
outlet_float(x->x_outlet2, x->x_ele);
outlet_int(x->x_outlet3, x->x_spread);
- outlet_int(x->x_outlet4, x->x_gain);
+ //outlet_int(x->x_outlet4, x->x_gain);
}
else
error("vbap: Configure loudspeakers first!");
diff --git a/vbap.h b/vbap.h
index dc9858b..3da2157 100644
--- a/vbap.h
+++ b/vbap.h
@@ -14,7 +14,7 @@
#define MAX_LS_AMOUNT 55 // maximum amount of loudspeakers, can be increased
#define MIN_VOL_P_SIDE_LGTH 0.01
-#define VBAP_VERSION "vbap - v1.0.3 - 12 Aug 2006 - (c) Ville Pulkki 1999-2006"
+#define VBAP_VERSION "vbap - v1.0.3 - 12 Aug 2006 - (c) Ville Pulkki 1999-2006 (Pd port by HCS)"
#define DFLS_VERSION "define_loudspeakers - v1.0.3 - 12 Aug 2006 - (c) Ville Pulkki 1999-2006"
static float rad2ang = 360.0 / ( 2.0f * M_PI );
@@ -71,7 +71,6 @@ typedef struct t_ls_set
long x_dimension; // 2 or 3
# ifdef PD
t_float x_spread; // speading amount of virtual source (0-100)
- t_float x_gain; // general gain control (0-2)
# else /* Max */
long x_spread; // speading amount of virtual source (0-100)
double x_gain; // general gain control (0-2)