data_len here is an original size, not len of input_re input_im
| 832 | |
| 833 | // data_len here is an original size, not len of input_re input_im |
| 834 | int perform_ifft (double *input_re, double *input_im, int data_len, double *restored_data) |
| 835 | { |
| 836 | if ((!restored_data) || (!input_re) || (!input_im) || (data_len <= 0) || (data_len % 2 == 1)) |
| 837 | { |
| 838 | data_logger->error ( |
| 839 | "Please check to make sure all arguments aren't empty and data_len is even."); |
| 840 | return (int)BrainFlowExitCodes::INVALID_ARGUMENTS_ERROR; |
| 841 | } |
| 842 | double *temp = new double[data_len]; |
| 843 | kiss_fft_cpx *cin = new kiss_fft_cpx[data_len]; |
| 844 | for (int i = 0; i < data_len / 2 + 1; i++) |
| 845 | { |
| 846 | cin[i].r = input_re[i]; |
| 847 | cin[i].i = input_im[i]; |
| 848 | } |
| 849 | kiss_fftr_cfg cfg = NULL; |
| 850 | try |
| 851 | { |
| 852 | cfg = kiss_fftr_alloc (data_len, 1, 0, 0); |
| 853 | kiss_fftri (cfg, cin, temp); |
| 854 | for (int i = 0; i < data_len; i++) |
| 855 | { |
| 856 | restored_data[i] = temp[i] / data_len; |
| 857 | } |
| 858 | delete[] cin; |
| 859 | cin = NULL; |
| 860 | delete[] temp; |
| 861 | temp = NULL; |
| 862 | kiss_fftr_free (cfg); |
| 863 | } |
| 864 | catch (...) |
| 865 | { |
| 866 | if (temp) |
| 867 | { |
| 868 | delete[] temp; |
| 869 | } |
| 870 | if (cin) |
| 871 | { |
| 872 | delete[] cin; |
| 873 | } |
| 874 | if (cfg) |
| 875 | { |
| 876 | kiss_fftr_free (cfg); |
| 877 | } |
| 878 | data_logger->error ("Error with doing inverse FFT."); |
| 879 | return (int)BrainFlowExitCodes::GENERAL_ERROR; |
| 880 | } |
| 881 | return (int)BrainFlowExitCodes::STATUS_OK; |
| 882 | } |
| 883 | |
| 884 | int get_psd (double *data, int data_len, int sampling_rate, int window_function, |
| 885 | double *output_ampl, double *output_freq) |
no outgoing calls
no test coverage detected