-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathtest.cpp
More file actions
55 lines (44 loc) · 1.22 KB
/
test.cpp
File metadata and controls
55 lines (44 loc) · 1.22 KB
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
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <string.h>
#include "teensy/synth.h"
#include "teensy/voice.h"
#include "teensy/tests.h"
#define NUM_VOICES 8
FILE *outf, *gp_outf;
int t;
Synth s;
ISynth *synth_ary[NUM_VOICES];
extern uint32_t tune[];
int main(int argc, char *argv[])
{
if (argc == 2 && strncmp(argv[1], "-t", 2) == 0) {
return run_tests();
}
synth_ary[0] = &s;
use_synth_array(synth_ary, NUM_VOICES);
use_synth(0);
gp_outf = fopen("foo.gp", "w");
outf = fopen("foo.py", "w");
fprintf(outf, "sampfreq = %lf\n", (double) SAMPLING_RATE);
fprintf(outf, "samples = [\n");
for (int i = 0; i < NUM_VOICES; i++) {
s.add(new NoisyVoice());
// s.add(new TwoSquaresVoice());
// s.add(new SimpleVoice());
}
for (t = 0; 1; t++) {
int32_t y;
uint32_t msecs = (1000 * t) / SAMPLING_RATE;
if (play_tune(tune, msecs)) break;
s.compute_sample();
ASSERT(s.get_sample((uint32_t *) &y) == 0);
fprintf(outf, "%u,\n", (uint16_t) (y << 6));
/* Numbers for Gnuplot */
fprintf(gp_outf, "%d %d\n", t, (int) y);
}
fprintf(outf, "]\n");
fclose(outf);
fclose(gp_outf);
}