-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvmatrix.h
54 lines (44 loc) · 1.62 KB
/
vmatrix.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <alsa/asoundlib.h>
#include <signal.h>
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "led-matrix-c.h"
#include "kiss_fftr.h"
/* Definitions. */
#define AUDIO_DEVICE "hw:1" // audio device to read from
#define MATRIX_ROWS 32 // matrix default row count
#define MATRIX_COLS 64 // matrix default column count
#define FS 44100 // Hz, audio sampling rate
#define N 1600 // audio sample buffer size
#define ENVELOPE_CTR 1 // number of clicks envelope falls
/* Computed definitions. */
#define N_NYQUIST (N / 2) + 1 // Nyquist frequency
#define FREQ_RES (FS / N) // FFT frequency resolution
#define MIN_FREQ FREQ_RES // freq. of lowest FFT bin
#define MAX_FREQ FREQ_RES * (N/2) // freq. of highest FFT bin
#define MAX_FREQ_CAP 16000 // max freq. for visualization purposes
/* Display modes. */
enum {
HISTOGRAM,
HISTOGRAM_HOLLOW,
HISTOGRAM_W_ENVELOPE,
SCROLLING_SPECTROGRAM
} DisplayModes;
#define DISPLAY_MODE HISTOGRAM_HOLLOW
/* Data structures. */
typedef struct {
int y;
int counter; // keep track of # of iterations passed
} PointHistory;
/* Function declarations. */
void sigint_handler(int signo);
void clean_up();
void alsa_config_hw_params();
double linspace(double min, double max, int i, int n);
double logspace(double min, double max, int i, int n);
float *bin_amplitudes(float *amplitudes, int size, int bin_size);
void histogram(float *amplitudes, float old_weight, float new_weight, bool show_envelope, bool fill_hist, bool show_bottom_row);
void scrolling_spectrogram(float *binarr);