Chirp Signal Generator

Dependencies:   mbed

Fork of TAU_ZOOLOG_Playback_Rev1_1 by Yossi_Students

Revision:
13:24d8512fc722
Parent:
12:e2b4a11ebe5a
--- a/main_filter3.cpp	Sun Aug 06 13:03:03 2017 +0000
+++ b/main_filter3.cpp	Sun Aug 06 13:07:52 2017 +0000
@@ -334,32 +334,32 @@
                     }
                         
                     // 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));