EINDWERK / DEMO

In dit Skillslab hebben we een demo moeten maken met zijn allen. We moesten eerst oefenen met sketches maken die bewogen. Dit hadden we voor een deel al gehad bij Heerko. Dit skillslab ging nog verder in op het bewegen en het laten bewegen op muziek. Hierbij heb ik geleerd om code om te zetten naar bewegende code op muziek. Uiteindelijk heb ik 4 sketches gemaakt die in de sketch demo zijn gekomen in het begin.

import procmod.*;

// define a new instance of the ModPlayer
ModPlayer mplayer;
// we’ll use this to draw rectangle colors for every channel
color ch1color;
color ch2color;
color ch3color;
color ch4color;

void setup() {
size(720,480);
background(0);
frameRate(30);
// Load the supplied test.mod file
mplayer = new ModPlayer(this, dataPath(“pat8.mod”));
// play it rightaway
mplayer.play();
}

float x,y,x2,y2,w;


void draw() {
background(0);
for ( int x = 0; x < 20; x++ ) {
for ( int y = 0; y < 20; y++ ) {
//drawShape( x * 40 + 20, y * 240 + 50, 10 );
stroke(ch1color);
pushMatrix();
translate(x * 50 + 20, y * 50 + 50);

stroke(ch2color);
//line( x * 40 + 20, y * 240 + 50, x * 40 + 20, y * 240 + 100 );
rotate(random(-PI/2, PI/2));
line(0, -30, 0, 5);

popMatrix();
}
}
}
void drawShape( int x, int y, int n ) {
for ( int i = 0; i < n; i++ ) {
if ( random(10)>2) {
if ( random(4)<1) {
stroke(random(ch3color), random(ch2color), random(ch1color));
strokeWeight(1.0);
strokeCap(ROUND);
} else {
stroke(random(ch3color), random(ch2color), random(ch1color));
strokeWeight(1.0);
strokeCap(ROUND);
}
float rnd = i/2;
int t = x – ( i * 10 ); // top
int l = y – ( i * 50 ); // left
float w = i * 20; // width
float r = l + 10; // right
line( l + random(45), t + random(45), r + random(45), t + random(45));
}
}
}

// This method is called every time an instrument is being played.
// Note: When no instrument is played on an iteration of the song
// (meaning continue playing the instrument) the instrument number
// will be 0. We’ll use that to change the color
void modRowEvent( int channel, int instrument, int note )
{
println(channel +”:”+ instrument +”:”+ note);
if (channel == 0)
{
ch1color = color(channel*64, 0, instrument*64);
}
else if ( channel == 1 )
{
ch2color = color(instrument*64, 0, note * 8);
}
else if ( channel == 2 )
{
ch3color = color(channel*64, 0, instrument*64);
}
else if ( channel == 3 )
{
ch4color = color(0, 0, note * 8);
}
}

import procmod.*;

// define a new instance of the ModPlayer
ModPlayer mplayer;
// we’ll use this to draw rectangle colors for every channel
color ch1color;
color ch2color;
color ch3color;
color ch4color;

int Y_AXIS = 1;
int X_AXIS = 2;

void setup() {
size(720,480);
background(0);
frameRate(30);
// Load the supplied test.mod file
mplayer = new ModPlayer(this, dataPath(“pat0.mod”));
// play it rightaway
mplayer.play();
}

void draw() {
// Background
setGradient(0, 0, width/2, height, ch1color, ch2color, X_AXIS);
setGradient(width/2, 0, width/2, height, ch3color, ch4color, X_AXIS);

}

void setGradient(int x, int y, float w, float h, color c1, color c2, int axis ) {

noFill();

if (axis == Y_AXIS) { // Top to bottom gradient
for (int i = y; i <= y+h; i++) {
float inter = map(i, y, y+h, 0, 1);
color c = lerpColor(c1, c2, inter);
stroke(c);
line(x, i, x+w, i);
}
}
else if (axis == X_AXIS) { // Left to right gradient
for (int i = x; i <= x+w; i++) {
float inter = map(i, x, x+w, 0, 1);
color c = lerpColor(c1, c2, inter);
stroke(c);
line(i, y, i, y+h);
}
}
}

