A world in dk(decay/denmark) » video http://rotand.dk Just another pointless weblog Sat, 30 Nov 2013 21:03:48 +0000 en-US hourly 1 https://wordpress.org/?v=4.3.18 Collection of Processing.org hacks http://rotand.dk/2009/02/27/collection-of-processingorg-hacks/ http://rotand.dk/2009/02/27/collection-of-processingorg-hacks/#comments Fri, 27 Feb 2009 20:07:06 +0000 http://rotand.dk/blog/?p=74 Its been quite a while since I last posted anything.

That doesn’t mean that i haven’t been coding small hacks, just that i haven’t posted them. But now is probably a good time to show some of the stuff.

As the title suggest it has something to do with processing.org. I have been using processing on and off for some time. Its is really nice when you want to make a quick hack, or as its called in processing a “sketch”.

In no particular order here is some of the fun stuff made using processing.

General remarks

The following sketches and their sourcecode have served as small hacks, hence don’t expect nice comments or optimal algorithms…

shrinkImage

It is possible to remove the line from a picture representing the least amount of information. The algorithm evaluates every pixels “weight” as the absolute difference between the different color channels (r,g,b). And then finds the “lightest path” from the bottom to the top.

This means that “prominent features” won’t be removed or change size when shrinking the image. Here the definition of “prominent features” is high difference in colors between the neighboring pixels.

Have a look at shrinkImage

Room for optimizations :

Eventhough its quite quick at calculating the weights and finding the lightest path, it does so in every iteration. Letting it use a bit more memory and just recalculate the changes when removing a line should speed it up. I found a huge speedup when just having an array with the weights from the last and current line, when calculation the path, so not only would saving all weights require a bit more memory it would also slow down the first calculation. But I’m sure it would give a significant speed up in the next iterations, and a lot of +-1 frustrations 😉

helloFoo

There a some quick getting to know processing hacks, this is one off the. helloFoo

One of the very cool things about processing is the ability to use openGL, so originally this sketch uses openGL. But applets and openGL isn’t exactly the best combination. It can be done, but since it doesn’t work for me (firefox, linux openJDK JRE) i just converted it to standard java graphics. And the effort required to do this, is remove an import and don’t say setup(400,400, OPENGL) but just setup(400,400). This is trivially true the other way around. If you want to use openGL its quite easy.

The sketch is just bouncing balls, when going away from openGL I reduced the size and number of balls, in order to get a decent animation speed.

FooIII

Again used openGl originally FooIII

Some satellites rotating around some satellites rotating around some ….

sndHello

yes sketches tend to have silly names : sndHello

From Clifford Pickovers  book : Computers, Pattern, Chaos, and Beauty – graphics from an unseen world (p 39 section 4.3 snowflakes from   sound)
Draw symmetrically and in “polar form” the fft of the sound, hence creating snowflakes based on the sound.
Music by David Rovics
Choppy sound I had some problems with the sound when run as an applet. You might have better luck using the jar directly or by downloading the sourcecode and running it with processing

Slit-scanning

The former applet relied on an external library for the sound, ther are quite a few libraries available. I did use GSvideo to hook up my crappy webcam and do some video effects. I experimented with slit-scanning in different ways.Unfortunately this won’t run as an applet and it might only run on Linux.

By creating a cube of the images, where the z-axis represents time, its possible to play back different parts of the movie from different layers in time. Which makes for some quite interesting and dizzing effects.

For example a time buble where playback is delayed around a “bulge in the timespace continuum” :s (a video of some guy playing with it (timebuble1.avi) some sourcecode for a similar effect where the mouse pointer moves the buble (TimeCube.pde) another more “traditional slitscan” (CamWarpTime.pde) .

In general there is plenty of room to fiddle with the code, there a functions like selectSlice or initQueues where its decided how to slice time. its great fun to play with..

]]>
http://rotand.dk/2009/02/27/collection-of-processingorg-hacks/feed/ 0
Flash development http://rotand.dk/2008/02/09/flash-development/ http://rotand.dk/2008/02/09/flash-development/#comments Fri, 08 Feb 2008 21:21:13 +0000 http://rotand.dk/blog/2008/02/09/flash-development/ A course Im taking requires that we use flash and we are left to using specific workstations at school or download a 30 day trial for the 6-7 week project. And well either way we are supposed to be using a proprietary piece of software from Adobe.

The first flash assignment were to create a picture slide show, with captions and a soundtrack. Using the Adobe flash gui its very easy, drag and drop “programming”.

But as Richard Stallman says “its not a matter of convenience, but of ethics”. So I went looking for replacements. In another course I had no problems using octave instead of matlab, so should this be any different? Yes, unfortunately it seems that its very difficult to get the needed features in free software, well at least in the given timeframe.

