Hello community,
here is the log from the commit of package cava for openSUSE:Factory checked in at 2017-04-30 21:23:48
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/cava (Old)
and /work/SRC/openSUSE:Factory/.cava.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "cava"
Sun Apr 30 21:23:48 2017 rev:2 rq:491963 version:0.4.3
Changes:
--------
--- /work/SRC/openSUSE:Factory/cava/cava.changes 2017-04-07 14:20:43.131178448 +0200
+++ /work/SRC/openSUSE:Factory/.cava.new/cava.changes 2017-04-30 21:24:42.401857246 +0200
@@ -1,0 +2,14 @@
+Thu Apr 27 15:04:00 UTC 2017 - mvetter@suse.com
+
+- Update to 0.4.3:
+ new features:
+ * support for more colors in ncurses output.
+ bugfixes:
+ * fixed bug where sensing of low values was done even when no sound
+ * fixed bug in raw output bit format check
+ * add a check for too many bars >200
+- Remove because contained in new version:
+ * cava-remove-nested-functions.patch
+ * cava-font.patch
+
+-------------------------------------------------------------------
Old:
----
0.4.2.tar.gz
cava-font.patch
cava-remove-nested-functions.patch
New:
----
0.4.3.tar.gz
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Other differences:
------------------
++++++ cava.spec ++++++
--- /var/tmp/diff_new_pack.i0iDhp/_old 2017-04-30 21:24:43.029768712 +0200
+++ /var/tmp/diff_new_pack.i0iDhp/_new 2017-04-30 21:24:43.033768148 +0200
@@ -17,17 +17,13 @@
Name: cava
-Version: 0.4.2
+Version: 0.4.3
Release: 0
Summary: Console-based Audio Visualizer for Alsa
License: MIT
Group: Productivity/Multimedia/Sound/Visualization
Url: https://github.com/karlstav/cava
Source: https://github.com/karlstav/%{name}/archive/%{version}.tar.gz
-# FIX-UPSTREAM: See https://github.com/karlstav/cava/issues/142
-Patch0: cava-remove-nested-functions.patch
-# FIX-UPSTREAM: https://github.com/karlstav/cava/issues/147
-Patch1: cava-font.patch
BuildRequires: alsa-devel
BuildRequires: fftw3-devel
# Use system ini parser instead of building own lib
@@ -44,10 +40,8 @@
%prep
%setup -q
-%patch0 -p1
-%patch1 -p1
./autogen.sh
-FONT_DIR="%{_datadir}/kbd/consolefonts" %configure
+%configure FONT_DIR="%{_datadir}/kbd/consolefonts"
%build
make %{?_smp_mflags}
++++++ 0.4.2.tar.gz -> 0.4.3.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/Makefile.am new/cava-0.4.3/Makefile.am
--- old/cava-0.4.2/Makefile.am 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/Makefile.am 2017-04-23 21:58:19.000000000 +0200
@@ -16,6 +16,9 @@
-D_POSIX_SOURCE -D _POSIX_C_SOURCE=200809L
cava_CFLAGS = -std=c99 -Wall -Wextra -Wno-unused-result -Wno-maybe-uninitialized
+cava_font_dir = @FONT_DIR@
+cava_font__DATA = cava.psf
+
if !SYSTEM_LIBINIPARSER
cava_SOURCES += iniparser/libiniparser.la
cava_LDADD += -Liniparser/.libs
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/README.md new/cava-0.4.3/README.md
--- old/cava-0.4.2/README.md 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/README.md 2017-04-23 21:58:19.000000000 +0200
@@ -5,6 +5,13 @@
by [Karl Stavestrand](mailto:karl@stavestrand.no)
+Now with more colors! Use hex codes in config, for example:
+```
+background = '#253552'
+foreground = '#FF479C'
+```
+(hex code must be within '')
+
![spectrum](https://cloud.githubusercontent.com/assets/5231746/7368413/7d7ca93e-ed9f-11e... "spectrum")
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).
@@ -55,14 +62,15 @@
* [ncursesw dev files](http://www.gnu.org/software/ncurses/) (bundled in ncurses in arch)
* [ALSA dev files](http://alsa-project.org/)
* [Pulseaudio dev files](http://freedesktop.org/software/pulseaudio/doxygen/)
+* libtool
-Only FFTW is actually required for CAVA to compile, but for maximum usage and preformance ncurses and pulseaudio and/or alsa dev files are recommended. Not sure how to get the pulseaudio dev files for other distros than debian/ubuntu or if they are bundled in pulseaudio.
+Only FFTW is actually required for CAVA to compile, but for maximum usage and performance ncurses and pulseaudio and/or alsa dev files are recommended. Not sure how to get the pulseaudio dev files for other distros than debian/ubuntu or if they are bundled in pulseaudio.
All the requirements can be installed easily in all major distros:
Debian/Raspbian:
- apt-get install libfftw3-dev libasound2-dev libncursesw5-dev libpulse-dev
+ apt-get install libfftw3-dev libasound2-dev libncursesw5-dev libpulse-dev libtool
ArchLinux:
@@ -70,14 +78,14 @@
openSUSE:
- zypper install alsa-devel ncurses-devel fftw3-devel
+ zypper install alsa-devel ncurses-devel fftw3-devel libpulse-devel libtool
Fedora:
- dnf install alsa-lib-devel ncurses-devel fftw3-devel
+ dnf install alsa-lib-devel ncurses-devel fftw3-devel pulseaudio-libs-devel libtool
-Iniparser is also required, but if it is not allready installed a bundled version will be used.
+Iniparser is also required, but if it is not already installed, a bundled version will be used.
To run the autogen script you will also need `automake`, `libtool` and `git`.
@@ -164,9 +172,9 @@
method = alsa
-in config file
+in the config file.
-ALSA can be difficult because there is no native way to grap audio from an output. If you want to capture audio straight fom the output (not just mic or line-in), you must create an ALSA loopback interface, then output the audio simultaneously to both the loopback and your normal interface.
+ALSA can be difficult because there is no native way to grab audio from an output. If you want to capture audio straight fom the output (not just mic or line-in), you must create an ALSA loopback interface, then output the audio simultaneously to both the loopback and your normal interface.
To create a loopback interface simply run:
@@ -174,15 +182,15 @@
Hopefully your `aplay -l` should now contain a loopback interface.
-To make it presistent across boot add the line `snd-aloop` to "/etc/modules". To keep it form beeing loaded as the first soundcard add the line `options snd-aloop index=1` to "/etc/modprobe.d/alsa-base.conf", this will load it at '1'. You can replace '1' with whatever makes most senes in your audio setup.
+To make it presistent across boot add the line `snd-aloop` to "/etc/modules". To keep it form beeing loaded as the first soundcard add the line `options snd-aloop index=1` to "/etc/modprobe.d/alsa-base.conf", this will load it at '1'. You can replace '1' with whatever makes most sense in your audio setup.
Playing the audio through your Loopback interface makes it possible for cava to to capture it, but there will be no sound in your speakers. In order to play audio on the loopback interface and your actual interface you must make use of the ALSA multi channel.
-Look at the inculded example file `example_files/etc/asound.conf` on how to use the multi channel. I was able to make this work on my laptop (an Asus UX31 running Ubuntu). But i had no luck with the ALSA method on my Rasberry PI (Rasbian) with an USB DAC. The PulseAudio method however works perfectly on my PI.
+Look at the included example file `example_files/etc/asound.conf` on how to use the multi channel. I was able to make this work on my laptop (an Asus UX31 running Ubuntu), but I had no luck with the ALSA method on my Rasberry PI (Rasbian) with an USB DAC. The PulseAudio method however works perfectly on my PI.
Read more about the ALSA method [here](http://stackoverflow.com/questions/12984089/capture-playback-on-play-only-so...).
-If you are having problems with the alsa method on Rasberry PI, try enabling `mmap` by addin the following line to `/boot/config.txt` and reboot:
+If you are having problems with the alsa method on Rasberry PI, try enabling `mmap` by adding the following line to `/boot/config.txt` and reboot:
```
dtoverlay=i2s-mmap
@@ -244,7 +252,7 @@
In terminal emulators like `xterm`, the font settings is chosen in the software and cannot be changed by an application. So find your terminal settings and try out different fonts and settings. Also character spacing affects the look of the bar spectrum.
-Speed preformance is also different, urxvt is the best I found so far, while Gnome-terminal is quite slow.
+Performance is also different, urxvt is the best I found so far, while Gnome-terminal is quite slow.
Cava also disables the terminal cursor, and turns it back on on exit, but in case it terminates unexpectedly, run `setterm -cursor on` to get it back.
@@ -256,7 +264,7 @@
If you see latency issues (sound before image) in a terminal emulator, try increasing the font size. This will reduce the number of characters that have to be shown.
-If your audio device has a huge buffer, you might experience that cava is actually faster than the audio you hear. This reduces the experience of the visualization. To fix this, you try decreasing the buffer settings in your audio playing software.
+If your audio device has a huge buffer, you might experience that cava is actually faster than the audio you hear. This reduces the experience of the visualization. To fix this, try decreasing the buffer settings in your audio playing software.
Usage
-----
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/autogen.sh new/cava-0.4.3/autogen.sh
--- old/cava-0.4.2/autogen.sh 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/autogen.sh 2017-04-23 21:58:19.000000000 +0200
@@ -1,4 +1,11 @@
#!/bin/sh
+
+if [ -d .git ]; then
+ git describe --always --tags --dirty > version # get version from git
+else
+ echo 0.4.2 > version # hard coded versions
+fi
+
libtoolize
aclocal
autoconf
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/cava.c new/cava-0.4.3/cava.c
--- old/cava-0.4.2/cava.c 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/cava.c 2017-04-23 21:58:19.000000000 +0200
@@ -23,6 +23,7 @@
#include
#include
#include
+#include
#ifdef NCURSES
@@ -261,6 +262,42 @@
}
+int validate_color(char *checkColor, int om)
+{
+ int validColor = 0;
+ if (checkColor[0] == '#' && strlen(checkColor) == 7) {
+ // If the output mode is not ncurses, tell the user to use a named colour instead of hex colours.
+ if (om != 1 && om != 2) {
+ fprintf(stderr, "Only 'ncurses' output method supports HTML colors. Please change the colours or the output method.\n");
+ exit(EXIT_FAILURE);
+ }
+ // 0 to 9 and a to f
+ for (int i = 1; checkColor[i]; ++i) {
+ if (!isdigit(checkColor[i])) {
+ if (tolower(checkColor[i]) >= 'a' && tolower(checkColor[i]) <= 'f') {
+ validColor = 1;
+ } else {
+ validColor = 0;
+ break;
+ }
+ } else {
+ validColor = 1;
+ }
+ }
+ } else {
+ if ((strcmp(checkColor, "black") == 0) || \
+ (strcmp(checkColor, "red") == 0) || \
+ (strcmp(checkColor, "green") == 0) || \
+ (strcmp(checkColor, "yellow") == 0) || \
+ (strcmp(checkColor, "blue") == 0) || \
+ (strcmp(checkColor, "magenta") == 0) || \
+ (strcmp(checkColor, "cyan") == 0) || \
+ (strcmp(checkColor, "white") == 0) || \
+ (strcmp(checkColor, "default") == 0)) validColor = 1;
+ }
+ return validColor;
+}
+
void validate_config()
{
@@ -325,7 +362,7 @@
if (strcmp(data_format, "binary") == 0) {
is_bin = 1;
//checking bit format:
- if (bit_format != 16 && bit_format != 16 ) {
+ if (bit_format != 8 && bit_format != 16 ) {
fprintf(stderr,
"bit format %d is not supported, supported data formats are: '8' and '16'\n",
bit_format );
@@ -404,6 +441,19 @@
}
// validate: color
+ if (!validate_color(color, om)) {
+ fprintf(stderr, "The value for 'foreground' is invalid. It can be either one of the 7 named colors or a HTML color of the form '#xxxxxx'.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ // validate: background color
+ if (!validate_color(bcolor, om)) {
+ fprintf(stderr, "The value for 'background' is invalid. It can be either one of the 7 named colors or a HTML color of the form '#xxxxxx'.\n");
+ exit(EXIT_FAILURE);
+ }
+
+ // In case color is not html format set bgcol and col to predefinedint values
+
if (strcmp(color, "black") == 0) col = 0;
if (strcmp(color, "red") == 0) col = 1;
if (strcmp(color, "green") == 0) col = 2;
@@ -424,6 +474,7 @@
if (strcmp(bcolor, "cyan") == 0) bgcol = 6;
if (strcmp(bcolor, "white") == 0) bgcol = 7;
// default if invalid
+
// validate: gravity
if (gravity < 0) {
@@ -644,7 +695,6 @@
if (inAtty) {
system("setfont cava.psf >/dev/null 2>&1");
- system("echo yep > /tmp/testing123");
system("setterm -blank 0");
}
}
@@ -744,7 +794,7 @@
#ifdef NCURSES
//output: start ncurses mode
if (om == 1 || om == 2) {
- init_terminal_ncurses(col, bgcol);
+ init_terminal_ncurses(color, bcolor, col, bgcol);
get_terminal_dim_ncurses(&w, &h);
}
#endif
@@ -800,7 +850,8 @@
} else bars = fixedbars;
- if (bars < 1) bars = 1; // must have at least 1 bar;
+ if (bars < 1) bars = 1; // must have at least 1 bars
+ if (bars > 200) bars = 200; // cant have more than 200 bars
if (stereo) { //stereo must have even numbers of bars
if (bars%2 != 0) bars--;
@@ -1059,7 +1110,7 @@
sens = sens * 0.99;
break;
}
- if (senseLow) sens = sens * 1.01;
+ if (senseLow && !silence) sens = sens * 1.01;
}
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/configure.ac new/cava-0.4.3/configure.ac
--- old/cava-0.4.2/configure.ac 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/configure.ac 2017-04-23 21:58:19.000000000 +0200
@@ -1,4 +1,4 @@
-AC_INIT([cava], [m4_esyscmd_s([git describe --always --tags --dirty])], [karl@stavestrand.no])
+AC_INIT([cava], [m4_esyscmd_s([cat version])], [karl@stavestrand.no])
AM_INIT_AUTOMAKE([subdir-objects -Wall -Werror foreign])
dnl AC_CONFIG_MACRO_DIRS([m4])
AM_PROG_AR
@@ -149,6 +149,14 @@
CPPFLAGS="$CPPFLAGS -DLEGACYINIPARSER"
])
+dnl ############################
+dnl Set font directory
+dnl ############################
+DEFAULT_FONT_DIR="/usr/share/consolefonts"
+AC_ARG_VAR(FONT_DIR, [Directory where the font will be installed.])
+if test -z "$FONT_DIR" ; then
+ FONT_DIR="$DEFAULT_FONT_DIR"
+fi
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/example_files/config new/cava-0.4.3/example_files/config
--- old/cava-0.4.2/example_files/config 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/example_files/config 2017-04-23 21:58:19.000000000 +0200
@@ -1,57 +1,57 @@
-## Configuration file for CAVA. Default values are commented out. Use either ; or # for commenting.
+## Configuration file for CAVA. Default values are commented out. Use either ';' or '#' for commenting.
[general]
-# smoothing mode, can be normal, scientific or waves.
+# Smoothing mode. Can be 'normal', 'scientific' or 'waves'.
; mode = normal
-# Framerate Default: 60. Accepts only non-negative values.
-; framerate = 60
+# Accepts only non-negative values.
+; framerate = 60
-# Sensitivity in %. If you think the bars are to low/response is to little, try
-# increasing this value 200 means double height. Accepts only non-negative values.
-; sensitivity = 100
-
-# Autosens will attempt to decrease sensitivity if cava peaks. 1 = on, 0 = off
-# overshoot allows bars to overshoot (in % of terminal height) without initiating autosens
+# 'autosens' will attempt to decrease sensitivity if the bars peak. 1 = on, 0 = off
+# 'overshoot' allows bars to overshoot (in % of terminal height) without initiating autosens.
; autosens = 1
; overshoot = 20
-# The number of bars (0-200). 0 (default) sets it to auto (fill up console).
-# width of bars and space between bars in number of characters. Default width 3 and space 1.
-; bars = 0
+# Manual sensitivity in %. Autosens must be turned off for this to take effect.
+# 200 means double height. Accepts only non-negative values.
+; sensitivity = 100
+
+# The number of bars (0-200). 0 sets it to auto (fill up console).
+# Bars' width and space between bars in number of characters.
+; bars = 0
; bar_width = 2
; bar_spacing = 1
# Lower and higher cutoff frequencies for lowest and highest bars
-# the bandwith of the visualizer, defaults to 50 - 10000 Hz
-# Note: there is a minimum total bandwith of 43Mhz x number of bars.
-# Cava will automatically increase the higher cuttoff if a too low band is specified.
-; lower_cutoff_freq = 50
-; higher_cutoff_freq = 10000
+# the bandwidth of the visualizer.
+# Note: there is a minimum total bandwidth of 43Mhz x number of bars.
+# Cava will automatically increase the higher cutoff if a too low band is specified.
+; lower_cutoff_freq = 50
+; higher_cutoff_freq = 10000
[input]
-# method of capturing audio, possible methods are: 'pulse', 'alsa' or 'fifo'.
-# Defaults to 'pulse', 'alsa' or 'fifo', in that order, dependent on what support cava was built with
+# Audio capturing method. Possible methods are: 'pulse', 'alsa' or 'fifo'.
+# Defaults to 'pulse', 'alsa' or 'fifo', in that order, dependent on what support cava was built with.
#
-# All input methods uses the same config variable 'source'
+# All input methods uses the same config variable 'source'
# to define where it should get the audio.
#
-# for pulseaudio 'source' will be the source. Default: 'auto', which uses the monitor source of the default sink
-# (all pulseaudio sinks(outputs) have 'monitor' sources(inputs) associated with them)
+# For pulseaudio 'source' will be the source. Default: 'auto', which uses the monitor source of the default sink
+# (all pulseaudio sinks(outputs) have 'monitor' sources(inputs) associated with them).
#
-# for alsa 'source' will be the capture device. Default: 'hw:Loopback,1'
-# for fifo 'source' will be the path to fifo-file. Default: '/tmp/mpd.fifo'
+# For alsa 'source' will be the capture device.
+# For fifo 'source' will be the path to fifo-file.
; method = pulse
; source = auto
-; method = alsa
-; source = hw:Loopback,1
+; method = alsa
+; source = hw:Loopback,1
; method = fifo
; source = /tmp/mpd.fifo
@@ -60,65 +60,66 @@
[output]
-# ouput method may be ncurses, noncurses or raw. noncurses is for systems that does not suport ncurses.
-# raw is a 16 bit data stream of the bar heights that can be used to send to other applications
-# raw defaults to 200 bars, can be adjusted in the bars option above
+# Ouput method. Can be 'ncurses', 'noncurses' or 'raw'.
+# 'noncurses' is for systems that does not suport ncurses.
+# 'raw' is a 16 bit data stream of the bar heights that can be used to send to other applications.
+# 'raw' defaults to 200 bars, which can be adjusted in the 'bars' option above.
; method = ncurses
-# visual styles, may be 'stereo' or 'mono'.
-# Stereo mirrors both channels with low frequencies in center.
-# Mono averages both channels and outputs left to right lowest to highest frequencies
-; style = stereo
+# Visual styles. Can be 'stereo' or 'mono'.
+# 'stereo' mirrors both channels with low frequencies in center.
+# 'mono' averages both channels and outputs left to right lowest to highest frequencies.
+; style = stereo
-# raw output target defaults to stdout, a fifo will be created if target does not exist
+# Raw output target. A fifo will be created if target does not exist.
; raw_target = /dev/stdout
-# raw data format, can be binary or ascii
+# Raw data format. Can be 'binary' or 'ascii'.
; data_format = binary
-# binary bit format, can be '8bit' (0-255) or '16bit' (0-65530)
+# Binary bit format, can be '8bit' (0-255) or '16bit' (0-65530).
; bit_format = 16bit
-# ascii max value, in ascii mode range will run from 0 to value specified here
+# Ascii max value. In 'ascii' mode range will run from 0 to value specified here
; ascii_max_range = 1000
-# ascii delimiters, in ascii format each bar and frame is separated by a delimiters.
-# use decimal value in ascii table (i.e. 59 = ';' and 10 = '\n' (line feed))
+# Ascii delimiters. In ascii format each bar and frame is separated by a delimiters.
+# Use decimal value in ascii table (i.e. 59 = ';' and 10 = '\n' (line feed)).
; bar_delimiter = 59
; frame_delimiter = 10
-
[color]
-# supported colors are: red, green, yellow, magenta, cyan, white, blue, black.
+# 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 '').
; background = black
; foreground = cyan
[smoothing]
-# multiplier for the integral smoothing calculations. Takes values from 0 - 0.99.
-# Higher values means smoother, but less precise. 0 to disable.
-; integral = 0.7
+# Multiplier for the integral smoothing calculations. Takes values from 0-0.99.
+# Higher values means smoother, but less precise. Set to 0 to disable.
+; integral = 0.7
-# disables or enables the so-called "Monstercat smoothing". Default: 1. Set to 0 to disable.
-; monstercat = 1
+# Disables or enables the so-called "Monstercat smoothing". Set to 0 to disable.
+; monstercat = 1
-# Set gravity multiplier for "drop off". Higher values means bars will drop faster.
+# Set gravity multiplier for "drop off". Higher values means bars will drop faster.
# Accepts only non-negative values. 0.5 means half gravity, 2 means double. Set to 0 to disable "drop off".
-; gravity = 1
+; gravity = 1
# In bar height, bars that would have been lower that this will not be drawn.
-; ignore = 0
+; ignore = 0
[eq]
-# This one is tricky. You can have as much keys as you want.
-# remember to uncomment more then one key! More keys = more precision.
+# This one is tricky. You can have as much keys as you want.
+# Remember to uncomment more then one key! More keys = more precision.
# Look at readme.md on github for further explanations and examples.
; 1 = 1 # bass
; 2 = 1
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/input/alsa.c new/cava-0.4.3/input/alsa.c
--- old/cava-0.4.2/input/alsa.c 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/input/alsa.c 2017-04-23 21:58:19.000000000 +0200
@@ -1,71 +1,106 @@
// input: ALSA
-void* input_alsa(void* data)
-{
- struct audio_data *audio = (struct audio_data *)data;
- signed char *buffer;
- snd_pcm_t *handle;
- snd_pcm_hw_params_t *params;
- unsigned int val;
- snd_pcm_uframes_t frames;
- val = 44100;
- int i, n, o, size, dir, err, lo;
- int tempr, templ;
- int radj, ladj;
+// assuming stereo
+#define CHANNELS_COUNT 2
+#define SAMPLE_RATE 44100
+
+static void initialize_audio_parameters(snd_pcm_t** handle, struct audio_data* audio,
+snd_pcm_uframes_t* frames) {
// alsa: open device to capture audio
- if ((err = snd_pcm_open(&handle, audio-> source, SND_PCM_STREAM_CAPTURE, 0) < 0)) {
- fprintf(stderr,
- "error opening stream: %s\n",
- snd_strerror(err));
+ int err = snd_pcm_open(handle, audio->source, SND_PCM_STREAM_CAPTURE, 0);
+ if (err < 0) {
+ fprintf(stderr, "error opening stream: %s\n", snd_strerror(err));
exit(EXIT_FAILURE);
}
-
#ifdef DEBUG
else printf("open stream successful\n");
#endif
- snd_pcm_hw_params_alloca(¶ms); //assembling params
- snd_pcm_hw_params_any (handle, params); //setting defaults or something
- snd_pcm_hw_params_set_access(handle, params,
- SND_PCM_ACCESS_RW_INTERLEAVED); //interleaved mode right left right left
- snd_pcm_hw_params_set_format(handle, params,
- SND_PCM_FORMAT_S16_LE); //trying to set 16bit
- snd_pcm_hw_params_set_channels(handle, params, 2); //assuming stereo
- val = 44100;
- snd_pcm_hw_params_set_rate_near(handle, params, &val, &dir); //trying 44100 rate
- frames = 256;
- snd_pcm_hw_params_set_period_size_near(handle, params, &frames,
- &dir); //number of frames pr read
-
- err = snd_pcm_hw_params(handle, params); //attempting to set params
+ snd_pcm_hw_params_t* params;
+ snd_pcm_hw_params_alloca(¶ms); // assembling params
+ snd_pcm_hw_params_any(*handle, params); // setting defaults or something
+ // interleaved mode right left right left
+ snd_pcm_hw_params_set_access(*handle, params, SND_PCM_ACCESS_RW_INTERLEAVED);
+ // trying to set 16bit
+ snd_pcm_hw_params_set_format(*handle, params, SND_PCM_FORMAT_S16_LE);
+ snd_pcm_hw_params_set_channels(*handle, params, CHANNELS_COUNT);
+ unsigned int sample_rate = SAMPLE_RATE;
+ // trying our rate
+ snd_pcm_hw_params_set_rate_near(*handle, params, &sample_rate, NULL);
+ // number of frames pr read
+ snd_pcm_hw_params_set_period_size_near(*handle, params, frames, NULL);
+ err = snd_pcm_hw_params(*handle, params); // attempting to set params
if (err < 0) {
- fprintf(stderr,
- "unable to set hw parameters: %s\n",
- snd_strerror(err));
+ fprintf(stderr, "unable to set hw parameters: %s\n", snd_strerror(err));
exit(EXIT_FAILURE);
}
- snd_pcm_hw_params_get_format(params,
- (snd_pcm_format_t * )&val); //getting actual format
- //converting result to number of bits
- if (val < 6)audio->format = 16;
- else if (val > 5 && val < 10)audio->format = 24;
- else if (val > 9)audio->format = 32;
-
- snd_pcm_hw_params_get_rate(params, &audio->rate, &dir); //getting rate
-
- snd_pcm_hw_params_get_period_size(params, &frames, &dir);
- snd_pcm_hw_params_get_period_time(params, &val, &dir);
-
- size = frames * (audio->format / 8) * 2; // frames * bits/8 * 2 channels
- buffer = malloc(size);
- radj = audio->format / 4; //adjustments for interleaved
- ladj = audio->format / 8;
- o = 0;
- while (1) {
+ // getting actual format
+ snd_pcm_hw_params_get_format(params, (snd_pcm_format_t*)&sample_rate);
+ // converting result to number of bits
+ if (sample_rate <= 5)
+ audio->format = 16;
+ else if (sample_rate <= 9 )
+ audio->format = 24;
+ else
+ audio->format = 32;
+ snd_pcm_hw_params_get_rate(params, &audio->rate, NULL);
+ snd_pcm_hw_params_get_period_size(params, frames, NULL);
+ // snd_pcm_hw_params_get_period_time(params, &sample_rate, &dir);
+}
+static int get_certain_frame(signed char* buffer, int buffer_index, int adjustment) {
+ // using the 10 upper bits this would give me a vert res of 1024, enough...
+ int temp = buffer[buffer_index + adjustment - 1] << 2;
+ int lo = buffer[buffer_index + adjustment - 2] >> 6;
+ if (lo < 0)
+ lo = abs(lo) + 1;
+ if (temp >= 0)
+ temp += lo;
+ else
+ temp -= lo;
+ return temp;
+}
- err = snd_pcm_readi(handle, buffer, frames);
+static void fill_audio_outs(struct audio_data* audio, signed char* buffer,
+const int size) {
+ int radj = audio->format / 4; // adjustments for interleaved
+ int ladj = audio->format / 8;
+ static int audio_out_buffer_index = 0;
+ // sorting out one channel and only biggest octet
+ for (int buffer_index = 0; buffer_index < size; buffer_index += ladj * 2) {
+ // first channel
+ int tempr = get_certain_frame(buffer, buffer_index, radj);
+ // second channel
+ int templ = get_certain_frame(buffer, buffer_index, ladj);
+
+ // mono: adding channels and storing it in the buffer
+ if (audio->channels == 1)
+ audio->audio_out_l[audio_out_buffer_index] = (templ + tempr) / 2;
+ else { // stereo storing channels in buffer
+ audio->audio_out_l[audio_out_buffer_index] = templ;
+ audio->audio_out_r[audio_out_buffer_index] = tempr;
+ }
+
+ ++audio_out_buffer_index;
+ audio_out_buffer_index %= 2048;
+ }
+}
+
+#define FRAMES_NUMBER 256
+
+void* input_alsa(void* data) {
+ struct audio_data* audio = (struct audio_data*)data;
+ snd_pcm_t* handle;
+ snd_pcm_uframes_t frames = FRAMES_NUMBER;
+
+ initialize_audio_parameters(&handle, audio, &frames);
+
+ // frames * bits/8 * channels
+ const int size = frames * (audio->format / 8) * CHANNELS_COUNT;
+ signed char* buffer = malloc(size);
+ while (1) {
+ int err = snd_pcm_readi(handle, buffer, frames);
if (err == -EPIPE) {
/* EPIPE means overrun */
#ifdef DEBUG
@@ -81,53 +116,11 @@
fprintf(stderr, "short read, read %d %d frames\n", err, (int)frames);
#endif
}
-
- //sorting out one channel and only biggest octet
- n = 0; //frame counter
-
-
- for (i = 0; i < size ; i = i + (ladj) * 2) {
-
- //first channel
- tempr = ((buffer[i + (radj) - 1 ] <<
- 2)); //using the 10 upper bits this would give me a vert res of 1024, enough...
-
- lo = ((buffer[i + (radj) - 2] >> 6));
- if (lo < 0)lo = abs(lo) + 1;
- if (tempr >= 0)tempr = tempr + lo;
- if (tempr < 0)tempr = tempr - lo;
-
- //other channel
- templ = (buffer[i + (ladj) - 1] << 2);
- lo = (buffer[i + (ladj) - 2] >> 6);
- if (lo < 0)lo = abs(lo) + 1;
- if (templ >= 0)templ = templ + lo;
- else templ = templ - lo;
-
- //mono: adding channels and storing it in the buffer
- if (audio->channels == 1) audio->audio_out_l[o] = (tempr + templ) / 2;
-
-
- //stereo storing channels in buffer
- if (audio->channels == 2) {
- audio->audio_out_l[o] = templ;
- audio->audio_out_r[o] = tempr;
- }
-
-
- o++;
- if (o == 2048 - 1)o = 0;
-
- n++;
- }
-
+ fill_audio_outs(audio, buffer, size);
if (audio->terminate == 1) {
free(buffer);
snd_pcm_close(handle);
- break;
+ return NULL;
}
}
-
- return 0;
}
-
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/input/pulse.c new/cava-0.4.3/input/pulse.c
--- old/cava-0.4.2/input/pulse.c 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/input/pulse.c 2017-04-23 21:58:19.000000000 +0200
@@ -7,62 +7,65 @@
#include
#define BUFSIZE 1024
-void getPulseDefaultSink(void* data) {
-
- struct audio_data *audio = (struct audio_data *)data;
- pa_mainloop_api *mainloop_api;
- pa_context *pulseaudio_context;
- pa_mainloop *m_pulseaudio_mainloop;
- int ret;
-
-
- void cb(__attribute__((unused)) pa_context *pulseaudio_context,const pa_server_info *i,__attribute__((unused)) void *userdata){
+pa_mainloop *m_pulseaudio_mainloop;
- //getting default sink name
- audio->source = malloc(sizeof(char) * 1024);
- strcpy(audio->source,i->default_sink_name);
+void cb(__attribute__((unused)) pa_context *pulseaudio_context, const pa_server_info *i, void *userdata){
- //appending .monitor suufix
- audio->source = strcat(audio->source, ".monitor");
-
- //quiting mainloop
- pa_mainloop_quit(m_pulseaudio_mainloop, 0);
+ //getting default sink name
+ struct audio_data *audio = (struct audio_data *)userdata;
+ audio->source = malloc(sizeof(char) * 1024);
+
+ strcpy(audio->source,i->default_sink_name);
+
+ //appending .monitor suufix
+ audio->source = strcat(audio->source, ".monitor");
+
+ //quiting mainloop
+ pa_mainloop_quit(m_pulseaudio_mainloop, 0);
+}
+
+
+void pulseaudio_context_state_callback(pa_context *pulseaudio_context,
+ void *userdata) {
+
+ //make sure loop is ready
+ switch (pa_context_get_state(pulseaudio_context))
+ {
+ case PA_CONTEXT_UNCONNECTED:
+ //printf("UNCONNECTED\n");
+ break;
+ case PA_CONTEXT_CONNECTING:
+ //printf("CONNECTING\n");
+ break;
+ case PA_CONTEXT_AUTHORIZING:
+ //printf("AUTHORIZING\n");
+ break;
+ case PA_CONTEXT_SETTING_NAME:
+ //printf("SETTING_NAME\n");
+ break;
+ case PA_CONTEXT_READY://extract default sink name
+ //printf("READY\n");
+ pa_operation_unref(pa_context_get_server_info(
+ pulseaudio_context, cb, userdata));
+ break;
+ case PA_CONTEXT_FAILED:
+ //printf("FAILED\n");
+ break;
+ case PA_CONTEXT_TERMINATED:
+ //printf("TERMINATED\n");
+ pa_mainloop_quit(m_pulseaudio_mainloop, 0);
+ break;
}
+}
- void pulseaudio_context_state_callback(__attribute__((unused)) pa_context *c,
- void *userdata) {
-
- //make sure loop is ready
- switch (pa_context_get_state(pulseaudio_context))
- {
- case PA_CONTEXT_UNCONNECTED:
- //printf("UNCONNECTED\n");
- break;
- case PA_CONTEXT_CONNECTING:
- //printf("CONNECTING\n");
- break;
- case PA_CONTEXT_AUTHORIZING:
- //printf("AUTHORIZING\n");
- break;
- case PA_CONTEXT_SETTING_NAME:
- //printf("ETTING_NAM\n");
- break;
- case PA_CONTEXT_READY://extract default sink name
- //printf("READY\n");
- pa_operation_unref(pa_context_get_server_info(
- pulseaudio_context, cb, userdata));
- break;
- case PA_CONTEXT_FAILED:
- //printf("FAILED\n");
- break;
- case PA_CONTEXT_TERMINATED:
- //printf("TERMINATED\n");
- break;
- }
- }
+void getPulseDefaultSink(void* data) {
+ struct audio_data *audio = (struct audio_data *)data;
+ pa_mainloop_api *mainloop_api;
+ pa_context *pulseaudio_context;
+ int ret;
// Create a mainloop API and connection to the default server
m_pulseaudio_mainloop = pa_mainloop_new();
@@ -78,7 +81,7 @@
//This function defines a callback so the server will tell us its state.
pa_context_set_state_callback(pulseaudio_context,
pulseaudio_context_state_callback,
- NULL);
+ (void*)audio);
//starting a mainloop to get default sink
if (pa_mainloop_run(m_pulseaudio_mainloop, &ret) < 0)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/makefile.bak new/cava-0.4.3/makefile.bak
--- old/cava-0.4.2/makefile.bak 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/makefile.bak 1970-01-01 01:00:00.000000000 +0100
@@ -1,60 +0,0 @@
-PACKAGE ?= cava
-VERSION ?= $(shell git describe --always --tags --dirty)
-
-ifeq ($(SYSTEM_INIPARSER),1)
-CPPFLAGS_INIPARSER = -I/usr/include/iniparser4
-LDLIBS_INIPARSER = -liniparser4
-DEP_INIPARSER =
-else
-CPPFLAGS_INIPARSER = -Iiniparser/src
-LDLIBS_INIPARSER = iniparser/libiniparser.a
-DEP_INIPARSER = iniparser/libiniparser.a
-endif
-
-CC = gcc
-CFLAGS += -std=c99 -Wall -Wextra
-CPPFLAGS += -DPACKAGE=\"$(PACKAGE)\" -DVERSION=\"$(VERSION)\" \
- -D_POSIX_SOURCE -D _POSIX_C_SOURCE=200809L $(CPPFLAGS_INIPARSER)
-LDLIBS = $(LDLIBS_INIPARSER) -lasound -lm -lfftw3 -lpthread $(shell ncursesw5-config --cflags --libs)
-
-INSTALL = install
-INSTALL_BIN = $(INSTALL) -D -m 755
-
-PREFIX ?= /usr/local
-BINDIR = $(DESTDIR)/$(PREFIX)/bin
-
-CONFIGDIR = $(XDG_CONFIG_HOME)/cava
-
-debug ?= 0
-
-ifeq ($(debug),1)
-CPPFLAGS += -DDEBUG
-endif
-
-all: cava check-env copyconf
-
-cava: cava.c $(DEP_INIPARSER)
-
-iniparser/libiniparser.a:
- cd iniparser && $(MAKE)
-
-check-env:
-ifndef XDG_CONFIG_HOME
- CONFIGDIR = $(HOME)/.config/cava
-endif
-
-copyconf:
- mkdir -p $(CONFIGDIR)
- cp -n example_files/config $(CONFIGDIR)/config
-
-install: all
- $(INSTALL_BIN) cava $(BINDIR)/cava
-
-uninstall:
- $(RM) $(BINDIR)/cava
-
-clean:
- cd iniparser && $(MAKE) clean
- $(RM) cava
-
-.PHONY: all clean install uninstall
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/output/raw.c new/cava-0.4.3/output/raw.c
--- old/cava-0.4.2/output/raw.c 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/output/raw.c 2017-04-23 21:58:19.000000000 +0200
@@ -1,48 +1,49 @@
#include
-#include
#include
-
-int print_raw_out(int bars, int fp, int is_bin, int bit_format, int ascii_range, char bar_delim, char frame_delim, int f[200]) {
- int i;
-
- if (is_bin == 1){//binary
- if (bit_format == 16 ){//16bit:
-
- for (i = 0; i < bars; i++) {
- uint16_t f16 = ((float)f[i] / 10000) * 65535;
- write(fp, &f16,sizeof(uint16_t));
- }
-
- } else {//8bit:
-
- for (i = 0; i < bars; i++) {
- uint8_t f8 = ((float)f[i] / 10000) * 255;
- write(fp, &f8,sizeof(uint8_t));
- }
-
+#define TEN_THSND 10000
+#define TEN_THSND_F 10000.0
+#define BIT_16 16
+#define BIT_8 8
+
+#define NORMALIZE_AND_WRITE(type) _NORMALIZE_AND_WRITE(type)
+#define _NORMALIZE_AND_WRITE(type) \
+ for (int i = 0; i < bars_count; i++) { \
+ uint##type##_t f_##type = UINT##type##_MAX; \
+ if (f[i] < TEN_THSND) \
+ f_##type *= f[i] / TEN_THSND_F; \
+ write(fd, &f_##type, sizeof(uint##type##_t)); \
+ }
+
+int print_raw_out(int bars_count, int fd, int is_binary, int bit_format,
+int ascii_range, char bar_delim, char frame_delim, const int const f[200]) {
+ if (is_binary) {
+ switch (bit_format) {
+ case BIT_16:
+ NORMALIZE_AND_WRITE(BIT_16);
+ break;
+ case BIT_8:
+ NORMALIZE_AND_WRITE(BIT_8);
+ break;
}
- } else {//ascii:
+ } else { // ascii
+ for (int i = 0; i < bars_count; i++) {
+ int f_ranged = (f[i] / TEN_THSND_F) * ascii_range;
+ if (f_ranged > ascii_range)
+ f_ranged = ascii_range;
+
+ // finding size of number-string in byte
+ int bar_height_size = 2; // a number + \0
+ if (f_ranged != 0)
+ bar_height_size += floor (log10 (f_ranged));
- for (i = 0; i < bars; i++) {
- int f_ranged = ((float)f[i] / 10000) * ascii_range;
- if (f_ranged > ascii_range) f_ranged = ascii_range;
-
- //finding size of number-string in byte
- int size;
- if (f_ranged != 0) size = floor (log10 (abs (f_ranged))) + 1;
- else size = 1;
- char barheight[size];
+ char bar_height[bar_height_size];
+ snprintf(bar_height, bar_height_size, "%d", f_ranged);
- sprintf(barheight, "%d", f_ranged);
- write(fp, barheight,sizeof(barheight));
-
- write(fp, &bar_delim, sizeof(bar_delim));
+ write(fd, bar_height, bar_height_size - 1);
+ write(fd, &bar_delim, sizeof(bar_delim));
}
-
- write(fp, &frame_delim, sizeof(frame_delim));
-
- }
-
+ write(fd, &frame_delim, sizeof(frame_delim));
+ }
return 0;
-}
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/output/raw.h new/cava-0.4.3/output/raw.h
--- old/cava-0.4.2/output/raw.h 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/output/raw.h 2017-04-23 21:58:19.000000000 +0200
@@ -1 +1,2 @@
-int print_raw_out(int bars, int fp, int is_bin, int bin_datafrom, int ascii_range, char bar_delim, char frame_delim, int f[200]);
+int print_raw_out(int bars_count, int fd, int is_binary, int bit_format,
+ int ascii_range, char bar_delim, char frame_delim, const int const f[200]);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/output/terminal_ncurses.c new/cava-0.4.3/output/terminal_ncurses.c
--- old/cava-0.4.2/output/terminal_ncurses.c 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/output/terminal_ncurses.c 2017-04-23 21:58:19.000000000 +0200
@@ -1,80 +1,171 @@
#include
-#include
#include
-#include
#include
+struct colors {
+ NCURSES_COLOR_T color;
+ NCURSES_COLOR_T R;
+ NCURSES_COLOR_T G;
+ NCURSES_COLOR_T B;
+};
+
+#define COLOR_REDEFINITION -2
+
+#define MAX_COLOR_REDEFINITION 2
+
+static struct colors the_color_redefinitions[MAX_COLOR_REDEFINITION];
+
+
+static void parse_color(char* color_string, struct colors* color) {
+ if (color_string[0] == '#') {
+ if (!can_change_color()) {
+ cleanup_terminal_ncurses();
+ fprintf(stderr, "Your terminal can not change color definitions, "
+ "please use one of the predefined colors.\n");
+ exit(EXIT_FAILURE);
+ }
+ color->color = COLOR_REDEFINITION;
+ 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) {
+ the_color_redefinitions[index].color = color_number;
+ color_content(color_number,
+ &the_color_redefinitions[index].R,
+ &the_color_redefinitions[index].G,
+ &the_color_redefinitions[index].B);
+ }
+}
-int init_terminal_ncurses(int col, int bgcol) {
+// 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 ), \
+ CURSES_COLOR_COEFFICIENT( X.G ), CURSES_COLOR_COEFFICIENT( X.B )
+
+static NCURSES_COLOR_T change_color_definition(NCURSES_COLOR_T color_number,
+char* const color_string, NCURSES_COLOR_T predef_color) {
+ struct colors color = { 0 };
+ parse_color(color_string, &color);
+ NCURSES_COLOR_T return_color_number = predef_color;
+ if (color.color == COLOR_REDEFINITION) {
+ 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) {
initscr();
curs_set(0);
timeout(0);
noecho();
start_color();
use_default_colors();
- init_pair(1, col, bgcol);
- if(bgcol != -1)
- bkgd(COLOR_PAIR(1));
- attron(COLOR_PAIR(1));
-// attron(A_BOLD);
- return 0;
-}
-
-void get_terminal_dim_ncurses(int *w, int *h) {
+ NCURSES_COLOR_T fg_color_number;
+ fg_color_number = change_color_definition(1, fg_color_string, predef_fg_color);
- getmaxyx(stdscr,*h,*w);
- clear(); //clearing in case of resieze
+ 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
+
+ NCURSES_COLOR_T color_pair_number = 1;
+ init_pair(color_pair_number, fg_color_number, bg_color_number);
+
+ if (bg_color_number != -1)
+ bkgd(COLOR_PAIR(color_pair_number));
+ attron(COLOR_PAIR(color_pair_number));
+ refresh();
}
+void get_terminal_dim_ncurses(int* width, int* height) {
+ getmaxyx(stdscr, *height, *width);
+ clear(); // clearing in case of resieze
+}
-int draw_terminal_ncurses(int tty, int h, int w, int bars, int bw, int bs, int rest, int f[200], int flastd[200]) {
+#define TERMINAL_RESIZED -1
- int i, n, q;
- const wchar_t* bh[] = {L"\u2581", L"\u2582", L"\u2583", L"\u2584", L"\u2585", L"\u2586", L"\u2587", L"\u2588"};
+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]) {
+ 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)
// output: check if terminal has been resized
- if (!tty) {
- if ( LINES != h || COLS != w) {
- return -1;
+ if (!is_tty) {
+ if (LINES != terminal_height || COLS != terminal_width) {
+ return TERMINAL_RESIZED;
}
}
-
- h = h - 1;
-
- for (i = 0; i < bars; i++) {
-
- if(f[i] > flastd[i]){//higher then last one
- if (tty) for (n = flastd[i] / 8; n < f[i] / 8; n++) for (q = 0; q < bw; q++) mvprintw((h - n), i*bw + q + i*bs + rest, "%d",8);
- else for (n = flastd[i] / 8; n < f[i] / 8; n++) for (q = 0; q < bw; q++) mvaddwstr((h - n), i*bw + q + i*bs + rest, bh[7]);
- if (f[i] % 8 != 0) {
- if (tty) for (q = 0; q < bw; q++) mvprintw( (h - n), i*bw + q + i*bs + rest, "%d",(f[i] % 8) );
- else for (q = 0; q < bw; q++) mvaddwstr( (h - n), i*bw + q + i*bs + rest, bh[(f[i] % 8) - 1]);
+ 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 (is_tty) {
+ for (int n = flastd[bar] / 8; n < f[bar] / 8; n++)
+ 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 width = 0; width < bar_width; width++)
+ mvaddwstr((height - n), CURRENT_COLUMN,
+ bar_heights[LAST]);
}
- }else if(f[i] < flastd[i]){//lower then last one
- for (n = f[i] / 8; n < flastd[i]/8 + 1; n++) for (q = 0; q < bw; q++) mvaddstr( (h - n), i*bw + q + i*bs + rest, " ");
- if (f[i] % 8 != 0) {
- if (tty) for (q = 0; q < bw; q++) mvprintw((h - f[i] / 8), i*bw + q + i*bs + rest, "%d",(f[i] % 8) );
- else for (q = 0; q < bw; q++) mvaddwstr((h - f[i] / 8), i*bw + q + i*bs + rest, bh[(f[i] % 8) - 1]);
+ if (f[bar] % 8) {
+ if (is_tty) {
+ for (int width = 0; width < bar_width; width++)
+ mvprintw((height - f[bar] / 8), CURRENT_COLUMN, "%d",
+ (f[bar] % 8));
+ } else {
+ for (int width = 0; width < bar_width; width++)
+ mvaddwstr((height - f[bar] / 8), CURRENT_COLUMN,
+ bar_heights[(f[bar] % 8) - 1]);
+ }
+ }
+ } else if(f[bar] < flastd[bar]) { // lower then last one
+ 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 (is_tty) {
+ for (int width = 0; width < bar_width; width++)
+ mvprintw((height - f[bar] / 8), CURRENT_COLUMN, "%d",
+ (f[bar] % 8));
+ } else {
+ for (int width = 0; width < bar_width; width++)
+ mvaddwstr((height - f[bar] / 8), CURRENT_COLUMN,
+ bar_heights[(f[bar] % 8) - 1]);
+ }
}
}
- flastd[i] = f[i]; //memmory for falloff func
+ #undef CURRENT_COLUMN
+ flastd[bar] = f[bar]; // memory for falloff func
}
-
refresh();
return 0;
}
-
// general: cleanup
-void cleanup_terminal_ncurses(void)
-{
+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) {
+ if(the_color_redefinitions[i].color) {
+ init_color(the_color_redefinitions[i].color,
+ the_color_redefinitions[i].R,
+ the_color_redefinitions[i].G,
+ the_color_redefinitions[i].B);
+ }
+ }
endwin();
system("clear");
}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/cava-0.4.2/output/terminal_ncurses.h new/cava-0.4.3/output/terminal_ncurses.h
--- old/cava-0.4.2/output/terminal_ncurses.h 2016-09-16 16:08:40.000000000 +0200
+++ new/cava-0.4.3/output/terminal_ncurses.h 2017-04-23 21:58:19.000000000 +0200
@@ -1,5 +1,7 @@
-
-int init_terminal_ncurses(int col, int bgcol);
-void get_terminal_dim_ncurses(int *w, int *h);
-int draw_terminal_ncurses(int virt, int height, int width, int bars, int bw, int bs, int rest, int f[200], int flastd[200]);
+void init_terminal_ncurses(char* const fg_color_string,
+ char* const bg_color_string, int predef_fg_color, int predef_bg_color);
+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]);
void cleanup_terminal_ncurses(void);