Assuming the idea is to check the infile, the line needs to be:
if (psfinfo_in->channels != 2){
It is remarkable sometimes what a C compiler will accept.
The for loop over samples (which should not assume the read function
always returns the number of samples requested) should read:
for(i=0; i < count; i++)
not
for(i=0, i < BUFFRAMES; i++;)
One of those cases where we are asking the compiler to
"don't do what I say, do what I mean"!
Also, as the program reads mono in and writes stereo (I assume
duplicating samples), the loop body needs to be something like:
for(i=0; i < count; i++) {
out[i*2] = buffer[i];
out[i*2+1] = buffer[i];
}
HTH,
Richard Dobson
On 24/01/2014 16:49, Pablo Frank wrote:
After initializing psf_out2, initializing psfinfo_out to zero, and correcting
the if, as displayed below at (1), the code displayed below in (2) still
generates an empty stereo file. The correction of the code will be greatly
thanked, pointing errors will probably continue to cause misunderstandings (i'm
a beginner, sorry).
(1)
You never open psf_out2 si writing to it will be a disaster.
Also it is safer to initialise psfinfo_out to zero
psfinfo_out= (SF_INFO *) calloc(1,sizeof(SF_INFO));
/////////////
// check if file is mono or stereo
if (!(psfinfo_out->channels = 2))
/* allocate buffer memory */
buffer = (float *) malloc(sizeof(float)*BUFFRAMES);
out = (float *) malloc(sizeof(float)*BUFFRAMES*2);
I think you mean
if (psfinfo_out->channels != 2) {
…
}
...
--
dupswapdrop -- the music-dsp mailing list and website:
subscription info, FAQ, source code archive, list archive, book reviews, dsp
links
http://music.columbia.edu/cmc/music-dsp
http://music.columbia.edu/mailman/listinfo/music-dsp