[Gridflow-cvs] [svn] commit: r5001 - in /trunk: abstractions/#camera.pd src/quicktimeapple.cxx

gridflow-cvs at artengine.ca gridflow-cvs at artengine.ca
Mon Feb 8 21:08:27 EST 2010


Author: pboivin
Date: Mon Feb  8 21:08:26 2010
New Revision: 5001

Log:
multi-cam support for OSX !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Modified:
    trunk/abstractions/#camera.pd
    trunk/src/quicktimeapple.cxx

Modified: trunk/abstractions/#camera.pd
==============================================================================
--- trunk/abstractions/#camera.pd (original)
+++ trunk/abstractions/#camera.pd Mon Feb  8 21:08:26 2010
@@ -1,116 +1,117 @@
-#N canvas 599 0 420 358 10;
+#N canvas 599 22 420 358 10;
 #X obj 81 31 cnv 15 184 68 empty empty empty 20 12 0 14 -233017 -66577
 0;
 #X obj 143 34 hradio 12 1 0 4 \$0-s_channel \$0-channel _0_1_2_3 -2
 7 1 8 -233017 -195568 -195568 0;
-#N canvas 275 0 906 659 camera 1;
-#X obj 310 510 outlet;
-#X obj 51 9 inlet;
-#X obj 63 198 t a;
-#X msg 700 458 open videodev \$1 \, get;
-#X msg 673 309 size \$1 \$2;
-#X obj 598 8 r \$0-size0;
-#X msg 673 8 120 160;
-#X msg 673 27 120 180;
-#X obj 598 27 r \$0-size1;
-#X msg 673 46 240 320;
-#X msg 673 65 240 360;
-#X obj 598 46 r \$0-size2;
-#X obj 598 65 r \$0-size3;
-#X obj 598 84 r \$0-size4;
-#X obj 598 103 r \$0-size5;
-#X msg 673 84 480 640;
-#X msg 673 103 480 720;
-#X obj 598 122 r \$0-size6;
-#X obj 598 141 r \$0-size7;
-#X msg 673 122 576 720;
-#X msg 673 141 288 352;
-#X obj 673 204 unpack 0 0;
-#X obj 768 223 s \$0-width;
-#X obj 673 223 s \$0-height;
-#X obj 673 271 #pack;
-#X obj 673 290 #to_list;
-#X obj 700 439 makefilename /dev/video%d;
-#X obj 85 419 spigot;
-#X obj 308 579 args (device a -1);
-#X obj 308 617 s \$0-device;
-#X obj 85 441 route pwc;
-#X msg 85 460 pwc \$1 \, get;
-#X obj 51 28 list split 1;
-#X obj 51 47 makefilename \$0-%s;
-#X obj 51 104 s;
-#X obj 51 85 list;
-#X obj 51 66 t b s;
-#X msg 684 482 open dc1394 \, get;
-#X msg 391 363 colorspace \$1;
-#X obj 181 66 list prepend;
-#X obj 181 85 list trim;
-#X obj 174 174 foreach;
-#X obj 174 193 makefilename \$0-%s;
-#X msg 174 212 \; \$1 color 10 20 20;
-#X msg 179 559 \; \$1 color 18 17 22;
-#X obj 122 381 t b a b b;
-#X obj 391 306 s \$0-colorspace_e;
-#X obj 391 325 r \$0-s_colorspace_e;
-#X obj 673 243 r \$0-s_height;
-#X obj 768 243 r \$0-s_width;
-#X obj 656 368 r \$0-s_device;
-#X obj 580 186 r \$0-size;
-#X msg 180 400 0;
-#X msg 122 400 1;
-#X obj 580 205 route2 color;
-#X obj 580 224 s \$0-sizec;
-#X obj 571 243 s \$0-width;
-#X obj 561 263 s \$0-height;
-#X obj 371 265 route2 color;
-#X obj 371 246 r \$0-colorspace;
-#X obj 635 538 s \$0-title;
-#X msg 635 519 label \$1;
-#X obj 563 481 r \$0-name;
-#X obj 563 500 route color;
-#X msg 490 591 close;
-#X msg 490 612 label No_camera_selected;
-#X msg 339 181 label Unknown_camera;
-#X obj 339 200 s \$0-title;
-#X obj 731 8 r \$0-minsize;
-#X obj 731 46 unpack 0 0;
-#X obj 796 65 s \$0-minwidth;
-#X obj 731 84 s \$0-minheight;
-#X obj 731 141 unpack 0 0;
-#X obj 731 103 r \$0-maxsize;
-#X obj 731 179 s \$0-maxheight;
-#X obj 796 160 s \$0-maxwidth;
-#X obj 731 27 route list;
-#X obj 731 122 route list;
-#X obj 393 522 s \$0-minsize;
-#X msg 393 501 0 0;
-#X obj 403 542 s \$0-maxsize;
-#X obj 656 387 t a b;
-#X obj 67 482 r \$0-palette;
-#X obj 139 539 s \$0-palette2;
-#X msg 139 520 label \$1;
-#X obj 25 563 route minsize maxsize;
-#X obj 67 501 route color;
-#X obj 181 8 receives \$0-s_ channel tuner frequency brightness contrast
+#N canvas 275 22 906 659 camera 0;
+#X obj 310 515 outlet;
+#X obj 51 14 inlet;
+#X obj 63 203 t a;
+#X msg 700 463 open videodev \$1 \, get;
+#X msg 673 314 size \$1 \$2;
+#X obj 598 13 r \$0-size0;
+#X msg 673 13 120 160;
+#X msg 673 32 120 180;
+#X obj 598 32 r \$0-size1;
+#X msg 673 51 240 320;
+#X msg 673 70 240 360;
+#X obj 598 51 r \$0-size2;
+#X obj 598 70 r \$0-size3;
+#X obj 598 89 r \$0-size4;
+#X obj 598 108 r \$0-size5;
+#X msg 673 89 480 640;
+#X msg 673 108 480 720;
+#X obj 598 127 r \$0-size6;
+#X obj 598 146 r \$0-size7;
+#X msg 673 127 576 720;
+#X msg 673 146 288 352;
+#X obj 673 209 unpack 0 0;
+#X obj 768 228 s \$0-width;
+#X obj 673 228 s \$0-height;
+#X obj 673 276 #pack;
+#X obj 673 295 #to_list;
+#X obj 700 444 makefilename /dev/video%d;
+#X obj 85 424 spigot;
+#X obj 308 584 args (device a -1);
+#X obj 308 622 s \$0-device;
+#X obj 85 446 route pwc;
+#X msg 85 465 pwc \$1 \, get;
+#X obj 51 33 list split 1;
+#X obj 51 52 makefilename \$0-%s;
+#X obj 51 109 s;
+#X obj 51 90 list;
+#X obj 51 71 t b s;
+#X msg 684 487 open dc1394 \, get;
+#X msg 391 368 colorspace \$1;
+#X obj 181 71 list prepend;
+#X obj 181 90 list trim;
+#X obj 174 179 foreach;
+#X obj 174 198 makefilename \$0-%s;
+#X msg 174 217 \; \$1 color 10 20 20;
+#X msg 179 564 \; \$1 color 18 17 22;
+#X obj 122 386 t b a b b;
+#X obj 391 311 s \$0-colorspace_e;
+#X obj 391 330 r \$0-s_colorspace_e;
+#X obj 673 248 r \$0-s_height;
+#X obj 768 248 r \$0-s_width;
+#X obj 664 339 r \$0-s_device;
+#X obj 580 191 r \$0-size;
+#X msg 180 405 0;
+#X msg 122 405 1;
+#X obj 580 210 route2 color;
+#X obj 580 229 s \$0-sizec;
+#X obj 571 248 s \$0-width;
+#X obj 561 268 s \$0-height;
+#X obj 371 270 route2 color;
+#X obj 371 251 r \$0-colorspace;
+#X obj 635 543 s \$0-title;
+#X msg 635 524 label \$1;
+#X obj 563 486 r \$0-name;
+#X obj 563 505 route color;
+#X msg 490 596 close;
+#X msg 490 617 label No_camera_selected;
+#X msg 339 186 label Unknown_camera;
+#X obj 339 205 s \$0-title;
+#X obj 731 13 r \$0-minsize;
+#X obj 731 51 unpack 0 0;
+#X obj 796 70 s \$0-minwidth;
+#X obj 731 89 s \$0-minheight;
+#X obj 731 146 unpack 0 0;
+#X obj 731 108 r \$0-maxsize;
+#X obj 731 184 s \$0-maxheight;
+#X obj 796 165 s \$0-maxwidth;
+#X obj 731 32 route list;
+#X obj 731 127 route list;
+#X obj 393 527 s \$0-minsize;
+#X msg 393 506 0 0;
+#X obj 403 547 s \$0-maxsize;
+#X obj 664 358 t a b;
+#X obj 67 487 r \$0-palette;
+#X obj 139 544 s \$0-palette2;
+#X msg 139 525 label \$1;
+#X obj 25 568 route minsize maxsize;
+#X obj 67 506 route color;
+#X obj 181 13 receives \$0-s_ channel tuner frequency brightness contrast
 colour hue whiteness white_mode white_red white_blue white_speed white_delay
 auto_gain framerate noise_reduction compression pwc size colorspace
 norm transfer;
