B-Netz: Work on pilot signal generation
The pilot signal to switch to channel 19 can be: * a tone * a tone that is turned off (notone) * positive amplitude * negative amplitude
This commit is contained in:
committed by
Andreas Eversberg
parent
e029a6a858
commit
b205cfcf03
@@ -35,7 +35,7 @@ static sender_t **sender_tailp = &sender_head;
|
||||
int cant_recover = 0;
|
||||
|
||||
/* Init transceiver instance and link to list of transceivers. */
|
||||
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_wave, const char *read_wave, int loopback, double loss_volume, int use_pilot_signal)
|
||||
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_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal)
|
||||
{
|
||||
sender_t *master;
|
||||
int rc = 0;
|
||||
@@ -49,7 +49,7 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
|
||||
sender->de_emphasis = de_emphasis;
|
||||
sender->loopback = loopback;
|
||||
sender->loss_volume = loss_volume;
|
||||
sender->use_pilot_signal = use_pilot_signal;
|
||||
sender->pilot_signal = pilot_signal;
|
||||
sender->pilotton_phaseshift = 1.0 / ((double)samplerate / 1000.0);
|
||||
|
||||
PDEBUG_CHAN(DSENDER, DEBUG_DEBUG, "Creating 'Sender' instance\n");
|
||||
@@ -79,12 +79,12 @@ int sender_create(sender_t *sender, int kanal, const char *sounddev, int sampler
|
||||
rc = -EBUSY;
|
||||
goto error;
|
||||
}
|
||||
if (master->use_pilot_signal >= 0) {
|
||||
if (master->pilot_signal != PILOT_SIGNAL_NONE) {
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot share sound device with channel %d, because second channel is used for pilot signal!\n", master->kanal);
|
||||
rc = -EBUSY;
|
||||
goto error;
|
||||
}
|
||||
if (use_pilot_signal >= 0) {
|
||||
if (pilot_signal != PILOT_SIGNAL_NONE) {
|
||||
PDEBUG(DSENDER, DEBUG_ERROR, "Cannot share sound device with channel %d, because we need a stereo channel for pilot signal!\n", master->kanal);
|
||||
rc = -EBUSY;
|
||||
goto error;
|
||||
@@ -277,8 +277,8 @@ cant_recover:
|
||||
if (slave->pre_emphasis)
|
||||
pre_emphasis(&slave->estate, slave_samples, count);
|
||||
}
|
||||
switch (sender->use_pilot_signal) {
|
||||
case 2:
|
||||
switch (sender->pilot_signal) {
|
||||
case PILOT_SIGNAL_TONE:
|
||||
/* tone if pilot signal is on */
|
||||
if (sender->pilot_on)
|
||||
gen_pilotton(sender, pilot, count);
|
||||
@@ -289,7 +289,18 @@ cant_recover:
|
||||
else
|
||||
rc = sound_write(sender->sound, pilot, samples, count);
|
||||
break;
|
||||
case 1:
|
||||
case PILOT_SIGNAL_NOTONE:
|
||||
/* tone if pilot signal is off */
|
||||
if (!sender->pilot_on)
|
||||
gen_pilotton(sender, pilot, count);
|
||||
else
|
||||
memset(pilot, 0, count << 1);
|
||||
if (!sender->cross_channels)
|
||||
rc = sound_write(sender->sound, samples, pilot, count);
|
||||
else
|
||||
rc = sound_write(sender->sound, pilot, samples, count);
|
||||
break;
|
||||
case PILOT_SIGNAL_POSITIVE:
|
||||
/* positive signal if pilot signal is on */
|
||||
if (sender->pilot_on)
|
||||
memset(pilot, 127, count << 1);
|
||||
@@ -300,7 +311,7 @@ cant_recover:
|
||||
else
|
||||
rc = sound_write(sender->sound, pilot, samples, count);
|
||||
break;
|
||||
case 0:
|
||||
case PILOT_SIGNAL_NEGATIVE:
|
||||
/* negative signal if pilot signal is on */
|
||||
if (sender->pilot_on)
|
||||
memset(pilot, 128, count << 1);
|
||||
@@ -393,3 +404,8 @@ cant_recover:
|
||||
}
|
||||
}
|
||||
|
||||
void sender_pilot(sender_t *sender, int on)
|
||||
{
|
||||
sender->pilot_on = on;
|
||||
}
|
||||
|
||||
|
@@ -8,6 +8,15 @@
|
||||
|
||||
#define MAX_SENDER 16
|
||||
|
||||
/* 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,
|
||||
};
|
||||
|
||||
/* common structure of each transmitter */
|
||||
typedef struct sender {
|
||||
struct sender *next;
|
||||
@@ -47,7 +56,7 @@ typedef struct sender {
|
||||
loss_t loss;
|
||||
|
||||
/* pilot tone */
|
||||
int use_pilot_signal; /* -1 if not used, 1 for positive, 0 for negative, 2 for tone */
|
||||
enum pilot_signal pilot_signal; /* if pilot signal is used and how it is performed */
|
||||
int pilot_on; /* 1 or 0 for on or off */
|
||||
double pilotton_phaseshift; /* phase to shift every sample */
|
||||
double pilotton_phase; /* current phase */
|
||||
@@ -60,9 +69,10 @@ typedef struct sender {
|
||||
extern sender_t *sender_head;
|
||||
extern int cant_recover;
|
||||
|
||||
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_wave, const char *read_wave, int loopback, double loss_volume, int use_pilot_signal);
|
||||
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_wave, const char *read_wave, int loopback, double loss_volume, enum pilot_signal pilot_signal);
|
||||
void sender_destroy(sender_t *sender);
|
||||
void process_sender_audio(sender_t *sender, int *quit, int latspl);
|
||||
void sender_send(sender_t *sender, int16_t *samples, int count);
|
||||
void sender_receive(sender_t *sender, int16_t *samples, int count);
|
||||
void sender_pilot(sender_t *sender, int on);
|
||||
|
||||
|
Reference in New Issue
Block a user