summaryrefslogtreecommitdiffstats
path: root/test-sine.c
blob: ae9ac9e387f28c98b945d657d662f8c2785a45d2 (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
#include <assert.h>

#include "sydney.h"

#define ASSERT_SUCCESS(x) assert(x == SA_SUCCESS)

#define FREQ 440

int main(int argc, char *argv[]) {

    sa_device_t *dev;
    float data[4] = { 0.0, 1.0, 0.0, -1.0 };
    int i;

    ASSERT_SUCCESS(sa_device_create_pcm(&dev, argv[0], SA_MODE_WRONLY, SA_PCM_FORMAT_FLOAT32_NE, FREQ * 4, 1));
    ASSERT_SUCCESS(sa_device_change_device(dev, "/dev/dsp1"));
    ASSERT_SUCCESS(sa_device_open(dev));

    for (i = 0; i < 10; i++)
        ASSERT_SUCCESS(sa_device_write(dev, data, sizeof(data)));

    ASSERT_SUCCESS(sa_device_drain(dev));

    ASSERT_SUCCESS(sa_device_destroy(dev));
    
    return 0;
}