mdedwards / slippery-chicken

slippery chicken: algorithmic composition software in common lisp and clos
http://michael-edwards.org/sc
72 stars 3 forks source link

Error with write-xml when adding a bar containing grace-notes #69

Closed rubenphilipp closed 1 year ago

rubenphilipp commented 1 year ago

Hello Michael,

oddly, I have encountered a (hopefully) reproducible error which occurs when adding a bar containing grace-notes to a slippery-chicken piece via the insert-bar method and trying to export the data via write-xml. The resulting error-message is as follows:

Can't decode NaN or infinity: #.SB-EXT:SINGLE-FLOAT-NEGATIVE-INFINITY.
   [Condition of type SIMPLE-ERROR]

Restarts:
 0: [RETRY] Retry SLIME interactive evaluation request.
 1: [*ABORT] Return to SLIME's top level.
 2: [ABORT] Exit debugger, returning to top level.

Backtrace:
  0: ((FLET SB-UNIX::RUN-HANDLER :IN SB-UNIX::%INSTALL-HANDLER) 23 #.(SB-SYS:INT-SAP #X16B37EB80) #.(SB-SYS:INT-SAP #X16B37EBE8))
  1: ("bogus stack frame")
  2: ((FLET SB-UNIX::SELECT :IN SB-UNIX:UNIX-FAST-SELECT) #.(SB-SYS:INT-SAP #X00000000))
  3: (SB-IMPL::SUB-SUB-SERVE-EVENT NIL NIL)
  4: (SB-IMPL::SUB-SERVE-EVENT NIL NIL NIL)
  5: (SB-SYS:WAIT-UNTIL-FD-USABLE 0 :INPUT NIL T)
  6: (SB-IMPL::REFILL-INPUT-BUFFER #<SB-SYS:FD-STREAM for "standard input" {7005263913}>)
  7: (SB-IMPL::INPUT-CHAR/UTF-8 #<SB-SYS:FD-STREAM for "standard input" {7005263913}> NIL 0)
  8: ((LAMBDA (&REST REST) :IN SB-IMPL::GET-EXTERNAL-FORMAT) #<SB-SYS:FD-STREAM for "standard input" {7005263913}> NIL 0)
  9: (READ-CHAR #<SB-SYS:FD-STREAM for "standard input" {7005263913}> NIL 0 #<unused argument>)
 10: (READ-CHAR #<SYNONYM-STREAM :SYMBOL SB-SYS:*STDIN* {70030BE913}> NIL 0 #<unused argument>)
 11: (READ-CHAR #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {7005263AB3}> NIL 0 #<unused argument>)
 12: (SB-IMPL::%READ-PRESERVING-WHITESPACE #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {7005263AB3}> NIL (NIL) T)
 13: (SB-IMPL::%READ-PRESERVING-WHITESPACE #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {7005263AB3}> NIL (NIL) NIL)
 14: (READ #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {7005263AB3}> NIL (NIL) NIL)
 15: (SB-IMPL::REPL-READ-FORM-FUN #<SYNONYM-STREAM :SYMBOL SWANK::*CURRENT-STANDARD-INPUT* {7005263AB3}> #<unused argument>)
 16: (SB-IMPL::REPL-FUN NIL)
 17: ((LAMBDA NIL :IN SB-IMPL::TOPLEVEL-REPL))
 18: (SB-IMPL::%WITH-REBOUND-IO-SYNTAX #<FUNCTION (LAMBDA NIL :IN SB-IMPL::TOPLEVEL-REPL) {700526005B}>)
 19: (SB-IMPL::TOPLEVEL-REPL NIL)
 --more--

Below is a tiny sc-piece I was able to reproduce the error with. NB: midi-play, cmn-display, lp-display et al. work as expected...

(let ((sc
        (make-slippery-chicken
         '+insert-bar-xml+
         :ensemble '(((vln (violin))))
         :tempo-map '((1 (q 120)))
         :set-palette '((set1 ((c4 d4 e4 f4 g4 a4))))
         :set-map '((1 (set1 set1)))
         :rthm-seq-palette '((seq1 ((((4 4) q q - e e - q))
                                    :pitch-seq-palette ((1 2 3 4 5)
                                                        (5 4 3 2 1)))))
         :rthm-seq-map '((1 ((vln (seq1 seq1))))))))
  ;;; now, insert a bar
  (let ((bar (make-rthm-seq-bar '((4 4) (w)))))
    (fill-with-rhythms bar
                       (loop for p in '(b4 as4 d5 g4 f4)
                             for r in '(q e. g s h)
                             collect (make-event p r)))
    (insert-bar (piece sc) bar 1 1 'vln 2 '(2 4 8 3 2))
    (update-slots sc))
  ;;; remove irrelevant tempo-changes in second bar
  (delete-tempi sc 2)
  ;;; remove extraneous time signatures (due to the bar added)
  (update-write-time-sig2 (piece sc))
  (update-slots sc)
  (write-xml sc))

I did not have time yet to investigate this further. Hence, I am posting this as you might have a clue why this is happening.

Best, Ruben

mdedwards commented 1 year ago

That’s an interesting case Ruben. test-event-write-xml checks that grace notes are rendered correctly and I’ve just opened the xml file generated from that and confirmed that the grace notes are fine. So this is caused by making a grace note on-the-fly and adding to the sc object. The culprit was xml-simple-rhythm called by write-xml in the rhythm class and a simple change of logic/call order handled your (nicely obscure!) case. BTW glad to see you’re heading back to C Major with a hint of subdominant ;-). Thanks and best, Michael

rubenphilipp commented 1 year ago

Thank you for your "quick fix", Michael, and apologise my late response. I already suspected some logic error (as it has been the case in player ambitus -- commit d1bd8856f5bc27db429cf02f699efd9d4b1831b2, if you remember), but have not been bold enough to put my hands onto such a vital part of slippery-chicken myself without having posed this question to the "agora". Anyway, it confirms my assumptions that grace notes are somewhat "below the radar". ;)

Greetings Ruben

PS: Thanks a lot for you compliments on my piece. It demanded some courage on my part to depart that far from solid earth.

rubenphilipp commented 1 year ago

PPS: Of course, I have tested the most recent commit on my system both with the given œuvre and a more complex composition. Both tests, as well as the RTs passed. Hence, this issue might be closed.

mdedwards commented 1 year ago

Yeah, logic boards get a bit gummed up when they’re old ;-)

Grace notes are a little under the radar, it’s true, simply because they’re not used very often. If you want to hammer away at them with some new tests, have at it and check them in. This peculiar case was caused by the grace notes not being in rthm-seqs though—shouldn’t happen, but did ;-)

Best, Michael

On 27 Sep 2023, at 22:09, Ruben Philipp @.***> wrote:

Thank you for your "quick fix", Michael, and apologise my late response. I already suspected some logic error (as it has been the case in player ambitus -- commit d1bd885 https://github.com/mdedwards/slippery-chicken/commit/d1bd8856f5bc27db429cf02f699efd9d4b1831b2, if you remember), but have not been bold enough to put my hands onto such a vital part of slippery-chicken myself without having posed this question to the "agora". Anyway, it confirms my assumptions that grace notes are somewhat "below the radar". ;)

Greetings Ruben

PS: Thanks a lot for you compliments on my piece. It demanded some courage on my part to depart that far from solid earth.

— Reply to this email directly, view it on GitHub https://github.com/mdedwards/slippery-chicken/issues/69#issuecomment-1738009514, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3IOITRM5UVMEYNA4OQV6LX4SBZLANCNFSM6AAAAAA5DTVVKY. You are receiving this because you commented.

rubenphilipp commented 1 year ago

I am glad, that we are talking about software here… I have just added a RT to the suite which works fine on my machine.

Best Ruben

mdedwards commented 1 year ago

Nice! Thanks Ruben.

On 30 Sep 2023, at 16:28, Ruben Philipp @.***> wrote:

I am glad, that we are talking about software here… I have just added a RT to the suite which works fine on my machine.

Best Ruben

— Reply to this email directly, view it on GitHub https://github.com/mdedwards/slippery-chicken/issues/69#issuecomment-1741778191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3IOIWMWEJHEWV5VDBRE2DX5AUCBANCNFSM6AAAAAA5DTVVKY. You are receiving this because you commented.

rubenphilipp commented 1 year ago

You’re welcome.

Best Ruben

Am 02.10.2023 um 11:35 schrieb Michael Edwards @.***>:

Nice! Thanks Ruben.

On 30 Sep 2023, at 16:28, Ruben Philipp @.***> wrote:

I am glad, that we are talking about software here… I have just added a RT to the suite which works fine on my machine.

Best Ruben

— Reply to this email directly, view it on GitHub https://github.com/mdedwards/slippery-chicken/issues/69#issuecomment-1741778191, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC3IOIWMWEJHEWV5VDBRE2DX5AUCBANCNFSM6AAAAAA5DTVVKY. You are receiving this because you commented.

— Reply to this email directly, view it on GitHub https://github.com/mdedwards/slippery-chicken/issues/69#issuecomment-1742697277, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC7525XP7LVDKGNLKUKJRUTX5KDF3ANCNFSM6AAAAAA5DTVVKY. You are receiving this because you authored the thread.