Pages

Showing posts with label hobby. Show all posts
Showing posts with label hobby. Show all posts

Friday, 18 November 2011

Visualization calibration

What would a musical vector look like? Vectors have magnitude and direction; music possesses an amplitude (volume) and a frequency (pitch). If the directive parameter of the vector is substituted with the frequency of some noise and the magnitude of the vector substituted with the amplitude, and if the origin of the vector is held fixed, then it would move around that pivot, pointing in a certain direction for a given frequency and stretching in that direction according to the amplitude.

The next step is to model the direction according to the frequency: given that the noise playing could be at any frequency between 20 Hz and 20,000 Hz, it would be quite a mundane exercise to manually calibrate a scale and have the vector point at the appropriate positions. Instead, it would be more interesting to ditch the cylindrical coordinates normally taught in classrooms at the middle school level and take up the circular coordinate system. Here, instead of the X and Y axes, there's the radial vector and the angular position: if I stand at a particular point, instead of being so much to the left and so much toward the front, I will be some distance from an origin and inclined at some angle against a baseline.

[caption id="attachment_20680" align="aligncenter" width="300" caption="A circular, or polar, coordinate system"][/caption]

Now, let's fix the frequency conversion first. 20 Hz to 20,000 Hz is a range of 19,980 Hz. Dividing that value by 360 degrees, we get 55.5 Hz per degree: this means that starting at 0 degrees, each subsequent degree represents an increment of 55.5 Hz, as in 0 Hz, 55.5 Hz, 111 Hz, 166.5 Hz, and so on. Therefore, as the noise plays out, the vector will point in the corresponding direction. In order to make it more visually captivating, the timestep can be incremented to 0.5 seconds. In other words, the vector will correspond to the frequency only once every second instead of corresponding continuously. With suitable fade-in and fade-out effects, a smooth flashing motion can be visualized.

Before fixing the amplitude conversion, let's look at the following wave representation of some noise.



Demarcating it into three sections,



If the red line was to be held as the baseline, then the net displacement from it of each point of the green curve (with a timestep of 0.5 seconds) can be computed and a standard deviation (SD) arrived at. Now, the value of the SD is going to be different for different sections, the reasons behind which are evident. Now, instead of computing the deviations separately, section after section, it can be done continuously. Since the value of the SD is equal to the average value of all measured deviations in that section, the section under consideration can be moved with a timestep of 0.5 seconds and a range of 5 seconds.

For example, let's assume that the range of A is 5 seconds. This is the original section. Now, as the noise begins to play, we wait for the first 5 seconds to transpire. At 5.5 seconds, we move the head of the section we're considering to coincide with the the position at which the noise is playing - like a slider along a rail - while we bring up the rear, constantly ensuring that the range remains at 5 seconds. In this moving range, we continuously compute the SD and use this changing value as the radius of the circle we're using to visualize the vector in.

If the noise playing is a continuous and uniformly pitched beep, the vector is going to point in one direction all the time and the radius of the circle is going to be constant throughout. If a sine wave is playing out, then the radius of the circle will rise and fall according to the frequency of the wave and the vector will oscillate between two points on the perimeter of the circle. Here again, a latency can be effected by introducing a lag component to the vector's movement, ensuring that it moves, say, 0.25 seconds later than right then. The final step to calibrating a visualizer is the graphic effects: since we've assumed a circular coordinate system, the equation for the Archimedean spiral can be employed to assign each point, or pixel, within the circular a particulate color.

r = a + b . θ

'a' is the gradient of the coloring; 'b', the number of pixels on the radius of the circle; and 'r', the coloring function that has been employed. The total number of pixels in the circle will be πr2 which will also then be the number of colors to be assigned overall. Using a loop counter to increment the hex colors (and assigning them to the value of 'r'), the moving vector can be colorized depending on where it points to and to what distance within the circle (while θ is increased from 0-360 degrees). Since the radius of the circle, 'b', is going to keep changing, it would be better to colorize the entire canvas, superimpose the image of the circle on it, mask the colors, and then use the vector to unmask the colors on its "skin".

