Skip to content

Commit

Permalink
Upstream sync
Browse files Browse the repository at this point in the history
Signed-off-by: Viktar Lukashonak <[email protected]>
  • Loading branch information
LukashonakV committed Sep 27, 2024
1 parent cebff22 commit 86b6b12
Show file tree
Hide file tree
Showing 13 changed files with 253 additions and 126 deletions.
4 changes: 3 additions & 1 deletion .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,11 @@ Are you using cava from a package repository, like AUR?

If so, clone the master branch from here, build and run. Is your issue already resolved?

Don't know how to clone or compile source code? File report to package maintainer instead!
Don't know how to clone or compile source code? Learn before posting issues here.

**ALWAYS TRY TO BUILD AND RUN FROM THE SOURCE CODE ON GITLAB BEFORE POSTING ISSUES**

If the issue is resolved when building from source, do not post issues here.

**Describe the bug**

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/build-and-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,13 @@ jobs:
- uses: actions/checkout@v1
- name: Install dependencies
run: |
brew install fftw ncurses libtool automake autoconf-archive portaudio iniparser sdl2
brew install fftw libtool automake autoconf-archive portaudio iniparser sdl2
ln -s /usr/local/bin/glibtoolize /usr/local/bin/libtoolize
- name: Generate configure
- name: Generate configuresdl2
run: PATH="/opt/homebrew/opt/libtool/libexec/gnubin:$PATH" ./autogen.sh
- name: Run ./configure
run: LDFLAGS="-L/opt/homebrew/lib" CPPFLAGS="-I/opt/homebrew/include" ./configure
- name: Run make
run: make CFLAGS='-Werror'
run: make CFLAGS='-Werror'
- name: run non zero test
run: ./cava -p example_files/test_configs/non_zero_test > /dev/null
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,4 @@ missing
version
config_file.h
.*
cava
24 changes: 7 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ by [Karl Stavestrand](mailto:[email protected])
What it is
----------

Cava is a bar spectrum audio visualizer for terminal (ncurses) or desktop (SDL).
Cava is a bar spectrum audio visualizer for terminal or desktop (SDL).

works on:
* Linux
Expand Down Expand Up @@ -105,22 +105,22 @@ Additionally, run these commands on FreeBSD before building:

Debian/Ubuntu:

sudo apt install build-essential libfftw3-dev libasound2-dev libncursesw5-dev libpulse-dev libtool automake autoconf-archive libiniparser-dev libsdl2-2.0-0 libsdl2-dev libpipewire-0.3-dev libjack-jackd2-dev pkgconf
sudo apt install build-essential libfftw3-dev libasound2-dev libpulse-dev libtool automake autoconf-archive libiniparser-dev libsdl2-2.0-0 libsdl2-dev libpipewire-0.3-dev libjack-jackd2-dev pkgconf


ArchLinux:

pacman -S base-devel fftw ncurses alsa-lib iniparser pulseaudio autoconf-archive pkgconf
pacman -S base-devel fftw alsa-lib iniparser pulseaudio autoconf-archive pkgconf


openSUSE:

zypper install alsa-devel ncurses-devel fftw3-devel libpulse-devel libtool autoconf-archive pkgconf
zypper install alsa-devel fftw3-devel libpulse-devel libtool autoconf-archive pkgconf


Fedora:

dnf install alsa-lib-devel ncurses-devel fftw3-devel pulseaudio-libs-devel libtool autoconf-archive iniparser-devel pkgconf
dnf install alsa-lib-devel fftw3-devel pulseaudio-libs-devel libtool autoconf-archive iniparser-devel pkgconf


macOS:
Expand All @@ -131,26 +131,18 @@ First install homebrew if you have't already:

Then install prerequisites:

brew install fftw ncurses libtool automake autoconf-archive pkgconf portaudio iniparser
brew install fftw libtool automake autoconf-archive pkgconf portaudio iniparser

