summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristoph Helma <helma@in-silico.ch>2018-02-15 19:45:33 +0100
committerChristoph Helma <helma@in-silico.ch>2018-02-15 19:45:33 +0100
commitcbe481d6cb93cc87188d1f791296ba7e74a21b9b (patch)
tree47ffb5126a81957bf032532cf5b42af32eb55e51
parente5511608cce3236277266d67ddf521ac80df246b (diff)
pgm change
-rw-r--r--shader.frag4
-rw-r--r--sv.c45
2 files changed, 10 insertions, 39 deletions
diff --git a/shader.frag b/shader.frag
index 5492a95..07b7a28 100644
--- a/shader.frag
+++ b/shader.frag
@@ -31,6 +31,8 @@ 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];
+ if (program != 0) {
+ img.rgb = img.rgb*params[0];
+ }
fragColor = img;
}
diff --git a/sv.c b/sv.c
index 6f72e0c..93a822d 100644
--- a/sv.c
+++ b/sv.c
@@ -212,6 +212,7 @@ int ticks =0;
int running = 0;
int idx[2] = {0,1};
float vel[2] = {0,0};
+int program;
void *readMidi() {
midi_open();
@@ -307,6 +308,9 @@ void *readMidi() {
ev->data.control.value);
*/
}
+ else if(ev->type == SND_SEQ_EVENT_PGMCHANGE) {
+ program = 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,
@@ -322,40 +326,8 @@ void *readMidi() {
else if(ev->type == SND_SEQ_EVENT_CLOCK) {
if (running == 1) ticks++;
}
- else
- printf("[%d] Unknown: Unhandled Event Received\n", ev->time.tick);
- }
-}
-
-
-void *readStdin() {
- while (1) {
- char * str;
- size_t l = 80;
- getline(&str,&l,stdin);
- char *n = strtok(str," ");
- if (n[0] == 'i') {
- int i = atoi(strtok(NULL," "));
- strncpy(images[i].path, strtok(NULL,"\n"),40);
- images[i].new = 1;
- }
- else if (n[0] == 'f') {
- strncpy(shader.fragment, strtok(NULL,"\n"),40);
- shader.new = 1;
- }
- else if (n[0] == 'b') {
- bars = atof(strtok (NULL,"\n"));
- glfwSetTime(0);
- printf("%i\n",bars);
- }
- else if (n[0] == 'p') {
- int i = atoi(strtok(NULL," "));
- params[i].value = atof(strtok (NULL,"\n"));
- params[i].new = 1;
- }
- else if (n[0] == 'q') {
- glfwSetWindowShouldClose(window, GL_TRUE);
- }
+ //else
+ //printf("[%d] Unknown: Unhandled Event Received\n", ev->time.tick);
}
}
@@ -384,8 +356,6 @@ int main(int argc, char **argv) {
glTextureStorage2D(backbuffer,1,GL_RGBA32F,width,height);
glBindImageTexture(0,backbuffer, 0, GL_FALSE, 0, GL_READ_WRITE, GL_RGBA32F);
- //pthread_t stdin_t;
- //pthread_create(&stdin_t, NULL, readStdin, NULL);
pthread_t midiin_t;
pthread_create(&midiin_t, NULL, readMidi, NULL);
pthread_t frag_t;
@@ -395,8 +365,7 @@ int main(int argc, char **argv) {
//glUniform1f(glGetUniformLocation(shader.id, "time"),glfwGetTime());
//glUniform1f(glGetUniformLocation(shader.id, "time"),glfwGetTime());
glUniform1f(glGetUniformLocation(shader.id, "ticks"),(float)ticks);
- //printf("%i\n",note);
- //glUniform1i(glGetUniformLocation(shader.id, "program"),note-36);
+ glUniform1i(glGetUniformLocation(shader.id, "program"),program);
for (int i = 0; i<2; i++) {
glUniform1i(glGetUniformLocation(shader.id, "idx")+i,idx[i]);
glUniform1f(glGetUniformLocation(shader.id, "vel")+i,vel[i]);