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

mario buoninfante mario.buoninfante at gmail.com
Wed Jun 16 12:04:30 EDT 2021


Hi Dana,


Yap, I forgot to call that out, I get the same results with SndBuf2.

Cheers,

Mario


On 16/06/2021 17:03, Dana Batali wrote:
> Hi Mario , I’m not at my computer right now, but wonder if you’ve 
> tried SndBuf2?
>
> On Wed, Jun 16, 2021 at 8:57 AM mario buoninfante 
> <mario.buoninfante at gmail.com <mailto:mario.buoninfante at gmail.com>> wrote:
>
>     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/ <http://mbuoninfante.tumblr.com/>
>     https://vimeo.com/creativecodingsalerno
>     <https://vimeo.com/creativecodingsalerno>
>     https://github.com/mariobuoninfante
>     <https://github.com/mariobuoninfante>
>
>     _______________________________________________
>     chuck-users mailing list
>     chuck-users at lists.cs.princeton.edu
>     <mailto:chuck-users at lists.cs.princeton.edu>
>     https://lists.cs.princeton.edu/mailman/listinfo/chuck-users
>     <https://lists.cs.princeton.edu/mailman/listinfo/chuck-users>
>
>
> _______________________________________________
> chuck-users mailing list
> chuck-users at lists.cs.princeton.edu
> https://lists.cs.princeton.edu/mailman/listinfo/chuck-users

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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cs.princeton.edu/pipermail/chuck-users/attachments/20210616/ad1f1c0a/attachment.html>


More information about the chuck-users mailing list