-#X msg 174 116 list channel tuner frequency brightness contrast colour
+#X msg 174 121 list channel tuner frequency brightness contrast colour
 hue whiteness white_mode white_red white_blue white_speed white_delay
 auto_gain framerate noise_reduction compression pwc size colorspace
 norm transfer;
-#X obj 714 505 r \$0-transfer;
-#X obj 754 544 listfind read mmap;
-#X obj 744 563 s \$0-transfer_e;
-#X obj 744 582 r \$0-s_transfer_e;
-#X obj 744 601 listread read mmap;
-#X msg 744 620 transfer \$1;
-#X obj 714 524 route2 color;
-#X obj 308 598 mod 11;
-#X obj 656 417 range 8 9 10;
-#X msg 434 399 open quicktimecamera \, get;
-#X obj 391 287 listfind y yuv rgb magic none;
-#X obj 391 344 listread y yuv rgb magic none;
+#X obj 714 510 r \$0-transfer;
+#X obj 754 549 listfind read mmap;
+#X obj 744 568 s \$0-transfer_e;
+#X obj 744 587 r \$0-s_transfer_e;
+#X obj 744 606 listread read mmap;
+#X msg 744 625 transfer \$1;
+#X obj 714 529 route2 color;
+#X obj 391 292 listfind y yuv rgb magic none;
+#X obj 391 349 listread y yuv rgb magic none;
+#X obj 664 388 range 8 9 10 11 12 13;
+#X msg 456 407 open quicktimecamera \$1 \, get;
+#X obj 718 416 - 9;
+#X obj 308 603 mod 14;
 #X connect 1 0 32 0;
 #X connect 2 0 27 0;
 #X connect 3 0 45 0;
