本文整理汇总了C++中FFT::calculateFFT方法的典型用法代码示例。如果您正苦于以下问题:C++ FFT::calculateFFT方法的具体用法?C++ FFT::calculateFFT怎么用?C++ FFT::calculateFFT使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FFT
的用法示例。
在下文中一共展示了FFT::calculateFFT方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
int res;
pthread_t a_thread;
void *thread_result;
res = pthread_create(&a_thread, NULL, play_wav_d, argv[1]);
if(res != 0) {
perror("Thread creation failed!");
exit(EXIT_FAILURE);
}
FFT fft;
fft.setDataSize(bpf);
fft.setSampleRate(data.sampling_rate);
float max_l = 0, max_r = 0;
glfwSetTime(0);
do {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glUseProgram(programID);
glEnableVertexAttribArray(0);
glEnableVertexAttribArray(1);
glEnableVertexAttribArray(2);
computeMatricesFromInputs();
glm::mat4 Projection = getProjectionMatrix();
glm::mat4 View = getViewMatrix();
glm::mat4 ModelMatrix = glm::mat4(1.0);
PV = Projection * View;
MVP = PV * ModelMatrix;
glUniformMatrix4fv(MatrixID, 1, GL_FALSE, &MVP[0][0]);
float *FFTdata = fft.calculateFFT((short *)data.data + data_index);
int spectrum_interval = fps / 2;
for(int i = 0; i < bpf; i++) {
for(int j = 1; j < spectrum_interval; j++)
FFTdata[i * spectrum_interval] += FFTdata[i * spectrum_interval + j];
FFTdata[i * spectrum_interval] /= spectrum_interval * 10;
FFTdata[i * spectrum_interval + spectrum_interval / 2] = 0;
}
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer4); //z
glVertexAttribPointer(
2, //attribute. No particular reason for 0, but must match the layout in the shader.
1, //size
GL_FLOAT, //type
GL_FALSE, //normalized?
0, //stride
(void *)0 //array buffer offset
);
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer5); //spectrum
glBufferData(GL_ARRAY_BUFFER, spectrum_interval * bpf * 4, FFTdata, GL_STATIC_DRAW);
glVertexAttribPointer(
0, //attribute. No particular reason for 0, but must match the layout in the shader.
1, //size
GL_FLOAT, //type
GL_FALSE, //normalized?
spectrum_interval * 2, //stride
(void *)0 //array buffer offset
);
glUniform1i(objectID, 6);
glDrawArrays(GL_LINES, 0, bpf * 2); //draw spectrum