本文整理汇总了C++中FFT::setSampleRate方法的典型用法代码示例。如果您正苦于以下问题:C++ FFT::setSampleRate方法的具体用法?C++ FFT::setSampleRate怎么用?C++ FFT::setSampleRate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FFT
的用法示例。
在下文中一共展示了FFT::setSampleRate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
//.........这里部分代码省略.........
glGenBuffers(1, &colorbuffer1);
glBindBuffer(GL_ARRAY_BUFFER, colorbuffer1);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_color_buffer_data1), g_color_buffer_data1, GL_STATIC_DRAW);
GLuint colorbuffer2;
glGenBuffers(1, &colorbuffer2);
glBindBuffer(GL_ARRAY_BUFFER, colorbuffer2);
glBufferData(GL_ARRAY_BUFFER, sizeof(g_color_buffer_data2), g_color_buffer_data2, GL_STATIC_DRAW);
audio_data data = get_audio_data(argv[1]);
int bpf = data.sampling_rate / fps;
int data_index = 0;
double current_time;
double last_time;
double total_time = data.size / data.sampling_rate / 4;
float z[bpf * 2];
for(int i = 0; i < bpf; i++) z[i * 2] = z[i * 2 + 1] = waveform_length / bpf * i - waveform_length / 2;
glBindBuffer(GL_ARRAY_BUFFER, vertexbuffer4);
glBufferData(GL_ARRAY_BUFFER, bpf * 8, z, GL_STATIC_DRAW);
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;
}