Skip to content

Commit 2651195

Browse files
committed
added legacy ouput mode noncurses
1 parent 651f72e commit 2651195

File tree

6 files changed

+139
-65
lines changed

6 files changed

+139
-65
lines changed

README.md

+37-1
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,47 @@ thanks to [anko](https://github.com/anko) for the gif, here is the [recipe]( htt
1111

1212
[Demo video](http://youtu.be/vA4RyatP064) (old)
1313

14+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
15+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
16+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
17+
18+
- [C.A.V.A. ](#cava)
19+
- [Updates](#updates)
20+
- [What it is](#what-it-is)
21+
- [Build requirements](#build-requirements)
22+
- [Getting started](#getting-started)
23+
- [Installing](#installing)
24+
- [Uninstalling](#uninstalling)
25+
- [Capturing audio](#capturing-audio)
26+
- [Straight from output](#straight-from-output)
27+
- [PulseAudio (easy)](#pulseaudio-easy)
28+
- [ALSA (hard)](#alsa-hard)
29+
- [From mpd's fifo output](#from-mpds-fifo-output)
30+
- [Running via ssh](#running-via-ssh)
31+
- [Font notes](#font-notes)
32+
- [In ttys](#in-ttys)
33+
- [In terminal emulators](#in-terminal-emulators)
34+
- [Latency notes](#latency-notes)
35+
- [Usage](#usage)
36+
- [Controls](#controls)
37+
- [Configuration](#configuration)
38+
- [Example file:](#example-file)
39+
- [Sections:](#sections)
40+
- [[general]](#general)
41+
- [[input]](#input)
42+
- [[output]](#output)
43+
- [[color]](#color)
44+
- [[smoothing]](#smoothing)
45+
- [[eq]](#eq)
46+
47+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
1448

1549

1650
Updates
1751
-------
1852

53+
7/16/2015 - 0.3.2 - added legacy ouput mode 'noncurses', for people experiencing issues with ncurses
54+
1955
7/15/2015 - 0.3.1 - added config file
2056

2157
7/12/2015 - 0.3.0 - Modular source code
@@ -210,7 +246,7 @@ Usage
210246
Options:
211247
-b 1..(console columns/2-1) or 200 number of bars in the spectrum (default 25 + fills up the console), program will automatically adjust if there are too many frequency bands)
212248
-i 'input method' method used for listnening to audio, supports: 'alsa' and 'fifo'
213-
-o 'output method' method used for outputting processed data, only supports 'terminal'
249+
-o 'output method' method used for outputting processed data, supports: 'ncurses', 'noncurses' and 'circle'
214250
-d 'alsa device' name of alsa capture device (default 'hw:1,1')
215251
-p 'fifo path' path to fifo (default '/tmp/mpd.fifo')
216252
-c foreground color suported colors: red, green, yellow, magenta, cyan, white, blue, black (default: cyan)

cava.c

+28-35
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,9 @@ void load_config()
103103
}
104104
}
105105
}
106-
107106
// config: create directory
108107
mkdir(configPath, 0777);
109-
108+
110109
// config: create empty file
111110
strcat(configPath, configFile);
112111
FILE *fp = fopen(configPath, "ab+");
@@ -155,7 +154,7 @@ void load_config()
155154
void validate_config()
156155
{
157156
// validate: input method
158-
if (im == 0) {
157+
if (im == 0) {
159158
fprintf(stderr,
160159
"input method %s is not supported, supported methods are: 'alsa' and 'fifo'\n",
161160
inputMethod);
@@ -169,7 +168,7 @@ void validate_config()
169168
om = 3;
170169
bgcol = 0;
171170
}
172-
if (om == 0) {
171+
if (om == 0) {
173172
fprintf(stderr,
174173
"output method %s is not supported, supported methods are: 'terminal', 'circle'\n",
175174
outputMethod);
@@ -184,15 +183,15 @@ void validate_config()
184183
if (strcmp(modeString, "normal") == 0) mode = 1;
185184
if (strcmp(modeString, "scientific") == 0) mode = 2;
186185
if (strcmp(modeString, "waves") == 0) mode = 3;
187-
if (mode == 0) {
186+
if (mode == 0) {
188187
fprintf(stderr,
189188
"smoothing mode %s is not supported, supported modes are: 'normal', 'scientific', 'waves'\n",
190189
modeString);
191190
exit(EXIT_FAILURE);
192191
}
193192

194193
// validate: framerate
195-
if (framerate < 0) {
194+
if (framerate < 0) {
196195
fprintf(stderr,
197196
"framerate can't be negative!\n");
198197
exit(EXIT_FAILURE);
@@ -289,11 +288,8 @@ Options:\n\
289288

290289
audio.format = -1;
291290
audio.rate = 0;
292-
293-
setlocale(LC_ALL, "");
294-
295-
296291

292+
setlocale(LC_ALL, "");
297293

298294
for (i = 0; i < M; i++)audio.audio_out[i] = 0;
299295

@@ -343,10 +339,10 @@ Options:\n\
343339
bgcol = -2;
344340
bcolor = optarg;
345341
break;
346-
case 'h': // argument: print usage
347-
printf ("%s", usage);
342+
case 'h': // argument: print usage
343+
printf ("%s", usage);
348344
return 0;
349-
case '?': // argument: print usage
345+
case '?': // argument: print usage
350346
printf ("%s", usage);
351347
return 1;
352348
case 'v': // argument: print version
@@ -381,7 +377,7 @@ Options:\n\
381377
}
382378
}
383379
#ifdef DEBUG
384-
printf("got format: %d and rate %d\n", format, rate);
380+
printf("got format: %d and rate %d\n", format, rate);
385381
#endif
386382

387383
}
@@ -405,11 +401,6 @@ Options:\n\
405401
init_terminal_ncurses(col, bgcol);
406402
}
407403

408-
//output: start noncurses mode
409-
if (om == 3) {
410-
get_terminal_dim_noncurses(&w, &h);
411-
init_terminal_noncurses(col, bgcol, w, h);
412-
}
413404

414405

415406
while (1) {//jumbing back to this loop means that you resized the screen
@@ -421,18 +412,17 @@ Options:\n\
421412
fmem[i] = 0;
422413
}
423414

424-
425-
415+
426416
//getting orignial numbers of bands incase of resize
427417
if (autoband == 1) {
428418
bands = 25;
429419
} else bands = fixedbands;
430-
420+
431421

432422
// output: get terminal's geometry
433-
if (om == 1 || om == 2) get_terminal_dim_ncurses(&w, &h);
423+
if (om == 1 || om == 2) get_terminal_dim_ncurses(&w, &h);
434424

435-
if (om == 3) get_terminal_dim_noncurses(&w, &h);
425+
if (om == 3) get_terminal_dim_noncurses(&w, &h);
436426

437427

438428
if (bands > w / 2 - 1)bands = w / 2 -
@@ -459,23 +449,27 @@ Options:\n\
459449
if (rest < 0)rest = 0;
460450

461451
if ((smcount > 0) && (bands > 0)) {
462-
smh = (double)(((double)smcount)/((double)bands));
452+
smh = (double)(((double)smcount)/((double)bands));
463453
}
464454

455+
465456
#ifdef DEBUG
466457
printw("hoyde: %d bredde: %d bands:%d bandbredde: %d rest: %d\n",
467458
w,
468459
h, bands, bw, rest);
469460
#endif
470461

462+
//output: start noncurses mode
463+
if (om == 3) init_terminal_noncurses(col, bgcol, w, h, bw);
464+
471465
// process: calculate cutoff frequencies
472466
for (n = 0; n < bands + 1; n++) {
473467
fc[n] = 10000 * pow(10, -2.37 + ((((float)n + 1) / ((float)bands + 1)) *
474468
2.37)); //decided to cut it at 10k, little interesting to hear above
475469
fr[n] = fc[n] / (audio.rate /
476470
2); //remember nyquist!, pr my calculations this should be rate/2 and nyquist freq in M/2 but testing shows it is not... or maybe the nq freq is in M/4
477471
lcf[n] = fr[n] * (M /
478-
4); //lfc stores the lower cut frequency foo each band in the fft out buffer
472+
4); //lfc stores the lower cut frequency foo each band in the fft out buffer
479473
if (n != 0) {
480474
hcf[n - 1] = lcf[n] - 1;
481475
if (lcf[n] <= lcf[n - 1])lcf[n] = lcf[n - 1] +
@@ -490,16 +484,16 @@ Options:\n\
490484
}
491485
#endif
492486
}
493-
487+
494488
// process: weigh signal to frequencies
495489
for (n = 0; n < bands;
496490
n++)k[n] = pow(fc[n],0.85) * ((float)height/(M*4000)) * smooth[(int)floor(((double)n) * smh)];
497-
498-
cont = 1;
491+
492+
cont = 1;
499493
// general: main loop
500494
while (cont) {
501495

502-
// general: keyboard controls
496+
// general: keyboard controls
503497
if (om == 1 || om == 2) ch = getch();
504498
switch (ch) {
505499
case 65: // key up
@@ -528,7 +522,7 @@ Options:\n\
528522
cleanup();
529523
return EXIT_SUCCESS;
530524
}
531-
525+
532526

533527

534528
#ifdef DEBUG
@@ -571,7 +565,6 @@ Options:\n\
571565
if (temp <= ignore)temp = 0;
572566
f[o] = temp;
573567

574-
575568
}
576569

577570
} else { //**if in sleep mode wait and continue**//
@@ -591,7 +584,7 @@ Options:\n\
591584
int z;
592585

593586
// process [smoothing]: monstercat-style "average"
594-
587+
595588
int m_y, de;
596589
if (mode == 3) {
597590
for (z = 0; z < bands; z++) { // waves
@@ -670,10 +663,10 @@ Options:\n\
670663
}
671664

672665
if (rc == -1) break; //terminal has been resized breaking to recalibrating values
673-
666+
674667
if (framerate <= 1) {
675668
req.tv_sec = 1 / (float)framerate;
676-
} else {
669+
} else {
677670
req.tv_sec = 0;
678671
req.tv_nsec = (1 / (float)framerate) * 1000000000; //sleeping for set us
679672
}

iniparser/README.md

+15
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2+
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
3+
**Table of Contents** *generated with [DocToc](https://github.com/thlorenz/doctoc)*
4+
5+
- [Iniparser 4](#iniparser-4)
6+
- [I - Overview](#i---overview)
7+
- [II - Building project](#ii---building-project)
8+
- [III - License](#iii---license)
9+
- [IV - Versions](#iv---versions)
10+
- [V - FAQ](#v---faq)
11+
- [Is Iniparser thread safe ?](#is-iniparser-thread-safe-)
12+
- [Your build system isn't portable, let me help you...](#your-build-system-isnt-portable-let-me-help-you)
13+
14+
<!-- END doctoc generated TOC please keep comment here to allow auto update -->
15+
116
[![Build Status](https://travis-ci.org/ndevilla/iniparser.svg?branch=master)](https://travis-ci.org/ndevilla/iniparser)
217

318
# Iniparser 4 #

output/terminal_ncurses.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ int init_terminal_ncurses(int col, int bgcol) {
99
curs_set(0);
1010
timeout(0);
1111
noecho();
12-
start_color();
12+
start_color();
1313
use_default_colors();
1414
init_pair(1, col, bgcol);
1515
if(bgcol != -1)
@@ -35,8 +35,8 @@ int draw_terminal_ncurses(int virt, int h, int w, int bands, int bw, int rest, i
3535
// output: check if terminal has been resized
3636
if (virt != 0) {
3737
if ( LINES != h || COLS != w) {
38-
return -1;
39-
}
38+
return -1;
39+
}
4040
}
4141

4242
h = h - 1;
@@ -57,7 +57,7 @@ int draw_terminal_ncurses(int virt, int h, int w, int bands, int bw, int rest, i
5757
else for (q = 0; q < bw; q++) mvaddwstr((h - f[i] / 8), (i * bw) + q + i + rest, bars[(f[i] % 8) - 1]);
5858
}
5959
}
60-
flastd[i] = f[i]; //memmory for falloff func
60+
flastd[i] = f[i]; //memmory for falloff func
6161
}
6262

6363
refresh();

0 commit comments

Comments
 (0)