Hi list, I am having this rather silly problem trying to graph a sin function on an array? I have attached the patch, it uses counter from the GEM library. It won't seem to plot the points of the sin wave. Actually I didn't have much time to go over it and I want to use it later in a demo but haven't time to spend figuring out the problem, I know it's cheeky but can anyone help? Rory.
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
#N canvas 63 32 663 602 16; #N canvas 0 0 450 300 graph1 0; #X array array1 100 float 0; #X coords 0 5 99 -5 300 140 1; #X restore 153 410 graph; #X obj 149 324 tabwrite array1; #X floatatom 149 238 5 0 0 0 - - -; #X floatatom 149 294 5 0 0 0 - - -; #X obj 149 178 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #N canvas 421 54 464 314 count 0; #X msg 139 97 bang; #X obj 139 68 metro 300; #X floatatom 222 39 5 0 0 0 - - -; #X obj 140 127 counter 0 1000; #X obj 139 39 inlet; #X obj 223 9 inlet; #X obj 140 197 outlet; #X obj 140 157 * 0.1; #X connect 0 0 3 0; #X connect 1 0 0 0; #X connect 2 0 1 1; #X connect 3 0 7 0; #X connect 4 0 1 0; #X connect 5 0 2 0; #X connect 7 0 6 0; #X restore 149 202 pd count; #X floatatom 223 177 5 0 0 0 - - -; #X text 220 154 Count Speed; #X text 257 232 f(x) = sin(2PIt); #X obj 149 269 expr sin($f1*6.2831); #X connect 2 0 1 1; #X connect 2 0 9 0; #X connect 3 0 1 0; #X connect 4 0 5 0; #X connect 5 0 2 0; #X connect 6 0 5 1; #X connect 9 0 3 0;
Rory Walsh wrote:
can anyone help?
your problem is, that [tabwrite] quantizes along the x-axis: writing to 2.1 or 2.9 is the same as writing to 2. so the value that is actually stored at each point is "sin((i+0.9)*2pi)" which is sin(i*2pi+phi) , with i = integer; since sin() wraps at 2pi you always have the same value.
try using *pi/180 instead of *2pi.
btw, for your example you need 2 externals, while none is necessary.
mfg.asd.r IOhannes
Rory.
Of course, you know about
|; / |tab sinesum tab-len p1 p2 p3 ...\
where tab is your table, p[n]=partial strength (0-1) for n*fundamental, and tab-len is a power of 2. This is much faster and saves a lot of time from computing the sine wave to a table directly.
Hope that helps.
homepage: http://www.davidgolightly.net
From: Rory Walsh rorytheroar@yahoo.com To: PD-list@iem.at Subject: [PD] problem with array? Date: Wed, 19 Oct 2005 11:39:57 +0100 (BST)
Hi list, I am having this rather silly problem trying to graph a sin function on an array? I have attached the patch, it uses counter from the GEM library. It won't seem to plot the points of the sin wave. Actually I didn't have much time to go over it and I want to use it later in a demo but haven't time to spend figuring out the problem, I know it's cheeky but can anyone help? Rory.
To help you stay safe and secure online, we've developed the all new Yahoo! Security Centre. http://uk.security.yahoo.com
#N canvas 63 32 663 602 16; #N canvas 0 0 450 300 graph1 0; #X array array1 100 float 0; #X coords 0 5 99 -5 300 140 1; #X restore 153 410 graph; #X obj 149 324 tabwrite array1; #X floatatom 149 238 5 0 0 0 - - -; #X floatatom 149 294 5 0 0 0 - - -; #X obj 149 178 tgl 15 0 empty empty empty 0 -6 0 8 -262144 -1 -1 0 1; #N canvas 421 54 464 314 count 0; #X msg 139 97 bang; #X obj 139 68 metro 300; #X floatatom 222 39 5 0 0 0 - - -; #X obj 140 127 counter 0 1000; #X obj 139 39 inlet; #X obj 223 9 inlet; #X obj 140 197 outlet; #X obj 140 157 * 0.1; #X connect 0 0 3 0; #X connect 1 0 0 0; #X connect 2 0 1 1; #X connect 3 0 7 0; #X connect 4 0 1 0; #X connect 5 0 2 0; #X connect 7 0 6 0; #X restore 149 202 pd count; #X floatatom 223 177 5 0 0 0 - - -; #X text 220 154 Count Speed; #X text 257 232 f(x) = sin(2PIt); #X obj 149 269 expr sin($f1*6.2831); #X connect 2 0 1 1; #X connect 2 0 9 0; #X connect 3 0 1 0; #X connect 4 0 5 0; #X connect 5 0 2 0; #X connect 6 0 5 1; #X connect 9 0 3 0;
PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list