11// ===========================================================================
22// ===========================================================================
3- //
3+ //
44// File: Main.c
55//
66// Main implementation file for the ASRC demonstration program
@@ -77,7 +77,7 @@ char* pzOutFileName[ASRC_N_IO_CHANNELS]; // Output data file name
7777
7878unsigned int uiInFs ; // Input sampling rate
7979unsigned int uiOutFs ; // Output sampling rate
80- float fFsRatioDeviation ; // Fs ratio deviation
80+ double fFsRatioDeviation ; // Fs ratio deviation
8181
8282unsigned int uiNTotalInSamples ; // Total number of input sample pairs to process
8383unsigned int uiNTotalOutSamples ; // Total number of output sample pairs produced
@@ -94,7 +94,7 @@ ASRCState_t sASRCState[ASRC_N_IO_CHANNELS];
9494int iASRCStack [ASRC_N_IO_CHANNELS ][ASRC_STACK_LENGTH_MULT * N_IN_SAMPLES_MAX ];
9595ASRCCtrl_t sASRCCtrl [ASRC_N_IO_CHANNELS ];
9696int iASRCADFIRCoefs [ASRC_ADFIR_COEFS_LENGTH ];
97-
97+
9898
9999// Data I/O
100100// --------
@@ -133,13 +133,13 @@ void main(int argc, char *argv[])
133133 int iEndOfFile ;
134134 unsigned int ui , uj ;
135135
136- // Display application information
136+ // Display application information
137137 fprintf (stdout , "\n%s \nVersion: %s\n%s\n\n" ,
138138 APPLICATION , VERSION , COPYRIGHT );
139-
139+
140140 // Initialize default values
141- pzInFileName [0 ] = INPUT_FILE_CHANNEL_0_DEFAULT ; // Input data for channel 0
142- pzInFileName [1 ] = INPUT_FILE_CHANNEL_1_DEFAULT ; // Input data for channel 1
141+ pzInFileName [0 ] = INPUT_FILE_CHANNEL_0_DEFAULT ; // Input data for channel 0
142+ pzInFileName [1 ] = INPUT_FILE_CHANNEL_1_DEFAULT ; // Input data for channel 1
143143 pzOutFileName [0 ] = OUTPUT_FILE_CHANNEL_0_DEFAULT ; // Output data for channel 0
144144 pzOutFileName [1 ] = OUTPUT_FILE_CHANNEL_0_DEFAULT ; // Output data for channel 1
145145
@@ -155,7 +155,7 @@ void main(int argc, char *argv[])
155155 uiASRCRandSeed [0 ] = ASRC_RAND_SEED_CHANNEL_0_DEFAULT ; // Random seed for channel 0
156156 uiASRCRandSeed [1 ] = ASRC_RAND_SEED_CHANNEL_1_DEFAULT ; // Random seed for channel 1
157157
158- // Parse command line arguments
158+ // Parse command line arguments
159159 for (ui = 1 ; ui < (unsigned int )argc ; ui ++ )
160160 {
161161 if (* (argv [ui ]) == '-' )
@@ -187,15 +187,15 @@ void main(int argc, char *argv[])
187187
188188 printf ("Total number of input samples: %i\n" , uiNTotalInSamples );
189189 printf ("Number of input samples to process in one call: %i\n\n" , uiNInSamples );
190-
190+
191191
192192 // Clear data buffers
193193 for (ui = 0 ; ui < ASRC_N_IO_CHANNELS * N_TOTAL_IN_SAMPLES_MAX ; ui ++ )
194194 iIn [ui ] = 0 ;
195195 for (ui = 0 ; ui < ASRC_N_IO_CHANNELS * N_TOTAL_IN_SAMPLES_MAX * ASRC_N_IN_OUT_RATIO_MAX ; ui ++ )
196196 iOut [ui ] = 0 ;
197197
198- // Open i/o files
198+ // Open i/o files
199199 for (ui = 0 ; ui < ASRC_N_IO_CHANNELS ; ui ++ )
200200 {
201201 if ((InFileDat [ui ] = fopen (pzInFileName [ui ], "rt" )) == NULL )
@@ -209,7 +209,7 @@ void main(int argc, char *argv[])
209209 HandleError (pzError , FATAL );
210210 }
211211 }
212-
212+
213213
214214 // Process init
215215 // ------------
@@ -280,7 +280,7 @@ void main(int argc, char *argv[])
280280
281281 // Process data
282282 // ------------
283- // Initialize remaing number of samples to total number of input samples,
283+ // Initialize remaing number of samples to total number of input samples,
284284 // total number of output samples to 0 and setup input / output data pointers to base of buffers
285285 iNRemainingSamples = (int )uiNTotalInSamples ;
286286 uiNTotalOutSamples = 0 ;
@@ -322,7 +322,7 @@ void main(int argc, char *argv[])
322322 // ==================================
323323 for (ui = 0 ; ui < ASRC_N_IO_CHANNELS ; ui ++ )
324324 // Note: this is block based similar to SSRC, output will be on stack
325- // and there will be sASRCCtrl[0].uiNSyncSamples samples per channel produced
325+ // and there will be sASRCCtrl[0].uiNSyncSamples samples per channel produced
326326 if (ASRC_proc_F1_F2 (& sASRCCtrl [ui ]) != ASRC_NO_ERROR )
327327 {
328328 sprintf (pzError , "Error at ASRC F1 F2 process" );
@@ -377,13 +377,13 @@ void main(int argc, char *argv[])
377377 // We are back to block based processing. This is where the number of ASRC output samples is required again
378378 // (would not be used if sample by sample based (on output samples))
379379 for (ui = 0 ; ui < ASRC_N_IO_CHANNELS ; ui ++ )
380- // Note: this is block based similar to SSRC
380+ // Note: this is block based similar to SSRC
381381 if (ASRC_proc_dither (& sASRCCtrl [ui ]) != ASRC_NO_ERROR )
382382 {
383383 sprintf (pzError , "Error at ASRC F1 F2 process" );
384384 HandleError (pzError , FATAL );
385385 }
386-
386+
387387
388388 // Write output data to files
389389 // --------------------------
@@ -393,8 +393,8 @@ void main(int argc, char *argv[])
393393 {
394394 sprintf (pzError , "Error while writing to output file, %s" , pzOutFileName [ui ]);
395395 HandleError (pzError , FATAL );
396- }
397-
396+ }
397+
398398
399399 // Update input and outut data pointers for next round
400400 piIn += (sASRCCtrl [0 ].uiNInSamples * ASRC_N_IO_CHANNELS );
@@ -404,21 +404,21 @@ void main(int argc, char *argv[])
404404 // Update total output sample counter
405405 uiNTotalOutSamples += sASRCCtrl [0 ].uiNASRCOutSamples ;
406406 }
407-
408407
409- // Report MIPS
408+
409+ // Report MIPS
410410 for (ui = 0 ; ui < ASRC_N_IO_CHANNELS ; ui ++ )
411411 {
412412 printf ("MIPS total load channel %i: %f\n" , ui , (sASRCCtrl [ui ].fCycleCountF1F2 + sASRCCtrl [ui ].fCycleCountF3AdaptiveCoefs + sASRCCtrl [ui ].fCycleCountF3 + sASRCCtrl [ui ].fCycleCountDither ) / (float )(sASRCCtrl [ui ].uiNInSamples ) * (float )uiFsTable [sASRCCtrl [ui ].eInFs ]/ 1000000.0 );
413413 printf ("MIPS F1+F2 load channel %i: %f\n" , ui , sASRCCtrl [ui ].fCycleCountF1F2 / (float )(sASRCCtrl [ui ].uiNInSamples ) * (float )uiFsTable [sASRCCtrl [ui ].eInFs ]/ 1000000.0 );
414414 printf ("MIPS F3 Adaptive Coefs computation load channel %i: %f\n" , ui , sASRCCtrl [ui ].fCycleCountF3AdaptiveCoefs / (float )(sASRCCtrl [ui ].uiNInSamples ) * (float )uiFsTable [sASRCCtrl [ui ].eInFs ]/ 1000000.0 );
415415 printf ("MIPS F3 load channel %i: %f\n" , ui , sASRCCtrl [ui ].fCycleCountF3 / (float )(sASRCCtrl [ui ].uiNInSamples ) * (float )uiFsTable [sASRCCtrl [ui ].eInFs ]/ 1000000.0 );
416416 printf ("MIPS Dither load channel %i: %f\n\n" , ui , sASRCCtrl [ui ].fCycleCountDither / (float )(sASRCCtrl [ui ].uiNInSamples ) * (float )uiFsTable [sASRCCtrl [ui ].eInFs ]/ 1000000.0 );
417-
417+
418418 }
419419 // Report number of output samples produced
420420 printf ("Total number of output samples produced: %i\n\n\n" , uiNTotalOutSamples );
421-
421+
422422
423423 // Close i/o files
424424 for (ui = 0 ; ui < ASRC_N_IO_CHANNELS ; ui ++ )
@@ -435,11 +435,11 @@ void main(int argc, char *argv[])
435435 }
436436 }
437437
438-
438+
439439
440440 fprintf (stdout , "Application run finished, press any key to exit\n\n" );
441441 getchar ();
442-
442+
443443 exit (0 );
444444}
445445
@@ -461,15 +461,15 @@ void ParseCmdLine(char *input)
461461
462462 case 'e' :
463463 case 'E' :
464- fFsRatioDeviation = (float )(atof (input + 1 ));
464+ fFsRatioDeviation = (double )(atof (input + 1 ));
465465 break ;
466-
466+
467467 case 'h' :
468468 case 'H' :
469469 ShowUsage ();
470470 exit (0 );
471471 break ;
472-
472+
473473 case 'i' :
474474 case 'I' :
475475 pzInFileName [0 ] = input + 1 ;
@@ -553,7 +553,7 @@ void ShowHelp()
553553 fprintf (stdout ,"Invalid argument. Application will terminate now. Use -h to get usage.\n" );
554554 fprintf (stdout , "Press any key to exit\n\n" );
555555 getchar ();
556-
556+
557557 exit (0 );
558558}
559559
@@ -577,7 +577,7 @@ void ShowUsage()
577577 " -r Random seed for channel 0 for dither generation (default: 1)\n\n"
578578 " -s Random seed for channel 1 for dither generation (default: 1458976)\n\n"
579579 );
580-
580+
581581 exit (0 );
582582}
583583
@@ -603,5 +603,3 @@ void HandleError(char *pzErrorMessage, short sErrorType)
603603 getchar ();
604604 return ;
605605}
606-
607-
0 commit comments