Shift is an array of machines shifting bits and bytes informed by simple and highly repetitive algorithms. Shift pays attention to its environment through the ever-watchful eye of a built-in camera and responds to movement.
Changes in state are expressed through audio and visual abstractions. An algorithm is a process or a set of rules. Here, the algorithms are shaped by Andreas Schlegel, Benson Chong Thong Pin, Felix Sng, Jiahao Ma Darrick, Marvin Liang Yong Jie, Mike Chen, Muhammad Dhiya Bin Rahman, Sid Lim Xian Hao.
Materials; custom software Tools; Processing, Supercollider Hardware; 8 iMacs, 4 speakers, 1 mixer, 1 ethernet switch Dimension; 5 x 3 x 2m , Year; 2011
reduction
First - thanks to @FeltonChris and @RoyEltham for their patience in helping me understand this as well as the many twitter suggestions. So the frequency that we put into FRQA/B (in the main code) seems to actually be a calculated frequency. Ultimately, this portion of the code is an “optimized way” of doing Result (or FRQA/B) = freq * (2^32) / clkfreq. But since Spin doesn’t have multiplication or division, there are tricksy ways to use addition, subtraction, and bitshifting to do the same thing. So this code starts by saying:
Repeat the following loop 33 times. Bitshift Result left by 1.
Let’s talk a little about this idea of bitshifting. Bit shifting is just adding an extra “place” or 0 according to the code. Here we’re bitshifting by 1 (<<= 1) If we had a 4 bit number:
And with a 32-bit number. Let’s assume it’s 32-1s
Because Result (an automatic local variable) isn’t defined, it starts out as 0. 0 bitshifted left is still 0. It stays 0 unless freq is equal to or greater (=>) than clkfreq (the number of clock cycles for 1 second but also the clock frequency of the chip). If it is equal to or greater than clkfreq, then subtract clkfreq from freq (-=). And then post increment the result (result++) which means result = result + 1.
Now this bitshifting/subtraction stuff is supposed to represent freq * (2^32) / clkfreq. I initially had no clue as to how you get division out of subtraction, but let’s look at an example of long division.
When your dividend (what’s getting divided) is large enough, your divisor (what it’s divided by) is able to “go into it” - like 7 not being able to go into 1, but being able to go into 1.0. Then 7 is subtracted from 1.0 and the process repeats.
Just as we mentioned, when doing long division, if your dividend is NOT large enough, you put a period and then as many zeros as you need and solve until you get a remainder of 0. So you see in the above math example how instead of stopping at 0.142, we solved until 7 went perfectly into whatever resulting number came from the subtraction step to get 0.1428.
You might also notice that freq * 2^32. You’ll also notice that this function goes through 33 times. So each time, freq <<= 1 which, remember, also equates freq * 2 and then in going through 33 times, you’ll see that freq * 2 * 2 * 2 * 2 (for 32 times).
@feltonchris was kind enough to write the code out and show each step:
Given a clkfreq of 80_000_000 (or 80MHz) and freq of 2048, let’s use what this code is supposed to do mathematically:
Per the code, result at the end = 109951!
Let’s go through a couple lines of the code to see how it’d look. Note, it’s kind of like..simultaneous bitshifting/decimal adding. It doesn’t seem to be standard as to whether it looks like bits or decimals.:
Now Roy says that 109951 is what is placed in FRQ and it will get added to PHSA every clock cycle… and PHSA will wrap 2048 times over 1 second.
PHEW! and Tracy Allen over at the Parallax forums was able to give a great example with different numbers to explain the magic of binary math and how this code achieves what it does: http://forums.parallax.com/showthread.php?138066-Going-through-XBee-Tutorial&p=1079201&viewfull=1#post1079201 - Thanks!!
@atdiy/@tymkrs
1&2
source code by Aashish Gadani
km
i>>
/i
>>>
bitshift living
short
trying out apng, but it’s not animating.
Any tips for getting these to work on tumblr?
you can see it moving here if you’ve got firefox or the apng chrome plugin
http://adamferriss.com/apng/raindBowShort.png