29int main(
int argc,
char* argv[] )
35 const char* filename =
"thx-sound-test.wav";
36 FILE* wavFile = fopen( filename,
"r" );
37 if (wavFile ==
nullptr)
39 fprintf(stderr,
"Error: Failed to open file '%s'\n", filename);
40 fprintf(stderr,
"Download it at http://www.orangefreesounds.com/wp-content/uploads/Zip/thx-sound-test.zip");
44 fread( &wavHeader, 1,
sizeof(
wav_header ), wavFile );
48 uint32_t Ns = ( wavHeader.
chunkSize - 36 ) / Nb;
51 fread( x.memptr(), Nb, Ns, wavFile );
55 arma::Col<int16_t> x_left = x.row( 0 ).t();
58 const int FFT_SIZE = 1024;
59 const int FFT_OVERLAP = 128;
60 arma::mat P = 10 * log10( abs(
specgram( x_left, FFT_SIZE, FFT_OVERLAP ) ) );
63 arma::mat Q = P.rows( FFT_SIZE / 2, FFT_SIZE - 1 );
65 gp0.
window(
"Deep note spectrogram", 100, 100, 1200, 400 );
67 gp0.
send2gp(
"unset colorbox" );
void window(const int fig, const char *name, const int x, const int y, const int width, const int height)
Configure the figure used Windows environment.
arma::mat specgram(const arma::Col< T1 > &x, const arma::uword Nfft=512, const arma::uword Noverl=256)
Power spectrogram calculation.