xxxxxxxxxx
103
// The random notes code is derived from https://happycoding.io/examples/p5js/ and altered to create a meaningful creation
// The random notes are generated through an array that holds frequencies of the first minute of Dmitri Shostakovich Symphony 4. Presto (rapid) (https://www.youtube.com/watch?v=TwNgpRdiu9k). Each frequency represents 1/60 seconds. Shostakovich's fourth sympony is used in this representation as it defines 'insanity' and the year of creation between 1935 and 1936 which is in the same tima as the production of Not to be Reproduced of Rene Magritte.
//Not to be Reproduced from Rene Magritte (40_2022) is used as the canvas for this representation of 'developing insanity and estrangement' and is photoshopped to create the outline of chaos of the man and book in the mirror.
const minIntensity = 45;
const maxIntensity = 85;
const minSpeed = 2;
const maxSpeed = 10;
const margin = 100;
let note;
// list of frequencies (on average 2 per second)
let notearray = [
112, 697, 89, 87, 88, 104, 110, 104, 111, 93, 210, 95, 199, 100, 1801, 149, 88, 88, 89, 148, 98, 92, 185, 166, 156, 171, 211, 103, 202, 149, 146, 122, 98, 216, 98, 132, 196, 254, 206, 207, 104, 104, 87, 179, 168, 149, 130, 116, 103, 97, 277, 312, 353, 351, 369, 435, 418, 435, 418, 499, 403, 351, 424, 836, 175, 2372, 582, 555, 547, 582, 109, 352, 88, 122, 1377, 1331, 2823, 1656, 1395, 1120, 1792, 1927, 1956, 2022, 2281, 4437, 2060, 1484, 4423, 3652, 2910, 2232, 4760, 1948, 4302, 1928, 4036, 124, 123, 131, 294, 147, 78, 88, 92, 1046, 1328, 4080, 148, 147, 83, 87, 98, 104, 1470, 1586, 443, 443, 444, 173, 522, 589, 512, 167, 518, 469, 936, 751, 441, 1363, 82, 83, 726, 1133, 1137, 1155, 1400, 296, 294, 92, 99, 88, 84, 84, 86, 90, 1254, 100, 99, 2923, 107, 110, 124, 124, 248, 250, 165, 98, 268, 252, 268, 373, 371, 148, 98, 98, 1268, 104, 3768, 3580, 221, 769, 763, 82, 83
];
let speed;
let prevNote;
let prevSpeed;
//Images derived from Not to be Reproduced
let img;
let img2;
let img3;
let img4;
//Load images
function preload() {
img = loadImage("empty.png");
img2 = loadImage("empty withouth background.png");
img3 = loadImage("cutout_final2.png");
img4 = loadImage("man.png");
}
function setup() {
//create canvas
createCanvas(img.width, img.height);
//create background image
image(img, 0, 0);
//randomized speed of drawing the lines; to create chaos
speed = random(minSpeed, maxSpeed);
prevNote = note;
prevSpeed = speed;
strokeWeight(1);
}
function draw() {
//creating the speed
const frameDivider = floor(60 / speed);
if (frameCount % frameDivider == 0) {
playSynth();
}
//call function of lines
lines();
//call function of front image
frontImages();
}
function playSynth() {
for (let i = 0; i < notearray.length; i++) {
note = notearray[i];
//create visual movement
note += random(-notearray[i], notearray[i]);
//note = constrain(note, minIntensity, maxIntensity);
speed += random([-1, 0, 1]);
speed = constrain(speed, minSpeed, maxSpeed);
}
}
function frontImages() {
image(img2, 0, 0);
image(img3, 0, 0);
}
function lines() {
//stay in canvas transformed to fill the silhouet of the man and book in the mirror
const prevSpeedX = map(prevSpeed, minSpeed, maxSpeed, margin, width - margin);
const prevNoteY = map(prevNote, minIntensity, maxIntensity, height - margin, margin);
const speedX = map(speed, minSpeed, maxSpeed, margin, width - margin);
const noteY = map(note, minIntensity, maxIntensity, height - margin, margin);
prevNote = note;
prevSpeed = speed;
// get color of the pixels of the image
img.loadPixels();
const pixelX = random(img.width);
const pixelY = random(img.height);
const pixelColor = img.get(pixelX, pixelY);
//draw stroke
stroke(pixelColor);
line(prevSpeedX + 100, prevNoteY, speedX + 100, noteY);
}