Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Up sync #10

Merged
merged 15 commits into from
Oct 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions .github/ISSUE_TEMPLATE/bug_report.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,29 +7,42 @@ assignees: ''

---

**When/where was the bug introduced?**
- Are you using cava from a package repository, like AUR?
- If so, check out the master branch here, is your issue already resolved?
- Don't know how to clone, compile source code? File report to package maintainer instead.
- try using git bisect to find out where the bug was introduced.
**READ THIS BEFORE CREATING NEW ISSUE**

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!



**Describe the bug**

A clear and concise description of what the bug is.


**To Reproduce**

Steps to reproduce the behavior:
1. Set config parameter to
2. run
3. do something
4. See error


**Expected behavior**

A clear and concise description of what you expected to happen.


**Screenshots**

If applicable, add screenshots to help explain your problem.


**Desktop (please complete the following information):**

- OS: [e.g. macOS, Ubuntu]
- Version [e.g. 22]

Expand Down
12 changes: 8 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ Required components:
* libtool
* automake
* autoconf-archive (needed for setting up OpenGL)
* pkgconf
* build-essentials
* [iniparser](https://github.com/ndevilla/iniparser)

Expand All @@ -89,22 +90,22 @@ All the requirements can be installed easily in all major distros:

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
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 pkgconf


ArchLinux:

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


openSUSE:

zypper install alsa-devel ncurses-devel fftw3-devel libpulse-devel libtool autoconf-archive
zypper install alsa-devel ncurses-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
dnf install alsa-lib-devel ncurses-devel fftw3-devel pulseaudio-libs-devel libtool autoconf-archive iniparser-devel pkgconf


macOS:
Expand Down Expand Up @@ -406,6 +407,9 @@ So in `cava.psf`, the characters 1-7 are actually replaced by Unicode characters

Actually, `setfont` is supposed to return the default font, but this usually isn't set. I haven't found another way to get the current font. So cava sets the font to "Lat2-Fixed16" when interrupted. All major distros should have it. It will revert to your default font at reboot.

### Gradient not working in Konsole

Konsole simply does not support this. #194

Usage
-----
Expand Down
2 changes: 1 addition & 1 deletion autogen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [ -d .git ]; then
git describe --always --tags --dirty > version # get version from git
else
echo 0.8.3 > version # hard coded versions
echo 0.9.1 > version # hard coded versions
fi

libtoolize
Expand Down
4 changes: 2 additions & 2 deletions cava_win/README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
# cava on windows

All dependencies should install themselves via the nuget thing:
All dependencies should install themselves via the NuGet thing:
* SDL2
* FFTW
* pthreads
* glew

include paths are configure relativly to the project so linking and inlcuding should work autmatically with the nugets, but might stop workiong at some point.
include paths are configured relatively to the project so linking and including should work automatically with the nugets, but might stop working at some point.

The Visual C++ Redistributable for Visual Studio 2012 (maybe also a newer one) was needed when I first ran it.
4 changes: 2 additions & 2 deletions cavacore_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ void main() {
double noise_reduction = 0.77;
int low_cut_off = 50;
int high_cut_off = 10000;
double blueprint_2000MHz[10] = {0, 0, 0, 0, 0, 0, 0.494, 0.449, 0, 0};
double blueprint_200MHz[10] = {0, 0, 0.939, 0.008, 0, 0.001, 0, 0, 0, 0};
double blueprint_2000MHz[10] = {0, 0, 0, 0, 0, 0, 0.493, 0.446, 0, 0};
double blueprint_200MHz[10] = {0, 0, 0.978, 0.008, 0, 0.001, 0, 0, 0, 0};

printf("planning visualization with %d bars per channel, %d rate, %d channels, autosens, "
"%.2f noise reduction, %d - %d MHz bandwith.\n",
Expand Down
6 changes: 3 additions & 3 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ AC_ARG_ENABLE([input_pipewire],
)

AS_IF([test "x$enable_input_pipewire" != "xno"], [
AC_CHECK_LIB(pipewire-0.3, pw_stream_connect, have_pipewire=yes, have_pipewire=no)
PKG_CHECK_MODULES(PIPEWIRE, libpipewire-0.3, have_pipewire=yes, have_pipewire=no)
if [[ $have_pipewire = "yes" ]] ; then
LIBS="$LIBS -lpipewire-0.3"
CPPFLAGS="$CPPFLAGS -DPIPEWIRE -D_REENTRANT -I/usr/include/pipewire-0.3 -I/usr/include/spa-0.2"
LIBS="$LIBS $PIPEWIRE_LIBS"
CPPFLAGS="$CPPFLAGS -DPIPEWIRE $PIPEWIRE_CFLAGS"
fi

if [[ $have_pipewire = "no" ]] ; then
Expand Down
3 changes: 2 additions & 1 deletion example_files/config
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@

# Audio capturing method. Possible methods are: 'pulse', 'alsa', 'fifo', 'sndio' or 'shmem'
# Defaults to 'pulse', 'pipewire', 'alsa' or 'fifo', in that order, dependent on what support cava was built with.
# On Mac it defaults to 'portaudio' or 'fifo'
# On windows this is automatic and no input settings are needed.
#
# All input methods uses the same config variable 'source'
Expand All @@ -62,7 +63,7 @@
# For pulseaudio and pipewire '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 piepwire 'source' will be the object name or object.serial of the device to capture from.
# For pipewire 'source' will be the object name or object.serial of the device to capture from.
# Both input and output devices are supported.
#
# For alsa 'source' will be the capture device.
Expand Down
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
project(
'cava',
'c',
version: '0.8.5',
version: '0.9.1',
license: 'MIT',
meson_version: '>=0.50.0',
default_options : [
Expand Down
6 changes: 0 additions & 6 deletions src/cavacore.c
Original file line number Diff line number Diff line change
Expand Up @@ -494,12 +494,6 @@ void cava_execute(double *cava_in, int new_samples, double *cava_out, struct cav
cava_out[n] = p->cava_mem[n] * p->noise_reduction + cava_out[n];
p->cava_mem[n] = cava_out[n];
if (p->autosens) {
double diff = 1 - cava_out[n];
if (diff < 0)
diff = 0;
double div = 1 / (diff + 1);
p->cava_mem[n] = p->cava_mem[n] * (1 - div / 20);

// check if we overshoot target height
if (cava_out[n] > 1.0) {
overshoot = 1;
Expand Down
12 changes: 8 additions & 4 deletions src/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const char *default_shader_name[NUMBER_OF_SHADERS] = {"northern_lights.frag", "p
double smoothDef[5] = {1, 1, 1, 1, 1};

enum input_method default_methods[] = {
INPUT_FIFO, INPUT_PORTAUDIO, INPUT_ALSA, INPUT_PULSE, INPUT_WINSCAP,
INPUT_FIFO, INPUT_PORTAUDIO, INPUT_ALSA, INPUT_PIPEWIRE, INPUT_PULSE, INPUT_WINSCAP,
};

char *outputMethod, *orientation, *channels, *xaxisScale, *monoOption, *fragmentShader,
Expand Down Expand Up @@ -224,7 +224,7 @@ bool validate_config(struct config_params *p, struct error_s *error) {
if (strcmp(outputMethod, "sdl_glsl") == 0) {
p->output = OUTPUT_SDL_GLSL;
#ifndef SDL_GLSL
write_errorf(error, "cava was built without sdl support, install sdl dev files "
write_errorf(error, "cava was built without opengl support, install opengl dev files "
"and run make clean && ./configure && make again\n");
return false;
#endif
Expand Down Expand Up @@ -388,6 +388,10 @@ bool validate_config(struct config_params *p, struct error_s *error) {
}

// setting sens
if (p->sens < 1) {
write_errorf(error, "Sensitivity needs to be at least 1%%\n");
return false;
}
p->sens = p->sens / 100;

return validate_colors(p, error);
Expand Down Expand Up @@ -678,11 +682,11 @@ bool load_config(char configPath[PATH_MAX], struct config_params *p, bool colors

free(p->audio_source);

int default_input = -1;
enum input_method default_input = INPUT_FIFO;
for (size_t i = 0; i < ARRAY_SIZE(default_methods); i++) {
enum input_method method = default_methods[i];
if (has_input_method[method]) {
default_input++;
default_input = default_methods[i];
}
}
char *input_method_name =
Expand Down
7 changes: 6 additions & 1 deletion src/input/pipewire.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
#include "cava/input/pipewire.h"
#include "cava/input/common.h"
#include <math.h>

#include <spa/param/audio/format-utils.h>
#include <spa/param/latency-utils.h>

#include <pipewire/pipewire.h>

Expand Down Expand Up @@ -73,6 +75,8 @@ void *input_pipewire(void *audiodata) {
struct pw_properties *props;
struct spa_pod_builder b = SPA_POD_BUILDER_INIT(buffer, sizeof(buffer));
char **argv;
uint32_t nom;
nom = nearbyint((10000 * data.cava_audio->rate) / 1000000.0);

pw_init(0, &argv);

Expand All @@ -83,13 +87,14 @@ void *input_pipewire(void *audiodata) {

pw_properties_set(props, PW_KEY_TARGET_OBJECT, data.cava_audio->source);
pw_properties_set(props, PW_KEY_STREAM_CAPTURE_SINK, "true");
pw_properties_setf(props, PW_KEY_NODE_LATENCY, "%u/%u", nom, data.cava_audio->rate);

data.stream = pw_stream_new_simple(pw_main_loop_get_loop(data.loop), "cava", props,
&stream_events, &data);

params[0] = spa_format_audio_raw_build(
&b, SPA_PARAM_EnumFormat,
&SPA_AUDIO_INFO_RAW_INIT(.format = SPA_AUDIO_FORMAT_S16, .rate = 44100));
&SPA_AUDIO_INFO_RAW_INIT(.format = SPA_AUDIO_FORMAT_S16, .rate = data.cava_audio->rate));

pw_stream_connect(data.stream, PW_DIRECTION_INPUT, PW_ID_ANY,
PW_STREAM_FLAG_AUTOCONNECT | PW_STREAM_FLAG_MAP_BUFFERS |
Expand Down
15 changes: 8 additions & 7 deletions src/output/sdl_cava.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,16 @@ int draw_sdl(int bars_count, int bar_width, int bar_spacing, int remainder, int

SDL_Delay(frame_time);

SDL_PollEvent(&e);
if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
rc = -1;
if (gradient) {
free(gradient_colors_sdl);
while (SDL_PollEvent(&e)) {
if (e.window.event == SDL_WINDOWEVENT_SIZE_CHANGED) {
rc = -1;
if (gradient) {
free(gradient_colors_sdl);
}
}
if (e.type == SDL_QUIT)
rc = -2;
}
if (e.type == SDL_QUIT)
rc = -2;

return rc;
}
Expand Down