OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2010 Google Inc. All rights reserved. | 2 * Copyright (C) 2010 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
110 vDSP_fft_zrip(m_FFTSetup, &m_frame, 1, m_log2FFTSize, FFT_FORWARD); | 110 vDSP_fft_zrip(m_FFTSetup, &m_frame, 1, m_log2FFTSize, FFT_FORWARD); |
111 } | 111 } |
112 | 112 |
113 void FFTFrame::doInverseFFT(float* data) | 113 void FFTFrame::doInverseFFT(float* data) |
114 { | 114 { |
115 vDSP_fft_zrip(m_FFTSetup, &m_frame, 1, m_log2FFTSize, FFT_INVERSE); | 115 vDSP_fft_zrip(m_FFTSetup, &m_frame, 1, m_log2FFTSize, FFT_INVERSE); |
116 vDSP_ztoc(&m_frame, 1, (DSPComplex*)data, 2, m_FFTSize / 2); | 116 vDSP_ztoc(&m_frame, 1, (DSPComplex*)data, 2, m_FFTSize / 2); |
117 | 117 |
118 // Do final scaling so that x == IFFT(FFT(x)) | 118 // Do final scaling so that x == IFFT(FFT(x)) |
119 float scale = 1.0f / m_FFTSize; | 119 float scale = 1.0f / m_FFTSize; |
120 vDSP_vsmul(data, 1, &scale, data, 1, m_FFTSize); | 120 VectorMath::vsmul(data, 1, &scale, data, 1, m_FFTSize); |
121 } | 121 } |
122 | 122 |
123 FFTSetup FFTFrame::fftSetupForSize(unsigned fftSize) | 123 FFTSetup FFTFrame::fftSetupForSize(unsigned fftSize) |
124 { | 124 { |
125 if (!fftSetups) { | 125 if (!fftSetups) { |
126 fftSetups = (FFTSetup*)malloc(sizeof(FFTSetup) * kMaxFFTPow2Size); | 126 fftSetups = (FFTSetup*)malloc(sizeof(FFTSetup) * kMaxFFTPow2Size); |
127 memset(fftSetups, 0, sizeof(FFTSetup) * kMaxFFTPow2Size); | 127 memset(fftSetups, 0, sizeof(FFTSetup) * kMaxFFTPow2Size); |
128 } | 128 } |
129 | 129 |
130 int pow2size = static_cast<int>(log2(fftSize)); | 130 int pow2size = static_cast<int>(log2(fftSize)); |
(...skipping 30 matching lines...) Expand all Loading... |
161 float* FFTFrame::imagData() const | 161 float* FFTFrame::imagData() const |
162 { | 162 { |
163 return m_frame.imagp; | 163 return m_frame.imagp; |
164 } | 164 } |
165 | 165 |
166 } // namespace blink | 166 } // namespace blink |
167 | 167 |
168 #endif // #if OS(MACOSX) | 168 #endif // #if OS(MACOSX) |
169 | 169 |
170 #endif // ENABLE(WEB_AUDIO) | 170 #endif // ENABLE(WEB_AUDIO) |
OLD | NEW |