@@ -137,7 +138,7 @@
 #X connect 25 0 4 0;
 #X connect 26 0 3 0;
 #X connect 27 0 30 0;
-#X connect 28 0 96 0;
+#X connect 28 0 101 0;
 #X connect 30 0 31 0;
 #X connect 30 1 0 0;
 #X connect 31 0 45 0;
@@ -159,7 +160,7 @@
 #X connect 45 2 66 0;
 #X connect 45 2 88 0;
 #X connect 45 3 52 0;
-#X connect 47 0 100 0;
+#X connect 47 0 97 0;
 #X connect 48 0 24 0;
 #X connect 49 0 24 1;
 #X connect 50 0 81 0;
@@ -171,7 +172,7 @@
 #X connect 54 0 57 0;
 #X connect 54 1 21 0;
 #X connect 58 0 46 0;
-#X connect 58 1 99 0;
+#X connect 58 1 96 0;
 #X connect 59 0 58 0;
 #X connect 61 0 60 0;
 #X connect 62 0 63 0;
@@ -191,7 +192,7 @@
 #X connect 77 0 72 0;
 #X connect 79 0 78 0;
 #X connect 79 0 80 0;
-#X connect 81 0 97 0;
+#X connect 81 0 98 0;
 #X connect 81 1 79 0;
 #X connect 82 0 86 0;
 #X connect 84 0 83 0;
@@ -207,14 +208,18 @@
 #X connect 94 0 2 0;
 #X connect 95 0 91 0;
 #X connect 95 1 90 0;