The installation location for Homebrew packages is different between Intel Macs and Apple Silicon Macs.
As such, the commands will be a little bit different.
You can find out which type you have [here](https://support.apple.com/en-us/HT211814#:~:text=To%20open%20About%20This%20Mac,as%20an%20Intel%2Dbased%20Mac.)

For both machines, run these commands to fix macOS not finding libtool and ncursesw:
For both machines, run these commands to fix macOS not finding libtool:

export LIBTOOL=`which glibtool`
export LIBTOOLIZE=`which glibtoolize`
ln -s `which glibtoolize` /usr/local/bin/libtoolize

On an Intel Mac, run the following command as well:

ln -s /usr/lib/libncurses.dylib /usr/local/lib/libncursesw.dylib

On an Apple Silicon Mac, run this command instead:

ln -s /opt/homebrew/lib/lib/libncursesw.6.dylib /usr/local/lib/libncursesw.dylib

Note that the file name may be a little bit different depending on the versions, but the directory should be the same.

Additionally, run these commands on Apple Silicon Macs so that ./configure can find the Homebrew packages:
Expand Down Expand Up @@ -645,8 +637,6 @@ If cava quits unexpectedly or is force killed, echo must be turned on manually w

### Controls

NOTE: only works in ncurses output mode.

| Key | Description |
| --- | ----------- |
| <kbd>up</kbd> / <kbd>down</kbd>| increase/decrease sensitivity |
Expand Down
7 changes: 6 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,12 @@ dnl ######################
AC_CHECK_LIB(iniparser,iniparser_load, have_iniparser=yes, have_iniparser=no)
if [[ $have_iniparser = "yes" ]] ; then
LIBS="$LIBS -liniparser"
CPPFLAGS="$CPPFLAGS -I/usr/include/iniparser"
if [[ $build_mac = "yes" ]] ; then
CPPFLAGS="$CPPFLAGS -I/usr/local/include/iniparser/"
CPPFLAGS="$CPPFLAGS -I/opt/homebrew/include/iniparser/"
else
CPPFLAGS="$CPPFLAGS -I/usr/include/iniparser"
fi
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <iniparser.h>]],
[[dictionary* ini;
const char *keys[3];
Expand Down
19 changes: 10 additions & 9 deletions example_files/config
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
; bar_width = 20
; bar_spacing = 5

# sdl_glsl have these default values, they are only used to calulate max number of bars.
# sdl_glsl have these default values, they are only used to calculate max number of bars.
; bar_width = 1
; bar_spacing = 0

Expand Down Expand Up @@ -144,10 +144,12 @@
# use one of the predefined ones.
; method = noncurses

# Orientation of the visualization. Can be 'bottom', 'top', 'left' or 'right'.
# Default is 'bottom'. Other orientations are only supported on sdl and ncruses
# output. Note: many fonts have weird glyphs for 'top' and 'right' characters,
# which can make ncurses not look right.
# Orientation of the visualization. Can be 'bottom', 'top', 'left', 'right' or
# 'horizontal'. Default is 'bottom'. 'left and 'right' are only supported on sdl
# and ncruses output. 'horizontal' (bars go up and down from center) is only supported
# on noncurses output.
# Note: many fonts have weird or missing glyphs for characters used in orientations
# other than 'bottom', which can make output not look right.
; orientation = bottom

# Visual channels. Can be 'stereo' or 'mono'.
Expand Down Expand Up @@ -187,11 +189,11 @@
# 'frequency' displays the lower cut off frequency of the bar above.
# Only supported on ncurses and noncurses output.
; xaxis = none

# enable alacritty synchronized updates. 1 = on, 0 = off
# enable synchronized sync. 1 = on, 0 = off
# removes flickering in alacritty terminal emulator.
# defaults to off since the behaviour in other terminal emulators is unknown
; alacritty_sync = 0
; synchronized_sync = 0

# Shaders for sdl_glsl, located in $HOME/.config/cava/shaders
; vertex_shader = pass_through.vert
Expand Down Expand Up @@ -228,7 +230,6 @@
# background must also be defined in hex or remain commented out. 1 = on, 0 = off.
# You can define as many as 8 different colors. They range from bottom to top of screen
; gradient = 0
; gradient_count = 8
; gradient_color_1 = '#59cc33'
; gradient_color_2 = '#80cc33'
; gradient_color_3 = '#a6cc33'
Expand Down
9 changes: 8 additions & 1 deletion include/cava/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,14 @@ enum data_format { FORMAT_ASCII = 0, FORMAT_BINARY = 1, FORMAT_NTK3000 = 2 };

enum xaxis_scale { NONE, FREQUENCY, NOTE };

enum orientation { ORIENT_BOTTOM, ORIENT_TOP, ORIENT_LEFT, ORIENT_RIGHT };
enum orientation {
ORIENT_BOTTOM,
ORIENT_TOP,
ORIENT_LEFT,
ORIENT_RIGHT,
ORIENT_SPLIT_H,
ORIENT_SPLIT_V
};

struct config_params {
char *color, *bcolor, *raw_target, *audio_source,
Expand Down
8 changes: 6 additions & 2 deletions include/cava/output/terminal_noncurses.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
#include "../config.h"

int init_terminal_noncurses(int inAtty, char *const fg_color_string, char *const bg_color_string,
int col, int bgcol, int gradient, int gradient_count,
char **gradient_colors, int w, int h, int bar_width);
char **gradient_colors, int w, int h, int bar_width,
enum orientation orientation);
void get_terminal_dim_noncurses(int *w, int *h);
int draw_terminal_noncurses(int inAtty, int lines, int width, int number_of_bars, int bar_width,
int bar_spacing, int rest, int bars[], int previous_frame[],
int gradient, int x_axis_info);
int gradient, int x_axis_info, enum orientation orientation,
int offset);
void cleanup_terminal_noncurses(void);
34 changes: 26 additions & 8 deletions src/cava.c
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,11 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
if (p.disable_blanking)
system("setterm -blank 0");
#endif
if (p.orientation != ORIENT_BOTTOM) {
cleanup(output_mode);
fprintf(stderr, "only default bottom orientation is supported in tty\n");
exit(EXIT_FAILURE);
}
}

