[chuck-users] SndBuf | accessing samples from stereo file

mario buoninfante mario.buoninfante at gmail.com
Wed Jun 16 11:56:51 EDT 2021


Hi,

I'm working on an algorithm that requires accessing samples from a 
stereo file and am using SndBuf to achieve that.
I was expecting that to work so that samples were returned in "frames", 
for example:

'''

buffer.valueAt(0) = sample 0 on left channel

buffer.valueAt(1) = sample 0 on right channel

buffer.valueAt(2) = sample 1 on left channel

buffer.valueAt(3) = sample 1 on right channel

...

'''

but that doesn't seem to be the case.

Also SndBuf.samples() always returns the same amount of samples, 
regardless the file being mono or stereo (the size matches the time in 
msec, so it seems that reports the size of a single channel).

I also played around with .channel(n), but I get the same set of samples 
regardless the channel number used.

Then I just now found out that basically the channels seem to be stored 
(or at least accessed) sequentially.
Let's say you have a stereo file containing 1024 samples (512 per 
channel), you get:

samples 0-511 = left channel

samples 512-1023 = right channel

I was wondering if my assumption is correct, but also if this is 
intentional.


Cheers,

Mario



-- 
musician, QA engineer
http://mbuoninfante.tumblr.com/
https://vimeo.com/creativecodingsalerno
https://github.com/mariobuoninfante



More information about the chuck-users mailing list