Hello community, here is the log from the commit of package cava for openSUSE:Factory checked in at 2017-08-22 11:10:02 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/cava (Old) and /work/SRC/openSUSE:Factory/.cava.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "cava" Tue Aug 22 11:10:02 2017 rev:3 rq:517924 version:0.5.0 Changes: -------- --- /work/SRC/openSUSE:Factory/cava/cava.changes 2017-04-30 21:24:42.401857246 +0200 +++ /work/SRC/openSUSE:Factory/.cava.new/cava.changes 2017-08-22 11:10:03.412756892 +0200 @@ -1,0 +2,11 @@ +Fri Aug 18 20:43:54 UTC 2017 - [email protected] + +- Update to 0.5.0: + new features: + * gradient + bugfixes: + * memory leak + * increased config reload speed + * raw output not goint to /dev/stdout + +------------------------------------------------------------------- Old: ---- 0.4.3.tar.gz New: ---- 0.5.0.tar.gz ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ cava.spec ++++++ --- /var/tmp/diff_new_pack.voTkus/_old 2017-08-22 11:10:04.496604280 +0200 +++ /var/tmp/diff_new_pack.voTkus/_new 2017-08-22 11:10:04.504603154 +0200 @@ -17,7 +17,7 @@ Name: cava -Version: 0.4.3 +Version: 0.5.0 Release: 0 Summary: Console-based Audio Visualizer for Alsa License: MIT ++++++ 0.4.3.tar.gz -> 0.5.0.tar.gz ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/CONTRIBUTING.md new/cava-0.5.0/CONTRIBUTING.md --- old/cava-0.4.3/CONTRIBUTING.md 1970-01-01 01:00:00.000000000 +0100 +++ new/cava-0.5.0/CONTRIBUTING.md 2017-08-14 22:34:14.000000000 +0200 @@ -0,0 +1,15 @@ +# How to contribute +Thank you for wanting to contribute to this project. In order to get the development of this project to run as smooth as possible, we will encourage all contributions to follw this simple process: + +1. Before any pull request is submitted a github issue must be created for the task. +2. The new github task is to be opened for suggestions from other contributors. +3. A pull request is published. +4. Contributors code review pull request and approve/reject pull request. +5. Pull request either gets approved or rejected. +5. Github task is updated and everyone is notified. + +# Coding conventions +* tab for indents +* curly braces on same line as if, while, for statements + +Generally please try to keep the style consistent with the code as it is. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/README.md new/cava-0.5.0/README.md --- old/cava-0.4.3/README.md 2017-04-23 21:58:19.000000000 +0200 +++ new/cava-0.5.0/README.md 2017-08-14 22:34:14.000000000 +0200 @@ -5,14 +5,12 @@ by [Karl Stavestrand](mailto:[email protected]) -Now with more colors! Use hex codes in config, for example: +Now with multicolored gradient: ``` -background = '#253552' -foreground = '#FF479C' +gradient = 1 ``` -(hex code must be within '') - + thanks to [anko](https://github.com/anko) for the gif, here is the [recipe]( http://unix.stackexchange.com/questions/113695/gif-screencastng-the-unix-way). @@ -43,7 +41,7 @@ - [Usage](#usage) - [Controls](#controls) - [Configuration](#configuration) -- [Thanks](#thanks) +- [Contribution](#contribution) <!-- END doctoc generated TOC please keep comment here to allow auto update --> @@ -122,12 +120,15 @@ ### openSUSE -On openSUSE you need to add jubalh's home repository to install cava via zypper. For example for Tumbleweed do: +Tumbleweed users have cava in their repo. They can just use: - zypper ar -f http://download.opensuse.org/repositories/home:/jubalh/openSUSE_Tumbleweed/home:jubalh.repo - zypper in cava + zypper in cava -If you use 13.2 or 13.1 just replace *openSUSE_Tumbleweed* with *openSUSE_13.2*, adjust it to your version. +Leap users need to add the multimedia:apps repository first: + + zypper ar -f obs://multimedia:apps/openSUSE_Leap_42.2 multimedia + +If you use another version just replace *openSUSE_Leap_42.2* with *openSUSE_13.2*, adjust it to your version. ### Fedora @@ -326,13 +327,16 @@  -Thanks +Contribution ------ -Contributors: -* [Karl Stavestrand](mailto:[email protected]) - creator +Please read CONTRIBUTING.md before opening a pull request. + +Thanks to: * [CelestialWalrus](https://github.com/CelestialWalrus) * [anko](https://github.com/anko) * [livibetter](https://github.com/livibetter) +for mayor contributions in the early development of this project. + Also thanks to [dpayne](https://github.com/dpayne/) for figuring out how to find the pulseaudio default sink name. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/cava.c new/cava-0.5.0/cava.c --- old/cava-0.4.3/cava.c 2017-04-23 21:58:19.000000000 +0200 +++ new/cava-0.5.0/cava.c 2017-08-14 22:34:14.000000000 +0200 @@ -71,6 +71,8 @@ char *inputMethod, *outputMethod, *modeString, *color, *bcolor, *style, *raw_target, *data_format; // *bar_delim, *frame_delim ; +char *gradient_color_1; +char *gradient_color_2; double monstercat, integral, gravity, ignore, smh, sens; int fixedbars, framerate, bw, bs, autosens, overshoot; unsigned int lowcf, highcf; @@ -81,6 +83,7 @@ 0.7, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6, 0.6}; double *smooth = smoothDef; int smcount = 64; +int customEQ = 0; struct audio_data audio; int im = 0; int om = 1; @@ -91,12 +94,17 @@ int autobars = 1; int stereo = -1; int M = 2048; -char supportedInput[255] = "'fifo'"; int is_bin = 1; char bar_delim = ';'; char frame_delim = '\n'; int ascii_range = 1000; int bit_format = 16; +int gradient = 0; +dictionary* ini; +char supportedInput[255] = "'fifo'"; +int sourceIsAuto = 1; + + // whether we should reload the config or not int should_reload = 0; @@ -175,20 +183,18 @@ } // config: parse ini - dictionary* ini = iniparser_load(configPath); + ini = iniparser_load(configPath); //setting fifo to defaualt if no other input modes supported inputMethod = (char *)iniparser_getstring(ini, "input:method", "fifo"); //setting alsa to defaualt if supported #ifdef ALSA - strcat(supportedInput,", 'alsa'"); inputMethod = (char *)iniparser_getstring(ini, "input:method", "alsa"); #endif //setting pulse to defaualt if supported #ifdef PULSE - strcat(supportedInput,", 'pulse'"); inputMethod = (char *)iniparser_getstring(ini, "input:method", "pulse"); #endif @@ -209,6 +215,12 @@ color = (char *)iniparser_getstring(ini, "color:foreground", "default"); bcolor = (char *)iniparser_getstring(ini, "color:background", "default"); + gradient = iniparser_getint(ini, "color:gradient", 0); + if (gradient) { + gradient_color_1 = (char *)iniparser_getstring(ini, "color:gradient_color_1", "#0099ff"); + gradient_color_2 = (char *)iniparser_getstring(ini, "color:gradient_color_2", "#ff3399"); + } + fixedbars = iniparser_getint(ini, "general:bars", 0); bw = iniparser_getint(ini, "general:bar_width", 2); bs = iniparser_getint(ini, "general:bar_spacing", 1); @@ -229,8 +241,10 @@ bit_format = iniparser_getint(ini, "output:bit_format", 16); // read & validate: eq + smcount = iniparser_getsecnkeys(ini, "eq"); if (smcount > 0) { + customEQ = 1; smooth = malloc(smcount*sizeof(*smooth)); #ifndef LEGACYINIPARSER const char *keys[smcount]; @@ -243,6 +257,7 @@ smooth[sk] = iniparser_getdouble(ini, keys[sk], 1); } } else { + customEQ = 0; smcount = 64; //back to the default one } @@ -303,6 +318,7 @@ // validate: input method + im = 0; if (strcmp(inputMethod, "alsa") == 0) { im = 1; #ifndef ALSA @@ -316,9 +332,6 @@ } if (strcmp(inputMethod, "pulse") == 0) { im = 3; - #ifdef PULSE - if (strcmp(audio.source, "auto") == 0) getPulseDefaultSink((void*)&audio); - #endif #ifndef PULSE fprintf(stderr, "cava was built without pulseaudio support, install pulseaudio dev files and run make clean && ./configure && make again\n"); @@ -334,6 +347,7 @@ } // validate: output method + om = 0; if (strcmp(outputMethod, "ncurses") == 0) { om = 1; #ifndef NCURSES @@ -612,12 +626,6 @@ int sleep = 0; int i, n, o, height, h, w, c, rest, inAtty, silence, fp, fptest; float temp; - double inr[2 * (M / 2 + 1)]; - fftw_complex outr[M / 2 + 1][2]; - fftw_plan pr; - double inl[2 * (M / 2 + 1)]; - fftw_complex outl[M / 2 + 1][2]; - fftw_plan pl; //int cont = 1; int fall[200]; float fpeak[200]; @@ -636,6 +644,8 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.config/cava/' \n"; char ch = '\0'; + double inr[2 * (M / 2 + 1)]; + double inl[2 * (M / 2 + 1)]; //int maxvalue = 0; @@ -676,17 +686,26 @@ n = 0; } + #ifdef ALSA + strcat(supportedInput,", 'alsa'"); + #endif + #ifdef PULSE + strcat(supportedInput,", 'pulse'"); + #endif + //fft: planning to rock + fftw_complex outl[M / 2 + 1][2]; + fftw_plan pl = fftw_plan_dft_r2c_1d(M, inl, *outl, FFTW_MEASURE); + + fftw_complex outr[M / 2 + 1][2]; + fftw_plan pr = fftw_plan_dft_r2c_1d(M, inr, *outr, FFTW_MEASURE); - - // general: main loop while (1) { //config: load & validate load_config(configPath); - validate_config(); - + validate_config(); if (om != 4) { // Check if we're running in a Virtual console todo: replace virtual console with terminal emulator @@ -759,7 +778,12 @@ #ifdef PULSE if (im == 3) { - thr_id = pthread_create(&p_thread, NULL, input_pulse, (void*)&audio); //starting fifomusic listener + if (strcmp(audio.source, "auto") == 0) { + getPulseDefaultSink((void*)&audio); + sourceIsAuto = 1; + } + else sourceIsAuto = 0; + thr_id = pthread_create(&p_thread, NULL, input_pulse, (void*)&audio); //starting pulsemusic listener audio.rate = 44100; } #endif @@ -771,12 +795,8 @@ ); exit(EXIT_FAILURE); } + - pl = fftw_plan_dft_r2c_1d(M, inl, *outl, FFTW_MEASURE); //planning to rock - - if (stereo) { - pr = fftw_plan_dft_r2c_1d(M, inr, *outr, FFTW_MEASURE); - } bool reloadConf = FALSE; bool senseLow = TRUE; @@ -794,8 +814,8 @@ #ifdef NCURSES //output: start ncurses mode if (om == 1 || om == 2) { - init_terminal_ncurses(color, bcolor, col, bgcol); - get_terminal_dim_ncurses(&w, &h); + init_terminal_ncurses(color, bcolor, col, bgcol, gradient, gradient_color_1, gradient_color_2,&w, &h); + //get_terminal_dim_ncurses(&w, &h); } #endif @@ -821,18 +841,16 @@ } fptest = open(raw_target, O_RDONLY | O_NONBLOCK, 0644); //fifo needs to be open for reading in order to write to it } - - - fp = open(raw_target, O_WRONLY | O_NONBLOCK | O_CREAT, 0644); - if (fp == -1) { - printf("could not open file %s for writing\n",raw_target); - exit(1); - } - printf("open file %s for writing raw ouput\n",raw_target); + } - + fp = open(raw_target, O_WRONLY | O_NONBLOCK | O_CREAT, 0644); + if (fp == -1) { + printf("could not open file %s for writing\n",raw_target); + exit(1); } - + printf("open file %s for writing raw ouput\n",raw_target); + + //height and with must be hardcoded for raw output. h = 112; w = 200; } @@ -967,9 +985,6 @@ } if (should_reload) { - //**telling audio thread to terminate**// - audio.terminate = 1; - pthread_join( p_thread, NULL); reloadConf = TRUE; resizeTerminal = TRUE; @@ -1119,7 +1134,7 @@ switch (om) { case 1: #ifdef NCURSES - rc = draw_terminal_ncurses(inAtty, h, w, bars, bw, bs, rest, f, flastd); + rc = draw_terminal_ncurses(inAtty, h, w, bars, bw, bs, rest, f, flastd, gradient); break; #endif case 2: @@ -1152,9 +1167,19 @@ } } }//reloading config - req.tv_sec = 1; //waiting a second to free audio streams - req.tv_nsec = 0; + req.tv_sec = 0; + req.tv_nsec = 100; //waiting some time to make shure audio is ready nanosleep (&req, NULL); + + //**telling audio thread to terminate**// + audio.terminate = 1; + pthread_join( p_thread, NULL); + + if (customEQ) free(smooth); + if (sourceIsAuto) free(audio.source); + iniparser_freedict(ini); + + //fclose(fp); } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/changelog new/cava-0.5.0/changelog --- old/cava-0.4.3/changelog 2017-04-23 21:58:19.000000000 +0200 +++ new/cava-0.5.0/changelog 1970-01-01 01:00:00.000000000 +0100 @@ -1,70 +0,0 @@ -2016-02-10 - 0.4.1 - -new features: -- added auto pulseaudio source mode -- pulsaudio is now default -- cava is now cavamp -- pushing 'r' now reloads audio -- Added console title - -bugfixes: -- Error on Raspbian at run-time when running from installed path - -2015-11-22 - 0.4.0 - -- added pulseadio support -- added confg script -- removed commanline argumets -- added optional config path -- added autosens feature -- bugfixes - -2015-9-19 - 0.3.5 - -- now in stereo! - - -2015-8-25 - 0.3.4 - -- added setting of bar width, bar spacing and frequency bandwidth to config file. - - -2015-8-9 - 0.3.3 - -- autodetection of alsa loopback interface - - -2015-7-16 - 0.3.2 - -- added legacy ouput mode 'noncurses', for people experiencing issues with ncurses - - -2015-7-15 - 0.3.1 - -- added config file - - -2015-7-12 - 0.3.0 - -- Modular source code - - -2015-5-23 - 0.2.0 - -- Switched to ncurses - - -2015-4-23 - -- Fixed terminal window resizing, added smoothing - - -2015-4-19 - -- Added Monstercat style FFT easing (by [CelestialWalrus)](https://github.com/CelestialWalrus). - - -2014-9-22 - -- Added support for mpd FIFO input. - diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/example_files/config new/cava-0.5.0/example_files/config --- old/cava-0.4.3/example_files/config 2017-04-23 21:58:19.000000000 +0200 +++ new/cava-0.5.0/example_files/config 2017-08-14 22:34:14.000000000 +0200 @@ -93,10 +93,19 @@ [color] # Colors can be one of seven predefined: black, blue, cyan, green, magenta, red, white, yellow. -# Or defined by hex code '#xxxxxx' (hex code must be within ''). +# Or defined by hex code '#xxxxxx' (hex code must be within ''). User defined colors requires a +# terminal that can change color definitions such as Gnome-terminal or rxvt. ; background = black ; foreground = cyan +# Gradient mode, only hex defined colors are supported, background must also be defined in hex +# or remain commented out. 1 = on, 0 = off. Warning: for certain terminal emulators cava will +# not able to restore color definitions on exit, simply restart your terminal to restore colors. +; gradient = 0 +; gradient_color_1 = '#0099ff' +; gradient_color_2 = '#ff3399' + + [smoothing] diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/input/fifo.c new/cava-0.5.0/input/fifo.c --- old/cava-0.4.3/input/fifo.c 2017-04-23 21:58:19.000000000 +0200 +++ new/cava-0.5.0/input/fifo.c 2017-08-14 22:34:14.000000000 +0200 @@ -4,7 +4,7 @@ int audio_out_l[2048]; int format; unsigned int rate ; - char *source ; //alsa device, fifo path or pulse source + char *source; //alsa device, fifo path or pulse source int im; //input mode alsa, fifo or pulse int channels; int terminate; // shared variable used to terminate audio thread diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/input/pulse.c new/cava-0.5.0/input/pulse.c --- old/cava-0.4.3/input/pulse.c 2017-04-23 21:58:19.000000000 +0200 +++ new/cava-0.5.0/input/pulse.c 2017-08-14 22:34:14.000000000 +0200 @@ -21,7 +21,10 @@ audio->source = strcat(audio->source, ".monitor"); //quiting mainloop + pa_context_disconnect(pulseaudio_context); + pa_context_unref(pulseaudio_context); pa_mainloop_quit(m_pulseaudio_mainloop, 0); + pa_mainloop_free(m_pulseaudio_mainloop); } @@ -111,7 +114,7 @@ .fragsize = BUFSIZE }; - pa_simple *s = NULL; + pa_simple *s = NULL; int error; if (!(s = pa_simple_new(NULL, "cava", PA_STREAM_RECORD, audio->source, "audio for cava", &ss, NULL, &pb, &error))) { @@ -144,10 +147,10 @@ if (n == 2048 - 1)n = 0; } - if (audio->terminate == 1) { + if (audio->terminate == 1) { pa_simple_free(s); break; - } + } } return 0; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/output/terminal_ncurses.c new/cava-0.5.0/output/terminal_ncurses.c --- old/cava-0.4.3/output/terminal_ncurses.c 2017-04-23 21:58:19.000000000 +0200 +++ new/cava-0.5.0/output/terminal_ncurses.c 2017-08-14 22:34:14.000000000 +0200 @@ -2,6 +2,8 @@ #include <wchar.h> #include <stdlib.h> +int gradient_size = 64; + struct colors { NCURSES_COLOR_T color; NCURSES_COLOR_T R; @@ -11,9 +13,9 @@ #define COLOR_REDEFINITION -2 -#define MAX_COLOR_REDEFINITION 2 +#define MAX_COLOR_REDEFINITION 256 -static struct colors the_color_redefinitions[MAX_COLOR_REDEFINITION]; +//static struct colors the_color_redefinitions[MAX_COLOR_REDEFINITION]; static void parse_color(char* color_string, struct colors* color) { @@ -28,7 +30,7 @@ sscanf(++color_string, "%02hx%02hx%02hx", &color->R, &color->G, &color->B); } } - +/* static void remember_color_definition(NCURSES_COLOR_T color_number) { int index = color_number - 1; // array starts from zero and colors - not if(the_color_redefinitions[index].color == 0) { @@ -39,7 +41,7 @@ &the_color_redefinitions[index].B); } } - +*/ // ncurses use color range [0, 1000], and we - [0, 255] #define CURSES_COLOR_COEFFICIENT( X ) (( X ) * 1000.0 / 0xFF + 0.5) #define COLORS_STRUCT_NORMALIZE( X ) CURSES_COLOR_COEFFICIENT( X.R ), \ @@ -51,15 +53,17 @@ parse_color(color_string, &color); NCURSES_COLOR_T return_color_number = predef_color; if (color.color == COLOR_REDEFINITION) { - remember_color_definition(color_number); + //remember_color_definition(color_number); init_color(color_number, COLORS_STRUCT_NORMALIZE(color)); return_color_number = color_number; } return return_color_number; } + void init_terminal_ncurses(char* const fg_color_string, -char* const bg_color_string, int predef_fg_color, int predef_bg_color) { +char* const bg_color_string, int predef_fg_color, int predef_bg_color, int gradient, + char* const gradient_color_1, char* const gradient_color_2, int* width, int* height) { initscr(); curs_set(0); timeout(0); @@ -67,25 +71,72 @@ start_color(); use_default_colors(); - NCURSES_COLOR_T fg_color_number; - fg_color_number = change_color_definition(1, fg_color_string, predef_fg_color); + getmaxyx(stdscr, *height, *width); + clear(); + + NCURSES_COLOR_T color_pair_number = 1; + + NCURSES_COLOR_T bg_color_number; + bg_color_number = change_color_definition(0, bg_color_string, predef_bg_color); + + if (!gradient) { + + NCURSES_COLOR_T fg_color_number; + fg_color_number = change_color_definition(1, fg_color_string, predef_fg_color); + + init_pair(color_pair_number, fg_color_number, bg_color_number); + + } else if (gradient) { + + short unsigned int rgb[3][3]; + char next_color[8]; + + gradient_size = *height; + + if (gradient_size > COLORS) gradient_size = COLORS - 1; + + if (gradient_size > COLOR_PAIRS) gradient_size = COLOR_PAIRS - 1; + + if (gradient_size > MAX_COLOR_REDEFINITION) gradient_size = MAX_COLOR_REDEFINITION - 1; - NCURSES_COLOR_T bg_color_number; - bg_color_number = change_color_definition(2, bg_color_string, predef_bg_color); - // do not forget to increase MAX_COLOR_REDEFINITION if you change more color - // definitions + sscanf(gradient_color_1 + 1, "%02hx%02hx%02hx", &rgb[0][0], &rgb[0][1], &rgb[0][2]); + sscanf(gradient_color_2 + 1, "%02hx%02hx%02hx", &rgb[1][0], &rgb[1][1], &rgb[1][2]); - NCURSES_COLOR_T color_pair_number = 1; - init_pair(color_pair_number, fg_color_number, bg_color_number); + for (int n = 0; n < gradient_size; n++) { + + for(int i = 0; i < 3; i++) { + rgb[2][i] = rgb[0][i] + (rgb[1][i] - rgb[0][i]) * n / (gradient_size * 0.85); + if (rgb[2][i] > 255) rgb[2][i] = 0; + if ( n > gradient_size * 0.85 ) rgb[2][i] = rgb[1][i]; + } + + sprintf(next_color,"#%02x%02x%02x",rgb[2][0], rgb[2][1], rgb[2][2]); + + change_color_definition(n + 1, next_color, n + 1); + init_pair(color_pair_number++, n + 1, bg_color_number); + + } + + } if (bg_color_number != -1) bkgd(COLOR_PAIR(color_pair_number)); attron(COLOR_PAIR(color_pair_number)); refresh(); + +} + +void change_colors(int cur_height, int tot_height) { + tot_height /= gradient_size ; + if (tot_height < 1) tot_height = 1; + cur_height /= tot_height; + if (cur_height > gradient_size - 1) cur_height = gradient_size - 1; + attron(COLOR_PAIR(cur_height + 1)); } void get_terminal_dim_ncurses(int* width, int* height) { getmaxyx(stdscr, *height, *width); + gradient_size = *height; clear(); // clearing in case of resieze } @@ -93,7 +144,8 @@ int draw_terminal_ncurses(int is_tty, int terminal_height, int terminal_width, int bars_count, int bar_width, int bar_spacing, int rest, const int f[200], -int flastd[200]) { +int flastd[200], int gradient) { + const wchar_t* bar_heights[] = {L"\u2581", L"\u2582", L"\u2583", L"\u2584", L"\u2585", L"\u2586", L"\u2587", L"\u2588"}; #define LAST ((sizeof(bar_heights) / sizeof(bar_heights[0])) - 1) @@ -107,17 +159,22 @@ const int height = terminal_height - 1; #define CURRENT_COLUMN bar*bar_width + width + bar*bar_spacing + rest for (int bar = 0; bar < bars_count; bar++) { - if (f[bar] > flastd[bar]) { // higher then last one + if (f[bar] > flastd[bar]) { // higher then last frame if (is_tty) { - for (int n = flastd[bar] / 8; n < f[bar] / 8; n++) + for (int n = flastd[bar] / 8; n < f[bar] / 8; n++) { + if (gradient) change_colors(n, height); for (int width = 0; width < bar_width; width++) mvprintw((height - n), CURRENT_COLUMN, "%d", 8); + } } else { - for (int n = flastd[bar] / 8; n < f[bar] / 8; n++) + for (int n = flastd[bar] / 8; n < f[bar] / 8; n++) { + if (gradient) change_colors(n, height); for (int width = 0; width < bar_width; width++) mvaddwstr((height - n), CURRENT_COLUMN, bar_heights[LAST]); + } } + if (gradient) change_colors(f[bar] / 8, height); if (f[bar] % 8) { if (is_tty) { for (int width = 0; width < bar_width; width++) @@ -129,11 +186,12 @@ bar_heights[(f[bar] % 8) - 1]); } } - } else if(f[bar] < flastd[bar]) { // lower then last one + } else if(f[bar] < flastd[bar]) { // lower then last frame for (int n = f[bar] / 8; n < flastd[bar]/8 + 1; n++) for (int width = 0; width < bar_width; width++) mvaddstr((height - n), CURRENT_COLUMN, " "); if (f[bar] % 8) { + if (gradient) change_colors(f[bar] / 8, height); if (is_tty) { for (int width = 0; width < bar_width; width++) mvprintw((height - f[bar] / 8), CURRENT_COLUMN, "%d", @@ -152,13 +210,15 @@ return 0; } + + // general: cleanup void cleanup_terminal_ncurses(void) { echo(); system("setfont >/dev/null 2>&1"); system("setfont /usr/share/consolefonts/Lat2-Fixed16.psf.gz >/dev/null 2>&1"); system("setterm -blank 10"); - for(int i = 0; i < MAX_COLOR_REDEFINITION; ++i) { + /*for(int i = 0; i < gradient_size; ++i) { if(the_color_redefinitions[i].color) { init_color(the_color_redefinitions[i].color, the_color_redefinitions[i].R, @@ -166,7 +226,9 @@ the_color_redefinitions[i].B); } } + */ endwin(); system("clear"); + system("reset"); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.3/output/terminal_ncurses.h new/cava-0.5.0/output/terminal_ncurses.h --- old/cava-0.4.3/output/terminal_ncurses.h 2017-04-23 21:58:19.000000000 +0200 +++ new/cava-0.5.0/output/terminal_ncurses.h 2017-08-14 22:34:14.000000000 +0200 @@ -1,7 +1,8 @@ void init_terminal_ncurses(char* const fg_color_string, - char* const bg_color_string, int predef_fg_color, int predef_bg_color); + char* const bg_color_string, int predef_fg_color, int predef_bg_color, int gradient, + char* const gradient_color_1, char* const gradient_color_2,int* width, int* height); void get_terminal_dim_ncurses(int* width, int* height); int draw_terminal_ncurses(int is_tty, int terminal_height, int terminal_width, int bars_count, int bar_width, int bar_spacing, int rest, const int f[200], - int flastd[200]); + int flastd[200], int gradient); void cleanup_terminal_ncurses(void);
