buffer~ b_outputbytes


    May 19 2008 | 6:18 pm
    Hi list,
    I'm wrote a function to resize a buffer, but I'm not sure what the b_outputbytes member is for, and therefor don't know wether I should care about it or not. It is set to 2 by default I noticed. Since b_samples is a float* I wonder why this is not 4, and what "output" it is referring to. I guess it has to do with b_outputfmt... but what's that?
    Below is my code. It seems to work fine btw, in case someone's interested.
    I also tried to use the sysmem api but that didn't seem to be compatible. Is the buffer relying on legacy code for its memory allocation, or is there a good reason why its not using sysmem_* ?
    Cheers, Thijs
    int mutResizeBuffer(t_buffer *b, long nFrames, long nChans) { if(!b->b_valid) return 1;
    long saveinuse = b->b_inuse; b->b_inuse = true;
    long newSize = nFrames * nChans;
    t_resizebytes((char *)b->b_samples, b->b_size * sizeof(float), newSize * sizeof(float));
    // alternative for resizebytes // t_freebytes((char *)b->b_samples, b->b_size * sizeof(float)); // b->b_samples = (float *)t_getbytes(newSize * sizeof(float));
    // update buffer attributes b->b_size = newSize; // size in samples b->b_nchans = nChans; b->b_frames = nFrames; //b->b_outputbytes = sizeof(float); // for if we weren't already dealing with floats?
    b->b_inuse = saveinuse;
    return 0; }