From ed5ec5c193630c230e4a4d3a1a8b0f218381511b Mon Sep 17 00:00:00 2001 From: erdgeist Date: Mon, 16 Apr 2018 15:37:20 +0200 Subject: Add normalizing and pitch bending delay code --- engine.c | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'engine.c') diff --git a/engine.c b/engine.c index d9b35f7..82f1355 100644 --- a/engine.c +++ b/engine.c @@ -8,6 +8,7 @@ #include "midi.h" static int g_selected_string = -1; +static int g_normalize_mode = 0; #ifndef NO_DISPLAY #include "display.h" @@ -19,6 +20,13 @@ static ConfigSelect g_selected_config; static void highlight_line(int value, int y, int max_x, uint32_t color); #define scale(X) display_scale_harfe_to_screen(X) +static int64_t +engine_normalize(int height, int y) +{ + int64_t yf = (y << 16) / height; + yf = (((yf * yf - (yf << 16)) * ((int64_t)g_normalize_factor))) + (yf << 32); + return (((int64_t)height) * yf) >> 32; +} void engine_redraw() @@ -28,6 +36,7 @@ engine_redraw() const int tos1 = g_midi_three_octave_split_1, tos2 = g_midi_three_octave_split_2; const int height = g_max_y - g_min_y; int i, x2, MAX_X, MAX_Y, FONT_HEIGHT; + int t1 = 0, t2 = 0, t3 = 0; display_redraw(); display_clear(); @@ -47,6 +56,35 @@ engine_redraw() display_text( " 0", 4, scale(g_min_y + (tos1 + tos2) * height / 200) + FONT_HEIGHT / 2, 0x007f7f7fff); display_text( b ? "-1" : "+1", 4, scale(g_min_y + (tos2 / 2 + 50 ) * height / 100) + FONT_HEIGHT / 2, 0x007f7f7fff); + for (int x=0; x> 48; + + double xf = ((double)x) / 100.0f; + double yf = g_normalize_factor * (xf*xf-xf) + xf; + y = ax^2 + x - ax = a * (x^2 - x) + x + int y = scale(g_min_y + (int)(((double)height) * yf)); + */ + + display_line_color(0, scale(g_min_y + (y>>16)), MAX_X, scale(g_min_y + (y>>16)), 0x1f1f1f1f); + if (y >> 16 > (tos2 * height) / 100 ) + t1++; + else if (y >> 16 > (tos1 * height) / 100 ) + t2++; + else + t3++; + } + + if (g_normalize_mode) { + sprintf(text, "%lf", g_normalize_factor / 65336.0f); + display_text(text, 8, MAX_Y - 32, 0xff003fff ); + sprintf(text, "%d %d %d", t1, t2, t3); + display_text(text, 8, MAX_Y - 64, 0xff003fff ); + } + display_line_color(0, scale(g_min_y), MAX_X, scale(g_min_y), 0xff00ffff); display_line_color(0, scale(g_max_y), MAX_X, scale(g_max_y), 0xff00ffff); #ifdef HAVE_TWO_OCTAVE_MODE @@ -146,6 +184,19 @@ engine_select_config(ConfigSelect sel) { g_selected_config = sel; } +void +engine_toggle_normalize_mode() { + if (g_normalize_mode) + g_config_source = source_edit; + g_normalize_mode = 1 - g_normalize_mode; +} + +void +engine_mouse_y(int y) { + if (g_normalize_mode) + g_normalize_factor = y; +} + ConfigSelect engine_change_selected(int off) { -- cgit v1.2.3