-#X connect 96 0 29 0;
-#X connect 97 0 26 0;
-#X connect 97 1 37 0;
-#X connect 97 2 98 0;
-#X connect 97 3 64 0;
-#X connect 98 0 45 0;
-#X connect 99 0 46 0;
-#X connect 100 0 38 0;
+#X connect 96 0 46 0;
+#X connect 97 0 38 0;
+#X connect 98 0 26 0;
+#X connect 98 1 37 0;
+#X connect 98 2 100 0;
+#X connect 98 3 100 0;
+#X connect 98 4 100 0;
+#X connect 98 5 100 0;
+#X connect 98 6 64 0;
+#X connect 99 0 45 0;
+#X connect 100 0 99 0;
+#X connect 101 0 29 0;
 #X restore 34 410 pd camera;
 #X obj 7 429 outlet image;
 #X obj 7 372 inlet;
@@ -223,45 +228,45 @@
 #X obj 46 372 r \$0-o;
 #X text 84 35 channel:;
 #X text 98 47 tuner:;
-#X obj 6 31 cnv 15 70 216 empty empty empty 20 12 0 14 -233017 -66577
+#X obj 6 31 cnv 15 70 251 empty empty empty 20 12 0 14 -233017 -66577
 0;
-#X text 9 32 device:;
-#X obj 11 50 vradio 15 1 0 11 \$0-s_device \$0-device empty 0 -6 0
-8 -241291 -1 -1 0;
-#X obj 81 105 cnv 15 184 172 empty empty empty 20 12 0 14 -233017 -66577
+#X text 9 31 device:;
+#X obj 11 50 vradio 15 1 0 14 \$0-s_device \$0-device empty 0 -6 0
+8 -241291 -1 -1 9;
+#X obj 81 105 cnv 15 184 177 empty empty empty 20 12 0 14 -233017 -66577
 0;
 #X obj 270 214 cnv 15 144 140 empty \$0-palette2 YUYV 86 8 0 10 -233017
 -1 0;
 #X obj 270 31 cnv 15 144 178 empty empty empty 20 12 0 14 -233017 -66577
 0;
 #X obj 312 66 nbx 5 14 -1e+37 1e+37 0 0 \$0-s_height \$0-height empty
-0 -6 1 10 -62784 -44926 -1 480 256;
+0 -6 1 10 -233017 -195568 -195568 0 256;
 #X obj 360 66 nbx 5 14 -1e+37 1e+37 0 0 \$0-s_width \$0-width empty
-0 -6 1 10 -62784 -44926 -1 640 256;
+0 -6 1 10 -233017 -195568 -195568 0 256;
 #X text 275 65 size:;
 #X text 315 35 height;
 #X text 365 35 width;
 #X msg 291 331 transfer mmap 4;
 #X obj 291 362 s \$0-o;
 #X obj 329 124 bng 12 250 50 0 \$0-size0 \$0-sizec 120x160 -46 6 1
-8 -62784 -44926 -1;
+8 -233017 -195568 -195568;
 #X obj 344 124 bng 12 250 50 0 \$0-size1 \$0-sizec 120x180 16 6 1 8
--62784 -44926 -1;
+-233017 -195568 -195568;
 #X obj 329 136 bng 12 250 50 0 \$0-size2 \$0-sizec 240x320 -46 6 1
-8 -62784 -44926 -1;
+8 -233017 -195568 -195568;
 #X obj 344 136 bng 12 250 50 0 \$0-size3 \$0-sizec 240x360 16 6 1 8
--62784 -44926 -1;
+-233017 -195568 -195568;
 #X obj 329 148 bng 12 250 50 0 \$0-size4 \$0-sizec 480x640 -46 6 1
-8 -62784 -44926 -1;
+8 -233017 -195568 -195568;
 #X obj 344 148 bng 12 250 50 0 \$0-size5 \$0-sizec 480x720 16 6 1 8
--62784 -44926 -1;
+-233017 -195568 -195568;
 #X obj 344 160 bng 12 250 50 0 \$0-size6 \$0-sizec 576x720 16 6 1 8
--62784 -44926 -1;
+-233017 -195568 -195568;
 #X obj 344 172 bng 12 250 50 0 \$0-size7 \$0-sizec 288x352 16 6 1 8
--62784 -44926 -1;
+-233017 -195568 -195568;
 #X obj 360 191 nbx 5 14 -1e+37 1e+37 0 0 \$0-s_framerate \$0-framerate
 empty 0 -6 1 10 -233017 -195568 -195568 0 256;
