Define a global t_symbol called ps_buffer:
t_symbol *ps_buffer;
Do this in the main function:
void main(void){
...
ps_buffer = gensym("buffer~");
...
}
This function should convert a buffer name into an actual buffer:
t_buffer* _sym_to_buffer(t_symbol* s) {
t_buffer *b;
if ((b = (t_buffer *)(s->s_thing)) && ob_sym(b) == ps_buffer) {
return b;
} else {
return 0;
}
}
Reading from the buffer -- samples are interleaved across channels:
t_buffer* my_buf;
int offset, i, n;
int channel;
if(my_buf->b_valid) {
i = 0;
n = 1024; // read 1024 samples
while(i + offset < my_buf->b_frames && i < n) {
output[i] = my_buf->b_samples[ my_buf->b_nchans * (i + offset) + channel];
i++;
}
} else {
post("error: buffer %s is no longer valid!", my_buf->b_name->s_name);
}
Refer to buffer.h in the msp sdk for more details.