2016-03-01 17:40:38 +00:00
|
|
|
#include "sound.h"
|
2016-03-25 12:58:16 +00:00
|
|
|
#include "wave.h"
|
2016-03-01 17:40:38 +00:00
|
|
|
#include "samplerate.h"
|
|
|
|
#include "jitter.h"
|
|
|
|
#include "loss.h"
|
2016-04-23 16:50:11 +00:00
|
|
|
#include "emphasis.h"
|
2016-06-17 05:28:45 +00:00
|
|
|
#include "display_wave.h"
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2016-04-25 18:20:54 +00:00
|
|
|
#define MAX_SENDER 16
|
|
|
|
|
2016-10-03 12:46:25 +00:00
|
|
|
/* how to send a 'pilot' signal (trigger transmitter) */
|
|
|
|
enum pilot_signal {
|
|
|
|
PILOT_SIGNAL_NONE = 0,
|
|
|
|
PILOT_SIGNAL_TONE,
|
|
|
|
PILOT_SIGNAL_NOTONE,
|
|
|
|
PILOT_SIGNAL_POSITIVE,
|
|
|
|
PILOT_SIGNAL_NEGATIVE,
|
|
|
|
};
|
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* common structure of each transmitter */
|
|
|
|
typedef struct sender {
|
|
|
|
struct sender *next;
|
2016-04-25 18:20:54 +00:00
|
|
|
struct sender *slave; /* points to audio device slave member */
|
|
|
|
struct sender *master; /* points to audio device master source */
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
/* system info */
|
|
|
|
int kanal; /* channel number */
|
|
|
|
|
|
|
|
/* sound */
|
|
|
|
void *sound;
|
2016-04-25 18:20:54 +00:00
|
|
|
char sounddev[64]; /* sound device name */
|
2016-03-01 17:40:38 +00:00
|
|
|
int samplerate;
|
2016-04-25 18:20:54 +00:00
|
|
|
int cross_channels; /* swap right and left on IO */
|
2016-03-01 17:40:38 +00:00
|
|
|
samplerate_t srstate; /* sample rate conversion state */
|
2016-05-06 05:00:27 +00:00
|
|
|
double rx_gain; /* factor of level to apply on rx samples */
|
2016-04-23 16:50:11 +00:00
|
|
|
int pre_emphasis; /* use pre_emhasis, done by sender */
|
|
|
|
int de_emphasis; /* use de_emhasis, done by sender */
|
|
|
|
emphasis_t estate; /* pre and de emphasis */
|
2016-03-01 17:40:38 +00:00
|
|
|
|
|
|
|
/* loopback test */
|
|
|
|
int loopback; /* 0 = off, 1 = internal, 2 = external */
|
|
|
|
|
2016-03-25 12:58:16 +00:00
|
|
|
/* record and playback */
|
2016-11-27 05:47:06 +00:00
|
|
|
wave_rec_t wave_rx_rec; /* wave recording (from rx) */
|
|
|
|
wave_rec_t wave_tx_rec; /* wave recording (from tx) */
|
|
|
|
wave_play_t wave_rx_play; /* wave playback (as rx) */
|
2016-03-25 12:58:16 +00:00
|
|
|
|
2016-03-01 17:40:38 +00:00
|
|
|
/* audio buffer for audio to send to transmitter (also used as loopback buffer) */
|
|
|
|
jitter_t audio;
|
|
|
|
|
|
|
|
/* audio buffer for audio to send to caller (20ms = 160 samples @ 8000Hz) */
|
|
|
|
int16_t rxbuf[160];
|
|
|
|
int rxbuf_pos; /* current fill of buffer */
|
|
|
|
|
|
|
|
/* loss of carrier detection */
|
|
|
|
double loss_volume;
|
|
|
|
loss_t loss;
|
|
|
|
|
|
|
|
/* pilot tone */
|
2016-10-03 12:46:25 +00:00
|
|
|
enum pilot_signal pilot_signal; /* if pilot signal is used and how it is performed */
|
2016-03-01 17:40:38 +00:00
|
|
|
int pilot_on; /* 1 or 0 for on or off */
|
|
|
|
double pilotton_phaseshift; /* phase to shift every sample */
|
|
|
|
double pilotton_phase; /* current phase */
|
2016-06-17 05:28:45 +00:00
|
|
|
|
|
|
|
/* display wave */
|
|
|
|
dispwav_t dispwav; /* display wave form */
|
2016-03-01 17:40:38 +00:00
|
|
|
} sender_t;
|
|
|
|
|
|
|
|
/* list of all senders */
|
|
|
|
extern sender_t *sender_head;
|
2016-02-16 17:56:55 +00:00
|
|
|
extern int cant_recover;
|
2016-03-01 17:40:38 +00:00
|
|
|
|
2016-11-27 05:47:06 +00:00
|
|
|
int sender_create(sender_t *sender, int kanal, const char *sounddev, int samplerate, int cross_channels, double rx_gain, int pre_emphasis, int de_emphasis, const char *write_rx_wave, const char *write_tx_wave, const char *read_rx_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal);
|
2016-03-01 17:40:38 +00:00
|
|
|
void sender_destroy(sender_t *sender);
|
2016-06-17 05:28:45 +00:00
|
|
|
void process_sender_audio(sender_t *sender, int *quit, int latspl);
|
2016-03-01 17:40:38 +00:00
|
|
|
void sender_send(sender_t *sender, int16_t *samples, int count);
|
|
|
|
void sender_receive(sender_t *sender, int16_t *samples, int count);
|
2016-10-03 12:46:25 +00:00
|
|
|
void sender_pilot(sender_t *sender, int on);
|
2016-03-01 17:40:38 +00:00
|
|
|
|