Exemplo n.º 1
0
Arquivo: main.c Projeto: Olical/gray
int main()
{
	char input[] = "Hello, World!";
	int length = strlen(input);
	char output[length];
	char reverse[length];
	int i;

	output[length] = '\0';
	reverse[length] = '\0';

	printf("Input is: \"%s\".\n", input);
	printf("Input contains %i bytes.\n", length);

	for (i = 0; i < length; i++) {
		output[i] = gray_encode(input[i]);
	}

	printf("Output is: \"%s\".\n", output);
	printf("Now back the other way!\n");

	for (i = 0; i < length; i++) {
		reverse[i] = gray_decode(output[i]);
	}

	printf("Reversed output is: \"%s\".\n", reverse);


	char c;

	printf("\nSTDIN: ");
	while ((c = fgetc(stdin)) != EOF) {
		printf("%c", c);
	}

	return 0;
}
Exemplo n.º 2
0
    q->modulate_using_map = 1;

    // initialize soft-demodulation look-up table
    if (q->m >= 3)
        MODEM(_demodsoft_gentab)(q, 2);

    return q;
}

// modulate PSK
void MODEM(_modulate_psk)(MODEM()      _q,
                          unsigned int _sym_in,
                          TC *         _y)
{
    // 'encode' input symbol (actually gray decoding)
    _sym_in = gray_decode(_sym_in);

    // compute output sample
    *_y = liquid_cexpjf(_sym_in * 2 * _q->data.psk.alpha );
}

// demodulate PSK
void MODEM(_demodulate_psk)(MODEM()        _q,
                            TC             _x,
                            unsigned int * _sym_out)
{
    // compute angle and subtract phase offset, ensuring phase is in [-pi,pi)
    T theta = cargf(_x);
    theta -= _q->data.psk.d_phi;
    if (theta < -M_PI)
        theta += 2*M_PI;