summaryrefslogtreecommitdiff
path: root/sv.c
diff options
context:
space:
mode:
Diffstat (limited to 'sv.c')
-rw-r--r--sv.c51
1 files changed, 42 insertions, 9 deletions
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);