[CM] make-polyshape

2021-02-07 Thread James Hearon

Hi,
re: make-polyshape

Very cool.  At least three ways to get the coeffs parameter working.  I don't 
why I couldn't figure that out earlier.
Thanks
JIm


(with-sound ()
  (let ((gen (make-polyshape 400.0 :coeffs  (float-vector -1.0 -5.0 18.0 8.0 
-48.0 0.0 32.0))))
(do ((i 0 (+ i 1)))
((= i 88200))
  (outa i (* .5 (polyshape gen 0.25))

(with-sound ()
  (let ((gen (make-polyshape 400.0 :coeffs #r(-1.0 -5.0 18.0 8.0 -48.0 0.0 
32.0))))
(do ((i 0 (+ i 1)))
((= i 88200))
  (outa i (* .5 (polyshape gen 0.25))

(with-sound ()
  (let ((gen (make-polyshape 400.0 :coeffs (partials->polynomial '(1 1 3 2 6 1) 
mus-chebyshev-second-kind
(do ((i 0 (+ i 1)))
((= i 88200))
  (outa i (* .5 (polyshape gen 0.25))



___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] something like let-set! for undefined vars?

2021-02-07 Thread Iain Duncan
Thanks Bill, I shall use your example! I'm loving the environment
flexibility.  I got so excited making my algorithmic process object
hierarchy I went and ordered "The Art of the Meta-object Protocol", haha. I
don't think I'll be able to happily use a language that tells me how
objects *must* work anymore... :-)

iain

On Sun, Feb 7, 2021 at 7:11 AM  wrote:

> Another possibility:
>
> (let init-loop ((args init-args))
>(unless (null? args)
>  ((if (defined? (car args) env) let-set! varlet) env (car args)
> (cadr args))
>  (init-loop (cddr args)
>
> varlet adds a new binding to the let even if one already
> exists for the symbol (shadowing the old one).
>
>
>
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] something like let-set! for undefined vars?

2021-02-07 Thread bil

Another possibility:

   (let init-loop ((args init-args))
  (unless (null? args)
((if (defined? (car args) env) let-set! varlet) env (car args) 
(cadr args))

(init-loop (cddr args)

varlet adds a new binding to the let even if one already
exists for the symbol (shadowing the old one).


___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] something like let-set! for undefined vars?

2021-02-07 Thread Christos Vagias
Hi Iain!
Indeed lets are amazingly powerful :)

I think what you're looking for here is (apply varlet env args)

On Sun, Feb 7, 2021, 05:58 Iain Duncan  wrote:

> Answering myself! Just didn't understand the docs properly, got it all
> working nicely with varlet.
>
> Though I am curious to know whether my way of iterating through a keyword
> assoc list in a constructor is reasonable. This is what I'm doing, feedback
> most welcome:
>
> ;  loop through the init-args keyword arg list, which is an assoc list
> of sym/value to set
> ; this allows setting any instance vars from keyword list to
> constructor
> (let* init-loop ((args init-args))
>   (if (not (null? args))
> (begin
>   (varlet env (car args) (cadr args))
>   (init-loop (cddr args)
>
>
>
>
> On Sat, Feb 6, 2021 at 5:06 PM Iain Duncan 
> wrote:
>
>> Hi folks, I've been digging into S7s environment support and loving it. I
>> have implemented a really convenient pseudo-inheritance-through-delegation
>> setup for my process objects, and one thing I'm using is the let-set!
>> function to allow updating internal variables from outside if desired. My
>> little method looks like this (in side of a let inside a function)
>>
>> (define (set sym val)
>>   ;; TODO this doesn't allow setting values that are not yet set
>>   ;; need to check if symbol is in let and then set it
>>   (let-set! proc-env sym val))
>>
>> However, this of course errors if I try to use if and sym is not defined.
>> I tried mucking about with the defined?  predicate, but got confused by the
>> docs. If anyone can tell me how I can easily add to the above the
>> following, that would be lovely:
>>
>> - if sym not defined in proc-env, define sym to val
>>
>> iain
>>
>> ___
> Cmdist mailing list
> Cmdist@ccrma.stanford.edu
> https://cm-mail.stanford.edu/mailman/listinfo/cmdist
>
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] make-polyshape

2021-02-07 Thread Tito Latini
On Sat, Feb 06, 2021 at 06:51:07PM +, James Hearon wrote:
> [...]
> It rather seems to want the whole function call:
> (set! gen1 (make-polyshape 440.0 :coeffs (partials->polynomial '(1 1
> 
> or
> (set! gen1 (make-polyshape 440.0 :coeffs (partials->polynomial '(1 1 3 2 6 
> 1

Generally, it works with a float-vector, for example

#r(-1.0 -5.0 18.0 8.0 -48.0 0.0 32.0)

or

(float-vector -1.0 -5.0 18.0 8.0 -48.0 0.0 32.0)

The output of partials->polynomial is a float-vector:

(partials->polynomial '(1 1 3 2 6 1))
;; => #r(-1.0 -5.0 18.0 8.0 -48.0 0.0 32.0)
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist