Can anyone help me with this? I have a piece of code that uses input from the mic to create graphics. It worked on my old computer but won’t work on the new mac with touchbar for some reason.
// Example 20-5: Live Input with Sonia
PImage shape1;
PImage shape2;
PImage shape3;
PImage shape4;
PImage shape5;
PImage shape6;
PImage D;
PImage A1;
PImage A2;
PImage P;
PImage grid;
float shape1Height;
float shape1Width;
float shape2Height;
float shape2Width;
float shape3Height;
float shape3Width;
float shape4Height;
float shape4Width;
float shape5Height;
float shape5Width;
float shape6Height;
float shape6Width;
float DHeight;
float DWidth;
float A1Height;
float A1Width;
float A2Height;
float A2Width;
float PHeight;
float PWidth;
float gridHeight;
float gridWidth;
import processing.sound.*;
AudioIn input;
Amplitude analyzer;
void setup() {
size(500, 700);
shape1 = loadImage("shape1.png");
shape1Height = 300;
shape1Width = 300;
shape2 = loadImage("shape2.png");
shape1Height = 30;
shape1Width = 30;
shape3 = loadImage("shape3.png");
shape1Height = 80;
shape1Width = 80;
shape4 = loadImage("shape4.png");
shape1Height = 100;
shape1Width = 100;
shape5 = loadImage("shape5.png");
shape1Height = 150;
shape1Width = 150;
shape6 = loadImage("shape6.png");
shape1Height = 30;
shape1Width = 30;
D = loadImage("D.png");
DHeight = 15;
DWidth = 15;
A1 = loadImage("A1.png");
A1Height = 60;
A1Width = 60;
A2 = loadImage("A2.png");
A2Height = 20;
A2Width = 60;
P = loadImage("P.png");
PHeight = 200;
PWidth = 200;
grid = loadImage("grid.png");
gridHeight = 200;
gridWidth = 200;
// Start listening to the microphone
// Create an Audio input and grab the 1st channel
input = new AudioIn(this, 0);
// start the Audio Input
input.start();
// create a new Amplitude analyzer
analyzer = new Amplitude(this);
// Patch the input to an volume analyzer
analyzer.input(input);
}
void draw() {
background(255);
// Get the overall volume (between 0 and 1.0)
float vol = analyzer.analyze();
fill(127);
stroke(0);
//Draw grid
rotate(vol* 5);
image(grid, -18, 20, 300 +vol*3000, 300 +vol*3000);
//Draw shape1
image(shape1, 250, -10, 300 +vol*2000, 300 +vol*2000);
//Draw shape3
image(shape3, 50, 60, 80 +vol*2000, 80 +vol*2000);
//Draw shape4
image(shape4, 100 , 100, 100 +vol*2000, 100 +vol*2000);
//Draw shape5
image(shape5, 100, 400, 70 +vol*2000, 70 +vol*2000);
//Draw shape6
image(shape6, 85, 200, 30 +vol*2000, 30 +vol*2000);
rotate(vol* 5);
//Draw shape2
image(shape2, -70, 450, 300 +vol*2000, 300 +vol*2000);
rotate(vol*10);
image(D, 270, 220, DHeight+ vol*800, DWidth + vol*800);
image(A1, 290, 240, A1Height+ vol*800, A1Width + vol*800);
image(A2, 190, 310, A2Height+ vol*800, A2Width + vol*800);
image(P, 340, 400, PHeight+ vol*800, PWidth + vol*800);
rotate(vol* -10);
image(D, 270, 220, DHeight+ vol*2000, DWidth + vol*2000);
rotate(vol* -10);
image(A1, 290, 240, A1Height+ vol*2000, A1Width + vol*2000);
rotate(vol* -10);
image(A2, 190, 310, A2Height+ vol*2000, A2Width + vol*2000);
rotate(vol* -10);
image(P, 340, 400, PHeight+ vol*2000, PWidth + vol*2000);
}