-#X obj 83 179 tgl 12 0 \$0-s_white_mode \$0-white_mode manual_white_balance
+#X obj 83 178 tgl 12 0 \$0-s_white_mode \$0-white_mode manual_white_balance
 20 7 1 8 -233017 -195568 -195568 0 1;
 #X text 27 48 #0;
 #X text 27 63 #1;
@@ -272,22 +277,22 @@
 #X text 27 138 #6;
 #X text 27 153 #7;
 #X text 317 106 presets:;
-#X text 90 167 ------- PWC ONLY: -------;
-#X obj 83 251 hradio 12 1 0 4 \$0-s_noise_reduction \$0-noise_reduction
+#X text 90 166 ------- PWC ONLY: -------;
+#X obj 83 256 hradio 12 1 0 4 \$0-s_noise_reduction \$0-noise_reduction
 _0_1_2_3_noise_reduction -2 7 1 8 -233017 -195568 -195568 0;
-#X obj 83 263 hradio 12 1 0 4 \$0-s_compression \$0-compression _0_1_2_3_compression
+#X obj 83 268 hradio 12 1 0 4 \$0-s_compression \$0-compression _0_1_2_3_compression
 -2 7 1 8 -233017 -195568 -195568 0;
-#X obj 11 226 tgl 12 0 \$0-s_pwc \$0-pwc empty 20 7 1 10 -62784 -44926
--1 0 1;
-#X text 26 224 use PWC;
-#X text 28 168 DC1394;
+#X obj 11 265 tgl 12 0 \$0-s_pwc \$0-pwc empty 20 7 1 10 -233017 -195568
+-195568 0 1;
+#X text 26 263 use PWC;
+#X text 27 168 DC1394;
 #X obj 345 232 vradio 12 1 0 5 \$0-s_colorspace_e \$0-colorspace_e
-empty 0 -8 0 10 -62784 -44926 -1 0;
+empty 0 -8 0 10 -233017 -195568 -195568 0;
 #X text 359 228 y (grey);
 #X text 359 240 yuv;
 #X text 359 253 rgb;
 #X text 269 246 Colorspaces:;
-#N canvas 0 0 450 300 command_filtre 0;
+#N canvas 0 22 450 300 command_filtre 0;
 #X obj 22 24 inlet;
 #X obj 22 92 outlet;
 #X obj 22 43 route bang device;
@@ -304,21 +309,21 @@
 #X text 214 45 NTSC;
 #X text 213 57 SECAM;
 #X text 213 68 auto;
-#X obj 6 6 cnv 15 408 20 empty \$0-title Built-in_iSight 4 10 1 12
--1 -262144 0;
+#X obj 6 6 cnv 15 408 20 empty \$0-title Unknown_camera 4 10 1 12 -1
+-262144 0;
 #X obj 345 300 vradio 12 1 0 2 \$0-s_transfer_e \$0-transfer_e empty
-0 -8 0 10 -62784 -44926 -1 1;
+0 -8 0 10 -233017 -195568 -195568 0;
 #X text 286 304 Transfer:;
 #X text 359 298 read;
 #X text 360 310 mmap;
 #X obj 312 52 nbx 5 14 -1e+37 1e+37 0 0 empty \$0-minheight empty 0
--6 1 10 -233017 -1 -195568 32 256;
+-6 1 10 -233017 -1 -195568 0 256;
 #X obj 360 52 nbx 5 14 -1e+37 1e+37 0 0 empty \$0-minwidth empty 0
--6 1 10 -233017 -1 -195568 48 256;
+-6 1 10 -233017 -1 -195568 0 256;
 #X obj 312 80 nbx 5 14 -1e+37 1e+37 0 0 empty \$0-maxheight empty 0
--6 1 10 -233017 -1 -195568 480 256;
+-6 1 10 -233017 -1 -195568 0 256;
 #X obj 360 80 nbx 5 14 -1e+37 1e+37 0 0 empty \$0-maxwidth empty 0
--6 1 10 -233017 -1 -195568 640 256;
+-6 1 10 -233017 -1 -195568 0 256;
 #X text 275 79 max:;
 #X text 275 51 min:;
 #X text 297 214 Palette:;
