forked from EliasOenal/multimon-ng
-
Notifications
You must be signed in to change notification settings - Fork 0
/
demod_dumpcsv.c
74 lines (52 loc) · 1.75 KB
/
demod_dumpcsv.c
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
* demod_dumpcsv.c -- dump data in CSV format
*
* Written and placed into the public domain by
* Peter Shipley < [email protected] >
*/
/*
* Useful for piping to gnuplot
* format is in time,value
* where :
* time is a float in ms
* value is a float from the current data stream
*
*/
/* ---------------------------------------------------------------------- */
#include "multimon.h"
#include <string.h>
#include <stdio.h>
/* ---------------------------------------------------------------------- */
#define SAMPLING_RATE 22050
#define SAMPLE_MS 22.050f
/* ---------------------------------------------------------------------- */
static void dumpcsv_init(struct demod_state *s)
{
memset(&s->l1.dumpcsv, 0, sizeof(s->l1.dumpcsv));
}
/* ---------------------------------------------------------------------- */
static void dumpcsv_demod(struct demod_state *s, buffer_t buffer, int length)
{
short p;
const short *src;
float f;
int i;
verbprintf(2, "dump_demod length=%d, current_sequence=%d\n", length, s->l1.dumpcsv.current_sequence);
src = buffer.sbuffer;
for ( i=0 ; i < length ; i++, src++) {
f = (float) ( (i + s->l1.dumpcsv.current_sequence) / SAMPLE_MS );
/* cut back on superfluous plot points
if ( abs(p - *src ) < 40 )
continue;
*/
fprintf(stdout, "%.6f,%hd\n", f, *src);
p = *src;
}
// Save current count
s->l1.dumpcsv.current_sequence = s->l1.dumpcsv.current_sequence + i;
}
/* ---------------------------------------------------------------------- */
const struct demod_param demod_dumpcsv = {
"DUMPCSV", false, SAMPLING_RATE, 0, dumpcsv_init, dumpcsv_demod, NULL
};
/* ---------------------------------------------------------------------- */