// This method is called every time an instrument is being played.
// Note: When no instrument is played on an iteration of the song
// (meaning continue playing the instrument) the instrument number
// will be 0. We’ll use that to change the color
void modRowEvent( int channel, int instrument, int note )
{
println(channel +”:”+ instrument +”:”+ note);
if (channel == 0)
{
ch1color = color(0, 0, instrument*64);
}
else if ( channel == 1 )
{
ch2color = color(0, 0, note * 8);
}
else if ( channel == 2 )
{
ch3color = color(0, 0, instrument*64);
}
else if ( channel == 3 )
{
ch4color = color(0, 0, note * 8);
}
}

import procmod.*;

// define a new instance of the ModPlayer
ModPlayer mplayer;
// we’ll use this to draw rectangle colors for every channel
color ch1color;
color ch2color;
color ch3color;
color ch4color;

float x, y, x2, y2, w;

void setup() {
size(720, 480);
background(0);
frameRate(30);
// Load the supplied test.mod file
mplayer = new ModPlayer(this, dataPath(“pat11.mod”));
// play it rightaway
mplayer.play();
}

void draw () {
background(0);
noStroke();
x = x + 60;

if (x > width) {
x = 0;
}
fill(random(ch1color), random(255), 255);
ellipse(x, 0, 100, 200);
ellipse(x, 100, random(200), 200);
ellipse(x, 200, random(480/16), 300);
ellipse(x, 300, random(480/8), 400);
ellipse(x, 400, random(480/2), 500);
ellipse(x, 500, random(480/4), 600);
}

// This method is called every time an instrument is being played.
// Note: When no instrument is played on an iteration of the song
// (meaning continue playing the instrument) the instrument number
// will be 0. We’ll use that to change the color
void modRowEvent( int channel, int instrument, int note )
{
println(channel +”:”+ instrument +”:”+ note);
if (channel == 0)
{
ch1color = color(0, 0, instrument*64);
} else if ( channel == 1 )
{
ch2color = color(instrument*64, channel*64, note * 8);
} else if ( channel == 2 )
{
ch3color = color(channel*64, note * 8, instrument*64);
} else if ( channel == 3 )
{
ch4color = color(0, instrument*64, note * 8);
}
}

import procmod.*;

// define a new instance of the ModPlayer
ModPlayer mplayer;
// we’ll use this to draw rectangle colors for every channel
color ch1color;
color ch2color;
color ch3color;
color ch4color;

void setup() {
size(720,480);
background(0);
frameRate(30);
// Load the supplied test.mod file
mplayer = new ModPlayer(this, dataPath(“pat4.mod”));
// play it rightaway
mplayer.play();
}

float x,y,x2,y2,w;


void draw(){
background(ch4color);
translate(width/17,height/2);

for(int i=0;i<12;i++){
rotateX(radians(random(ch1color)));
stroke(ch2color);
strokeWeight(random(10,100));
x=random(-width,width*2);
y=-height;
x2=random(-width,width*2);
y2=height*ch3color;
line(x,y,x2,y2);
}
for(int i=0;i<12;i++){
rotateX(radians(random(360)));
stroke(0);
strokeWeight(random(50,100));
x=random(-width,width*2);
y=-height;
x2=random(-width,width*23);
y2=height*2;
line(x,y,x2,y2);
}
}

// This method is called every time an instrument is being played.
// Note: When no instrument is played on an iteration of the song
// (meaning continue playing the instrument) the instrument number
// will be 0. We’ll use that to change the color
void modRowEvent( int channel, int instrument, int note )
{
println(channel +”:”+ instrument +”:”+ note);
if (channel == 0)
{
ch1color = color(0, 0, instrument*30);
}
else if ( channel == 1 )
{
ch2color = color(0, 0, note * 8);
}
else if ( channel == 2 )
{
ch3color = color(0, 0, instrument*20);
}
else if ( channel == 3 )
{
ch4color = color(0, 0, note * 4);
}
}