Skip to content

Commit

Permalink
grid studies: Processing (2024 update) (#423)
Browse files Browse the repository at this point in the history
  • Loading branch information
dndrks authored Sep 11, 2024
1 parent 4ff8324 commit 82e50df
Show file tree
Hide file tree
Showing 18 changed files with 186 additions and 86 deletions.
Binary file modified grid/studies/processing/files/grid-studies-processing.zip
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import org.monome.Monome;
import oscP5.*;

Monome m;

public void setup() {
m = new Monome(this);
}

public void key(int x, int y, int s) {
System.out.println("key received: " + x + ", " + y + ", " + s);
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ public void setup() {
}

public void draw() {
int[][] led = new int[8][16];
int[][] led = new int[16][16];
led[0][0] = 15;
led[2][0] = 5;
led[0][2] = 5;
Expand All @@ -19,4 +19,3 @@ public void draw() {
public void key(int x, int y, int s) {
System.out.println("key received: " + x + ", " + y + ", " + s);
}

Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ boolean dirty;

public void setup() {
m = new Monome(this);
led = new int[8][16];
led = new int[16][16];
dirty = true;
}

Expand All @@ -22,4 +22,3 @@ public void key(int x, int y, int s) {
led[y][x] = s * 15;
dirty = true;
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public void setup() {

public void draw() {
if(dirty) {
int[][] led = new int[8][16];
int[][] led = new int[16][16];

// display steps
for(int x=0;x<16;x++)
Expand All @@ -33,8 +33,6 @@ public void key(int x, int y, int s) {
// toggle steps
if(s == 1 && y < 6) {
step[y][x] ^= 1;

dirty = true;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ int timer;
int play_position;
int STEP_TIME = 10;


public void setup() {
m = new Monome(this);

Expand All @@ -20,18 +19,14 @@ public void setup() {

public void draw() {
if(timer == STEP_TIME) {
if(play_position == 15)
play_position = 0;
else
play_position++;

play_position = (play_position + 1) % 16;
timer = 0;
dirty = true;
}
else timer++;

if(dirty) {
int[][] led = new int[8][16];
int[][] led = new int[16][16];
int highlight;

// display steps
Expand All @@ -56,8 +51,6 @@ public void key(int x, int y, int s) {
// toggle steps
if(s == 1 && y < 6) {
step[y][x] ^= 1;

dirty = true;
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ public void draw() {
rect(0,0,width,height);

if(timer == STEP_TIME) {
if(play_position == 15)
play_position = 0;
else
play_position++;
play_position = (play_position + 1) % 16;

// TRIGGER SOMETHING
for(int y=0;y<6;y++)
Expand All @@ -42,7 +39,7 @@ public void draw() {
else timer++;

if(dirty) {
int[][] led = new int[8][16];
int[][] led = new int[16][16];
int highlight;

// display steps
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ boolean dirty;
int[][] step;
int timer;
int play_position;
int loop_start, loop_end;
int STEP_TIME = 10;
boolean cutting;
int next_position;
Expand All @@ -18,7 +17,6 @@ public void setup() {

dirty = true;
step = new int[6][16];
loop_end = 15;

size(360,140);
background(51);
Expand All @@ -34,9 +32,7 @@ public void draw() {
play_position = next_position;
else if(play_position == 15)
play_position = 0;
else if(play_position == loop_end)
play_position = loop_start;
else
else
play_position++;

// TRIGGER SOMETHING
Expand All @@ -51,7 +47,7 @@ public void draw() {
else timer++;

if(dirty) {
int[][] led = new int[8][16];
int[][] led = new int[16][16];
int highlight;

// display steps
Expand Down Expand Up @@ -89,22 +85,11 @@ public void key(int x, int y, int s) {

dirty = true;
}
// cut and loop
// cut
else if(y == 7) {
// track number of keys held
keys_held = keys_held + (s*2) - 1;

// cut
if(s == 1 && keys_held == 1) {
if(s == 1)
cutting = true;
next_position = x;
key_last = x;
}
// set loop points
else if(s == 1 && keys_held == 2) {
loop_start = key_last;
loop_end = x;
}
}
}

Expand Down
113 changes: 113 additions & 0 deletions grid/studies/processing/files/grid_studies_3_5/grid_studies_3_5.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
import org.monome.Monome;
import oscP5.*;

Monome m;
boolean dirty;

int[][] step;
int timer;
int play_position;
int loop_start, loop_end;
int STEP_TIME = 10;
boolean cutting;
int next_position;
int keys_held, key_last;

public void setup() {
m = new Monome(this);

dirty = true;
step = new int[6][16];
loop_end = 15;

size(360,140);
background(51);
stroke(255,204);
}

public void draw() {
fill(51, 60);
rect(0,0,width,height);

if(timer == STEP_TIME) {
if(cutting)
play_position = next_position;
else if(play_position == 15)
play_position = 0;
else if(play_position == loop_end)
play_position = loop_start;
else
play_position++;

// TRIGGER SOMETHING
for(int y=0;y<6;y++)
if(step[y][play_position] == 1)
trigger(y);

cutting = false;
timer = 0;
dirty = true;
}
else timer++;

if(dirty) {
int[][] led = new int[16][16];
int highlight;

// display steps
for(int x=0;x<16;x++) {
// highlight the play position
if(x == play_position)
highlight = 4;
else
highlight = 0;

for(int y=0;y<6;y++)
led[y][x] = step[y][x] * 11 + highlight;
}

// draw trigger bar and on-states
for(int x=0;x<16;x++)
led[6][x] = 4;
for(int y=0;y<6;y++)
if(step[y][play_position] == 1)
led[6][y] = 15;

// draw play position
led[7][play_position] = 15;

// update grid
m.refresh(led);
dirty = false;
}
}

public void key(int x, int y, int s) {
// toggle steps
if(s == 1 && y < 6) {
step[y][x] ^= 1;

dirty = true;
}
// cut and loop
else if(y == 7) {
// track number of keys held
keys_held = keys_held + (s*2) - 1;

// cut
if(s == 1 && keys_held == 1) {
cutting = true;
next_position = x;
key_last = x;
}
// set loop points
else if(s == 1 && keys_held == 2) {
loop_start = key_last;
loop_end = x;
}
}
}

public void trigger(int i) {
line(20,20+i*20,width-20,20+i*20);
}
Binary file not shown.
Binary file removed grid/studies/processing/images/grid-studies-p5-2.png
Binary file not shown.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit 82e50df

Please sign in to comment.