xxxxxxxxxx
let sound;
let peaks;
let index = 0;
let amplitude;
let radius;
let a;
let bf = 3700 / 3
let hf = 3200 / 3
let id = "";
let tmp_id = "";
let rfid = false;
function preload() {
sound = loadSound("chilly.mp3");
duration = loadSound("empty.mp3");
Statistik1 = loadImage("Statistik_1.png")
Statistik2 = loadImage("Statistik_2.png")
Statistik3 = loadImage("Statistik_3.png")
innen = loadImage("Plattenspieler23.png")
vid4 = createVideo("Auflegen.mp4")
vid4.loop();
vid4.hide();
vid3 = createVideo("Bestandteile.mp4")
vid3.loop();
vid3.hide();
}
function setup() {
cnv = createCanvas(bf, hf);
colorMode(HSB, 360, 100, 100, 100);
background(0, 100, 0);
//cnv.mouseClicked(togglePlay);
sound.amp(0.2); //
sound.loop();
duration.loop();
amplitude = new p5.Amplitude();
peaks = sound.getPeaks();
print(sound.duration());
mic = new p5.AudioIn();
mic.start();
//angleMode = degrees;
}
function draw() {
//background(0, 100, 0);
//peakswidth = sound.getPeaks(width);
radius = (width / 2 - 50) * 10; //radius
translate(width / 2, height / 2); //translate to middle
let rot = map(millis(), 0, 10000, 2 * PI, 0) ///////rotation
//rotate(rot);
//1204540/pink
//862000/orange
//511990/chip
//854210/green
//780590/tiny
//empty
if (key === 'l') {
background(0, 100, 0);
}
/// Frame1/Platte auflegen
if (key === 'a') {
background(0, 100, 0);
//vid.loop();
image(vid4, -bf / 2, -hf / 2, bf, hf);
}
//Frame 2/Bestandteile
else if (key === 'b') {
background(0, 100, 0);
//vid.loop();
image(vid3, -bf / 2, -hf / 2, bf, hf);
}
/// Frame3/Umsatzanteile
else if (key === 'c') {
//background(10, 100, 100);
image(Statistik1, -bf / 2, -hf / 2, bf, hf);
}
/// Frame4/Altersstruktur
else if (key === 'd') {
//background(20, 100, 100);
image(Statistik2, -bf / 2, -hf / 2, bf, hf);
}
/// Frame5/absatz
else if (key === 'e') {
//background(50, 100, 100);
image(Statistik3, -bf / 2, -hf / 2, bf, hf);
}
/// Frame6/punktuell
// Timing + Rot
else if (key === 'f') {
//duration.play();
background(0, 100, 0);
//background(Statistik1, 50)
translate(-60, 0) // Mitte der SP
rotate(PI / 4); //Winkel der Nadel
var r = map(mic.getLevel(), 0, 0.2, 0, height / 2);
var x = map(duration.currentTime(), 0, duration.duration(), hf / 2 - 50, hf / 3)
let h = map(r, 0, height, 130, 270) //Farbe
//text(x, 10, 10)
noFill();
stroke(h, 100, 100);
ellipse(x, 0, r, r);
}
/// Frame7/live
// Roation
else if (key === 'g') {
//duration.play();
//background(0, 0, 0, 100)
translate(-60, 0) // Mitte der SP
let rot = map(millis(), 0, 10000, 5 * PI, 0) ///////rotation
//rotate(rot);
beginShape();
//fill(0, 0, 0)
//noStroke();
//rect(-320, -370, 320, 370)
noFill();
stroke(255);
for (i = 0; i < peaks.length; i++) {
peak = map(mic.getLevel(), 0, 0.1, 0, hf / 10); // Größe der Kleinen Kreise
e = map(duration.currentTime(), 0, duration.duration(), 0, 9 * PI); // letzte Zahl sind Umdrehungen
a = map(duration.currentTime(), 0, duration.duration(), 1, 0.35);
let h = map(mic.getLevel(), 0, 1, 130, 180);
radius = width / 2 - 50;
x7 = a * cos(e) * radius //// a Verkleinert den Radius, Ergebnis von Cos/ Sin = >0 <1 d.h. der Radius muss multipilziert werden
y = a * sin(e) * radius;
strokeWeight(1);
stroke(h, 100, 100, 1);
ellipse(x7, y, peak, peak);
}
endShape();
pop();
}
/// Frame8/vertex
// Timing+Rot
else if (key === 'h') {
background(0, 100, 0);
//background(Statistik1, 100)
translate(-60, 0) // Mitte der SP
radius = (height / 2 - 50) * 10; //radius
let rot = map(millis(), 0, 10000, 5 * PI, 0) ///////rotation
rotate(rot);
beginShape();
for (i = 0; i < peaks.length; i++) { //Variable hochzählen aber kleiner als peaks
peak = map(peaks[i], 0, 1, 0, hf / 10); //peaks zum Zeitpunkt i
step = map(i, 0, peaks.length, 0, 20 * PI); //anzahl runden
a = map(i, 0, peaks.length, 1, 0.4) // Verdichtung
x8 = a * (peak * 5 + radius) * cos(step) / 10; //Zeichnen im Kreis
y = a * (peak * 5 + radius) * sin(step) / 10;
noFill();
stroke(255);
vertex(x8, y);
// ellipse(x8, y, 10, 10)
}
endShape();
}
/// Frame9/ellipse
// Timing+Rot
else if (key === 'i') {
background(0, 100, 0);
//background(Statistik1, 100)
translate(-60, 0) // Mitte der SP
radius = (height / 2 - 50) * 10
let rot = map(millis(), 0, 10000, 5 * PI, 0) ///////rotation
rotate(rot);
beginShape();
for (i = 0; i < peaks.length; i++) { //Variable hochzählen aber kleiner als peaks
//peak = map(peaks[i], 0, 1, 0, hf/2); //peaks zum Zeitpunkt i
step = map(i, 0, peaks.length, 0, 10 * PI); //anzahl runden
a = map(i, 0, peaks.length, 1, 0.45) // Verdichtung/kreis in der Mitte
//x9 = a * (peak * 5 + radius) * cos(step) / 10; //Zeichnen im Kreis
// y = a * (peak * 5 + radius) * sin(step) / 10;
x9 = a * radius * cos(step) / 10
y = a * radius * sin(step) / 10
let h = map(peaks[i], 0, 0.2, 130, 180) //Farbe
let r = map(peaks[i], 0, 0.2, 0, hf / 15)
noFill();
stroke(h, 100, 100);
ellipse(x9, y, r, r);
endShape();
}
}
else {
background(0, 100, 0);
}
}
function keyPressed() {
if (keyCode == ENTER) {
id = tmp_id;
tmp_id = "";
} else {
tmp_id += key;
}
}