Skip to content

Instantly share code, notes, and snippets.

@tam17aki
Created March 7, 2015 10:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tam17aki/e28a4a93e0b5f505abc1 to your computer and use it in GitHub Desktop.
Save tam17aki/e28a4a93e0b5f505abc1 to your computer and use it in GitHub Desktop.
--- test.orig.cpp 2015-03-07 19:06:34.000000000 +0900
+++ test.cpp 2015-03-07 19:08:17.000000000 +0900
@@ -63,6 +63,7 @@
#endif
namespace {
+#if 0
bool CheckLoadedFile(double *x, int fs, int nbit, int x_length) {
if (x == NULL) {
printf("error: File not found.\n");
@@ -75,6 +76,7 @@
printf("Length %f [sec]\n", static_cast<double>(x_length) / fs);
return true;
}
+#endif
void F0Estimation(double *x, int x_length, int fs, int f0_length, double *f0,
double *time_axis) {
@@ -91,6 +93,7 @@
option.f0_ceil = 640.0;
option.channels_in_octave = 2.0;
+#if 0
printf("\nAnalysis\n");
DWORD elapsed_time = timeGetTime();
Dio(x, x_length, fs, option, time_axis, f0);
@@ -100,6 +103,10 @@
elapsed_time = timeGetTime();
StoneMask(x, x_length, fs, time_axis, f0, f0_length, refined_f0);
printf("StoneMask: %d [msec]\n", timeGetTime() - elapsed_time);
+#else
+ Dio(x, x_length, fs, option, time_axis, f0);
+ StoneMask(x, x_length, fs, time_axis, f0, f0_length, refined_f0);
+#endif
for (int i = 0; i < f0_length; ++i) f0[i] = refined_f0[i];
@@ -107,6 +114,7 @@
return;
}
+#if 0
void SpectralEnvelopeEstimation(double *x, int x_length, int fs,
double *time_axis, double *f0, int f0_length, double **spectrogram) {
DWORD elapsed_time = timeGetTime();
@@ -196,6 +204,7 @@
printf("WORLD: %d [msec]\n", timeGetTime() - elapsedTime);
}
}
+#endif
} // namespace
@@ -210,17 +219,21 @@
// flag : argv[5] Excitation signal or Aperiodicity(0 or 1)
//-----------------------------------------------------------------------------
int main(int argc, char *argv[]) {
+#if 0
if (argc != 2 && argc != 3 && argc != 4 && argc != 5 && argc != 6) {
printf("error\n");
return 0;
}
+#endif
int fs, nbit, x_length;
double *x = wavread(argv[1], &fs, &nbit, &x_length);
+#if 0
if (CheckLoadedFile(x, fs, nbit, x_length) == false) {
printf("error: File not found.\n");
return 0;
}
+#endif
// Allocate memories
// The number of samples for F0
@@ -228,6 +241,7 @@
double *f0 = new double[f0_length];
double *time_axis = new double[f0_length];
+#if 0
// FFT size for CheapTrick, PLATINUM and Aperiodicity
int fft_size = GetFFTSizeForCheapTrick(fs);
double **spectrogram = new double *[f0_length];
@@ -238,11 +252,17 @@
residual_spectrogram[i] = new double[fft_size + 1]; // miss??
aperiodicity[i] = new double[fft_size / 2 + 1];
}
+#endif
// F0 estimation
//-------------------------------
F0Estimation(x, x_length, fs, f0_length, f0, time_axis);
+#if 0
+#else
+ fwrite(f0, sizeof(*f0), f0_length, stdout);
+#endif
+#if 0
// Spectral envelope estimation
SpectralEnvelopeEstimation(x, x_length, fs, time_axis, f0, f0_length,
spectrogram);
@@ -270,10 +290,12 @@
wavwrite(y, y_length, fs, 16, argv[2]);
printf("complete.\n");
+#endif
delete[] x;
delete[] time_axis;
delete[] f0;
+#if 0
delete[] y;
for (int i = 0; i < f0_length; ++i) {
delete[] spectrogram[i];
@@ -283,6 +305,7 @@
delete[] spectrogram;
delete[] residual_spectrogram;
delete[] aperiodicity;
+#endif
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment