37 using namespace Nsound;
43 sample_rate_(static_cast<
uint32>(sample_rate)),
59 Buffer f_domain = v[0].getMagnitude();
87 for(
int32 n = 0; n < input_length; n += (N - n_overlap))
100 sub_signal *= fft_window;
107 (*chunk.real_) = sub_signal;
112 for(
int32 i = 0; i < N - chunk_size; ++i)
114 (*chunk.real_) << 0.0;
118 (*chunk.imag_) = gen.
silence(N);
120 fft(*chunk.real_, *chunk.imag_, N);
122 vec.push_back(chunk);
133 const int32 n_minus_1 = N - 1;
134 const int32 n_devide_2 = N / 2;
136 std::log10(static_cast<float64>(N)) / std::log10(2.0) + 0.5);
138 int32 j = n_devide_2;
141 for(
int32 i = 1; i <= N - 2 ; ++i)
155 int32 k = n_devide_2;
166 for(
int32 l = 1; l <= m; ++l)
168 int32 le =
static_cast<int32>(std::pow(2.0, l) + 0.5);
175 float64 sr = std::cos(pi / static_cast<float64>(le2));
176 float64 si = -1.0 * std::sin(pi / static_cast<float64>(le2));
179 for(j = 1; j <= le2; ++j)
181 int32 j_minus_1 = j - 1;
184 for(
int32 i = j_minus_1; i <= n_minus_1; i += le)
189 float64 temp_real = ur * real[ip] - ui * img[ip];
190 float64 temp_img = ui * real[ip] + ur * img[ip];
192 real[ip] = real[i] - temp_real;
193 img[ip] = img[i] - temp_img;
195 real[i] += temp_real;
199 ur = temp * sr - ui * si;
200 ui = temp * si + ui *
sr;
211 FFTChunkVector::const_iterator itor = vec.
begin();
212 FFTChunkVector::const_iterator end = vec.end();
224 *chunk.
imag_ *= -1.0;
238 output << *chunk.
real_;
254 *chunk.real_ << frequency_domain;
261 *chunk.real_ << frequency_domain.
getReverse();
263 *chunk.imag_ = 0.0 * *chunk.real_;
267 vec.push_back(chunk);
276 raw =
static_cast<int32>(::fabs(static_cast<float64>(raw - 1)));
Buffer subbuffer(uint32 start_index, uint32 n_samples=0) const
Slice the Buffer.
Buffer getSpeedUp(float64 step_size) const
Resamples a copy of this Buffer by the step_size, no interpolation.
Results of performing an FFT are stored in this class.
void toCartesian()
convertes the magnitude & phase to cartesian form: real & imaginary
Buffer drawWindow(const float64 &duration, WindowType type) const
Draws a window of the specified type.
uint32 getLength() const
Returns the number of samples in the Buffer.
Buffer silence(const float64 &duration) const
This method generates silence.
iterator begin()
Retruns the itreator at the start of the Buffer.
A Buffer for storing audio samples.
Buffer getReverse() const
Reverses the samples in a copy of this Buffer.
std::vector< FFTChunk > FFTChunkVector
A class the provides draw utilities and a wavetable oscillator.