summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2018-02-15 19:35:16 +0100
committerChristoph Helma <helma@in-silico.ch>2018-02-15 19:35:16 +0100
commite5511608cce3236277266d67ddf521ac80df246b (patch)
treeeafc790f2d2f7d6241dce2c92986d13181998765
parentd3f4d3285d1be8a6445bae43827961c44880033b (diff)
cc params
-rw-r--r--shader.frag3
-rw-r--r--sv.c51
2 files changed, 44 insertions, 10 deletions
diff --git a/shader.frag b/shader.frag
index 4bb6810..5492a95 100644
--- a/shader.frag
+++ b/shader.frag
@@ -7,7 +7,7 @@ uniform vec2 resolution;
uniform float ticks;
uniform int program;
-uniform sampler2D images[4];
+uniform sampler2D images[8];
layout (binding = 0,rgba32f) uniform image2D backbuffer;
uniform float ratios[4];
uniform int idx[2];
@@ -31,5 +31,6 @@ void main (void) {
img = texture2D(images[idx[0]],st);
st = coordinates(idx[1]);
img = pow(img, texture2D(images[idx[1]],st));
+ img.rgb = img.rgb*params[0];
fragColor = img;
}
diff --git a/sv.c b/sv.c
index 338509d..6f72e0c 100644
--- a/sv.c
+++ b/sv.c
@@ -41,14 +41,14 @@ typedef struct Img {
int new;
} Image;
-Image images[4];
+Image images[8];
typedef struct Param {
float value;
int new;
} Parameter;
-Parameter parameters[4];
+Parameter params[4];
static snd_seq_t *seq_handle;
static int in_port;
@@ -189,7 +189,7 @@ void readImage(int i) {
}
void updateImages(int force) {
- for (int i = 0; i<4; i++) {
+ for (int i = 0; i<8; i++) {
if (images[i].new || force) {
readImage(i);
printf("%s\n",images[i].path);
@@ -201,9 +201,9 @@ void updateImages(int force) {
void updateParams(int force) {
glUniform1i(glGetUniformLocation(shader.id, "bars"), bars);
for (int i = 0; i<4; i++) {
- if (parameters[i].new || force) {
- glUniform1f(glGetUniformLocation(shader.id, "params")+i, parameters[i].value);
- parameters[i].new = 0;
+ if (params[i].new || force) {
+ glUniform1f(glGetUniformLocation(shader.id, "params")+i, params[i].value);
+ params[i].new = 0;
}
}
}
@@ -243,6 +243,18 @@ void *readMidi() {
else if (j == 5) {
idx[i] = 3; vel[i] = (float)v/127.0;
}
+ else if (j == 7) {
+ idx[i] = 4; vel[i] = (float)v/127.0;
+ }
+ else if (j == 9) {
+ idx[i] = 5; vel[i] = (float)v/127.0;
+ }
+ else if (j == 11) {
+ idx[i] = 6; vel[i] = (float)v/127.0;
+ }
+ else if (j == 12) {
+ idx[i] = 7; vel[i] = (float)v/127.0;
+ }
}
else if (ev->type == SND_SEQ_EVENT_NOTEOFF) {
@@ -269,11 +281,32 @@ void *readMidi() {
else if (j == 5) {
idx[i] = 3; vel[i] = 0;
}
+ else if (j == 7) {
+ idx[i] = 4; vel[i] = 0;
+ }
+ else if (j == 9) {
+ idx[i] = 5; vel[i] = 0;
+ }
+ else if (j == 11) {
+ idx[i] = 6; vel[i] = 0;
+ }
+ else if (j == 12) {
+ idx[i] = 7; vel[i] = 0;
+ }
}
- else if(ev->type == SND_SEQ_EVENT_CONTROLLER)
+ else if(ev->type == SND_SEQ_EVENT_CONTROLLER) {
+ int p = ev->data.control.param;
+ int v = ev->data.control.value;
+ if (p < 4) {
+ params[p].value = (float)v/127;
+ params[p].new = 1;
+ }
+ /*
printf("[%d] Control: %2x val(%2x)\n", ev->time.tick,
ev->data.control.param,
ev->data.control.value);
+ */
+ }
else if(ev->type == SND_SEQ_EVENT_SONGPOS) {
ticks = ev->data.control.value*24;
printf("[%d] SPP: %i val(%i)\n", ev->time.tick,
@@ -317,8 +350,8 @@ void *readStdin() {
}
else if (n[0] == 'p') {
int i = atoi(strtok(NULL," "));
- parameters[i].value = atof(strtok (NULL,"\n"));
- parameters[i].new = 1;
+ params[i].value = atof(strtok (NULL,"\n"));
+ params[i].new = 1;
}
else if (n[0] == 'q') {
glfwSetWindowShouldClose(window, GL_TRUE);