diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/synth_engine_v2.c | 4 | ||||
-rw-r--r-- | src/synth_gui.c | 36 | ||||
-rw-r--r-- | src/web.c | 74 |
3 files changed, 76 insertions, 38 deletions
diff --git a/src/synth_engine_v2.c b/src/synth_engine_v2.c index 4d9721c..7db9a6f 100644 --- a/src/synth_engine_v2.c +++ b/src/synth_engine_v2.c @@ -271,7 +271,7 @@ make_sample(synth_t * synth, unsigned int sample_rate, int frame) // band stop for high freqs //sample = bw_band_stop(synth->fff2, sample); - //if (synth->clamp) sample = clamp(sample, -1, 1); + if (synth->clamp) sample = clamp(sample, -1, 1); // autogain if (synth->autogain && (sample >= 1 || sample <= -1)) { @@ -424,7 +424,7 @@ sound_gen(const void *inputBuffer, void *outputBuffer, get_frame(buffer, synth, frame); } - smooth_buffer(buffer, framesPerBuffer, 0.1f); + //smooth_buffer(buffer, framesPerBuffer, 0.1f); // output buffer for( unsigned long i=0; i<framesPerBuffer * 2; i += 2 ) { diff --git a/src/synth_gui.c b/src/synth_gui.c index 215b8f5..e1f3101 100644 --- a/src/synth_gui.c +++ b/src/synth_gui.c @@ -874,6 +874,7 @@ void rayrun(synth_t *synth){ PaTime current_time = 0; PaTime prev_time = 0; + int mod = 0; osc_sound(0); @@ -889,6 +890,41 @@ rayrun(synth_t *synth){ keyboard(synth); mouse(synth); + if (true || mod++ % 10 == 0) { + char b[256]; + sprintf(b, "wvt_pos:%d", synth->wvt_pos); + ws_send_message(b); + sprintf(b, "cci:%d", synth->cci); + ws_send_message(b); + sprintf(b, "autogain:%d", synth->autogain); + ws_send_message(b); + sprintf(b, "x:%f", synth->x); + ws_send_message(b); + sprintf(b, "midi_active_n:%d", synth->midi_active_n); + ws_send_message(b); + sprintf(b, "octave:%d", synth->octave); + ws_send_message(b); + sprintf(b, "delay:%d", synth->delay); + ws_send_message(b); + sprintf(b, "deli:%d", synth->deli); + ws_send_message(b); + sprintf(b, "f_adsr_enabled:%d", synth->f_adsr_enabled); + ws_send_message(b); + sprintf(b, "filter:%d", synth->filter); + ws_send_message(b); + sprintf(b, "biquad:%d", synth->biquad); + ws_send_message(b); + sprintf(b, "clamp:%d", synth->clamp); + ws_send_message(b); + sprintf(b, "modi:%d", synth->modi); + ws_send_message(b); + sprintf(b, "geni:%d", synth->geni ); + ws_send_message(b); + sprintf(b, "active:%d", synth->active); + ws_send_message(b); + sprintf(b, "sound_active:%d", synth->sound_active); + ws_send_message(b); + } // Draw //---------------------------------------------------------------------------------- if (synth->gui.screen == SCREEN_MAIN) @@ -58,6 +58,38 @@ char *read_file_to_string(const char *filename) { return buffer; } +char *get_from_template() { + int size = 1024^3 * 1000; + char * ret = (char *)malloc(sizeof(char) * size); + + int pipefd[2]; + if (pipe(pipefd) == -1) { + perror("pipe"); + return NULL; + } + + synth_t * synth = synthx; + #define OUT pipefd[1] + #define INT(x) dprintf(OUT, "%d", x); + #define FLOAT(x) dprintf(OUT, "%f", x); + #define STR(x) dprintf(OUT, "%s", x); + #define PERCENT dprintf(OUT, "%s", "%"); + #include "index.html.h" + close(pipefd[1]); + + // Read from the pipe into a buffer + ssize_t bytes_read = read(pipefd[0], ret, size - 1); + if (bytes_read == -1) { + perror("read"); + return NULL; + } + + // Null-terminate the ret + ret[bytes_read] = '\0'; + close(pipefd[0]); + return ret; +} + int key_to_number(char key) { switch (key) { @@ -164,7 +196,7 @@ static int callback_ws(struct lws *wsi, enum lws_callback_reasons reason, break; } case LWS_CALLBACK_SERVER_WRITEABLE: { - printf("\nLWS_CALLBACK_SERVER_WRITEABLE\n\n"); + printf("LWS_CALLBACK_SERVER_WRITEABLE\n"); /* size_t msg_len = strlen(message_buffer); */ /* unsigned char buffer[LWS_PRE + BUFFER_SIZE]; */ /* memcpy(&buffer[LWS_PRE], message_buffer, msg_len); */ @@ -172,10 +204,12 @@ static int callback_ws(struct lws *wsi, enum lws_callback_reasons reason, break; } case LWS_CALLBACK_HTTP: { + html_content = get_from_template(); snprintf(tmp, sizeof(tmp), html_header, strlen(html_content)); strcpy(buf, tmp); strcat(buf, html_content); lws_write(wsi, (unsigned char *)buf, strlen(buf), LWS_WRITE_HTTP); + free(html_content); break; } case LWS_CALLBACK_CLOSED: { @@ -221,40 +255,10 @@ void *websocket_server_thread(void *arg) { return NULL; } -char *get_from_template() { - int size = 1024^3 * 1000; - char * ret = (char *)malloc(sizeof(char) * size); - - int pipefd[2]; - if (pipe(pipefd) == -1) { - perror("pipe"); - return NULL; - } - - #define OUT pipefd[1] - #define INT(x) dprintf(OUT, "%d", x); - #define PERCENT dprintf(OUT, "%s", "%"); - #include "index.html.h" - close(pipefd[1]); - - // Read from the pipe into a buffer - ssize_t bytes_read = read(pipefd[0], ret, size - 1); - if (bytes_read == -1) { - perror("read"); - return NULL; - } - - // Null-terminate the ret - ret[bytes_read] = '\0'; - close(pipefd[0]); - return ret; -} - void init_web(synth_t * synth) { //html_content = read_file_to_string("src/index.html"); - html_content = get_from_template(); synthx = synth; lws_set_log_level(LLL_WARN, NULL); @@ -274,14 +278,12 @@ free_web() void ws_send_message(const char *message) { if (client_wsi != NULL) { - /* strcpy(message_buffer, message); */ - /* lws_callback_on_writable(client_wsi); */ size_t msg_len = strlen(message); unsigned char buffer[LWS_PRE + BUFFER_SIZE]; memcpy(&buffer[LWS_PRE], message, msg_len); lws_write(client_wsi, &buffer[LWS_PRE], msg_len, LWS_WRITE_TEXT); - printf("[WS]: Sent <<%s>>\n", message); - - //lws_write(client_wsi, (unsigned char *)message, strlen(message), LWS_WRITE_TEXT); + // printf("[WS]: Sent <<%s>>\n", message); + // do I need this? + //lws_callback_on_writable(client_wsi); ??? } } |