[caption id="attachment_20677" align="aligncenter" width="474" caption="A still of a visualization on Windows Media Player, achieved by using more subtle gradients, fading effects, and multiple layers of images."][/caption]

Visualization calibration

What would a musical vector look like? Vectors have magnitude and direction; music possesses an amplitude (volume) and a frequency (pitch). If the directive parameter of the vector is substituted with the frequency of some noise and the magnitude of the vector substituted with the amplitude, and if the origin of the vector is held fixed, then it would move around that pivot, pointing in a certain direction for a given frequency and stretching in that direction according to the amplitude.

The next step is to model the direction according to the frequency: given that the noise playing could be at any frequency between 20 Hz and 20,000 Hz, it would be quite a mundane exercise to manually calibrate a scale and have the vector point at the appropriate positions. Instead, it would be more interesting to ditch the cylindrical coordinates normally taught in classrooms at the middle school level and take up the circular coordinate system. Here, instead of the X and Y axes, there's the radial vector and the angular position: if I stand at a particular point, instead of being so much to the left and so much toward the front, I will be some distance from an origin and inclined at some angle against a baseline.

[caption id="attachment_20680" align="aligncenter" width="300" caption="A circular, or polar, coordinate system"][/caption]

Now, let's fix the frequency conversion first. 20 Hz to 20,000 Hz is a range of 19,980 Hz. Dividing that value by 360 degrees, we get 55.5 Hz per degree: this means that starting at 0 degrees, each subsequent degree represents an increment of 55.5 Hz, as in 0 Hz, 55.5 Hz, 111 Hz, 166.5 Hz, and so on. Therefore, as the noise plays out, the vector will point in the corresponding direction. In order to make it more visually captivating, the timestep can be incremented to 0.5 seconds. In other words, the vector will correspond to the frequency only once every second instead of corresponding continuously. With suitable fade-in and fade-out effects, a smooth flashing motion can be visualized.

Before fixing the amplitude conversion, let's look at the following wave representation of some noise.



Demarcating it into three sections,



If the red line was to be held as the baseline, then the net displacement from it of each point of the green curve (with a timestep of 0.5 seconds) can be computed and a standard deviation (SD) arrived at. Now, the value of the SD is going to be different for different sections, the reasons behind which are evident. Now, instead of computing the deviations separately, section after section, it can be done continuously. Since the value of the SD is equal to the average value of all measured deviations in that section, the section under consideration can be moved with a timestep of 0.5 seconds and a range of 5 seconds.

For example, let's assume that the range of A is 5 seconds. This is the original section. Now, as the noise begins to play, we wait for the first 5 seconds to transpire. At 5.5 seconds, we move the head of the section we're considering to coincide with the the position at which the noise is playing - like a slider along a rail - while we bring up the rear, constantly ensuring that the range remains at 5 seconds. In this moving range, we continuously compute the SD and use this changing value as the radius of the circle we're using to visualize the vector in.

If the noise playing is a continuous and uniformly pitched beep, the vector is going to point in one direction all the time and the radius of the circle is going to be constant throughout. If a sine wave is playing out, then the radius of the circle will rise and fall according to the frequency of the wave and the vector will oscillate between two points on the perimeter of the circle. Here again, a latency can be effected by introducing a lag component to the vector's movement, ensuring that it moves, say, 0.25 seconds later than right then. The final step to calibrating a visualizer is the graphic effects: since we've assumed a circular coordinate system, the equation for the Archimedean spiral can be employed to assign each point, or pixel, within the circular a particulate color.

r = a + b . θ

