rfft.h (1618B)
1 /** 2 * Copyright (c) 2022 Xiaomi Corporation (authors: Fangjun Kuang) 3 * 4 * See LICENSE for clarification regarding multiple authors 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 #ifndef KALDI_NATIVE_FBANK_CSRC_RFFT_H_ 20 #define KALDI_NATIVE_FBANK_CSRC_RFFT_H_ 21 22 #include <memory> 23 #include <cstdint> 24 25 namespace knf { 26 27 // n-point Real discrete Fourier transform 28 // where n is a power of 2. n >= 2 29 // 30 // R[k] = sum_j=0^n-1 in[j]*cos(2*pi*j*k/n), 0<=k<=n/2 31 // I[k] = sum_j=0^n-1 in[j]*sin(2*pi*j*k/n), 0<k<n/2 32 class Rfft { 33 public: 34 // @param n Number of fft bins. it should be a power of 2. 35 explicit Rfft(int32_t n); 36 ~Rfft(); 37 38 /** @param in_out A 1-D array of size n. 39 * On return: 40 * in_out[0] = R[0] 41 * in_out[1] = R[n/2] 42 * for 1 < k < n/2, 43 * in_out[2*k] = R[k] 44 * in_out[2*k+1] = I[k] 45 * 46 */ 47 void Compute(float *in_out); 48 void Compute(double *in_out); 49 50 private: 51 class RfftImpl; 52 53 std::unique_ptr<RfftImpl> impl_; 54 }; 55 56 } // namespace knf 57 58 #endif // KALDI_NATIVE_FBANK_CSRC_RFFT_H_