Advertisement
Guest User

Untitled

a guest
Apr 24th, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.11 KB | None | 0 0
  1. --- test.orig.cpp 2015-03-07 19:06:34.000000000 +0900
  2. +++ test.cpp 2015-03-07 19:08:17.000000000 +0900
  3. @@ -63,6 +63,7 @@
  4. #endif
  5.  
  6. namespace {
  7. +#if 0
  8. bool CheckLoadedFile(double *x, int fs, int nbit, int x_length) {
  9. if (x == NULL) {
  10. printf("error: File not found.\n");
  11. @@ -75,6 +76,7 @@
  12. printf("Length %f [sec]\n", static_cast<double>(x_length) / fs);
  13. return true;
  14. }
  15. +#endif
  16.  
  17. void F0Estimation(double *x, int x_length, int fs, int f0_length, double *f0,
  18. double *time_axis) {
  19. @@ -91,6 +93,7 @@
  20. option.f0_ceil = 640.0;
  21. option.channels_in_octave = 2.0;
  22.  
  23. +#if 0
  24. printf("\nAnalysis\n");
  25. DWORD elapsed_time = timeGetTime();
  26. Dio(x, x_length, fs, option, time_axis, f0);
  27. @@ -100,6 +103,10 @@
  28. elapsed_time = timeGetTime();
  29. StoneMask(x, x_length, fs, time_axis, f0, f0_length, refined_f0);
  30. printf("StoneMask: %d [msec]\n", timeGetTime() - elapsed_time);
  31. +#else
  32. + Dio(x, x_length, fs, option, time_axis, f0);
  33. + StoneMask(x, x_length, fs, time_axis, f0, f0_length, refined_f0);
  34. +#endif
  35.  
  36. for (int i = 0; i < f0_length; ++i) f0[i] = refined_f0[i];
  37.  
  38. @@ -107,6 +114,7 @@
  39. return;
  40. }
  41.  
  42. +#if 0
  43. void SpectralEnvelopeEstimation(double *x, int x_length, int fs,
  44. double *time_axis, double *f0, int f0_length, double **spectrogram) {
  45. DWORD elapsed_time = timeGetTime();
  46. @@ -196,6 +204,7 @@
  47. printf("WORLD: %d [msec]\n", timeGetTime() - elapsedTime);
  48. }
  49. }
  50. +#endif
  51.  
  52. } // namespace
  53.  
  54. @@ -210,17 +219,21 @@
  55. // flag : argv[5] Excitation signal or Aperiodicity(0 or 1)
  56. //-----------------------------------------------------------------------------
  57. int main(int argc, char *argv[]) {
  58. +#if 0
  59. if (argc != 2 && argc != 3 && argc != 4 && argc != 5 && argc != 6) {
  60. printf("error\n");
  61. return 0;
  62. }
  63. +#endif
  64. int fs, nbit, x_length;
  65. double *x = wavread(argv[1], &fs, &nbit, &x_length);
  66.  
  67. +#if 0
  68. if (CheckLoadedFile(x, fs, nbit, x_length) == false) {
  69. printf("error: File not found.\n");
  70. return 0;
  71. }
  72. +#endif
  73.  
  74. // Allocate memories
  75. // The number of samples for F0
  76. @@ -228,6 +241,7 @@
  77. double *f0 = new double[f0_length];
  78. double *time_axis = new double[f0_length];
  79.  
  80. +#if 0
  81. // FFT size for CheapTrick, PLATINUM and Aperiodicity
  82. int fft_size = GetFFTSizeForCheapTrick(fs);
  83. double **spectrogram = new double *[f0_length];
  84. @@ -238,11 +252,17 @@
  85. residual_spectrogram[i] = new double[fft_size + 1]; // miss??
  86. aperiodicity[i] = new double[fft_size / 2 + 1];
  87. }
  88. +#endif
  89.  
  90. // F0 estimation
  91. //-------------------------------
  92. F0Estimation(x, x_length, fs, f0_length, f0, time_axis);
  93. +#if 0
  94. +#else
  95. + fwrite(f0, sizeof(*f0), f0_length, stdout);
  96. +#endif
  97.  
  98. +#if 0
  99. // Spectral envelope estimation
  100. SpectralEnvelopeEstimation(x, x_length, fs, time_axis, f0, f0_length,
  101. spectrogram);
  102. @@ -270,10 +290,12 @@
  103. wavwrite(y, y_length, fs, 16, argv[2]);
  104.  
  105. printf("complete.\n");
  106. +#endif
  107.  
  108. delete[] x;
  109. delete[] time_axis;
  110. delete[] f0;
  111. +#if 0
  112. delete[] y;
  113. for (int i = 0; i < f0_length; ++i) {
  114. delete[] spectrogram[i];
  115. @@ -283,6 +305,7 @@
  116. delete[] spectrogram;
  117. delete[] residual_spectrogram;
  118. delete[] aperiodicity;
  119. +#endif
  120.  
  121. return 0;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement