No output is produced. See #92
Unified · Split
| @@ -18,11 +18,13 @@ · 17 unmodified lines | |||
| 18 | #define BUFFER_LEN 2048 | 18 | #define BUFFER_LEN 2048 |
| 19 | 19 | ||
| 20 | static void simple_test (int converter, double ratio) ; | 20 | static void simple_test (int converter, double ratio) ; |
| 21 | static void src_simple_produces_output (int converter, int channels, double src_ratio) ; | ||
| 22 | static void src_simple_produces_output_test (int converter, double src_ratio) ; | ||
| 21 | 23 | ||
| 22 | int | 24 | int |
| 23 | main (void) | 25 | main (void) |
| 24 | { static double src_ratios [] = | 26 | { static double src_ratios [] = |
| 25 | { 1.0001, 0.099, 0.1, 0.33333333, 0.789, 1.9, 3.1, 9.9 | 27 | { 1.0001, 0.099, 0.1, 0.33333333, 0.789, 1.9, 3.1, 9.9, 256.0, 1.0 / 256.0 |
| 26 | } ; | 28 | } ; |
| 27 | 29 | ||
| 28 | int k ; | 30 | int k ; |
| @@ -31,21 +33,74 @@ main (void) · 2 unmodified lines | |||
| 31 | 33 | ||
| 32 | puts (" Zero Order Hold interpolator :") ; | 34 | puts (" Zero Order Hold interpolator :") ; |
| 33 | for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++) | 35 | for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++) |
| 34 | simple_test (SRC_ZERO_ORDER_HOLD, src_ratios [k]) ; | 36 | { simple_test (SRC_ZERO_ORDER_HOLD, src_ratios [k]) ; |
| 37 | src_simple_produces_output_test (SRC_ZERO_ORDER_HOLD, src_ratios [k]) ; | ||
| 38 | } | ||
| 35 | 39 | ||
| 36 | puts (" Linear interpolator :") ; | 40 | puts (" Linear interpolator :") ; |
| 37 | for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++) | 41 | for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++) |
| 38 | simple_test (SRC_LINEAR, src_ratios [k]) ; | 42 | { simple_test (SRC_LINEAR, src_ratios [k]) ; |
| 43 | src_simple_produces_output_test (SRC_LINEAR, src_ratios [k]) ; | ||
| 44 | } | ||
| 39 | 45 | ||
| 40 | puts (" Sinc interpolator :") ; | 46 | puts (" Sinc interpolator :") ; |
| 41 | for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++) | 47 | for (k = 0 ; k < ARRAY_LEN (src_ratios) ; k++) |
| 42 | simple_test (SRC_SINC_FASTEST, src_ratios [k]) ; | 48 | { simple_test (SRC_SINC_FASTEST, src_ratios [k]) ; |
| 49 | src_simple_produces_output_test (SRC_SINC_FASTEST, src_ratios [k]) ; | ||
| 50 | } | ||
| 43 | 51 | ||
| 44 | puts ("") ; | 52 | puts ("") ; |
| 45 | 53 | ||
| 46 | return 0 ; | 54 | return 0 ; |
| 47 | } /* main */ | 55 | } /* main */ |
| 48 | 56 | ||
| 57 | static void | ||
| 58 | src_simple_produces_output_test (int converter, double src_ratio) | ||
| 59 | { | ||
| 60 | for (int channels = 1; channels <= 9; channels++) | ||
| 61 | src_simple_produces_output(converter, channels, src_ratio); | ||
| 62 | } | ||
| 63 | |||
| 64 | static void | ||
| 65 | src_simple_produces_output (int converter, int channels, double src_ratio) | ||
| 66 | { | ||
| 67 | // Choose a suitable number of frames. | ||
| 68 | // At least 256 so a conversion ratio of 1/256 can produce any output | ||
| 69 | const long NUM_FRAMES = 1000; | ||
| 70 | int error; | ||
| 71 | |||
| 72 | printf ("\tproduces_output\t(SRC ratio = %6.4f, channels = %d) ... ", src_ratio, channels) ; | ||
| 73 | fflush (stdout) ; | ||
| 74 | |||
| 75 | float *input = calloc (NUM_FRAMES * channels, sizeof (float)); | ||
| 76 | float *output = calloc (NUM_FRAMES * channels, sizeof (float)); | ||
| 77 | |||
| 78 | SRC_DATA src_data; | ||
| 79 | memset (&src_data, 0, sizeof (src_data)) ; | ||
| 80 | src_data.data_in = input; | ||
| 81 | src_data.data_out = output; | ||
| 82 | src_data.input_frames = NUM_FRAMES; | ||
| 83 | src_data.output_frames = NUM_FRAMES; | ||
| 84 | src_data.src_ratio = src_ratio; | ||
| 85 | |||
| 86 | if ((error = src_simple (&src_data, converter, channels))) | ||
| 87 | { printf ("\n\nLine %d : %s\n\n", __LINE__, src_strerror (error)) ; | ||
| 88 | exit (1) ; | ||
| 89 | } ; | ||
| 90 | if (src_data.input_frames_used == 0) | ||
| 91 | { printf ("\n\nLine %d : No input frames used.\n\n", __LINE__) ; | ||
| 92 | exit (1) ; | ||
| 93 | } ; | ||
| 94 | if (src_data.output_frames_gen == 0) | ||
| 95 | { printf ("\n\nLine %d : No output frames generated.\n\n", __LINE__) ; | ||
| 96 | exit (1) ; | ||
| 97 | } ; | ||
| 98 | free(input); | ||
| 99 | free(output); | ||
| 100 | puts ("ok") ; | ||
| 101 | } | ||
| 102 | |||
| 103 | |||
| 49 | static void | 104 | static void |
| 50 | simple_test (int converter, double src_ratio) | 105 | simple_test (int converter, double src_ratio) |
| 51 | { static float input [BUFFER_LEN], output [BUFFER_LEN] ; | 106 | { static float input [BUFFER_LEN], output [BUFFER_LEN] ; |
| @@ -54,7 +109,7 @@ simple_test (int converter, double src_ratio) · 2 unmodified lines | |||
| 54 | 109 | ||
| 55 | int input_len, output_len, error, terminate ; | 110 | int input_len, output_len, error, terminate ; |
| 56 | 111 | ||
| 57 | printf ("\tsimple_test (SRC ratio = %6.4f) ........... ", src_ratio) ; | 112 | printf ("\tsimple_test\t(SRC ratio = %6.4f) ................. ", src_ratio) ; |
| 58 | fflush (stdout) ; | 113 | fflush (stdout) ; |
| 59 | 114 | ||
| 60 | /* Calculate maximun input and output lengths. */ | 115 | /* Calculate maximun input and output lengths. */ |