blob: b63727bed10afd312a878836b00aabf22ac45672 (
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
|
#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 sine_wave[8*SAMPLE_RATE];
const int frequency = 440;
for (long i=0; i<8*SAMPLE_RATE; i++) {
float time = ((float)i)/SAMPLE_RATE;
sine_wave[i] = sin(2*PI*frequency*time);
}
struct mossrose_sound_t sound = {
.left = sine_wave, .right = NULL, .mono = true, .len = 8*SAMPLE_RATE
};
int err = mossrose_init(SAMPLE_RATE, N_CHANNELS, true);
if (err != 0)
fprintf(stderr, "FAILED TO INITIALIZE MOSSROSE\n");
Pa_Sleep(500);
int chan = mossrose_play(&sound, -1, 1);
for (int i=0; i<8000; i++) {
float time = ((float)i)/1000;
mossrose_channel_set_pan(chan, cos(2*PI*time), 0);
Pa_Sleep(1);
}
mossrose_terminate();
return 0;
}
|