Problems with pc:relative

40 views
Skip to first unread message

George

unread,
Jul 16, 2026, 12:27:29 AM (6 days ago) Jul 16
to Extempore
Ben and Minoru and others
I have some code that ran nicely in the old version 9 but doesn't run now on 10.2
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; This in v9 would play a 60 note and then random walk either side of that note.
;; Now in v10.2 the note just climbs higher and higher - never comes back.
(*metro* 'set-tempo 80)
;;
(define node1
(lambda (beat pitch dlst)
(println pitch)
(play piano1 pitch (cosr 80 20 8) 2.2 0)
(callback (*metro* (+ beat (* .9 (car dlst))))
'node1
(+ beat (car dlst))
(pc:relative pitch (random '( -1 1 0 )) scale) ;; the -1 results in a 0 !!
(if (null? (cdr dlst))
(make-rhythm 4 2 .9 '(1/3 1/3 1/2 1/2 1/2))
(cdr dlst)))))

(node1 (*metro* 'get-beat 4) 60 '(1/2 1/3 1/3 1/2 1/3 1) )

; Random walk 60, 60, 62, 60, 60, 60, 62, 64, 64, 62, 62, 60, 62, 64, 62, 62, 60, 59, on old version 9
;; But on version 10.2 the pitch just keeps climbing.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Here are some tests
(println scale) ;; (0 2 4 5 6 8 10 11)
(println (pc:relative 68 (random '(-1 1 0)) scale)) ;; 66 68 70 on v9.0 .... but 68 and 70 only on v10.2
(println (random '( -1 1 0 ))) ;; 0 1 -1 on both v9.0 and v10.2
(pc:relative 64 -1 '(0 2 4 5 7 9 11)) ;; 63 on v9.0 .... but 64 on v10.2
(pc:relative 64 -2 '(0 2 4 5 7 9 11)) ;; 60 on v9.0 .... but 64 on v10.2
(pc:relative 64 1 '(0 2 4 5 7 9 11)) ;; 65 on both v9.0 and v10.2
(pc:relative 64 0 '(0 2 4 5 7 9 11)) ;; 64 on both v9.0 and v10.2

;; I note that pc:relative makes use of real->integer in its define. As do most pc:* defs.

(real->integer 4.7) ;; 4 in both v9.0 and v10.2
(real->integer -4.7) ;; -4 in v9.0 but 0 in v10.2
;; Maybe real->integer is the source of problems for other pc:* I haven't yet tested.
;;
Regards
George

Minoru

unread,
Jul 16, 2026, 1:22:11 AM (6 days ago) Jul 16
to Extempore
Hi George,

Thanks for your report !
I got the return value like below .... I have 4 extempore versions ....

extempore version          ---->              .7    .89  .94  .10.2
(pc:relative 64 -1 '(0 2 4 5 7 9 11))  ;; 62,  62,  64,   64
(pc:relative 64 -2 '(0 2 4 5 7 9 11))  ;; 60,  60,  64,   64
(pc:relative 64 1 '(0 2 4 5 7 9 11))   ;; 65,  65,  65,   65
(pc:relative 64 0 '(0 2 4 5 7 9 11))   ;; 64,  64,  64,   64

I think .7 and .89 is correct .... anyway, your 63 is typing mistake ?

2026年7月16日木曜日 13:27:29 UTC+9 George:

Ben Swift

unread,
Jul 16, 2026, 2:35:30 AM (6 days ago) Jul 16
to extemp...@googlegroups.com
Hi George, Minoru,

Good sleuthing — real->integer was a bit dodgy. The C code behind it converts the double to an unsigned 64-bit integer, which is undefined behaviour for negative numbers: Intel machines happen to wrap around to the correct negative answer, but Apple Silicon clamps to 0. With the step truncated to 0, pc:relative returns the input pitch unchanged, which is why George's random walk could climb but never come back down.

That also explains the version table: the buggy cast has been in the codebase since 0.8.3, but 0.7/0.8.9 predate native Apple Silicon builds (they ran as Intel code under Rosetta), so it only surfaced from 0.9.x. And yes — 62 is the expected answer for (pc:relative 64 -1 ...), so George's 63 looks like a typo, as Minoru guessed.

The fix (plus regression tests, including real->rational which had the same problem) is on master, and I've cut a v0.10.3 patch release: binaries should be up at https://github.com/digego/extempore/releases shortly.

Cheers,
Ben
>--
>You received this message because you are subscribed to the Google Groups "Extempore" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com.
>To view this discussion visit https://groups.google.com/d/msgid/extemporelang/c3ffbfc8-2261-46d7-bd40-61e59a61dd2cn%40googlegroups.com.


--

Cheers,
Ben

George

unread,
Jul 16, 2026, 2:51:22 AM (6 days ago) Jul 16
to Extempore
Thanks Minoru & Ben
Actually I don't know which version I have on the older Intel computer. It doesn't have then"./extempore --version" command that later ones have.
It was loaded first in May 2012. OK on the typo - checked again.

Ben I guess that you are confident that the other pc:* things are fixed too?
Regards
George

Ben Swift

unread,
Jul 16, 2026, 3:49:49 AM (6 days ago) Jul 16
to 'George' via Extempore
Reasonably confident that this will fix the issue you described (the new release that is).

Ben
>To view this discussion visit https://groups.google.com/d/msgid/extemporelang/60bd8321-bb1a-450a-b88b-50347e9829e1n%40googlegroups.com.


--

Cheers,
Ben

Minoru

unread,
Jul 16, 2026, 5:43:30 AM (6 days ago) Jul 16
to Extempore
Hi Ben and George,

Thanks much Ben, I got it, CPU differences of Intel and Apple Silicon, and Rosetta's working, I forgot it at all though I used it, too !

2026年7月16日木曜日 16:49:49 UTC+9 ben:

George

unread,
Jul 21, 2026, 11:37:16 PM (7 hours ago) Jul 21
to Extempore
Ben
I've been checking for arrival of v0.10.3 but nothing yet.

How's it going?

Regards
George

Ben Swift

unread,
12:13 AM (6 hours ago) 12:13 AM
to extemp...@googlegroups.com, Extempore
Oh whoops, that’s my bad. I had made the commits but hadn’t pushed the trigger to cut the new release. I’ve just done that now, and it will take an hour or so to build and then it should be up.

Cheers
Ben

On 22 Jul 2026, at 1:37 pm, 'George' via Extempore <extemp...@googlegroups.com> wrote:



geor...@bigpond.net.au

unread,
12:57 AM (6 hours ago) 12:57 AM
to extemp...@googlegroups.com, Extempore
Many thanks. 
I guessed something like that had happened.
No worries!!
George 

George J Wright 

“You never know how the past will turn out. “

On 22 Jul 2026, at 2:13 pm, Ben Swift <b...@benswift.me> wrote:

Oh whoops, that’s my bad. I had made the commits but hadn’t pushed the trigger to cut the new release. I’ve just done that now, and it will take an hour or so to build and then it should be up.

Minoru

unread,
1:28 AM (5 hours ago) 1:28 AM
to Extempore
Hi Ben,

I'm using ver 0.10.3, pc:relative, real->integer, is working nicely !
Thanks so much evry time.

2026年7月22日水曜日 13:57:12 UTC+9 George:

Ben Swift

unread,
2:48 AM (4 hours ago) 2:48 AM
to extemp...@googlegroups.com
No worries team :)

Ben
>> <https://groups.google.com/d/msgid/extemporelang/256beec9-1074-4ae1-bfc9-d066bd3be40en%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Extempore" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to extemporelan...@googlegroups.com.
>>
>> To view this discussion visit
>> https://groups.google.com/d/msgid/extemporelang/F0A6D488-D8EA-456F-BC6C-53F551C657AD%40benswift.me
>> <https://groups.google.com/d/msgid/extemporelang/F0A6D488-D8EA-456F-BC6C-53F551C657AD%40benswift.me?utm_medium=email&utm_source=footer>
>> .
>>
>>
>
>--
>You received this message because you are subscribed to the Google Groups "Extempore" group.
>To unsubscribe from this group and stop receiving emails from it, send an email to extemporelan...@googlegroups.com.
>To view this discussion visit https://groups.google.com/d/msgid/extemporelang/ae32c5d0-9a22-4ac8-83a7-3d8a5a3aa152n%40googlegroups.com.


--

Cheers,
Ben
Reply all
Reply to author
Forward
0 new messages