| 917 | } |
| 918 | |
| 919 | int get_band_power (double *ampl, double *freq, int data_len, double freq_start, double freq_end, |
| 920 | double *band_power) |
| 921 | { |
| 922 | if ((ampl == NULL) || (freq == NULL) || (freq_start > freq_end) || (band_power == NULL) || |
| 923 | (data_len < 2)) |
| 924 | { |
| 925 | data_logger->error ("Please check to make sure all arguments aren't empty, freq_start > " |
| 926 | "freq_end and data_len >=2"); |
| 927 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 928 | } |
| 929 | double res = 0.0; |
| 930 | int counter = 0; |
| 931 | double freq_res = freq[1] - freq[0]; |
| 932 | for (int i = 0; i < data_len - 1; i++) |
| 933 | { |
| 934 | if (freq[i] > freq_end) |
| 935 | { |
| 936 | break; |
| 937 | } |
| 938 | if (freq[i] >= freq_start) |
| 939 | { |
| 940 | res += 0.5 * freq_res * (ampl[i] + ampl[i + 1]); |
| 941 | counter++; |
| 942 | } |
| 943 | } |
| 944 | if (counter == 0) |
| 945 | { |
| 946 | data_logger->error ("No data between freq_end and freq_start."); |
| 947 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 948 | } |
| 949 | *band_power = res; |
| 950 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 951 | } |
| 952 | |
| 953 | int get_nearest_power_of_two (int value, int *output) |
| 954 | { |
no outgoing calls
no test coverage detected