int main (int argc, char *argv []) { CONVERTER_TEST snr_test_data [] = { { SRC_ZERO_ORDER_HOLD, 7, BOOLEAN_FALSE, { { 1, { 0.01111111111 }, 3.0, 1, 36.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 37.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 37.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 38.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 14.0, 1.0 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 32.0, 1.0 }, { 1, { 0.3511111111 }, 1.33, 1, 10.0, 1.0 } } }, { SRC_LINEAR, 7, BOOLEAN_FALSE, { { 1, { 0.01111111111 }, 3.0, 1, 73.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 74.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 74.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 77.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 97.0, 0.94 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 60.0, 0.95 }, { 1, { 0.3511111111 }, 1.33, 1, 22.0, 0.99 } } }, { SRC_SINC_FASTEST, 8, BOOLEAN_TRUE, { { 1, { 0.01111111111 }, 3.0, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 100.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 97.0, 1.0 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 100.0, 0.5 }, { 2, { 0.011111, 0.45 }, 0.6, 1, 97.0, 0.5 }, { 1, { 0.3511111111 }, 1.33, 1, 97.0, 1.0 } } }, { SRC_SINC_MEDIUM_QUALITY, 8, BOOLEAN_TRUE, { { 1, { 0.01111111111 }, 3.0, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 100.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 97.0, 1.0 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 100.0, 0.5 }, { 2, { 0.011111, 0.45 }, 0.6, 1, 97.0, 0.5 }, { 1, { 0.43111111111 }, 1.33, 1, 97.0, 1.0 } } }, { SRC_SINC_BEST_QUALITY, 8, BOOLEAN_TRUE, { { 1, { 0.01111111111 }, 3.0, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 100.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 97.0, 1.0 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 100.0, 0.5 }, { 2, { 0.011111, 0.45 }, 0.6, 1, 97.0, 0.5 }, { 1, { 0.47111111111 }, 1.33, 1, 97.0, 1.0 } }, }, } ; /* snr_test_data */ double best_snr, snr, freq3dB, conversion_rate, worst_conv_rate ; int j, k, converter, verbose = 0 ; /* Force output of the Electric Fence banner message. */ force_efence_banner () ; if (argc == 2 && strcmp (argv [1], "--verbose") == 0) verbose = 1 ; puts ("") ; for (j = 0 ; j < ARRAY_LEN (snr_test_data) ; j++) { best_snr = 5000.0 ; worst_conv_rate = 1e200 ; converter = snr_test_data [j].converter ; printf (" Converter %d : %s\n", converter, src_get_name (converter)) ; printf (" %s\n", src_get_description (converter)) ; for (k = 0 ; k < snr_test_data [j].tests ; k++) { snr = snr_test (&(snr_test_data [j].test_data [k]), k, converter, verbose, &conversion_rate) ; if (best_snr > snr) best_snr = snr ; if (worst_conv_rate > conversion_rate) worst_conv_rate = conversion_rate ; } ; printf (" Worst case Signal-to-Noise Ratio : %.2f dB.\n", best_snr) ; printf (" Worst case conversion rate : %.0f samples/sec.\n", worst_conv_rate) ; if (snr_test_data [j].do_bandwidth_test == BOOLEAN_FALSE) { puts (" Bandwith test not performed on this converter.\n") ; continue ; } freq3dB = bandwidth_test (converter, verbose) ; printf (" Measured -3dB rolloff point : %5.2f %%.\n\n", freq3dB) ; } ; return 0 ; } /* main */
int main (int argc, char *argv []) { CONVERTER_TEST snr_test_data [] = { { SRC_ZERO_ORDER_HOLD, 8, BOOLEAN_FALSE, { { 1, { 0.01111111111 }, 3.0, 1, 28.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 36.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 36.0, 1.0 }, { 1, { 0.01111111111 }, 1.0, 1, 150.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 38.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 14.0, .96 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 12.0, .96 }, { 1, { 0.3511111111 }, 1.33, 1, 10.0, 1.0 } } }, { SRC_LINEAR, 8, BOOLEAN_FALSE, { { 1, { 0.01111111111 }, 3.0, 1, 73.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 73.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 73.0, 1.0 }, { 1, { 0.01111111111 }, 1.0, 1, 150.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 77.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 16.0, 0.96 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 26.0, 0.96 }, { 1, { 0.3511111111 }, 1.33, 1, 14.4, 0.99 } } }, { SRC_SINC_FASTEST, 9, BOOLEAN_TRUE, { { 1, { 0.01111111111 }, 3.0, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 99.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 100.0, 1.0 }, { 1, { 0.01111111111 }, 1.0, 1, 150.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 100.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 97.0, 1.0 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 100.0, 0.5 }, { 2, { 0.011111, 0.45 }, 0.6, 1, 97.0, 0.5 }, { 1, { 0.3511111111 }, 1.33, 1, 97.0, 1.0 } } }, { SRC_SINC_MEDIUM_QUALITY, 9, BOOLEAN_TRUE, { { 1, { 0.01111111111 }, 3.0, 1, 130.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 132.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 138.0, 1.0 }, { 1, { 0.01111111111 }, 1.0, 1, 155.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 134.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 127.0, 1.0 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 124.0, 0.5 }, { 2, { 0.011111, 0.45 }, 0.6, 1, 126.0, 0.5 }, { 1, { 0.43111111111 }, 1.33, 1, 121.0, 1.0 } } }, { SRC_SINC_BEST_QUALITY, 9, BOOLEAN_TRUE, { { 1, { 0.01111111111 }, 3.0, 1, 147.0, 1.0 }, { 1, { 0.01111111111 }, 0.6, 1, 147.0, 1.0 }, { 1, { 0.01111111111 }, 0.3, 1, 147.0, 1.0 }, { 1, { 0.01111111111 }, 1.0, 1, 155.0, 1.0 }, { 1, { 0.01111111111 }, 1.001, 1, 147.0, 1.0 }, { 2, { 0.011111, 0.324 }, 1.9999, 2, 147.0, 1.0 }, { 2, { 0.012345, 0.457 }, 0.456789, 1, 148.0, 0.5 }, { 2, { 0.011111, 0.45 }, 0.6, 1, 149.0, 0.5 }, { 1, { 0.43111111111 }, 1.33, 1, 145.0, 1.0 } } }, } ; /* snr_test_data */ double best_snr, snr, freq3dB ; int j, k, converter, verbose = 0 ; if (argc == 2 && strcmp (argv [1], "--verbose") == 0) verbose = 1 ; puts ("") ; for (j = 0 ; j < ARRAY_LEN (snr_test_data) ; j++) { best_snr = 5000.0 ; converter = snr_test_data [j].converter ; printf (" Converter %d : %s\n", converter, src_get_name (converter)) ; printf (" %s\n", src_get_description (converter)) ; for (k = 0 ; k < snr_test_data [j].tests ; k++) { snr = snr_test (&(snr_test_data [j].test_data [k]), k, converter, verbose) ; if (best_snr > snr) best_snr = snr ; } ; printf (" Worst case Signal-to-Noise Ratio : %.2f dB.\n", best_snr) ; if (snr_test_data [j].do_bandwidth_test == BOOLEAN_FALSE) { puts (" Bandwith test not performed on this converter.\n") ; continue ; } freq3dB = bandwidth_test (converter, verbose) ; printf (" Measured -3dB rolloff point : %5.2f %%.\n\n", freq3dB) ; } ; return 0 ; } /* main */