Example #1
0
int main(int argc, char *argv[]) {
    SystemInit();
    gpio_init();
    machdep_profile_init ();
    adc_open(4*DAC_BUF_SZ);
    dac_open(4*DAC_BUF_SZ);

    printf("Starting power_ut\n");

    c2speedtest(CODEC2_MODE_1600, "stm_in.raw");

    printf("Finished\n");

    return 0;
}
int main(int argc, char *argv[]) {
    struct freedv *f;
    short          inbuf[FREEDV_NSAMPLES], outbuf[FREEDV_NSAMPLES];
    FILE          *fin, *fout;
    int            frame;
    PROFILE_VAR(freedv_start);

    machdep_profile_init();

    f = freedv_open(FREEDV_MODE_1600);

    // Transmit ---------------------------------------------------------------------

    fin = fopen("stm_in.raw", "rb");
    if (fin == NULL) {
        printf("Error opening input file\n");
        exit(1);
    }

    fout = fopen("mod.raw", "wb");
    if (fout == NULL) {
        printf("Error opening output file\n");
        exit(1);
    }

    frame = 0;

    while (fread(inbuf, sizeof(short), FREEDV_NSAMPLES, fin) == FREEDV_NSAMPLES) {
        PROFILE_SAMPLE(freedv_start);
        freedv_tx(f, outbuf, inbuf);
        PROFILE_SAMPLE_AND_LOG2(freedv_start, "  freedv_tx");     
       
        fwrite(outbuf, sizeof(short), FREEDV_NSAMPLES, fout);
        printf("frame: %d\n", ++frame);
        machdep_profile_print_logged_samples();
   }

    fclose(fin);
    fclose(fout);

    return 0;
}
Example #3
0
int main(int argc, char *argv[]) {
    gpio_init();
    machdep_profile_init ();

    printf("Starting c2demo\n");

    /* File I/O test for profiling or (with #define DUMP)
       dumping states for optimisation and tiuning */

    c2demo(CODEC2_MODE_1600, "stm_in.raw", "stm_out.raw");

    printf("Starting c2 speed test\n");

    /* Another test of execution speed. Look at PD13 with a
       oscilliscope.  On time is enc, off is dec */

    c2speedtest(CODEC2_MODE_1600, "stm_in.raw");

    printf("Finished\n");

    return 0;
}
int main(int argc, char *argv[]) {
    struct freedv *f;
    short          adc16k[FDMDV_OS_TAPS_16K+FREEDV_NSAMPLES_16K];
    short          dac16k[FREEDV_NSAMPLES_16K];
    short          adc8k[FREEDV_NSAMPLES];
    short          dac8k[FDMDV_OS_TAPS_8K+FREEDV_NSAMPLES];
    FILE          *fin, *fout, *ftotal;
    int            frame, nin_16k, nin, i, nout = 0;
    struct FDMDV_STATS  stats;
    PROFILE_VAR(fdmdv_16_to_8_start, freedv_rx_start, fdmdv_8_to_16_start);

    machdep_profile_init();

    f = freedv_open(FREEDV_MODE_1600);

    // Receive ---------------------------------------------------------------------

    frame = 0;

    fin = fopen("mod_16k.raw", "rb");
    if (fin == NULL) {
        printf("Error opening input file\n");
        exit(1);
    }

    fout = fopen("speechout_16k.raw", "wb");
    if (fout == NULL) {
        printf("Error opening output file\n");
        exit(1);
    }

    ftotal = fopen("total.txt", "wt");
    assert(ftotal != NULL);

    /* clear filter memories */

    for(i=0; i<FDMDV_OS_TAPS_16K; i++)
	adc16k[i] = 0.0;
    for(i=0; i<FDMDV_OS_TAPS_8K; i++)
	dac8k[i] = 0.0;
    
    nin = freedv_nin(f);
    nin_16k = 2*nin;
    nout = nin;
    while (fread(&adc16k[FDMDV_OS_TAPS_16K], sizeof(short), nin_16k, fin) == nin_16k) {

        PROFILE_SAMPLE(fdmdv_16_to_8_start);

        fdmdv_16_to_8_short(adc8k, &adc16k[FDMDV_OS_TAPS_16K], nin);

        PROFILE_SAMPLE_AND_LOG(freedv_rx_start, fdmdv_16_to_8_start, "  fdmdv_16_to_8");

        nout = freedv_rx(f, &dac8k[FDMDV_OS_TAPS_8K], adc8k);
        nin = freedv_nin(f); nin_16k = 2*nin;
        fdmdv_get_demod_stats(f->fdmdv, &stats);

        PROFILE_SAMPLE_AND_LOG(fdmdv_8_to_16_start, freedv_rx_start, "  freedv_rx");     

        fdmdv_8_to_16_short(dac16k, &dac8k[FDMDV_OS_TAPS_8K], nout);              

        PROFILE_SAMPLE_AND_LOG2(fdmdv_8_to_16_start, "  fdmdv_8_to_16");

        fprintf(ftotal, "%d\n", machdep_profile_sample() - fdmdv_16_to_8_start);
        machdep_profile_print_logged_samples();

        fwrite(dac16k, sizeof(short), 2*nout, fout);
        fdmdv_get_demod_stats(f->fdmdv, &stats);
        printf("frame: %d nin_16k: %d sync: %d SNR: %3.2f \n", 
               ++frame, nin_16k, stats.sync, (double)stats.snr_est);
    }

    fclose(fin);
    fclose(fout);
    fclose(ftotal);

    return 0;
}