// We use unicode block characters to draw the bars and
Expand Down Expand Up @@ -260,7 +265,7 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
if (timeout_counter > 2000) {
cleanup(output_mode);
fprintf(stderr, "could not get rate and/or format, problems with audio thread? "
"quiting...\n");
"quitting...\n");
exit(EXIT_FAILURE);
}
}
Expand Down Expand Up @@ -442,8 +447,9 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
// output: draw processed input
#ifdef NDEBUG
if (p.sync_updates) {
printf("\033P=1s\033\\");
printf("\033[2026h\033\\");
fflush(stdout);
printf("\033[2026l\033\\");
}
int rc;
#ifdef _MSC_VER
Expand All @@ -468,10 +474,21 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
break;
#endif
case OUTPUT_NONCURSES:
rc = draw_terminal_noncurses(
p.inAtty, audio_raw.lines, audio_raw.width, audio_raw.number_of_bars,
p.bar_width, p.bar_spacing, audio_raw.remainder, audio_raw.bars,
audio_raw.previous_frame, p.gradient, p.x_axis_info);
if (p.orientation == ORIENT_SPLIT_H) {
rc = draw_terminal_noncurses(p.inAtty, audio_raw.lines, audio_raw.width, audio_raw.number_of_bars,
p.bar_width, p.bar_spacing, audio_raw.remainder, audio_raw.bars,
audio_raw.previous_frame, p.gradient, p.x_axis_info,
ORIENT_BOTTOM, 1);
rc = draw_terminal_noncurses(p.inAtty, audio_raw.lines, audio_raw.width, audio_raw.number_of_bars,
p.bar_width, p.bar_spacing, audio_raw.remainder, audio_raw.bars,
audio_raw.previous_frame, p.gradient, p.x_axis_info,
ORIENT_TOP, 1);
} else {
rc = draw_terminal_noncurses(p.inAtty, audio_raw.lines, audio_raw.width, audio_raw.number_of_bars,
p.bar_width, p.bar_spacing, audio_raw.remainder, audio_raw.bars,
audio_raw.previous_frame, p.gradient, p.x_axis_info,
p.orientation, 0);
}
break;
case OUTPUT_NCURSES:
#ifdef NCURSES
Expand All @@ -496,11 +513,12 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
default:
exit(EXIT_FAILURE); // Can't happen.
}

if (p.sync_updates) {
printf("\033P=2s\033\\");
printf("\033[2026h\033\\");
fflush(stdout);
printf("\033[2026l\033\\");
}

// terminal has been resized breaking to recalibrating values
if (rc == -1)
resizeTerminal = true;
Expand Down
Loading

0 comments on commit 86b6b12

Please sign in to comment.