blob: 9ae3acca1b1d605767e6d2cc618dbab13fe14ece (
plain)
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
|
#include <stdio.h>
#include <math.h>
#include <mossrose.h>
#include <portaudio.h>
#define PI 3.14159
#define SAMPLE_RATE 44100
#define N_CHANNELS 8
int main()
{
float sin1[SAMPLE_RATE];
const int f1 = 440;
float sin2[SAMPLE_RATE];
const int f2 = 512;
for (long i=0; i<SAMPLE_RATE; i++) {
float time = ((float)i)/SAMPLE_RATE;
sin1[i] = sin(2*PI*f1*time);
sin2[i] = sin(2*PI*f2*time);
}
mossrose_init(SAMPLE_RATE, N_CHANNELS);
Pa_Sleep(500);
printf("play 1\n");
mossrose_play(sin1, NULL, SAMPLE_RATE, -1);
printf("wait\n");
Pa_Sleep(1000);
printf("play 2\n");
mossrose_play(sin2, NULL, SAMPLE_RATE, -1);
printf("wait\n");
Pa_Sleep(500);
printf("play 3\n");
mossrose_play(NULL, sin1, SAMPLE_RATE, -1);
printf("wait\n");
Pa_Sleep(1000);
mossrose_terminate();
return 0;
}
|