HaXe is able to compile to swf, as well as doing a lot of other nifty stuff. I just learnt about it recently from this video.

I didn’t manage to make the entire assignment, (yet?) in haxe, but i did make this :
flash presentation(5MB+)

UPDATE

I did manage to add sound and captions.

So how did I do it?

Well first of all i installed haxe and swfmill. Haxe is able to use the actionsscript api and swfmill can create resources so your are able to refference them in you haxe code.Here is the recipe i used to create this slideshow.

1. create a xml file for swfmill, in order to create a resources for the haxe code.This i something like

 <movie width="480" height="480" framerate="25">
   <frame>
      <library><clip id="img1" import="library/newton001Slide_.png"/>

unfortunately swfmill isn’t able to add sound to a library, so that had to be loaded directly from a file. I had some trouble getting it to function on the server but i think that adding “-D network-sandbox” to the haxe compilation might have done something. ???

2. run swfmill, thats swfmill simple slides.xml slides.swf

now i had linkage names for the image files, and could add them to the movieClip.

3. Create file SlideShow.hx

The main part. The basic haxe syntax is pretty straightforward, but since it uses the actionscript api it were mostly a question of getting a hang of actionscript. I did however strugle a bit with making a anonymous function, for the sounds onLoad. I used “static inline function sndStart(succes){…}” , its a wee bit diffrent than what i would do in java. but it works.

3. compile.

make a “make file” for haxe, compile.hxml

-swf test.swf
-main SlideShow
-swf-lib slides.swf
-swf-header 480:480:25:FFFFFF
-D network-sandbox

The last part -D is a conditional flag and as far as i can tell it shouldn’t do anything, but a saw it in Fmp3PlayerHx and when i added it the sound seemed to work from the server, using a URL :s :s

4. run haxe compile.hxml

5. display the pretty result. (try not to go crazy when wordpress decides to help you format the html code….), at first i tried embedding the flash in this post, but wordpress kept on changing the code, apparently if you add code and have newlines between the tags it throws in a couple og <p> tags …..

Now its on a separate page, then you don’t have to download the 5 mb flash file just to view the page, and I can use wordpress with out getting too frustrated.

sourcecode slideShow.hx

The music is “the free software song” this version is by Jono Bacon , and I personally prefer it to the version by Richard Stallman

]]>
http://rotand.dk/2008/02/09/flash-development/feed/ 2
Sound Sequencing Mouse http://rotand.dk/2007/12/02/sound-sequencing-mouse/ http://rotand.dk/2007/12/02/sound-sequencing-mouse/#comments Sat, 01 Dec 2007 22:27:32 +0000 http://rotand.dk/blog/2007/12/02/sound-sequencing-mouse/ I saw this cool sound sequencer ( arduino punk console ). I don’t much about sound and that kind of stuff, but i thought it was quite nifty. And I had just gotten a ps2-mouse to work with the arduino. And hmmm, I had to use it for something. So why not try to make a sound sequencer with it ?

So I started hacking away. Unfortunately I don’t have any nice video or sound clip, but then again its more like a noisemaker and its just a mess of wires. I’ll try to get something up soon.

But it does work, you have to take my word for it or download the sourcecode and wire up your arduino and try it out.

How does it work ?

There a two modes of operation “play mode” or “sequencing mode”, and it shift between modes by clicking the middelbutton (mousewheel button) and it starts out in sequence mode.

sequencing mode

  • moving the mouse changes the frequency of the sound. It’s very simple the more you move, the more it changes (just by (X + Y) *magic_number)
  • pressing the right mouse button reduces the duration of the sound
  • pressing the left mouse button increases the duration
  • turning the mousewheel selects a tone in the sequence, either an existing or adds a new one to the sequence.

play mode

  • it plays the sequence of tones you’ve recorded.
  • the mouse wheel changes the playback speed.

So it keeps track of both a duration and a frequency, it uses a queue and its possible to add sounds to both ends. I haven’t yet hit a maximum but since its in a int array my guess is that it should be able to hold a lot 100 or 1000 of tones. And it should be possible to do some bytepacking to reduce the memory requirements, but since you have to enter each sound manually and there are no persistent storage you really don’t need that to hold a lot of tones.

Sound Sequencing Mouse sourcecode

]]>
http://rotand.dk/2007/12/02/sound-sequencing-mouse/feed/ 0
Wonderful collection of toys amazes me http://rotand.dk/2007/11/02/wonderfull-collection-of-toys-amazes-me/ http://rotand.dk/2007/11/02/wonderfull-collection-of-toys-amazes-me/#comments Fri, 02 Nov 2007 09:44:35 +0000 http://rotand.dk/blog/2007/11/02/wonderfull-collection-of-toys-amazes-me/ I stumbled upon a toyshop that is quite fascinating, Grand illusions