'a' is the gradient of the coloring; 'b', the number of pixels on the radius of the circle; and 'r', the coloring function that has been employed. The total number of pixels in the circle will be πr2 which will also then be the number of colors to be assigned overall. Using a loop counter to increment the hex colors (and assigning them to the value of 'r'), the moving vector can be colorized depending on where it points to and to what distance within the circle (while θ is increased from 0-360 degrees). Since the radius of the circle, 'b', is going to keep changing, it would be better to colorize the entire canvas, superimpose the image of the circle on it, mask the colors, and then use the vector to unmask the colors on its "skin".

[caption id="attachment_20677" align="aligncenter" width="474" caption="A still of a visualization on Windows Media Player, achieved by using more subtle gradients, fading effects, and multiple layers of images."][/caption]

Saturday, 29 October 2011

Stuff I could use

Some of the stuff I could use right now.

Kindle Fire



Need I say anything?

Olympus VN-8100PC Digital Voice Recorder



Most of my better ideas - whether they're ideas for stories, concepts or papers - occur when I least expect them to. Of course, I could carry a notepad around, but that's just too tedious. A voice recorder should solve the problem, I'm thinking, if I don't care about being seen in public animatedly talking to a stick. (Couldn't I just use my smartphone? Sure, but a voice recorder is much more powerful, could be used in other scenarios, and generally appeases my personal dislike of multi-purpose non-electrical devices.)

Rigol DS1052E 50 MHz Digital Oscilloscope (2 channels + USB storage + 1 GSa/s sampling)


I have a thing for circuit modeling, analysis and lots of tinkering-around-with-function-generators. Anyone who's used an oscilloscope for any amount of time cannot find fiddling with it not fun. Then again, $400 is a high price to pay for it. What'd I use it for? Well, troubleshooting, signal probing, circuit analysis, study Fourier transforms and to put together my own designs for various electronic applications.

For similar purposes, I'd like the following as well.

Extech EX330 Autoranging Multimeter

Radio-frequency Generator

Resistance and Conformity in the Third Reich, Martyn Housden



This seems to be a good book that sums up the popular resistance to Nazism in Germany during the course of the Second World War (1939-1945) as well as details the effect that the ideological movement had on daily life at the time. A very long-lasting and curious obsession of mine has been the Second World War, and I've covered it in "phases" over the years. First came the weaponry, then the geopolitics, then the strategies, then the ideologies that drove various leaders, and now, the time has come for me to understand the lives of those who resisted the Nazis.

Foyle's Philavery: A Treasury of Unusual Words, Christopher Foyle



There's no particular reason in wanting to read this book but the hilarity of it all when these unusual words are used well. And, of course, there's the bit about wanting to know weird stuff.

Zeikos ZE-HC36 Medium Hard Case



I like my stuff to be safe, immune to all kinds of clumsiness (most importantly mine), and I'd like to exude the impeccability of a man who likes his stuff to be safe. (Yes, I can be quite nervous.)

Celestron 44302-A Deluxe Handheld Digital Microscope (2MP)



Don't tell me you weren't thrilled when you first watched a microorganism under a microscope, and don't tell me that the more you saw, the less you were fascinated about life at such small scales. What makes such a tool even more fun to use is that it's only an intermediary object: by allowing me to magnify things by 150x, I'm only limited by my own imagination to delve deeper into the world around me. Most of the things we know in this universe is, in one way or another, a mimicry of a natural process, and a microscope makes the principles behind these simple processes visible to the naked eye.

MagnaLight IR LED Emitter Bar (12W, 4 LED, 80' x 80' Beam, 9-42 VDC)



Versatile mounting and power options, wide-ass 850-940 nm beam, limited spread/spillage, high durability, heat reduction. *Whistle* Again, $200 is a lot of money to spend on a source of infrared radiation but given the amount of convenience this thing provides, I could build a whole range of censors without breaking sweat. Throw in some customized interfaces and the Microsoft Robotics Studio- voila! If only the people who pulled the purse strings took the "no price on happiness" idea a little too seriously.