I want to read wav file into mat using Armadillo. It looks like wavread function in matlab:
[sample_data,sample_rate] = wavread('test.wav');
sample_data = sample_data(1 : sample_rate * 1.5);
Seems Armadillo doesn't support this, so I tried to use libsndfile lib:
SNDFILE *infile = NULL ;
SF_INFO sfinfo ;
infile = sf_open(filename, SFM_READ, &sfinfo);
int N = 1024;
double samples[N];
double sample_rate = sfinfo.samplerate;
sf_read_double(infile, samples, N);
My questions:
- Is this way correct? Seem I can only read fixed amount samples.
- How can I convert sample data to
mat
orvec
? - Is there any way to access matrix by colon range index like this matlab code:
sample_data = sample_data(1 : sample_rate * 1.5);
?