Thay have a nice collection of different, and perhaps a little geeky toys. But the best part is there are several articles and videos documenting the toys, not only for the stuff they have in there shop but also from Tim’s huge collection of toys. I don’t know who Tim is, but he does a very nice and distinctly British job of presenting those nifty gadgets, and i am left thinking that it would be a great joy to be his grandchild.

And as can bee seen be the heading I have read Jacob Nielsen: “Passive Voice Is Redeemed For Web Headings”

]]>
http://rotand.dk/2007/11/02/wonderfull-collection-of-toys-amazes-me/feed/ 0
Newton fractals http://rotand.dk/2007/09/22/newton-fractals/ http://rotand.dk/2007/09/22/newton-fractals/#comments Sat, 22 Sep 2007 15:47:35 +0000 http://rotand.dk/blog/2007/09/22/newton-fractals/ I the moment I’m taking a course in Numerical Analysis, and here we were of course introduced to the Newton-Raphson method for finding roots. That is the method where, geometrical speaking, we take at tangent line to a function and use that to approximate the root, and keep on doing that until we reach satisfying precision.

Depending on where you start the iteration you get a a different root, and requiring a different amount of iterations. That’s self-evident. The “funny” part is that when searching for complex roots there are areas in the complex plane, where a very small difference in starting point gives different roots, and with remarkable difference in the number of iterations.

Newton for x^4+2

This is a plot where each root in the polynomial x^4+2 have been assigned a different color. And each point is colored according to which root a iteration starting here finds.

Now thats the mathematical part of it. Now to the beautiful part or at least more fascinating part. The pattern reapeats it self, as a fractal, when you zoom in.

So i modified my code to zoom in, and i used a diffenrent coloring scheme where i only colored according to the number of iterations taken. This made it possible to generate a video zooming in og showing the rapeating patterns in “nice” colors.

Here a some videos :

4 roots (14.6 mb)
7 roots (50 mb)

Yes I know that its very large files, and maybe i will upload them to google video at a later time for easy viewing and less quality.

]]>
http://rotand.dk/2007/09/22/newton-fractals/feed/ 0
Cellular Automata II http://rotand.dk/2007/05/30/cellular-automata-ii/ http://rotand.dk/2007/05/30/cellular-automata-ii/#comments Wed, 30 May 2007 20:46:28 +0000 http://rotand.dk/blog/2007/05/30/cellular-automata-ii/ As mentioned before I’ve made a one dimensional Cellular Automata(CA). And although it was intriguing they quickly became very predictive. Actually it was in two dimensions. As the a y-coordinate represented time, but since the states were only depending an the adjacent neighbor’s to the right or left its considered to be one-dimensional.

But they are not as fascinating as CA’s where you expand the neighborhood to include all the eight adjacent cells. That’s called the Moore Neighborhood.

Representing the time dimension. As the intersting part is the evolution of the system, representing time is essential. With a two-dimensional CA it has to be done using animations, and who doesn’t like blinking pixels. This makes CA’s makes even more fun.

In order to decide the state of a cell I look at the Moore neighborhood for every cell on the grid, and count how many neighboring cells are alive. If a cell is alive, then we have to determine whether it survives or dies. If a cell is dead / empty there is the posibility of birth. By defining how many neighbors a cell has to have to survive, and hov many it takes to “give birth” it is possible to run the automata. And this is enough to define a highly complex behavior.

The ubiquitous Conway’s game of life survives if there are 2 or 3 neighbor’s alive and a cell is born if 2 cells are alive, this can be written as : S/B = 23/2. Using a notation like this makes it easy to try out new rules, just adjusting the S/B sets.

I made a small c++ program again using CImg to render these automatons. It’s a rather quick hack, and as such there are plenty off room for optimizing.

But for now it does its job and I don’t intend to develop it further, at least for now. And I think that CIimg might not be the best api for this, I need to look into SDL.

I spent way too much time hacking around to get a nice coloring scheme, and well CImgs intended users are making image manipulation, and not generating images from scratch. SDL is’t intended to generate images from scratch either, but as far as i can tell its easier to manipulate images as int arrays.

Well it does work and i were able to try out some of the rules listed at Wikipedia article about Life like cellular automatons, there online java simulators somewhere on the Internets so I won’t bother to upload any videos – as its much more fun to watch in action an play about with the settings as you go along. If you want to play with the code, well here it is : Cellular Automaton code it’s ugly and you need CImg.h

And now I’ve just downloaded EvoCell which has all the features and a lot more.

Online simulator : MJcell this is a very good implementation. Its fast and has lots of rules and patterns

]]>
http://rotand.dk/2007/05/30/cellular-automata-ii/feed/ 0