shadermeh/shadermeh.h
tyrolyean 664f8d0305
Make fft work, add sample rate to stabilize waveform
This adds a sliding window buffer approach to the audio sample data as well as
force the user to set the sampling rate of the input data. This was needed to
stabilize fft output to a usable degree. Also the fft output is now in db, which
makes it a lot better to look at.

Signed-off-by: tyrolyean <tyrolyean@tyrolyean.net>
2022-07-20 23:43:41 +02:00

69 lines
1.3 KiB
C

/* SPDX-License-Identifier: ISC */
/*
* shadermeh.h
*
* Copyright (C) 2022 David Oberhollenzer <goliath@infraroot.at>
*/
#ifndef SHADERMEH_H
#define SHADERMEH_H
#include <X11/X.h>
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/Xresource.h>
#include <GL/glew.h>
#include <GL/gl.h>
#include <GL/glx.h>
#include <stdbool.h>
#include <string.h>
#include <stdlib.h>
#include <getopt.h>
#include <unistd.h>
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <poll.h>
#include <time.h>
#include <math.h>
#include <complex.h>
#include <fftw3.h>
#define AUDIO_SAMPLES (4096)
#define AUDIO_BUFFER_SIZE (sample_rate * 3)
#define AUDIO_FFT_SIZE (AUDIO_SAMPLES * 2)
#define AUDIO_CHANNELS (2)
typedef struct {
Window wnd;
GLXContext gl;
bool visible;
} window;
window *window_create(unsigned int width, unsigned int height,
const char *caption);
void window_make_current(window *wnd);
void window_swap_buffers(window *wnd);
void window_set_vsync(window *wnd, int enable);
void window_destroy(window *wnd);
void window_show(window *wnd);
void window_hide(window *wnd);
bool window_handle_events(void);
GLuint shader_program_load(const char *fsh);
int shader_program_get_build_status(GLuint prog);
void shader_program_print_info_log(GLuint prog);
#endif /* SHADERMEH_H */