void test_wave_file_utils() { WaveFile wave_file; // read_wave_file("/Users/quangpham/Desktop/test.wav", wave_file); // write_wave_file("/Users/quangpham/Desktop/result.wav", wave_file); read_wave_file("/Users/quangpham/Desktop/vietnamese-synthesis-system/vss/searcher/recorded_database/wave/PTP50008_000.wav", 117643, 124672, wave_file); write_wave_file("/Users/quangpham/Desktop/result.wav", wave_file); cout << "=> " << wave_file.get_all_data().size() << endl; cout << wave_file.chunk_id << endl; cout << wave_file.chunk_size << endl; cout << wave_file.format << endl; cout << wave_file.subchunk1_id << endl; cout << wave_file.subchunk1_size << endl; cout << wave_file.compression_code << endl; cout << wave_file.number_channels << endl; cout << wave_file.sample_rate << endl; cout << wave_file.byte_rate << endl; cout << wave_file.block_align << endl; cout << wave_file.bits_per_sample << endl; cout << wave_file.subchunk2_id << endl; cout << wave_file.subchunk2_size << endl; }
/*! * @brief プログラムのエントリポイント * * 使い方<br> * $ ./main [wavefile-name] N * @param [in] argc コマンドライン引数の数 * @param [in] argv コマンドライン引数 * @return 終了コード */ int main(int argc, char *argv[]) { unsigned int N; unsigned int k; double frq_rate; double *restrict f_real; double *restrict f_imag; WAVE_DATA *restrict wd; POINT *restrict points; RANGE range = {{0.0, 0.0}, {0.0, 0.0}}; if (argc != 3) { fprintf(stderr, "bad argument!\n"); return EXIT_FAILURE; } wd = read_wave_file(argv[1]); N = str2int(argv[2]); print_wave_header(wd); f_real = CALLOC(double, N); f_imag = CALLOC(double, N); points = CALLOC(POINT, N); if (f_real == NULL || f_imag == NULL || points == NULL) { fputs("メモリ確保エラーです\n", stderr); return EXIT_FAILURE; } auto_dft(f_real, f_imag, wd->s_data1, NULL, N); frq_rate = (double)wd->samples_per_sec / N; for (k = 0; k < N; k++) { points[k].x = frq_rate * k; points[k].y = sqrt(SQ(f_real[k]) + SQ(f_imag[k])); if (range.max.y < points[k].y) range.max.y = points[k].y; } range.max.x = (double)wd->samples_per_sec / 2; range.max.y = (range.max.y == 0.0 ? 1.0 : range.max.y * 1.2); // print_result(points, N); if (show_gplot(points, N, range) == -1) { fputs("gnuplotを起動できません\n", stderr); fputs("gnuplotにPATHが通っているか、確認してください\n", stderr); } FREE(&f_real); FREE(&f_imag); FREE(&points); free_wave_data(wd); return EXIT_SUCCESS; }