21 #include <pulse/simple.h>
23 #include "../ckb/ckb-anim.h"
33 CKB_GUID(
"{097D69F0-70B2-48B8-AFE2-25CA1DB0D92C}");
58 pa_simple *
pas = NULL;
62 static const pa_sample_spec ss ={
63 .format = PA_SAMPLE_S16LE,
67 pas = pa_simple_new(NULL,
"CKB Music Viz", PA_STREAM_RECORD, NULL,
"CKB Music Viz", &ss, NULL, NULL, NULL);
97 int max(
int a,
int b){
102 return a < b ? a : b;
109 pa_simple_read(
pas, data,
sizeof(data), NULL);
110 for(
int j=0; j<2048; j++){
111 inbuf[j].
r = data[j];
117 for(
unsigned int j=0; j < 2048; j++)
119 powers[j] = outbuf[j].
r*outbuf[j].
r + outbuf[j].
i*outbuf[j].
i;
121 powers[j] = sqrt(outbuf[j].r*outbuf[j].r + outbuf[j].i*outbuf[j].i);
131 unsigned int frames = context->
width*context->
height - 1;
132 int height = context->
height;
134 int posl = height*
key->x +
key->y - 1;
136 int posr = height*
key->x +
key->y + 1;
138 int lowi = floorf(pow(2,posl*11.f/frames));
139 int highi = ceilf(pow(2,posr*11.f/frames));
140 highi=
min(highi, (
int)
sizeof(
powers)/
sizeof(
double)-1);
143 unsigned int height = context->
height;
144 for(
unsigned int i = lowi; i <= highi; i++)
146 total /= highi - lowi + 1;
void ckb_keypress(ckb_runctx *context, ckb_key *key, int x, int y, int state)
void ckb_parameter(ckb_runctx *context, const char *name, const char *value)
#define CKB_VERSION(version)
#define CKB_TIMEMODE(mode)
#define CKB_PARSE_AGRADIENT(param_name, gradient_ptr)
#define CKB_TIME_ABSOLUTE
#define CKB_LICENSE(license)
#define CKB_COPYRIGHT(year, author)
#define CKB_DESCRIPTION(description)
int ckb_frame(ckb_runctx *context)
#define CKB_PRESET_START(name)
void ckb_time(ckb_runctx *context, double delta)
void kiss_fft_cleanup(void)
#define CKB_PARAM_AGRADIENT(name, prefix, postfix, default)
#define CKB_LIVEPARAMS(enable)
kiss_fft_cfg kiss_fft_alloc(int nfft, int inverse_fft, void *mem, size_t *lenmem)
void anim_remove(int index)
#define CKB_PARSE_BOOL(param_name, value_ptr)
void kiss_fft(kiss_fft_cfg cfg, const kiss_fft_cpx *fin, kiss_fft_cpx *fout)
void ckb_init(ckb_runctx *context)
#define CKB_REPEAT(enable)
#define CKB_KEYCLEAR(context)
void ckb_start(ckb_runctx *context, int state)
#define CKB_PRESET_PARAM(name, value)
#define CKB_PARAM_BOOL(name, text, default)
void ckb_alpha_blend(ckb_key *key, float a, float r, float g, float b)
void ckb_grad_color(float *a, float *r, float *g, float *b, const ckb_gradient *grad, float pos)