Ultrasonic Audio File Player
Dependencies: mbed
Fork of TAU_ZOOLOG_Chirp_Generator by
Diff: main_filter3.cpp
- Revision:
- 9:6d4136d9c074
- Parent:
- 8:4a9979fe0122
- Child:
- 12:e2b4a11ebe5a
--- a/main_filter3.cpp Tue Jul 11 14:08:31 2017 +0000 +++ b/main_filter3.cpp Sun Jul 16 12:39:53 2017 +0000 @@ -329,33 +329,35 @@ printf("\r\nWrong input - default is taken\r\n"); signal_low_threshold = SIGNAL_LOW_THRESHOD; } + + // not used // +// isSignalClipped = true; +// while (isSignalClipped) { +// printf("Enter amplitude scale parameter for predefined signal (default - %5.2f): ", SCALE_FOR_PREDEFINED_OUTPUT); +// memset(command, 0, sizeof(command)); +// gets(command); +// scale_for_predefined_output = atof(command); +// if (scale_for_predefined_output == float(0.0)) { +// printf("\r\nWrong input - default is taken\r\n"); +// scale_for_predefined_output = SCALE_FOR_PREDEFINED_OUTPUT; +// } +// isSignalClipped = false; +// for (k=0; k < AMOUNT_OF_SIGNIFICANT_SAMPLES; k++ ) { +// scaled_sounddata[k] = sounddata[k]* scale_for_predefined_output; +// if (scaled_sounddata[k] < (float)-1.0) { +// scaled_sounddata[k] = (float)-1.0; +// isSignalClipped = true; +// } +// if (scaled_sounddata[k] > (float)1.0) { +// scaled_sounddata[k] = (float)1.0; +// isSignalClipped = true; +// } +// } +// if (isSignalClipped) { +// printf("With amplitude scale %5.2f, signal will be clipped !!!. Select smaller scale.\r\n",scale_for_predefined_output); +// } +// } // end of while (isSignalClipped) - isSignalClipped = true; - while (isSignalClipped) { - printf("Enter amplitude scale parameter for predefined signal (default - %5.2f): ", SCALE_FOR_PREDEFINED_OUTPUT); - memset(command, 0, sizeof(command)); - gets(command); - scale_for_predefined_output = atof(command); - if (scale_for_predefined_output == float(0.0)) { - printf("\r\nWrong input - default is taken\r\n"); - scale_for_predefined_output = SCALE_FOR_PREDEFINED_OUTPUT; - } - isSignalClipped = false; - for (k=0; k < AMOUNT_OF_SIGNIFICANT_SAMPLES; k++ ) { - scaled_sounddata[k] = sounddata[k]* scale_for_predefined_output; - if (scaled_sounddata[k] < (float)-1.0) { - scaled_sounddata[k] = (float)-1.0; - isSignalClipped = true; - } - if (scaled_sounddata[k] > (float)1.0) { - scaled_sounddata[k] = (float)1.0; - isSignalClipped = true; - } - } - if (isSignalClipped) { - printf("With amplitude scale %5.2f, signal will be clipped !!!. Select smaller scale.\r\n",scale_for_predefined_output); - } - } // end of while (isSignalClipped) printf("Enter delay after signal in microseconds (default - %d): ", DELAY_AFTER_SIGNAL_TRANSMISSION); memset(command, 0, sizeof(command)); gets(command); @@ -364,38 +366,39 @@ printf("\r\nWrong input - default is taken\r\n"); delay_after_signal_transmission = DELAY_AFTER_SIGNAL_TRANSMISSION; } - printf("Enter number of cycles to detect threshold crossing (default - %d): ", NUM_OF_CYCLES_TO_DETECT_THRESHOLD_CROSSING); - memset(command, 0, sizeof(command)); - gets(command); - num_of_cycles_to_detect_threshold_crossing = atoi(command); - if (num_of_cycles_to_detect_threshold_crossing == 0) { - printf("\r\nWrong input - default is taken\r\n"); - num_of_cycles_to_detect_threshold_crossing = NUM_OF_CYCLES_TO_DETECT_THRESHOLD_CROSSING; - } - printf("Use high pass filter with predefined output: Y/N (default - %s): ", - USE_FILTER_WITH_PREDEFINED_OUTPUT ? "Y" : "N" ); - memset(command, 0, sizeof(command)); - gets(command); - if ((command[0] == 'Y') || (command[0] == 'y')) { - use_filter_with_predefined_output = true; - } else if ((command[0] == 'N') || (command[0] == 'n')) { - use_filter_with_predefined_output = false; - } else { - use_filter_with_predefined_output = USE_FILTER_WITH_PREDEFINED_OUTPUT; - } +// printf("Enter number of cycles to detect threshold crossing (default - %d): ", NUM_OF_CYCLES_TO_DETECT_THRESHOLD_CROSSING); +// memset(command, 0, sizeof(command)); +// gets(command); +// num_of_cycles_to_detect_threshold_crossing = atoi(command); +// if (num_of_cycles_to_detect_threshold_crossing == 0) { +// printf("\r\nWrong input - default is taken\r\n"); +// num_of_cycles_to_detect_threshold_crossing = NUM_OF_CYCLES_TO_DETECT_THRESHOLD_CROSSING; +// } + // not implemeted filter not activated // + //printf("Use high pass filter with predefined output: Y/N (default - %s): ", +// USE_FILTER_WITH_PREDEFINED_OUTPUT ? "Y" : "N" ); +// memset(command, 0, sizeof(command)); +// gets(command); +// if ((command[0] == 'Y') || (command[0] == 'y')) { +// use_filter_with_predefined_output = true; +// } else if ((command[0] == 'N') || (command[0] == 'n')) { +// use_filter_with_predefined_output = false; +// } else { +// use_filter_with_predefined_output = USE_FILTER_WITH_PREDEFINED_OUTPUT; +// } +// +// if (delay_after_signal_transmission == 0) { +// delay_after_signal_transmission = USE_FILTER_WITH_PREDEFINED_OUTPUT; +// } +// memset(command, 0, sizeof(command)); - if (delay_after_signal_transmission == 0) { - delay_after_signal_transmission = USE_FILTER_WITH_PREDEFINED_OUTPUT; - } - memset(command, 0, sizeof(command)); isInputNotValid = 0; - } else if (UseFilterMode == TEST_OUTPUT_MODE) { isInputNotValid = 0; - - } if (UseFilterMode == HIGH_PASS_FILTER_MODE) { - isInputNotValid = 0; - + } else if (UseFilterMode == NO_FILTER_MODE) { + isInputNotValid = 0; + } else if (UseFilterMode == HIGH_PASS_FILTER_MODE) { + isInputNotValid = 0; } else if (UseFilterMode == TRIGGERED_OUTPUT_MODE) { // define threshold @@ -444,7 +447,7 @@ gets(command); saturation_detection = (bool)atoi(command); printf("\r\nChosen - %d\r\n",saturation_detection); - + // no point asking quations if not enabled if (saturation_detection) { // set saturation threshold