{
int main(
int argc,
char* argv[] )
{
const char* filename = "thx-sound-test.wav";
FILE* wavFile = fopen( filename, "r" );
if (wavFile == nullptr)
{
fprintf(stderr, "Error: Failed to open file '%s'\n", filename);
fprintf(stderr, "Download it at http://www.orangefreesounds.com/wp-content/uploads/Zip/thx-sound-test.zip");
return 1;
}
fread( &wavHeader, 1,
sizeof(
wav_header ), wavFile );
uint32_t Ns = ( wavHeader.
chunkSize - 36 ) / Nb;
fread( x.memptr(), Nb, Ns, wavFile );
fclose( wavFile );
arma::Col<int16_t> x_left = x.row( 0 ).t();
const int FFT_SIZE = 1024;
const int FFT_OVERLAP = 128;
arma::mat P = 10 * log10( abs(
specgram( x_left, FFT_SIZE, FFT_OVERLAP ) ) );
arma::mat Q = P.rows( FFT_SIZE / 2, FFT_SIZE - 1 );
gp0.
window(
"Deep note spectrogram", 100, 100, 1200, 400 );
return 0;
}
void send2gp(const char *cmdstr)
Send command to Gnuplot pipe.
void image(const arma::Mat< T > &x)
Plot mat as image.
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.
struct WAV_HEADER wav_header