forked from ec429/3psk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
audio.h
59 lines (48 loc) · 1.19 KB
/
audio.h
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
#pragma once
/*
3psk - 3-pole Phase Shift Keying
Copyright (c) Edward Cree, 2012
Licensed under the GNU GPL v3+
audio: AUDio Input/Output subsystem
*/
#include <stdint.h>
#include <stdbool.h>
#include <SDL/SDL.h>
#include <SDL/SDL_audioin.h>
#include <unistd.h>
#define SAMPLE_RATE 22050
#ifdef WINDOWS
#include <windef.h>
#include <winbase.h>
#define AUDIOBUFLEN 4096
#else
#define AUDIOBUFLEN 1024
#endif
#define SLEEP SDL_Delay(sleeptime)
#include "bits.h"
#ifdef WAVLIB
#include "wavlib/wavlib.h"
#endif
typedef struct
{
unsigned int audiobuflen;
unsigned int rp, wp;
int16_t *buf;
unsigned int srate;
bool underrun;
FILE *wav;
#ifdef WAVLIB
wavhdr wavhdr;
#endif
}
audiobuf;
unsigned int sample_rate, sleeptime;
int init_audiorx(audiobuf *a, unsigned int audiobuflen, unsigned int sdlbuflen, FILE *wav);
void rxaudio(void *udata, Uint8 *stream, int len);
void stop_audiorx(audiobuf *a);
int rxsample(audiobuf *a, int16_t *samp); // returns 0 if we got a sample
int init_audiotx(audiobuf *a, unsigned int audiobuflen, unsigned int sdlbuflen);
void txaudio(void *udata, Uint8 *stream, int len);
void stop_audiotx(audiobuf *a);
void txsample(audiobuf *a, int16_t samp);
bool cantx(audiobuf *a);