Re: [CM] clm delay offset for tap?

2016-09-28 Thread Kjetil Matheussen
On Wed, Sep 28, 2016 at 4:01 PM,  wrote:

> (int)-1 % (unsigned int)10=> 5
>>
>
> That's very interesting -- I never noticed this!
> Thanks very much for the bugfix -- I'll merge it into
> my sources today -- then I need to look at all
> the other % cases.
>
>
Yes, very good catch. Regarding unsigned integers, there have
been so many bugs caused by unsigned integers that I have
stopped using them completely in my software.
(The common bug is of course "(unsigned int)-1 < 0", and
variants of it, which is always false.)

I think Qt practices the same philosophy; no unsigned integers.
___
Cmdist mailing list
Cmdist@ccrma.stanford.edu
https://cm-mail.stanford.edu/mailman/listinfo/cmdist


Re: [CM] clm delay offset for tap?

2016-09-28 Thread bil

(int)-1 % (unsigned int)10=> 5


That's very interesting -- I never noticed this!
Thanks very much for the bugfix -- I'll merge it into
my sources today -- then I need to look at all
the other % cases.

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



Re: [CM] clm delay offset for tap?

2016-09-28 Thread Tito Latini
On Wed, Sep 28, 2016 at 11:45:11AM +0200, ander...@notam02.no wrote:
> Hi Bill, others.
> 
> I'm confused about (positive) offset argument to tap.
> 
> Negative offsets yields perhaps expected results, but positive offsets
> starts pulling values from what seems an odd offset into the line.
> 
> (set! (*s7* 'print-length) 20)
> 
> (define d1 (make-delay 10))
> 
> (do ((i 0 (+ 1 i)))
> ((= i 10))
>   (delay d1 i))
> 
> (mus-data d1)
> => (float-vector 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)
> 
> (tap d1)
> => 0.0
> (tap d1 1)
> => 5.0
> (tap d1 -1)
> => 1.0
> 
> (map (lambda (i) (tap d1 i)) '(0 1 2 3 4 5 6 7 8 9))
> => (0.0 5.0 4.0 3.0 2.0 1.0 0.0 9.0 8.0 7.0)
> 
> (map (lambda (i) (tap d1 i)) '(-0 -1 -2 -3 -4 -5 -6 -7 -8 -9))
> => (0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)

That's a bug with the modulus operator in c

(int)-1 % (unsigned int)10=> 5

(int)-1 % (int)10 => -1

The follow patch seems ok:

diff -ur snd-16~/clm.c snd-16/clm.c
--- snd-16~/clm.c   2016-09-28 15:21:57.567364000 +0200
+++ snd-16/clm.c2016-09-28 15:22:15.075143897 +0200
@@ -4382,7 +4382,7 @@
   int taploc;
   if (gen->size == 0) return(gen->line[0]);
   if ((int)loc == 0) return(gen->line[gen->loc]);
-  taploc = (int)(gen->loc - (int)loc) % gen->size;
+  taploc = (int)(gen->loc - (int)loc) % (int)gen->size;
   if (taploc < 0) taploc += gen->size;
   return(gen->line[taploc]);
 }

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



[CM] clm delay offset for tap?

2016-09-28 Thread andersvi
Hi Bill, others.

I'm confused about (positive) offset argument to tap.

Negative offsets yields perhaps expected results, but positive offsets
starts pulling values from what seems an odd offset into the line.

(set! (*s7* 'print-length) 20)

(define d1 (make-delay 10))

(do ((i 0 (+ 1 i)))
((= i 10))
  (delay d1 i))

(mus-data d1)
=> (float-vector 0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)

(tap d1)
=> 0.0
(tap d1 1)
=> 5.0
(tap d1 -1)
=> 1.0

(map (lambda (i) (tap d1 i)) '(0 1 2 3 4 5 6 7 8 9))
=> (0.0 5.0 4.0 3.0 2.0 1.0 0.0 9.0 8.0 7.0)

(map (lambda (i) (tap d1 i)) '(-0 -1 -2 -3 -4 -5 -6 -7 -8 -9))
=> (0.0 1.0 2.0 3.0 4.0 5.0 6.0 7.0 8.0 9.0)

Thanks for all help and guidance.

-anders

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