@@ -327,26 +332,34 @@
 #X obj 46 56 cnv 1 1 53 empty empty empty 20 12 0 14 -1 -66577 0;
 #X obj 47 110 cnv 1 3 1 empty empty V4L1 6 0 0 8 -1 -66577 0;
 #X obj 46 112 cnv 1 1 53 empty empty empty 20 12 0 14 -1 -66577 0;
-#X text 27 198 OFF;
-#X text 27 183 MacOSX;
+#X text 27 245 OFF;
 #X obj 83 107 gf.nbxhsl \$0 contrast;
 #X obj 7 410 #in;
 #X obj 83 119 gf.nbxhsl \$0 brightness;
 #X obj 83 131 gf.nbxhsl \$0 colour;
 #X obj 83 143 gf.nbxhsl \$0 hue;
 #X obj 83 155 gf.nbxhsl \$0 whiteness;
-#X obj 82 191 gf.nbxhsl \$0 white_red;
-#X obj 82 203 gf.nbxhsl \$0 white_blue;
-#X obj 82 215 gf.nbxhsl \$0 white_speed;
-#X obj 82 227 gf.nbxhsl \$0 white_delay;
-#X obj 82 239 gf.nbxhsl \$0 auto_gain;
+#X obj 83 193 gf.nbxhsl \$0 white_red;
+#X obj 83 205 gf.nbxhsl \$0 white_blue;
+#X obj 83 217 gf.nbxhsl \$0 white_speed;
+#X obj 83 229 gf.nbxhsl \$0 white_delay;
+#X obj 83 241 gf.nbxhsl \$0 auto_gain;
 #X obj 83 85 gf.nbxhsl \$0 frequency;
 #X text 360 278 none(bad);
 #X text 360 265 magic;
-#X connect 2 0 79 0;
+#X text 27 183 #0;
+#X text 27 198 #1;
+#X text 27 213 #2;
+#X text 27 228 #3;
+#X obj 43 189 cnv 1 3 1 empty empty empty 20 12 0 14 -1 -66577 0;
+#X obj 46 191 cnv 1 1 22 empty empty empty 20 12 0 14 -1 -66577 0;
+#X obj 47 214 cnv 1 3 1 empty empty OSX 6 0 0 8 -1 -66577 0;
+#X obj 43 238 cnv 1 3 1 empty empty empty 20 12 0 14 -1 -66577 0;
+#X obj 46 216 cnv 1 1 22 empty empty empty 20 12 0 14 -1 -66577 0;
+#X connect 2 0 78 0;
 #X connect 4 0 52 0;
-#X connect 6 0 79 0;
+#X connect 6 0 78 0;
 #X connect 20 0 21 0;
-#X connect 52 0 79 0;
-#X connect 79 0 3 0;
-#X connect 79 1 2 0;
+#X connect 52 0 78 0;
+#X connect 78 0 3 0;
+#X connect 78 1 2 0;

Modified: trunk/src/quicktimeapple.cxx
==============================================================================
--- trunk/src/quicktimeapple.cxx (original)
+++ trunk/src/quicktimeapple.cxx Mon Feb  8 21:08:26 2010
@@ -185,6 +185,8 @@
   int m_newFrame; 
   SeqGrabComponent m_sg;
   SGChannel m_vc;
+  SGDeviceList deviceList;
+  int nDevices;
   short m_pixelDepth;
   Rect rect;
   GWorldPtr m_srcGWorld;
@@ -192,14 +194,13 @@
   Ptr m_baseAddr;
   long m_rowBytes;
   int m_quality;
