[CM] poly questions

James Hearon j_hearon at hotmail.com
Wed Oct 27 10:24:17 PDT 2021

Thank you for the example re: polyshape , square wave. I am surprised to see that fractions vs. decimals for amps in the float-vector makes a difference in the chebyshev coefficients.

(partials->polynomial (float-vector 1 1 3 1/3 5 1/5 7 1/7 9 1/9 ))
;(0.0 1.0 0.0 -7.999999999999999 0.0 35.2 0.0 -54.85714285714286 0.0 28.44444444444444)

(with-sound (:srate 48000 :channels 1 :play #t)
  (let ((gen (make-polyshape 100.0 :coeffs #r(0.0 1.0 0.0 -7.999999999999999 0.0 35.2 0.0 -54.85714285714286 0.0 28.44444444444444) ))
    (do ((i 0 (+ i 1)))
        ((= i 88200))
      (outa i (* .75 (polyshape gen 1.0 ))))))

When trying to plug the coefficents back into make-polyshape, I get a different wave shape, which looks more like a triangle-ish wave instead of the square:
I believe this is where I'm stuck, trying to empirically understand how the chebyshev coefficient numbers work for additive synthesis. I thought the problem might be normalization or order of coefficients?  Still not sure where I'm going wrong.

Any help, advice much appreciated.


From: cmdist-bounces at ccrma.Stanford.EDU <cmdist-bounces at ccrma.Stanford.EDU> on behalf of cmdist-request at ccrma.Stanford.EDU <cmdist-request at ccrma.Stanford.EDU>
Sent: Tuesday, October 26, 2021 9:00 AM
To: cmdist at ccrma.Stanford.EDU <cmdist at ccrma.Stanford.EDU>
Subject: Cmdist Digest, Vol 161, Issue 11

Send Cmdist mailing list submissions to
        cmdist at ccrma.stanford.edu

To subscribe or unsubscribe via the World Wide Web, visit
or, via email, send a message with subject or body 'help' to
        cmdist-request at ccrma.stanford.edu

You can reach the person managing the list at
        cmdist-owner at ccrma.stanford.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Cmdist digest..."

Today's Topics:

   1. poly questions (James Hearon)


Message: 1
Date: Tue, 26 Oct 2021 17:40:43 +0000
From: James Hearon <j_hearon at hotmail.com>
To: "cmdist at ccrma.Stanford.EDU" <cmdist at ccrma.Stanford.EDU>
Subject: [CM] poly questions
        <DM6PR10MB2537AB5EB7D8EC958CBB12C2E5849 at DM6PR10MB2537.namprd10.prod.outlook.com>

Content-Type: text/plain; charset="iso-8859-1"

Trying to get an understanding of all the interesting aspects of polywave in snd, and chebyshev polynomials, coefficients etc.  I was trying to get a squarish wave from the coefficients but failing.
Also tried partials->polynomial, and normalize-partials with same result.  Wondering what I'm misunderstanding about how you would employ the coefficients for a typical float-vector of partials, and amps for say a square wave?

(with-sound (:srate 48000 :channels 1 :play #t)
  (let ((gen (make-polyshape 100.0 :coeffs (partials->polynomial (float-vector 1 1 3 .33 5 .2 7 .142 9 0.111)) ))
    (do ((i 0 (+ i 1)))
        ((= i 88200))
      (outa i (* .75 (polyshape gen 1.0 ))))))

Also, if I can ask more than one question per email, how do you go about using the generators:

mus-chebyshev-tu-sum x t-coeffs u-coeffs
mus-chebyshev-t-sum x t-coeffs
mus-chebyshev-u-sum x u-coeffs

I couldn't seem to locate an ex. for those, but I did see the c code in clm.c which is interesting.
Thank you,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20211026/e9ebab85/attachment-0001.html>


Cmdist mailing list
Cmdist at ccrma.stanford.edu

End of Cmdist Digest, Vol 161, Issue 11
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cm-mail.stanford.edu/pipermail/cmdist/attachments/20211027/5a986838/attachment-0001.html>

More information about the Cmdist mailing list