
Flocking Keyboard
simulating flock behvior with keyboard

Fun with typing
How to make typing more interesting
The other day, I was reading the book “Out of Control” written by Kevin Kelly, and the idea of “ flocking behavior” drew my attention. I was surprised that following very simple and basic rules, a group of individual animals could demonstrate incredible swarm intelligence. In 1987 Craig Reynolds first simulated flocking behavior on a computer, which then was used to successfully simulate a scene of flocking bats in the film Batman Returns. I can’t help thinking whether we can use “flocking behavior” to make our interaction with computer more interesting, or more like we are interacting with a live creature but a cold and lifeless machine, so this project is aimed to make typing, one of the most basic way of our interaction with computer, fun and appealing.

Initial Research
Separation
Alignment
Cohesion
Basic models of flocking behavior are controlled by three simple rules:
1 Separation - avoid crowding neighbors (short range repulsion)
2 Alignment - steer towards average heading of neighbors
3 Cohesion - steer towards average position of neighbors (long range attraction)

Such complicated behavior could be simulated just following these three simple rules
What if we apply the flocking behavior to the basic interactive way with a computer, such as typing
Could we make every small letter acts with swarm intelligence

Project Constructure
The project combines visual, touch and auditory to create a multi-dimensional sensation. The projector locates above the Bluetooth keyboard, and the image of the projector is adjusted to perfectly match the keyboard size. Therefore, as soon as the user presses the keyboard, the projected image of keyboard letter emitted from the key and then explodes into a few simultaneously triggering piano sound, then the letter starts to fly as same as the bird flocking behavior.
Final video
import ddf.minim.*;
Minim minim;
AudioSample press[]=new AudioSample[26];
ArrayList<Particle> ps;
PImage []letter=new PImage[26];
PImage keyboard;
Flock flock;
void setup(){
minim = new Minim(this);
for(int i=0;i<26;i++){
int f=i+1;
letter[i]=loadImage(f+".png");
press[i] = minim.loadSample( f+".mp3", 100 );
}
fullScreen();
flock = new Flock();
for (int i = 0; i < 200; i++) {
int uu=int(random(1,25));
Boid b = new Boid(width/2,height/2,uu);
flock.addBoid(b);
}
ps=new ArrayList<Particle>();
}
void draw(){
blendMode(ADD);
background(0);
run();
flock.run();
}
Coding with processing
The interactive program is written by processing, and the flocking simulation was inspired by Daniel Shiffman, I import ddf.minim library to load and play sound files in the program. So every time people press the keyboard, the piano sound follows.
Whole code please see:
https://github.com/sai891215/Flocking-keyboard.git
Parts of the code
import ddf.minim.*;
Minim minim;
AudioSample press[]=new AudioSample[26];
ArrayList<Particle> ps;
PImage []letter=new PImage[26];
PImage keyboard;
Flock flock;
void setup(){
minim = new Minim(this);
for(int i=0;i<26;i++){
int f=i+1;
letter[i]=loadImage(f+".png");
press[i] = minim.loadSample( f+".mp3", 100 );
}
fullScreen();
flock = new Flock();
for (int i = 0; i < 200; i++) {
int uu=int(random(1,25));
Boid b = new Boid(width/2,height/2,uu);
flock.addBoid(b);
}
ps=new ArrayList<Particle>();
}
void draw(){
blendMode(ADD);
background(0);
run();
flock.run();
}
Coding with processing
The interactive program is written by processing, and the flocking simulation was inspired by Daniel Shiffman, I import ddf.minim library to load and play sound files in the program. So every time people press the keyboard, the piano sound follows.