-//int m_colorspace;
-  \constructor (t_symbol *mode) {
+  \constructor (t_symbol *mode, int device) {
 	//vdc = SGGetVideoDigitizerComponent(c);
 	dim = new Dim(240,320,4);
 	OSErr e;
 	rect.top=rect.left=0;
 	rect.bottom=dim->v[0]; rect.right=dim->v[1];
-	int n=0;
+	int n=0, i, j;
 	Component c = 0;
 	ComponentDescription cd;
 	cd.componentType = SeqGrabComponentType;
@@ -213,16 +214,16 @@
 		ComponentDescription cd2;
 		Ptr name=0,info=0,icon=0;
 		GetComponentInfo(c,&cd2,&name,&info,&icon);
-		post("Component #%d",n);
+		//post("Component #%d",n);
 		char *t = (char *)&cd.componentType;
-		post(" type='%c%c%c%c'",t[3],t[2],t[1],t[0]);
+		//post(" type='%c%c%c%c'",t[3],t[2],t[1],t[0]);
 		t = (char *)&cd.componentSubType;
-		post("  subtype='%c%c%c%c'",t[3],t[2],t[1],t[0]);
-		post("  name=%08x, *name='%*s'",name, *name, name+1);
-		post("  info=%08x, *info='%*s'",info, *name, info+1);
+		//post("  subtype='%c%c%c%c'",t[3],t[2],t[1],t[0]);
+		//post("  name=%08x, *name='%*s'",name, *name, name+1);
+		//post("  info=%08x, *info='%*s'",info, *name, info+1);
 		n++;
 	}
-	post("number of components: %d",n);
+	//post("  number of components: %d",n);
 	m_sg = OpenDefaultComponent(SeqGrabComponentType, 0);
 	if(!m_sg) RAISE("could not open default component");
 	e=SGInitialize(m_sg);
@@ -233,18 +234,43 @@
 	if(e!=noErr) post("could not make new SG channel");
 	e=SGSetChannelBounds(m_vc, &rect);
 	if(e!=noErr) post("could not set SG ChannelBounds");
+	
+    e=SGGetChannelDeviceList(m_vc, sgDeviceListIncludeInputs, &deviceList);
+    if (e!=noErr) post("could not get device list");
+    else {
+        nDevices = (*deviceList)->count;
+        //post("  number of available devices: %d", nDevices); 
+        //post("  current device: %d", (*deviceList)->selectedIndex);
+        //for (int i=0; i<nDevices; i++) post("  Device %d: %s", i, (*deviceList)->entry[i].name);
+    }
+    
+    // treat the device list in reverse order
+    device = nDevices-1-device;
+    e=SGSetChannelDevice(m_vc, (*deviceList)->entry[device].name);
+	if(e!=noErr) RAISE("could not set channel device");
+	else {
+        char *s1, s2[MAXPDSTRING];
+        s1 = (char *)(*deviceList)->entry[device].name;
+        for (i=1, j=0; i<=*s1; i++) {
+            if (isalnum(s1[i])) s2[j++] = s1[i];
+            else if (s1[i] == ' ') s2[j++] = '_';
+        }
+        s2[j++] = '\0';
+        name = gensym(s2);
+	}
+	
 	e=SGSetChannelUsage(m_vc, seqGrabPreview);
 	if(e!=noErr) post("could not set SG ChannelUsage");
-        e=SGSetDataProc(m_sg,NewSGDataUPP(callback),0);
+	e=SGSetDataProc(m_sg,NewSGDataUPP(callback),0);
 	if (e!=noErr) post("could not set SG DataProc");
-	//  m_rowBytes = m_vidXSize*4;
 	switch (3) {
 	  case 0: e=SGSetChannelPlayFlags(m_vc, channelPlayNormal); break;
 	  case 1: e=SGSetChannelPlayFlags(m_vc, channelPlayHighQuality); break;
 	  case 2: e=SGSetChannelPlayFlags(m_vc, channelPlayFast); break;
 	  case 3: e=SGSetChannelPlayFlags(m_vc, channelPlayAllData); break;
 	}
-	int dataSize = dim->prod();
+
+	int dataSize = dim->prod();             
 	buf = new uint8[dataSize];
 	buf2 = new uint8[dataSize];
 	m_rowBytes = dim->prod(1);
@@ -258,7 +284,6 @@
 	if (e!=noErr) RAISE("error #%d at QTNewGWorldFromPtr",e);
 	if (!m_srcGWorld) RAISE("Could not allocate off screen");
 	SGSetGWorld(m_sg,(CGrafPtr)m_srcGWorld, NULL);
-	//SGStartPreview(m_sg);
 	e=SGStartRecord(m_sg);
 	if (e!=noErr) RAISE("error #%d at SGStartRecord",e);
   }
@@ -271,9 +296,9 @@
   }
   \decl 0 bang ();
   \grin 0 int
+  
+  \attr t_symbol *name;
 };
-
-// /System/Library/Frameworks/CoreServices.framework/Frameworks/CarbonCore.framework/Headers/Components.h
 
 static int nn(int c) {return c?c:' ';}
 



More information about the Gridflow-cvs mailing list