Created
February 22, 2013 22:41
-
-
Save udalov/5017161 to your computer and use it in GitHub Desktop.
Revisions
-
udalov created this gist
Feb 22, 2013 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,30 @@ #include <cstdio> #include <vector> #include <sndfile.h> using namespace std; int main() { SF_INFO sfinfo; const int BUF_LEN = 2048; double buffer[BUF_LEN]; SNDFILE* f = sf_open("/Users/udalov/c/ch24/PreEC/input/P/1.wav", SFM_READ, &sfinfo); int read; vector<double> data; while ((read = sf_read_double(f, buffer, BUF_LEN))) { for (int i = 0; i < read; i++) { data.push_back(buffer[i]); } } printf("Sample rate: %d\n", sfinfo.samplerate); printf("Samples: %lu\n", data.size()); for (size_t i = 0; i < data.size(); i++) { printf("%.3lf\n", data[i]); } return 0; }